Skip to content

Record simulator tab opens and closes in main (dark, layout-owner build only) - #30034

Merged
Jinwoo-H merged 4 commits into
mainfrom
e2-simulator-tabs
Oct 17, 2026
Merged

Jinwoo-H merged 4 commits into
mainfrom
e2-simulator-tabs

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​401 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​401
Prod 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​201 $\color{#cf222e}{\Huge{\mathbf{−}}}$​47 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​154

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) reported tab … added when the tab opened and tab … removed when 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:

  • New layout command 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 (afterTabId or index), its creation time, and split when the open made a new group.
    • Sending the same open again changes nothing.
    • An id another tab already holds is refused with tab_exists.
    • A group the background process does not hold, beside groups it does hold, is refused with group_not_found.
    • A workspace with no group takes the window's group, as the editor open already does.
    • The model change is in src/shared/workspace-layout/workspace-layout-simulator-tab.ts, with its params in workspace-layout-params.ts.
  • Opens: ensureSimulatorTab records 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 existing newGroupSplitOf, as editor and browser opens do.
  • Closes: closeUnifiedTab records a simulator tab's close with the existing closeTabs command, right beside the editor close record.
  • Unchanged: paired-server workspaces (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:

  • Widen openEditorTab to accept simulator. Rejected: that command carries editor-only rules (file records, previews, editor views, dirty drafts), and a simulator tab needs none of them.
  • Let the background process create the tab and have the window draw it from the reply. Rejected for this step: the emulator pane and its launch coordination address the tab by id synchronously. The window drawing first and the background process recording under the window's ids is the pattern already used for editor, browser and chat tabs.
  • Put the model function in 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, its drawnTabOpen and withSendersGroup helpers 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

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Tests written first and seen failing: 10 tests failed at the base commit 824ca9545fc and pass at this head.

  • src/renderer/src/lib/simulator-tab-layout-owner.test.ts:
    • Uses the real store and the real layout model as a fake background process.
    • After each open and close, it compares the window's save with the background process's stored copy. That is the comparison the detector makes.
    • Covers: an open in the active group and its close; an open into a new right split and the collapse of that group on close; an open into an existing right group; an open into the window's emptied root group.
    • Also checks that nothing is sent when the tab already exists, for a paired-server workspace, or with the switch off.
  • 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.

  • A temporary spec (not committed) opens a Mobile Emulator tab the way the background process's "focus emulator pane" event does. This launches no device. The spec then closes the tab, letting the window save after each step.
  • With the detector log on:
    • base 824ca9545fc: 2 reports, tab … added and tab … removed;
    • this head: no reports.
  • The open-to-the-right path launches a real iOS or Android device, so the real-app run does not cover it. The unit-level save comparison above does.

Switch-off bundle check (unminified, base 824ca9545fc against this head). Every region that differs is one of:

  • the new command in the shared command model (one dispatch case, one CREATES_WORKSPACE entry, the new model file) and its params. layout.apply is not registered in off builds, so nothing can send it;
  • the new recorder module and newGroupSplitOf, now in the renderer's client chunk as dead code (exported, never called). ensureSimulatorTab lives in a separate chunk (App), so the client chunk keeps the export. This matches the chat-tab step.

ensure-simulator-tab.ts and tabs-close-actions.ts compile to the same code as at base.

Gates:

  • pnpm tc
  • pnpm run check:code-quality:changed
  • node config/scripts/check-layout-writer-ratchets.mjs
  • the anti-slop oxlint
  • pnpm run verify:rpc-params-catalog
  • vitest over src/renderer/src/store, src/renderer/src/lib, src/renderer/src/runtime, src/shared/workspace-layout, src/shared/rpc-contract and src/main/runtime. Only the three failures already known on main remain: orca-runtime.test.ts "badgeColor on runtime cloneRepo", and two local-only cases in orca-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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • SSH: the open and close go through the same routing as editor and browser opens, so an SSH workspace's tab is recorded in that host's partition.
  • Folder workspaces: ensureSimulatorTab already resolves folder workspaces. The command names the workspace by id, so folders take the same path as worktrees.
  • Paired servers (runtime:): nothing is sent, as tested. The layout of those workspaces stays with the server.
  • Mobile: no change. The phone has no simulator tab, and nothing the background process publishes changes in shipped builds.
  • Wire compatibility: openSimulatorTab is a new command on layout.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.
  • Cross-platform: no platform-specific code.
  • Merge conflict with Record chat tab opens and closes in main (dark, layout-owner build only) #30019: both PRs add a line next to the editor close record in tabs-close-actions.ts, and both widen NewGroupOpen and the LayoutApplyParams comment. Each is a small conflict to resolve by keeping both sides.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 847a410d-89d5-4827-81ce-790bd0ad29cd
📥 Commits

Reviewing files that changed from the base of the PR and between 5b81d8c and 1725ea1.

📒 Files selected for processing: 2
  • src/shared/rpc-contract/workspace-layout-params.ts
  • src/shared/rpc-contract/workspace-layout-sleep-wake-params.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

📝 Walkthrough

The workspace layout command flow now supports opening simulator tabs, including placement in a group or split. When the main process owns layout updates, the renderer records simulator-tab opens and closes. Tests cover command validation, tab placement, duplicate handling, and layout synchronization.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 1725e

The change adds simulator-tab layout recording behind an owner switch and leaves default behavior unchanged. No merge-blocking issue was found in the supplied code.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 14 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: recording simulator-tab opens and closes in the main layout owner for dark builds.
Description check Passed The description is detailed and covers the user-visible behavior, implementation, rationale, testing, compatibility, risks, and checklist. It is mostly complete; the Linked Issue section names the bro…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is detailed and covers the user-visible behavior, implementation, rationale, testing, compatibility, risks, and checklist. It is mostly complete; the Linked Issue section names the broader plan but does not include a concrete issue link.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

# 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
@Jinwoo-H
Jinwoo-H merged commit 609f342 into main Oct 17, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant