Skip to content

Keep an editor tab Orca moved to its file's workspace across restart; record editor renames in main (dark) - #29930

Merged
Jinwoo-H merged 9 commits into
mainfrom
e2-2-editor-tabs
Oct 17, 2026
Merged

Jinwoo-H merged 9 commits into
mainfrom
e2-2-editor-tabs

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor

ELI5

There are two changes here.

A fix that ships now. Orca sometimes moves a restored editor tab to another workspace by itself: the one that owns the file. That tab used to disappear the next time Orca started. It now stays open in the workspace it was moved to.

Dark changes, only in the test build where the background process owns the tab layout (switch ORCA_LAYOUT_OWNER=main):

  • Renaming or moving an open file in the explorer now reaches the background process.
  • When Orca closes a merge-conflict placeholder tab, that close now reaches the background process too.
  • Diff, conflict and preview editor tabs no longer lose their content when the background process sends a layout update.

What Changed

Shipped fix (every build): a moved editor tab survives restart.

  • Before:
    1. A restored editor tab's file loads under a sibling workspace, and Orca moves the tab there.
    2. The tab and its file are then named by the file's workspace-qualified id (editor:<workspace>:local:<path>).
    3. On restart, a local file is rebuilt under its bare path, so the tab names no open file and is dropped. The file's unsaved draft survived but was hidden.
  • After: restore rebuilds a file under the workspace-qualified id whenever a saved tab in that workspace names that id. The tab finds its file again.
  • Also fixed: the move now gives the tab its new workspace (worktreeId) and host (executionHostId), where before it kept the old ones.
  • What else changes: files whose saved tabs don't name a workspace-qualified id restore exactly as before.

What the moved tab's corrected workspace changes in shipped builds. These are the readers of a moved restored editor tab's worktreeId/executionHostId, found by reading code:

  • Tab palette and tab search (unified-tab-host-ownership.ts:67-71, used by workspace-tab-palette-entry-builder.ts and workspace-tab-palette-activation.ts). Visible: the moved tab used to be missing from the palette and tab search. It is now listed under the workspace it sits in, can be selected, and can show as the current tab.

  • Close all editors (recently-closed-editor-tabs.ts:89-94). Visible:

    • closing all in the tab's workspace used to leave the moved tab behind with its file gone;
    • closing all in the old workspace used to close the moved tab instead.

    Both now act on the right workspace.

  • Main-process session bookkeeping (worktree-identity-migration.ts, profile-session-owner-transfer.ts, session-worktree-ownership.ts). Renaming a worktree and pruning workspace metadata now count the row under its real workspace.

  • Moving the session store to the background service (orcad-source-workspace-session-eligibility.ts, orcad-migration-dormant-session-validation.ts). Very likely fixed, not reproduced: the stale workspace or host could block or fail the move.

  • No change: close, activate and move actions (they use the bucket key); mobile and web views (they publish per workspace bucket); the saved-session format (same fields).

Dark changes (switch-on builds only):

  • Explorer renames and moves of open files are recorded in main with a new renameEditorFiles command. It carries the window's own tab and file ids, one command per workspace.
    • The window still renames first, together with its drafts and the autosave guard, because the move needs its answer at once.
    • Main applies the command in the workspace's own partition, including an SSH host's.
    • A paired server's workspace (runtime:) acts as today.
    • Main's unused path-keyed rename transition is deleted. It could never match workspace-qualified or diff ids.
  • Conflict placeholders: when a git status poll drops a resolved conflict placeholder, main now closes its tab. Before, the next layout update brought it back.
  • Layout updates keep editor content.
    • Reproduced first: a layout update closed an open diff tab in the window while main kept it, and a markdown preview kept its tab but lost its content.
    • Now a diff, conflict or check tab survives when the window holds its record. A record goes away only with the last tab showing it.
  • Cleanup: the uncalled reorderFiles is deleted.

Why

This is step E2-2 of the plan to make main the only writer of tab layout. Editor changes that reach main only through window saves would be lost once saves stop carrying layout.

The owner approved fixing the restart bug inside this PR.

Alternative for the restart fix, considered first: map the saved id back to the bare path on restart. Review showed that main still holds the workspace-qualified id, so the window and main would disagree from the first layout update. Keeping the id the tab names keeps restart, layout updates and main consistent.

Linked Issue

Part of the layout single-owner plan (phase E2, step E2-2).

Visual Proof

Shipped restart fix, real app in a hidden window on an isolated profile, macOS. The steps: open a restored editor tab whose file belongs to a sibling worktree, let Orca move it, then restart.

  • Before (main fd1c6a592cc): after the restart the editor tab is gone; the workspace shows only a terminal.
  • After (this branch): after the restart the moved editor tab is open in the sibling worktree, with its content.

