Skip to content

fix(layout-owner): an unsaved editor draft survives conversion to a managed server (C5-L310) - #52238

Merged
Jinwoo-H merged 18 commits into
layout-owner-v2from
layout-owner-c5-l310-draft
Nov 29, 2026
Merged

Jinwoo-H merged 18 commits into
layout-owner-v2from
layout-owner-c5-l310-draft

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

With the new layout path on, an unsaved editor draft disappeared when an SSH host was converted to a managed Orca server: the tab showed the file's disk text instead. Now the draft survives conversion, reconnect and restart, as it does with the switch off.

Census row: C5-L310. Two files: the fix, and the spec with its C5-L310 forgiveness removed.

Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​244 $\color{#cf222e}{\Huge{\mathbf{−}}}$​23 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​221
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​133 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​126

Before / after

  • Before (switch on): after conversion the editor tab was redrawn under the server's id for the file (editor:<workspace>:<server>:<path>), while the draft stayed under the old id (the bare path). The tab was clean and showed disk text. Both ssh-orcad-editor-drafts-migration specs failed (CI run 46215992851 and locally).
  • After: the window moves the file to the server's id, draft included, before the server's frames start drawing the workspace. Both specs pass, and the C5-L310 forgiveness in the spec is removed, so it must pass.

Mechanism

  • A file restored from before the server has no owner (no environment, SSH target or provenance). With the switch off, the mirror keeps it under its old id until the editor loads it, then re-owns it through migrateRestoredEditorFileOwner, which moves the draft, buffers and save gate along with it.
  • With the switch on, the server's frames gate the workspace first. The frame store patch drops the window's file (old id) and adds the frame's file (new id) without its draft.
  • Fix (server-layout-editor-handover.ts): the gate check that already hands desktop-only tabs to the server now re-owns these restored files first, using the same migration. While the server's worktree route is still unknown (the worktree list arrives after the stream), the workspace stays on the mirror, and the existing routing-change re-check gates it later. If a migration fails and the file is still unowned, the workspace stays on the mirror for this stream, as a refused hand-over already does.
  • The file's route comes from the server being gated (no focus read), so a focused server's restored files are re-owned too. That is harmless (they already read and save there) and keeps the frame's id matching.

How it was tested

CI Actions may be down, so this was verified locally in Docker (arm64 host image, linux-arm64-glibc orcad template built in a container):

  • Switch on (ORCA_LAYOUT_OWNER=main, ORCA_SERVER_LAYOUT_OWNER=main): both specs --repeat-each=3, plus a store probe with a 2 MB draft ×3. 9/9 passed. The first fix only re-owned files whose route was known and still lost the 2 MB draft 3 times out of 4. The probe showed the route arriving after the first gate check, which is why the gate now holds.
  • Without the fix: both specs fail (expected-fail fired locally; CI run above).
  • Switch off: both specs pass.
  • pnpm run typecheck:ci and pnpm check:changed (base layout-owner-v2) pass.
  • After merging layout-owner-v2: both draft specs and ssh-orcad-browser-drop-owner pass with this change, and browser-drop-owner also passes without it. The first CI run's other ssh failures were terminal-typing specs (the C5-L312 race) and the pre-merge lane copy of browser-drop-owner; none of them open editor files.
  • Regression test: the existing ssh-orcad-editor-drafts-migration spec, now unmarked, fails without this fix (data loss, so it stays committed). No unit test was added: this path calls the app-global store's migration, and a unit test would only check wiring.

Visible changes

Bug fix only: with the switch on, a converted host's unsaved draft now shows (it used to show disk text). No change with the switch off.

Performance

None measurable, because the gate check adds one scan of the window's open files per server workspace, only while that workspace is not yet gated, and re-owns run once per restored file.

Restores the ssh-orcad journeys (cut 11-21) into the layout-owner suite, passes the
server setting to the Docker host's orcad through sshd, and checks the orcad took it.
…er-ssh-orcad-lane

# Conflicts:
#	.github/workflows/layout-owner-switch-on.yml
The nohup launch backgrounds its whole && chain, so the PID removal added in
#51342 ran in the background and could delete the PID file the foreground had
just written. The host's server then read as unverifiable and connect failed.
Remove the old PID before the chain instead.
…anaged server (C5-L310)

A server's frames name its files by the server-owned id. A window file restored from before the
server (no owner yet) was replaced by the frame's file under that id, leaving its draft under the
old id, so the editor showed the disk text. Before a server workspace gates to frames, the window
now re-owns such files through the existing restored-owner migration (drafts, buffers and the save
gate move with them), holding the gate while the server's worktree route is still unknown.
@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge, with no actionable new issues found.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no actionable new issues found.

Summary

The PR moves restored editor files, including their drafts, to the server’s file IDs before server frames take over the workspace.

  • Restored editor drafts stay visible when server frames take over.

No actionable new issues were found. No previous review threads were supplied. Checks were based on code inspection; tests were not run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Server frames arrive] --> B{Restored files remain?}
  B -->|No| F[Hand over desktop-only tabs]
  B -->|Yes| C{File route known?}
  C -->|No| D[Keep mirror drawing and wait for changes]
  D --> B
  C -->|Yes| E[Move file and draft to server-owned ID]
  E --> B
  F --> G[Allow server frames to draw]
