Repository navigation
Layout-owner builds: a phone's tab move is always the server's own; no ghost editor tabs after restart - #31925
Conversation
…its own hook status With the layout-owner switch on, main gives agent tabs their generated titles from the hook-server status it owns, on the desktop, headless serve and orcad: one renameTabs per status batch, so one write and one frame. It keeps the window's rules (setting, custom and quick-command titles, first title wins, dispatch labels). The window stops sending generated titles for tabs main holds; a paired server's tab, or one main has no tab-bar entry for, is still titled by the window as today. The title rules move to src/shared (agent-row-primary-text, and the new agent-generated-tab-title-rules) so both sides share them; switch-off behaviour is unchanged.
…lf, and a tab move names the tab it follows so a stale index can't misplace it (layout-owner build, L193)
…ow's way, a twin's agent tab keeps its window title, and orcad subscribes titles through the store attach (layout-owner build)
…ough its compat entry
…ts own, with no cyclic re-export
…e never falls back to the window (layout-owner build) - Main moves a client's tab itself in a workspace it owns; a row it holds no tab for (a combined diff) keeps no place, and an order must still name each row shown once (L280). - The window publishes an editor row under its tab id only; a file no group shows gets none. - Main's layout load gives a saved browser record with no tab its tab, as the window's hydration repair did, and the window no longer mints one for a workspace main owns. - Main's layout load drops the saved tabs the window's restore drops (view-less diff, conflict and check tabs, old html previews), through one shared rule; the next save writes it back (L286). - Main lists conflict-review and check-details tabs as the plain file rows the window lists, so older clients keep them once the window's rows are gone (L287).
…owner build) - A transient tab stays at load while a view is held for its file, as the window's frame build keeps it, not only for its own tab id. - The repaired browser tab goes to the saved active group only while it holds a tab, as selectHydratedActiveGroupId picks it; tests that the id is stable across loads and restarts, that a window-owned build restores it once, and that a paired server's record keeps the window's repair. - Two switch-on tests keyed editor drafts by path; drafts are keyed by editorFileKey (an owned id in a layout-owner build), so they now use it.
…s SSH workspace keeps the window repair
…'s views, so main's own edits keep a live diff
… drop with no host contact
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Do not advertise editor views when the partition has none. · workspace-layout-projection.ts:44-51
src/main/runtime/workspace-layout-projection.ts:44-51
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winDo not advertise editor views when the partition has none.
getLayoutEditorViews(hostId)can returnundefinedafter restart. This branch still supplieseditorViewsOf, so the loader treats the partition as views-aware and can drop saved transient tabs with no held view. A later full save removes those tabs from the session.Restore the base guard:
Suggested fix
- ...(store.getLayoutEditorViews ? { editorViewsOf: (key: string) => views?.[key] } : {}) + ...(views ? { editorViewsOf: (key: string) => views[key] } : {})
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
ffe7011b-dc33-426f-93da-50cd04083cab
📒 Files selected for processing: 1
src/shared/workspace-layout/workspace-layout-load-browser-repair.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
…and create anchor use, after #31925 dropped its import (layout-owner build, L288, L289) #31925 removed the L280 bridge in main's tab move, and with it the move's last use of resolveSessionTabRow, so it dropped the import; this branch's split selection and create-anchor lookup still resolve a row to main's tab through it. A row main's layout does not hold is now refused by main's move (tab_not_found) as #31925 rules; the phone test asserts that.
…ost does and uses a store that announces its writes (layout-owner build) Since #31925, main moves every tab of a workspace it owns and refuses a row its layout does not hold, and since D3b a chat the host opens is saved in main's layout. The test now opens the chat through the host's publish path and gives the runtime a profile-like store (partitions listed, writes announced), so the reorder reaches main's layout and its commit reaches the rows.
…holds chats and moves every row now (L283) Since D3b a chat the host opens is saved in main's layout, and since #31925 a phone cannot move a row main does not hold, so the rebuilt-group stray this placed no longer reaches a phone; the remaining strays are brief, and appending them gives the same order. withStrayIn and its callers return to main's behaviour, with its unit test. The phone-order spec stays as a guard that a windowless chat moved first stays first after a rebuild.
…lects the moved tab as the window does (dark, layout-owner build only) (#31924) * fix(session-tabs): a tab main's groups lack keeps the place its writer listed it, so a headless phone lists a chat first (layout-owner build, L283) On a host with no window, a rebuild writes its rows under a group id main's layout lacks. The row writer's reorder treated every row of that group main does not hold (a chat, a browser page) as a stray and appended it to the active group, so a chat the user moved first came back last, in both the groups and the tab list. Strays now go after the id they follow in the writer's order (else first), the same rule a group main does hold already used; the window publication path shares it. * fix(session-tabs): a phone's split move and its create after a split tab go through main's layout on a windowless host (layout-owner build, L288, L289) On a host with no window, a phone's split move only rewrote the runtime's own rows, and its new terminal anchored after a split tab reached main's layout with no anchor. Every write of the rows takes main's groups and order, so the split collapsed back into one group and the new tab landed after the trailing tab. The split is now main's splitGroup command (the moved tab selected in its new group, as a desktop drop), and the create passes the anchor's tab to main's createTerminalTab, as a window's create does. An older phone sends no anchor and still gets the end. * test(session-tabs): type the split move's async reply in the dispatch stub, and read an optional group map (L289) * fix(session-tabs): a phone's split goes to main's layout only for a tab main holds, as the window sends it (layout-owner build, L289 review) With the Store's write notices, today's runtime-only split already reached main's groups through the session write; what it lost on a windowless host was the selection: the moved tab and its new group did not become the active ones, as they do after a window's drop. The split stays main's splitGroup for a tab main's groups hold, with the window's checks: a drop main's groups make a no-op sends nothing (the window's pane-column rule, now in shared), and a refusal is dropped silently. A row main does not hold (a chat or browser tab) splits as today, with no error. The create anchor and its layout-owner hand-off move to their own module. The surface test fixture's session writes now notify listeners, as the Store's do. * chore(session-tabs): log when main refuses a phone's split, as the window logs its own refusals * fix(session-tabs): a phone's terminal created after a chat or browser tab main holds lands after it, in its group (layout-owner build, L288 follow-up) Since browser and chat tabs went main-first, main's layout holds them, but a windowless create handed main the row id (agent-session:<id>), which is not main's tab id, so main put the new tab at the end of its first group. The anchor is now resolved to main's own tab, as a window's create names it; main's read of a workspace's layout is one method the tab-move path shares. * fix(session-tabs): one move path: main's tab move selects a split tab in its new group and skips the window's no-op split (layout-owner build, L289) A phone's split now goes only through main's tab move (#31812); this branch's own split routing is gone. For a split only, main's tab move now does what the window's drop does: it sends nothing for a drop that changes nothing (the window's pane-column check, reused), and after main applies the split it selects the moved tab and makes its new group active. Refusals keep that path's codes. * fix(session-tabs): resolve a create's anchor to main's tab inside the tab-move module, so only the old-client boundary's listed importers read old-client rows (L288 follow-up) * perf(session-tabs): read main's layout for a create's anchor only when main places it, so switch-off and appending phones skip that load * fix(session-tabs): restore the row-to-tab lookup the split selection and create anchor use, after #31925 dropped its import (layout-owner build, L288, L289) #31925 removed the L280 bridge in main's tab move, and with it the move's last use of resolveSessionTabRow, so it dropped the import; this branch's split selection and create-anchor lookup still resolve a row to main's tab through it. A row main's layout does not hold is now refused by main's move (tab_not_found) as #31925 rules; the phone test asserts that. * test(session-tabs): the L283 phone-order test opens its chat as the host does and uses a store that announces its writes (layout-owner build) Since #31925, main moves every tab of a workspace it owns and refuses a row its layout does not hold, and since D3b a chat the host opens is saved in main's layout. The test now opens the chat through the host's publish path and gives the runtime a profile-like store (partitions listed, writes announced), so the reorder reaches main's layout and its commit reaches the rows. * test(session-tabs): type the L283 test's profile-like store as the Store contract declares it * revert(session-tabs): drop the stray-placement change; main's layout holds chats and moves every row now (L283) Since D3b a chat the host opens is saved in main's layout, and since #31925 a phone cannot move a row main does not hold, so the rebuilt-group stray this placed no longer reaches a phone; the remaining strays are brief, and appending them gives the same order. withStrayIn and its callers return to main's behaviour, with its unit test. The phone-order spec stays as a guard that a windowless chat moved first stays first after a rebuild.
ELI5
In the new layout mode (still switched off for everyone), the server now owns every tab a phone or a paired desktop can see. So when a phone drags a tab, the server moves it itself instead of falling back to the old desktop-window path. Four small gaps that kept that fallback alive are closed.
What Changed
Dark change: switched-on (layout-owner) builds only. One shared rule moves from the window into a shared file and behaves the same; the switched-off build is otherwise unchanged.
main-layout-session-tab-move.tsloses the bridge that sent a client's move to the window when a group showed a row the server couldn't resolve.translateSessionTabMovenow maps a "move to index N" past such a row, and a reorder must still name each shown row once; today's refusal codes (tab_not_found,invalid_tab_order,target_group_not_found) are unchanged.mobile-session-snapshots.ts), the one row id the server could not map.sendLayoutApplyuses (runtimeEnvironmentIdUnlessTwin,src/renderer/src/lib/resolve-owner.ts:214,layout-apply-send.ts:240). A directly dialed SSH workspace is the server's too (its layout loads under itsssh:host); a paired server's workspaces, SSH ones included, keep the window's repair. Two guarantees for direct SSH workspaces:loadWorkspaceLayout(hostId, session, context)(src/shared/workspace-layout/workspace-layout-load.ts:138) takes no connection input and never contacts the host. So a direct SSH workspace whose host is down still gets the same deterministic repair, and loses only what the window's own rule drops. Test:workspace-layout-load-browser-repair.test.ts, "repairs and drops the same in a direct SSH partition, whose host it never contacts".ORCA_LAYOUT_OWNER_IS_MAIN(src/renderer/src/store/slices/browser/browser-hydration-actions.ts:65). With the switch off, a direct SSH workspace keeps today's window repair. The "directly dialed SSH" case instore-session-browser-hydration.test.tsexpects the repaired tab with the switch off, and the comparison runs it in both modes.Not done through
openBrowserTab: that command cannot attach a tab to an existing record (it appends a second record and mints a page). The repair is made on every load with the same id, so it is idempotent. It is not guaranteed to reach the saved file: a server command rewrites only the records it changed, while a whole save writes it. A switched-off build reading either form ends with exactly one tab (tests for both).tabs-hydration.ts); the server's load kept them, so its groups counted tabs nobody could see. Both now use one rule,src/shared/workspace-layout/saved-editor-tab-restore.ts. The server applies it only in loads that carry its in-memory views (the layout it publishes and every client or window command), where it matches what the window draws from the server's frames. The server's own edits (a phone's browser tab, an agent tab) load without views, so they keep every saved tab and never drop a live diff. The saved file may keep the dropped entry until a whole save rewrites it; a switched-off build restores the same tabs from either form, since its own restore drops them too.reviewTabRow).editorFileKey(an owned id in a layout-owner build); they failed on main too and now use it.Why
Each gap is closed where it starts, so the server's layout is the one source for every tab a group shows and the fallback has nothing left to cover. Re-reading the window's list for those rows would have kept two sources.
Linked Issue
Internal (layout-owner refactor ledger rows L280, L286, L287).
Visual Proof
N/A: switched-off builds are unchanged; the switched-on changes are in the server's move and row handling, covered by the tests below.
Testing
Fail-first, red at base, green at head (switched on; the mocked-switch files also off):
main-layout-session-tab-move.test.ts: a move in a group showing a row the server holds no tab for is the server's own (window not asked); an order that doesn't name exactly the rows shown is refused.workspace-layout-load-view-less-tabs.test.ts: a load with the server's views drops what the window drops, keeps a diff of a saved file and a tab whose view is held, and a dropped tab never counts in a client's move index; a load without views keeps every saved tab.workspace-layout-projection.test.ts: the published layout loads with views even before any view is held (fails before the fix).workspace-layout-load-browser-repair.test.ts: the repaired tab, its group (including a saved active group the load empties), a stable id across loads and restarts.session-tab-rows-main-window-parity.test.ts: server and window rows are equal with conflict-review and check-details tabs added.sync-runtime-graph-editor-diff-tabs.test.ts,store-session-browser-hydration.test.ts(local and directly dialed SSH workspace: no window repair; a paired server's workspace and its SSH workspace: window repair kept),tabs-hydration-main-load-drop.test.ts(a switched-off build reads the rewritten session the same).Server specs (switched on, fresh build at each exact commit; base = main 01db1b8, head c1765f1 (pass at 5649cbe too); the last commit adds a test only):
Per-test comparison over
src/main/runtime src/main/persistence src/shared/workspace-layout src/renderer/src/runtime src/renderer/src/store, base main 01db1b8, head c1765f1 (the last commit adds a test only):Switched on: 24745 base / 24762 head tests; 26 base failures, 25 head. One head-only failure,
profile-state-backup-worker.test.ts, is a timing flake: it fails 2 of 3 runs alone at base too, in a file this PR does not touch. Two fixed since base: the converted stale draft-key fixtures.Switched off: 24745 base / 24763 head tests; 2 base failures, 3 head. The one head-only failure is the same backup-worker flake.
4 tests absent at head in both modes, all renamed by this PR: three parity tests whose
describenow reads "main's diff, markdown-preview and review rows", and the old window-fallback move test, converted to "moves in a group showing a row main holds no tab for, without asking the window".I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Three Opus passes on the code. Pass 1: approve with nits (fixed: view check keyed by file like the window; comment example; rebutted: review rows are never dirty since a review tab holds no draft, and the repaired browser tab is not activated, a view choice left to the window). Pass 2 found the repaired browser tab could land in a saved active group the load had just emptied; fixed with the same group-owner map the group order uses, plus a test. Pass 3 on the final code: approve, no findings above nit. The full per-test comparison then caught a regression none of the reviews did: the server's own edits loaded without its views and would have deleted a live diff tab (
editor-renames-across-partitions.test.tswent red). Fixed by dropping only in loads that carry the views; delta review: approve, and it traced that every publish and command path carries them and that a window-opened diff's view is stored before any load can see the tab. A commit adding SSH cases to a test had its own delta review: approve (traced: a directly dialed SSH workspace resolves to this app, a server's SSH workspace to that server).Agent skill upstream boundary
Notes
Security: none. Cross-platform: none. SSH/remote: directly dialed SSH workspaces get the server's repair like local ones; a paired server's workspaces (SSH included) keep the window's; rows older peers see keep today's shape and ids, and gain the review rows the window already sent. Mobile: no wire change. Performance: one pass over the saved tabs at load.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)