Skip to content

The agent that grows with you

test(desktop): document connection-scoped filesystem keys

dougatbuck855e191d89d0
diff --git a/apps/desktop/src/lib/desktop-fs.test.ts b/apps/desktop/src/lib/desktop-fs.test.ts
index 809cca02c46..7422a3acfb1 100644
--- a/apps/desktop/src/lib/desktop-fs.test.ts
+++ b/apps/desktop/src/lib/desktop-fs.test.ts
@@ -202,6 +202,31 @@ describe('desktop filesystem facade', () => {
expect(desktopFsCacheKey()).not.toBe(mrSmallKey)
})
+ it('prefers registry connection identity over SSH host identity', () => {
+ $connection.set({
+ baseUrl: 'http://127.0.0.1:41001',
+ connectionId: 'connection-a',
+ mode: 'remote',
+ remoteHost: 'operator@remote-box',
+ remoteKind: 'ssh',
+ remoteIdentity: 'operator@remote-box',
+ profile: 'default'
+ } as never)
+ const first = desktopFsCacheKey()
+
+ $connection.set({
+ baseUrl: 'http://127.0.0.1:52002',
+ connectionId: 'connection-b',
+ mode: 'remote',
+ remoteHost: 'operator@remote-box',
+ remoteKind: 'ssh',
+ remoteIdentity: 'operator@remote-box',
+ profile: 'default'
+ } as never)
+
+ expect(desktopFsCacheKey()).not.toBe(first)
+ })
+
it('keys SSH filesystem caches by stable host identity instead of the forwarded port', () => {
$connection.set({
mode: 'remote',
diff --git a/apps/desktop/src/lib/desktop-fs.ts b/apps/desktop/src/lib/desktop-fs.ts
index 193ca274123..16bc27f70e9 100644
--- a/apps/desktop/src/lib/desktop-fs.ts
+++ b/apps/desktop/src/lib/desktop-fs.ts
@@ -22,9 +22,9 @@ function connectionCacheKey(connection: HermesConnection | null) {
return 'local:'
}
- // A profile belongs to a registry connection, not the whole Desktop. Prefer
- // the stable registry id so two backends exposing the same profile/path never
- // share filesystem/gitignore cache entries during a connection switch.
+ // A profile belongs to a registry connection, not the whole Desktop. The
+ // registry id is the isolation boundary, including for SSH connections; the
+ // stable host identity below is only the fallback for legacy connections.
if (connection.connectionId) {
return `connection:${connection.connectionId}:${connection.profile || ''}`
}