Screenshots are kept locally (they show a terminal prompt with the machine's account name) and are available on request.

Testing

  • Unit tests:

    • restored-editor-owner-restart.test.ts: move, save, restart. It fails on main.
    • hydrated-editor-session-state.test.ts: the restored id, and a sibling workspace with the same path open, for a restart and for layout updates covering either or both workspaces.
    • A moved-tab profile in the startup layout-parity test: what the window restores matches what a layout update builds.
    • Main's rename command, including refusals and a record only for a tab main shows.
    • The rename in an SSH partition, and a folder workspace reopened from disk.
    • Conflict placeholder close; diff, preview and conflict tabs kept through a layout update.
  • pnpm tc passes, as do the changed-code quality gate, both layout-writer ratchets (renderer count 652 to 651), the static-analysis lint and the parameter-catalog check. Broad vitest over store, editor, app shell, workspace layout, runtime RPC and persistence passes.

  • Switch-off bundle check (unminified, against fd1c6a592cc). The only behaviour change is the restart fix in hydrated-editor-session-state and restored-editor-owner-transition. Every other region that differs is:

    • reorderFiles removed;
    • a renamed parameter in rekey-open-files-action and git-status-actions (setGitStatus also became a block body that still returns nothing);
    • a new tabs-hydration parameter that defaults to "keep nothing";
    • the new command in the shared command model and parameters. layout.apply is not registered in off builds.
  • Switch-on, hidden window, macOS: the layout oracle plus the real-app split, resize, close and relaunch spec pass, 22 of 22, at this head. The save-divergence detector logs the same set as main: the oracle has no rename, diff or conflict scenarios, so no baseline report is silenced here.

  • Latency, open file until its editor tab shows (30 runs):

    • switch off: p50 19 ms, p95 36 ms;
    • switch on: p50 32 ms, p95 67 ms.

    Flip blocker: open-file p95 is over 50 ms with the switch on. This is recorded for the switch decision, not tuned in dark code. Update (after merge): a 90-sample A/B that times until the change is drawn in both modes shows no switch gap for new tab or open file, so this flip blocker is closed. The 0 ms off baseline for rename and toggle was a harness artifact (off was timed before React drew); the real gap is about 6–10 ms at 22–27 ms p95, under the bar.

Review

  1. Fresh adversarial review: merge with fixes. It found a layout update rebuilding one workspace could point a tab at a sibling's same-path file, and a renamed file's record added with no tab. Both are fixed.
  2. First delta review: rework. Mapping only on restart left main and the window on different ids. Redesigned as above.
  3. Second delta review: merge as is, with two low findings.
    • The sibling test it asked for is added.
    • Left as is: the hidden-frontmatter flag is one map shared by all workspaces. In the rare case where a moved tab's file is also open by bare path in a sibling workspace, the two share the flag.

Agent skill upstream boundary

  • Not applicable.

Notes

  • SSH: the restore rule and the rename command cover SSH-hosted files and partitions.
  • Folder workspaces: they go through the same path.
  • Paired servers: their workspaces keep today's path.
  • Mixed versions: the new command only goes to the same build's main.
  • Mobile: not affected.

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)

…ross restart

The move saved the tab under the file's owned id and left the tab's
workspace pointing at the old one. Restore rebuilt a local file under
its bare path, so the tab named no open file and was dropped. Restore
now maps a saved owned id to the id it rebuilds, and the move gives
the tab its new workspace.
…me redraws editor tabs

Switch-on builds only. A frame rebuilds the window's tabs through the
restore builders, which drop every diff, conflict and check tab (restore
has no record for them), and the store patch dropped every open file
the frame did not carry. Frames carry only edit-mode files, so the next
frame after opening a diff closed it in the window while main kept it,
and a markdown preview kept its tab but lost its record.

