Repository navigation
Conversation
A window that navigated or detached its registration closed the binding with `browser.pane.registration.closed` and, for `client.closed`, forgot the tabs saved for that server and session. The renderer detaches on every session switch, so leaving a session - or any compaction that remounts it - deleted the session's saved tabs and left the pane's tab strip empty while the pages stayed alive on the server. Detaching or navigating is not the user closing the browser: it now suspends the binding, which keeps the tabs, releases only the pages, and lets the strip keep showing them. Only a session that no longer exists still forgets the saved tabs. A window that registers with an empty inventory restores the tabs saved for its session instead of letting the empty inventory win.
There was a problem hiding this comment.
The core fix looks right. Dropping client.closed from the forget condition stops a session switch or compaction from deleting the session's saved browser tabs. I couldn't verify it here: it needs the desktop app's built-in browser, which this sandbox can't run. With the PR, bun test src/browser in packages/gui-plugins passes and tsc -b is clean.
The public API is unchanged. PaneCloseReason keeps the same values, but client.closed and owner.closed now report browser.pane.suspended, which doesn't match how ipc.ts documents the two reasons.
Concerns:
- Closing a session tab now also keeps its browser tabs. The window sends
client.closewhenever a session key leavessessions.list(). That covers switching sessions and compaction, and also closing the shell tab. With this change, saved tabs are only deleted when the session no longer exists. Closing a session tab will keep its browser tabs (they come back when it reopens), and saved tab entries pile up over time. If that isn't intended, the window would need to tell main whether it is closing the tab or just moving to another session. - Two parts aren't needed for the fix. The new close reason and the
createConnectingchange don't affect this bug (details inline). Dropping them, and the test that covers the new reason, would keep the change to the one-line fix plus its test update.
| if (reason) return close(state, reason, event.type === "client.closed" || reason === "browser.pane.missing") | ||
| // Only a session that no longer exists forgets its tabs. A window that navigated or detached its registration keeps | ||
| // them: they are saved per server and session, and the pane restores them when it registers again. | ||
| if (reason) return close(state, reason, reason === "browser.pane.missing") |
There was a problem hiding this comment.
This is the actual fix. But client.closed also arrives when the user closes the session's shell tab (model.ts session.removed → stop() → connection.close()), not only on a session switch. After this change, only a missing session clears the saved tabs: a closed session tab's browser tabs come back if it is reopened, and saved tab entries pile up. Is that intended? If not, the window would need to say whether it is closing the tab or just detaching.
| if (event.type === "handshake.unsupported") return "browser.pane.unsupported" | ||
|
|
||
| if (event.type === "owner.closed" || event.type === "client.closed") return "browser.pane.registration.closed" | ||
| if (event.type === "owner.closed" || event.type === "client.closed") return "browser.pane.suspended" |
There was a problem hiding this comment.
Changing this reason doesn't help the bug. connection.close() calls stop() (unsubscribes) before sending client.close, so the tabs sent with this event never reach the window. For owner.closed, the window has already navigated away or been destroyed. It also no longer matches ipc.ts, which documents suspended as idle eviction or the plugin going away, and window closes as registration.closed. I'd keep the old reason here.
| } | ||
| // A window that just mounted registers with an empty inventory; the tabs saved for this server and session are what | ||
| // it restores from. A window that already shows tabs keeps its own inventory, which is newer than the saved one. | ||
| const restore = event.restore?.tabs.length |
There was a problem hiding this comment.
This isn't needed for the fix. After session.removed the attachment is deleted, so it registers again with restore: undefined and the saved tabs are already used on the base. An attachment that sends an explicitly empty inventory had already saved that empty state through save-restore. I'd drop this change so the fix stays minimal.
A window that detached its binding - every session switch, and the remount a compaction causes - closed it and the pane deleted the tabs saved for that server and session. The strip came back empty and nothing restored it, while the pages stayed alive in main. A closed binding now keeps its saved tabs and releases only its pages; the tabs return when the window registers again, and a window that registers with an empty inventory restores them instead of letting the empty inventory win. The close reason stays `browser.pane.registration.closed`, so the window still backs off and retries, as `ipc.ts` documents. Saved tabs are still cleaned up: the window marks the close `forget` when the session itself is gone (`session.removed`), and main deletes the saved tabs then, as it already did for `browser.pane.missing`.
|
Thanks, both comments were right and the patch follows them.
On confirming the path: yes, a session switch reaches it, through the re-register rather than |
There was a problem hiding this comment.
I couldn't verify this: it needs the desktop app's built-in browser, which this sandbox can't run. With the PR, bun test src/browser in packages/gui-plugins passes and tsc -b is clean. The public API is unchanged: the new optional forget field on the browser pane's close input is internal to the built-in plugin and backwards compatible.
The close reason is back to browser.pane.registration.closed, so the docs in ipc.ts and the window's retry hold again. The createConnecting change is still there.
The new forget flag comes from session.removed, and that probably brings the bug back (inline). session.removed doesn't mean the session was deleted. It fires when a session key leaves sessions.list(), the list of sessions owned by open shell tabs, and switching sessions inside a shell tab drops the old session's key. On that path main deletes the saved tabs again, as before this PR. Main already deletes them itself when a session is gone (browser.pane.missing), so the window may not need to send forget at all.
| sessions: Object.fromEntries(listed(state.sessions).filter((entry) => !sessionKeys.includes(entry[0]))), | ||
| }, | ||
| effects: gone.flatMap(([key, attachment]) => [...stop(key, attachment.phase), detach(key)]), | ||
| effects: gone.flatMap(([key, attachment]) => [...stop(key, attachment.phase, true), detach(key)]), |
There was a problem hiding this comment.
session.removed means the session's key left sessions.list() (sessions owned by open shell tabs), not that the session was deleted. host-apis.tsx builds those keys from each shell tab's sessionId/routeSessionId. Switching sessions inside a shell tab drops the old session's key, so this sends forget: true and main deletes the saved tabs: the bug from #64734 again. A deleted session is already handled by browser.pane.missing in main. Unless there is a signal that the session or its tab is really gone, I'd not forget here.
…loses A window that closes its binding - every session switch, and the remount a compaction causes - made the pane delete the tabs saved for that server and session. A session switch therefore emptied the strip for good: the saved row was gone, so the next registration had nothing to restore. Only a session that no longer exists deletes its saved tabs now, as main already does for `browser.pane.missing`. Everything else keeps them, so `registered` restores them from the saved inventory. The close reason stays `browser.pane.registration.closed`, so `ipc.ts` still describes every close and the window keeps its retry with backoff. Kept deliberately: closing a session's shell tab keeps that session's browser tabs, and they come back if it is reopened. Row cleanup stays with main, which deletes them when the session is gone.
|
Right on all three, and the patch is now the minimal one.
So the diff is now one condition in |
There was a problem hiding this comment.
I couldn't verify this in the app: it needs the desktop app's built-in browser, which this sandbox can't run. Reading the code, it now removes only the deletion that caused the bug: a window closing its binding (on a session switch or a compaction) no longer deletes the session's saved browser tabs. With the PR, bun test src/browser in packages/gui-plugins passes and tsc -b is clean. The public API is unchanged.
The extra close reason, the createConnecting change and the forget flag are gone. The description says that keeping a closed session tab's browser tabs is deliberate.
One trade-off for maintainers to accept: main only deletes a session's saved tabs (browser.pane.missing) when that session is opened again and turns out to be gone. Rows for deleted sessions that are never reopened stay in storage.
Issue for this PR
Closes #64734
Type of change
What does this PR do?
Leaving a session deletes that session's Review-pane browser tabs, and a compaction does the same. The renderer detaches the session's binding, and the pane read that close as the user closing the browser: it deleted the tabs saved for that server and session, so the strip came back empty and nothing restored it, while the pages stayed alive in main.
One line: a closed binding keeps its saved tabs, and only a session that no longer exists deletes them — which main already does for
browser.pane.missing.registeredthen restores the tabs from the saved inventory.Nothing else changes. The close reason stays
browser.pane.registration.closed, soipc.tsstill describes every close and the window keeps its retry with backoff. Kept deliberately: closing a session's shell tab keeps that session's browser tabs, so reopening the session brings them back; cleanup stays with main, which deletes them when the session is gone.How did you verify your code works?
Reproduced on the 2.3.2 desktop build: three tabs, then a session switch — the strip went empty,
browser.tabs.liststill returned the same tab IDs, and the saved row was gone from the desktop'sstatetable. Switching back re-registers the binding (previously with new page generations), which is the path this change fixes.bun testinpackages/gui-pluginspasses (1142),bun run typecheckandbun run lint:changedare clean, and the test that encoded the old behaviour now asserts the opposite: a window's close keeps the saved tabs, a missing session forgets them.Screenshots / recordings
No UI markup changed — the empty strip is the bug, and it keeps its tabs now.
Checklist