The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): deleting a session prunes its preview tabs in every profile bucket
teknium1db91e4d99321
diff --git a/apps/desktop/src/store/preview.test.ts b/apps/desktop/src/store/preview.test.tsindex c89f6503ef1..9b88dc9e2ba 100644--- a/apps/desktop/src/store/preview.test.ts+++ b/apps/desktop/src/store/preview.test.ts@@ -485,6 +485,35 @@ describe('preview session scoping (#73890)', () => {expect(paths($previewTabs.get())).toEqual(['/work/a.html'])})+ it("prunes a deleted session's tabs from its own profile while another profile is on screen", () => {+ try {+ setPreviewScope('prof-del-x')+ openPreview(fileTarget('/work/x-pinned.html'), 'stored-del-x')+ setPreviewTabPinned($previewTabs.get()[0]!.id, true)+ openPreview(urlTarget('https://x.example'), 'stored-del-x')+ openPreview(fileTarget('/work/x-other.html'), 'stored-del-other')+ setPreviewScope('prof-del-y')+ openPreview(fileTarget('/work/y.html'), 'stored-del-y')++ prunePreviewTabsForSession('stored-del-x')++ const stored = JSON.parse(window.localStorage.getItem('hermes.desktop.previewTabs.v2') ?? '{}') as Record<+ string,+ { target: PreviewTarget }[]+ >++ expect(paths(stored['prof-del-x'] ?? [])).toEqual(['/work/x-pinned.html', '/work/x-other.html'])+ expect(paths(stored['prof-del-y'] ?? [])).toEqual(['/work/y.html'])++ setPreviewScope('prof-del-x')+ expect(paths($previewTabs.get())).toEqual(['/work/x-pinned.html', '/work/x-other.html'])+ } finally {+ setPreviewScope('default')+ dropPreviewTabsForProfile('prof-del-x')+ dropPreviewTabsForProfile('prof-del-y')+ }+ })+it('keeps a draft tabs in the draft until that draft itself gets its stored id', () => {openPreview(fileTarget('/work/draft.html'))newBrowserTab()diff --git a/apps/desktop/src/store/preview.ts b/apps/desktop/src/store/preview.tsindex 9fe6dc3c51e..1b94f70d0d4 100644--- a/apps/desktop/src/store/preview.ts+++ b/apps/desktop/src/store/preview.ts@@ -1141,11 +1141,27 @@ export function setPreviewTabPinned(tabId: string, pinned: boolean): void {}/** Drop the tabs a deleted session opened. Pinned tabs survive — they belong- * to the workspace, not the session that opened them. */+ * to the workspace, not the session that opened them. Every profile bucket,+ * not just the view: a session can be deleted while another profile's chat+ * is on screen, and its tabs live in its own profile's bucket. */export function prunePreviewTabsForSession(sessionId: string): void {const doomed = currentSessionId(sessionId)+ const keep = (tab: PreviewTab) => tab.pinned || currentSessionId(tab.sessionId) !== doomed+ let backgroundChanged = false++ for (const [key, tabs] of Object.entries(tabsByProfile)) {+ if (key !== viewKey && !tabs.every(keep)) {+ tabsByProfile[key] = tabs.filter(keep)+ backgroundChanged = true+ }+ }++ if (backgroundChanged) {+ persistTabs()+ forgetGonePendingTabs()+ }- $previewTabs.set($previewTabs.get().filter(tab => tab.pinned || currentSessionId(tab.sessionId) !== doomed))+ $previewTabs.set($previewTabs.get().filter(keep))}export function closeRightRailTab(tabId: string) {