Skip to content

The agent that grows with you

fix(desktop): a local profile rename leaves other connections' owner hints alone

John Paul Solivac2f319292977
diff --git a/apps/desktop/src/store/session-states-profile-rename.test.ts b/apps/desktop/src/store/session-states-profile-rename.test.ts
index 0ab0cb7fe60..5e1ffec4aec 100644
--- a/apps/desktop/src/store/session-states-profile-rename.test.ts
+++ b/apps/desktop/src/store/session-states-profile-rename.test.ts
@@ -72,4 +72,24 @@ describe('migrateTilesForProfile', () => {
{ connectionId: 'local', profile: 'hutnik-projectmanager', targetProfile: 'hutnik-projectmanager' }
])
})
+
+ it('leaves owner hints of a same-named profile on another connection alone', async () => {
+ const storage = await import('@/lib/storage')
+ const remote = { connectionId: 'remote-1', profile: 'webdesign_bhp', targetProfile: 'webdesign_bhp' }
+ storage.writeJson('hermes.desktop.sessionOwnerHints.v1', [
+ ['s-1', { connectionId: 'local', profile: 'webdesign_bhp', targetProfile: 'webdesign_bhp' }],
+ ['s-9', remote]
+ ])
+
+ const sessionStore = await import('@/store/session')
+ const { migrateTilesForProfile } = await import('@/store/session-states')
+ migrateTilesForProfile('webdesign_bhp', 'hutnik-projectmanager')
+
+ expect(sessionStore.getSessionOwnerHints('s-1')).toEqual([
+ { connectionId: 'local', profile: 'hutnik-projectmanager', targetProfile: 'hutnik-projectmanager' }
+ ])
+ // The rename ran on the local backend; the remote profile still has its old name.
+ expect(sessionStore.getSessionOwnerHints('s-9')).toEqual([remote])
+ expect(storage.readJson<unknown[]>('hermes.desktop.sessionOwnerHints.v1')).toContainEqual(['s-9', remote])
+ })
})
diff --git a/apps/desktop/src/store/session.ts b/apps/desktop/src/store/session.ts
index 35759e98564..d30340823de 100644
--- a/apps/desktop/src/store/session.ts
+++ b/apps/desktop/src/store/session.ts
@@ -169,7 +169,9 @@ export function migrateSessionOwnerHintsForProfile(oldProfile: string, newProfil
for (const [key, entry] of [...sessionOwnerHints]) {
const { route } = entry
- if (route.profile !== from && route.targetProfile !== from) {
+ // Local-connection hints only, like every other rename family: a same-named
+ // profile on another connection was not renamed.
+ if (route.connectionId !== 'local' || (route.profile !== from && route.targetProfile !== from)) {
continue
}