The rebuild now keeps a transient tab whose record the window holds,
and a held record goes only with the last tab showing it; a record no
tab shows (a conflict review's selected file) stays.
…ceholders in main

Switch-on builds only; switch-off behaviour is unchanged.

A rename or move in the explorer rekeys open editor, preview and diff
tabs in the window and main learned it only from the window's save.
The window now records the rekey as a `renameEditorFiles` command,
under the ids it chose (bare path, owner-qualified id, diff id), one
per workspace, with each edit-mode file's new record. It records
rather than asks first: the rekey is atomic with drafts and the
autosave echo gate, and its answer gates the move coordinator. Main's
path-keyed `editorFilesRenamed` transition, which nothing produced and
which could not match owner-qualified or diff ids, becomes this command.

A git status poll that sees a deleted-side conflict resolved drops its
placeholder record but leaves the tab to the tab reconcile; frames then
brought main's edit record back. Main now closes that tab.
Restart and frames now agree: neither rekeys the tab, and a frame that
redraws one workspace never points its tab at a same-path file in
another. A rename that changes nothing leaves no empty file list.
@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: d6c67332-7915-4a1f-825a-bbed6b6b6e84
📥 Commits

Reviewing files that changed from the base of the PR and between 633df3a and 615d2f7.

📒 Files selected for processing: 28
  • config/renderer-layout-writer-baseline.txt
  • src/main/persistence/terminal-topology/editor-tab-layout-apply.test.ts
  • src/main/runtime/rpc/methods/workspace-layout-apply.test.ts
  • src/main/runtime/runtime-layout-apply.test.ts
  • src/main/runtime/runtime-layout-apply.ts
  • src/renderer/src/app-shell/startup-window-frame-parity.test.ts
  • src/renderer/src/runtime/layout-apply-send.ts
  • src/renderer/src/runtime/workspace-layout-frame-sync.ts
  • src/renderer/src/store/slices/editor-layout-owner-records.test.ts
  • src/renderer/src/store/slices/editor/actions/git-status-actions.ts
  • src/renderer/src/store/slices/editor/actions/hydrated-editor-session-state.test.ts
  • src/renderer/src/store/slices/editor/actions/hydrated-editor-session-state.ts
  • src/renderer/src/store/slices/editor/actions/open-file-mutations.ts
  • src/renderer/src/store/slices/editor/actions/rekey-open-files-action.ts
  • src/renderer/src/store/slices/editor/actions/restored-editor-owner-transition.ts
  • src/renderer/src/store/slices/editor/tabs/editor-tab-layout-owner.ts
  • src/renderer/src/store/slices/editor/types/editor-files-slice.ts
  • src/renderer/src/store/slices/restored-editor-owner-restart.test.ts
  • src/renderer/src/store/slices/tabs-hydration.ts
  • src/renderer/src/store/workspace-layout-frame-slices.ts
  • src/renderer/src/store/workspace-layout-frame-store-patch.ts
  • src/shared/rpc-contract/workspace-layout-params.ts
  • src/shared/workspace-layout/workspace-layout-command-types.ts
  • src/shared/workspace-layout/workspace-layout-commands.ts
  • src/shared/workspace-layout/workspace-layout-editor-rekey.test.ts
  • src/shared/workspace-layout/workspace-layout-editor-rekey.ts
  • src/shared/workspace-layout/workspace-layout-transitions.ts
  • src/shared/workspace-layout/workspace-layout-workspace-move.ts
💤 Files with no reviewable changes: 3
  • src/renderer/src/store/slices/editor/types/editor-files-slice.ts
  • src/shared/workspace-layout/workspace-layout-transitions.ts
  • src/renderer/src/store/slices/editor/actions/open-file-mutations.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.

📝 Walkthrough
📝 Walkthrough

The change adds an ID-based editor-file rename command and removes the transition-based rename path. Renderer actions record file renames and removals in the layout owner. Layout-frame reconciliation and hydration now use editor-tab and open-file ownership information. The change also updates restored-tab ownership and removes the reorderFiles mutation.

Priority: ➖ Normal

Estimated code review effort:

Merge Risk: ⚪ Minimal · up to 615d2

The change keeps moved editor tabs open across restart and records file renames in the layout owner. No concrete merge-blocking risk was identified in the supplied context.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 54.84% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 31 functions across 24 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
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.
Title check Passed The title clearly summarizes both primary changes: preserving a moved editor tab across restart and recording editor renames in main for dark builds. It is specific and related to the changeset.
Description check Passed The description is detailed and covers the required change summary, rationale, testing, review notes, compatibility considerations, and checklist. It does not provide an actual linked issue under the …
Full details: Description check

Explanation

The description is detailed and covers the required change summary, rationale, testing, review notes, compatibility considerations, and checklist. It does not provide an actual linked issue under the required Linked Issue section, and the visual proof is described as local rather than attached, but the description is otherwise mostly complete.

Full details: Docstring Coverage

Explanation

Docstring coverage is 54.84% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 31 functions across 24 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • 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.

@Jinwoo-H
Jinwoo-H merged commit 9cc5d6b into main Oct 17, 2026
46 checks passed
Jinwoo-H added a commit that referenced this pull request Oct 18, 2026
…space's id on save and from the first frame (#30172)

Sessions saved before #29930 can hold a moved editor tab whose
worktree id still names the workspace it came from. Pin that the
saver writes the workspace's own id and that the window's tab carries
it after main's first snapshot. Tests only.
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