Skip to content

Reopening a file in its open tab sends the main process the changed file record (dark, layout-owner build only) - #30197

Merged
Jinwoo-H merged 2 commits into
mainfrom
e2-6/p11-editor-reopen-record
Oct 18, 2026
Merged

Jinwoo-H merged 2 commits into
mainfrom
e2-6/p11-editor-reopen-record

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​88 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​88
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​85 $\color{#cf222e}{\Huge{\mathbf{−}}}$​13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​72

ELI5

In the build where the main process owns the tab layout (not shipped yet), reopening a file that already has a tab only switched to that tab. If the reopen changed what Orca remembers about the file, for example a read-only log tab becoming a normal editable tab, the main process never heard about it. This change tells it.

What Changed

Before (layout-owner build only): open a session's log with "View Log" (read-only, following new lines), then open the same file normally. The window makes the existing tab editable, but the main process keeps its record saying the file is read-only. Today the window's own save still writes the correct record, so nothing visible goes wrong yet. Once the main process becomes the only writer of the saved layout, restarting Orca would bring that tab back read-only. The same gap exists when a merge conflict open rewrites an open tab's file record (its relative path and language).

After: when an open lands in a tab the window already had and the file's saved record changed (read-only, live tail, SSH target, relative path, language, runtime environment), the window resends its existing open-tab command for that tab with the new record. The main process, on an open for a tab it already holds, now replaces the file record for that path, the same way it already does for a new tab, and leaves the tab's position, group and preview state alone. An unchanged record sends nothing.

Mechanism:

  • recordReopenedEditorFileInLayoutOwner (renderer, editor-tab-layout-owner.ts) compares the store before and after the open: the tab must have existed before, and the restorable record (the same fields the window's session save keeps) must differ.
  • openFile and openConflictFile call it behind the compile-time layout-owner switch.
  • openEditorTab (shared command model) applies the command's file record in both of its "tab already exists" branches, through one withEditorFile step now shared with the new-tab branch.

Why

The record lives with the tab in the main process, so the fix belongs in the existing open-tab command rather than a new command type: the command already carries an optional file record, and the main process already knows how to store it. Comparing before/after in the two callers keeps the shared tab-activation path untouched and keeps the switch-off build identical. Sending on every reopen was rejected because most reopens change nothing.

Linked Issue

N/A (internal layout-owner work, prerequisite for making the main process the only writer of the saved layout).

Visual Proof

N/A: no visible change in shipped builds (the code runs only in the layout-owner build), and in the layout-owner build the window's save still carries the correct record today, so the user-facing effect appears only after that save stops carrying layout.

Testing

  • Automated tests added/updated, or explained why not below
  • Failing first, then passing:
    • Command model (workspace-layout-editor-open.test.ts): an open of a tab the main process already holds, by tab id or by file, replaces the read-only record with the writable one and leaves tabs and groups unchanged. Before the fix the record stayed read-only.
    • Renderer (editor-tab-layout-owner.test.ts): View Log then a normal open sends one open-tab command for the existing tab with a record without read-only; a second normal open sends nothing; a conflict open that rewrites an open tab's record sends it. Before the fix nothing was sent.
  • Gates: pnpm tc pass; pnpm run check:code-quality:changed pass; check:focus-read-ratchet OK (1082 reads); check:layout-writer-ratchets OK (211 main, 651 renderer); audit:anti-slop pass; oxlint on changed files clean.
  • Vitest (capped at 4 workers): src/renderer/src/store 449 files / 4403 tests pass; src/shared/workspace-layout, src/main/persistence/terminal-topology, layout apply RPC tests: 58 files / 471 tests pass (2 pre-existing expected-fail).
  • End-to-end: skipped. The only end-to-end spec that opens a View Log tab (agent-session-log-tail-stability.spec.ts) never reopens the file normally, and until the main process stops reading layout from the window's save, no end-to-end run can show the difference.

Shipped (switch-off) bundle, unminified, base vs head, hashes and commit stamp normalized:

  • Renderer JavaScript: identical. The renderer manifest differs only in the order of two CSS entries, an artifact of hash normalization.
  • Main: only openEditorTab in the shared command model changed (the record step). It is reachable only through layout.apply, which is registered only in layout-owner builds, so shipped behaviour is unchanged.

Wire: no new field or command. openEditorTab.file already exists in the layout.apply schema. An older main that receives this resend for a tab it holds treats it as a no-op, which is today's behaviour.

Review

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

Security, cross-platform, SSH, mobile, compatibility, performance: the change is dark (layout-owner build only). The SSH target and runtime environment are among the compared record fields, so an SSH file's record also stays current. The comparison runs once per open of an existing tab and is cheap.

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 18, 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: 5864c9bd-d9af-4437-8a74-6d257d3297b3
📥 Commits

Reviewing files that changed from the base of the PR and between fa738f3 and b1ca78e.

📒 Files selected for processing: 6
  • src/renderer/src/store/slices/editor-tab-layout-owner.test.ts
  • src/renderer/src/store/slices/editor/actions/open-conflict-file.ts
  • src/renderer/src/store/slices/editor/actions/open-file-action.ts
  • src/renderer/src/store/slices/editor/tabs/editor-tab-layout-owner.ts
  • src/shared/workspace-layout/workspace-layout-content-commands.ts
  • src/shared/workspace-layout/workspace-layout-editor-open.test.ts

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

📝 Walkthrough

Reopened editor tabs can replace the stored workspace file record. When the main layout owner is active, normal and conflict-file open actions capture the prior editor state and record changed reopened files. Unchanged edit-mode file data does not produce a layout command. Tests cover record replacement, tab retention, and synchronization of updated file data.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to b1ca7

No unresolved issue identified here prevents merging after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 6 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 is concise, specific, and accurately identifies the main change: resending a changed file record to the main process when reopening an existing tab in layout-owner builds.
Description check Passed The description is detailed and covers the change, motivation, implementation, testing, compatibility, and visual-proof requirements. The Linked Issue section is marked N/A even though the template re…
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 change, motivation, implementation, testing, compatibility, and visual-proof requirements. The Linked Issue section is marked N/A even though the template requests an issue link, but the rest of the description is substantially complete.

  • 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 483a17b into main Oct 18, 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