Repository navigation
Record simulator tab opens and closes in main (dark, layout-owner build only) - #30034
Conversation
…yout-owner build only)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
# Conflicts: # src/renderer/src/store/slices/tabs/tabs-close-actions.ts # src/shared/rpc-contract/workspace-layout-params.ts # src/shared/workspace-layout/workspace-layout-group-commands.ts
ELI5
Orca is moving the job of remembering tab layout from the app window to its background process. It is doing this one tab kind at a time, behind a build switch that is off in every shipped build.
This step covers the Mobile Emulator tab. In the test build with the switch on (
ORCA_LAYOUT_OWNER=main), opening or closing a Mobile Emulator tab now tells the background process right away. Before, the background process only found out later, from the window's periodic session save. Shipped builds behave exactly as before.What Changed
Before (switch on): the window drew the Mobile Emulator tab and sent nothing. The background process learned about the tab only when the window next saved its session. The check that watches for "saves that still teach the background process something" (
ORCA_LAYOUT_SAVE_DIVERGENCE_LOG) reportedtab … addedwhen the tab opened andtab … removedwhen it closed.After (switch on): the window still draws the tab first, because the emulator pane attaches to it by tab id. It then records the tab in the background process under the same ids, so the next save teaches the background process nothing.
Mechanism:
openSimulatorTab. It carries the window's tab id (which is also the tab's content id), its group, where in the group the tab sits (afterTabIdorindex), its creation time, andsplitwhen the open made a new group.tab_exists.group_not_found.src/shared/workspace-layout/workspace-layout-simulator-tab.ts, with its params inworkspace-layout-params.ts.ensureSimulatorTabrecords the tab after each of its three creation paths: in the active group, in an existing group to the right, or in a new split to the right. Each path checks the switch at the call. The new-split case reads the split back with the existingnewGroupSplitOf, as editor and browser opens do.closeUnifiedTabrecords a simulator tab's close with the existingcloseTabscommand, right beside the editor close record.runtime:) send nothing and stay with their server. Selection and focus are still the window's own state. The emulator device and stream are untouched.Why
This is the simulator-tab step of phase E2 of the plan to make the background process the only writer of tab layout. Every tab change that reaches the background process only through window saves would be lost once saves stop carrying layout. Simulator tabs had no layout command at all.
Alternatives considered:
openEditorTabto acceptsimulator. Rejected: that command carries editor-only rules (file records, previews, editor views, dirty drafts), and a simulator tab needs none of them.workspace-layout-content-commands.ts. Rejected: Record chat tab opens and closes in main (dark, layout-owner build only) #30019 (chat tabs) is rewriting that file. A separate file keeps the two PRs from conflicting. Once Record chat tab opens and closes in main (dark, layout-owner build only) #30019 lands, itsdrawnTabOpenandwithSendersGrouphelpers can replace the inline id and group checks here. That follow-up is noted in the ledger.Linked Issue
Part of the layout single-owner plan (phase E2, simulator-tab step).
Visual Proof
N/A. Shipped builds have no visual or interaction change: the change is dark, and the off-bundle diff below shows that. With the switch on, the tab looks and behaves the same. Only the background process's copy of the layout changes, and the detector run below shows that.
Testing
Tests written first and seen failing: 10 tests failed at the base commit
824ca9545fcand pass at this head.src/renderer/src/lib/simulator-tab-layout-owner.test.ts:src/shared/workspace-layout/workspace-layout-simulator-tab.test.ts: the command's model rules.workspace-layout-apply.test.ts: the new params.Real app, switch on, hidden window, isolated profile, macOS.
824ca9545fc: 2 reports,tab … addedandtab … removed;Switch-off bundle check (unminified, base
824ca9545fcagainst this head). Every region that differs is one of:CREATES_WORKSPACEentry, the new model file) and its params.layout.applyis not registered in off builds, so nothing can send it;newGroupSplitOf, now in the renderer's client chunk as dead code (exported, never called).ensureSimulatorTablives in a separate chunk (App), so the client chunk keeps the export. This matches the chat-tab step.ensure-simulator-tab.tsandtabs-close-actions.tscompile to the same code as at base.Gates:
pnpm tcpnpm run check:code-quality:changednode config/scripts/check-layout-writer-ratchets.mjspnpm run verify:rpc-params-catalogsrc/renderer/src/store,src/renderer/src/lib,src/renderer/src/runtime,src/shared/workspace-layout,src/shared/rpc-contractandsrc/main/runtime. Only the three failures already known on main remain:orca-runtime.test.ts"badgeColor on runtime cloneRepo", and two local-only cases inorca-runtime-structured-agent-session-create-intent.test.ts.AI Disclosure
Review
An independent adversarial pass over the diff looked for any change when the switch is off and found none. It flagged one switch-on detail, which is fixed here: a tab missing from its group's order no longer sends
index: 0, so it no longer jumps ahead of pinned tabs. It also noted one gap that browser opens already have: the open carries no host id, so a tab drawn for a non-routed host twin would be recorded under the routed host. That is left for when the window draws tabs from the background process's updates.Agent skill upstream boundary
Notes
ensureSimulatorTabalready resolves folder workspaces. The command names the workspace by id, so folders take the same path as worktrees.runtime:): nothing is sent, as tested. The layout of those workspaces stays with the server.openSimulatorTabis a new command onlayout.apply, which exists only in switch-on builds. An older background process would reject it as invalid params. The window keeps its own copy either way.tabs-close-actions.ts, and both widenNewGroupOpenand theLayoutApplyParamscomment. Each is a small conflict to resolve by keeping both sides.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)