Loading

Reviews (4) · Last reviewed commit: "fix(layout-owner): restored-editor re-ow..." · Reviewed by Greptile

…er-c5-l310-draft

# Conflicts:
#	.github/workflows/layout-owner-switch-on.yml
#	src/main/managed-server/install/orcad-remote-empty-markers.integration.test.ts
#	tests/layout-owner-e2e/helpers/docker-ssh-host-target.ts
#	tests/layout-owner-e2e/helpers/orcad-convert-flow.ts
#	tests/layout-owner-e2e/helpers/orcad-managed-workspace.ts
#	tests/layout-owner-e2e/helpers/ssh-config-host-picker.ts
#	tests/layout-owner-e2e/helpers/ssh-remote-only-browser-fixture.ts
#	tests/layout-owner-e2e/ssh-orcad-browser-drop-owner.spec.ts
#	tests/layout-owner-e2e/ssh-orcad-browser-routing.spec.ts
#	tests/layout-owner-e2e/ssh-orcad-browser-service-status.spec.ts
#	tests/layout-owner-e2e/ssh-orcad-codex-question-skip.spec.ts
#	tests/layout-owner-e2e/ssh-orcad-desktop-browser-bridge.spec.ts
#	tests/layout-owner-e2e/ssh-orcad-editor-drafts-migration.spec.ts
#	tests/layout-owner-e2e/ssh-orcad-explorer-selected-host.spec.ts
#	tests/layout-owner-e2e/ssh-orcad-idle-exit.spec.ts
#	tests/layout-owner-e2e/ssh-orcad-pairing-repair.spec.ts
#	tests/layout-owner-e2e/ssh-orcad-shared-home-machines.spec.ts
#	tests/layout-owner-e2e/ssh-orcad-shared-login-migration.spec.ts
#	tests/layout-owner-e2e/ssh-orcad-sleep-disconnected.spec.ts
#	tests/layout-owner-e2e/ssh-orcad-terminal-browser-link.spec.ts
#	tests/layout-owner-e2e/ssh-orcad-terminal-journeys.spec.ts
#	tests/layout-owner-e2e/ssh-orcad-terminal-network-outage.spec.ts
#	tests/layout-owner-e2e/ssh-orcad-terminal-reconnect-idle-frame.spec.ts
#	tests/layout-owner-e2e/ssh-orcad-terminal-root-owner.spec.ts
#	tests/layout-owner-e2e/ssh-orcad-unbindable-tunnel-port.spec.ts
#	tests/layout-owner-e2e/ssh-orcad-update-anyway.spec.ts
#	tests/layout-owner-e2e/ssh-orcad-workspace-tools.spec.ts
…le, coalesce, and cover SSH-era files

- The re-own clears the pending-owner pause on every view of the shared record, not only the moved one,
  so a sibling workspace's view stays saveable and a shared draft rejoins instead of splitting.
- Concurrent re-owns of one file (editor load and server gate) share one migration instead of the second
  reading as stale and holding the workspace on the mirror.
- The gate re-asks when folder workspaces change, and when a held workspace's open files change.
- Files opened over the converted SSH host's relay route are re-owned too, as the switch-off mirror keeps them.
@Jinwoo-H
Jinwoo-H merged commit efce661 into layout-owner-v2 Nov 29, 2026
72 of 73 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