Repository navigation
Reopening a file in its open tab sends the main process the changed file record (dark, layout-owner build only) - #30197
Conversation
… main (dark, layout-owner build only)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
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.openFileandopenConflictFilecall 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 onewithEditorFilestep 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
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.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.pnpm tcpass;pnpm run check:code-quality:changedpass;check:focus-read-ratchetOK (1082 reads);check:layout-writer-ratchetsOK (211 main, 651 renderer);audit:anti-sloppass; oxlint on changed files clean.src/renderer/src/store449 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).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:
openEditorTabin the shared command model changed (the record step). It is reachable only throughlayout.apply, which is registered only in layout-owner builds, so shipped behaviour is unchanged.Wire: no new field or command.
openEditorTab.filealready exists in thelayout.applyschema. 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
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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)