Skip to content

Parked remote terminal scrollback is not persisted across a client restart #21295

Closed

Description

@nwparker

A parked remote terminal pane's scrollback is captured into the renderer store but is not persisted to disk, so it is gone after a client restart. The user sees a blank pane with tabs and splits intact.

This is the restart-straddling half of the data loss fixed within-session by #21285. #21285 does not close this — its scope section says so explicitly.

Measurement

Paired-desktop topology (headed host + paired client), remote-runtime pty, host forced to answer no snapshot. Hop-by-hop, one run:

[parked-restart] {"tokenBeforePark":true,"storeAtPark":315,"onDiskAfterQuit":0,
                  "storeAfterRelaunch":0,"tokenAfterReveal":false}
  • storeAtPark: 315 — the park capture ran and the buffer is in terminalLayoutsByTabId[tabId].buffersByLeafId.
  • onDiskAfterQuit: 0 — after beforeunload + a clean shutdown, the client's own orca-data.json was found and read, and it carries the tab's layout without the buffers. This is the hop that loses it.
  • storeAfterRelaunch: 0 / tokenAfterReveal: false — downstream consequences, not independent faults.

0 and -1 are deliberately distinguished: -1 means no session file was found at all (a reader problem), 0 means the file was found and the buffers were not in it. This run reads 0.

Repro

Branch repro/parked-scrollback-restart — tests/e2e/paired-remote-terminal-parked-scrollback-restart.spec.ts. It is a measurement rather than a guard, and it is deliberately not merged into #21285: it is currently red, and a red test in a fix PR reads as the fix failing.

pnpm exec playwright test \
  tests/e2e/paired-remote-terminal-parked-scrollback-restart.spec.ts \
  --config tests/playwright.config.ts --project electron-headless --workers=1

Run it on top of #21285's branch — the park capture only exists there, so on plain main storeAtPark is 0 and the experiment is moot.

Where to look first

The capture reaches the renderer store and does not reach disk, so the loss is in the write path, not in sync or reveal. The first thing to check is pruneLocalTerminalScrollbackBuffers (src/shared/workspace-session-terminal-buffers.ts:76), which strips buffersByLeafId for any worktree it judges local. It runs on the persist path (workspace-session-snapshot-publication.ts:43,97, session-host-partitions.ts:198, loaded-state-parsing.ts:202).

The suspicion — not verified — is that the renderer and the persist path disagree about this worktree. At park time the renderer's own shouldPreserveTerminalScrollbackBuffers returned true (the capture ran, and its diagnostic showed repoKnown: true, repoExecutionHostId: "runtime:<uuid>"). If main's repos classifies that same worktree as local — or does not hold it at all — the write strips what the renderer just captured. Confirming or ruling that out is the next step; instrument the prune call on the write path rather than reasoning from the renderer's view.

A second, independent hole in the same class

chooseRemoteTerminalLayout (src/renderer/src/runtime/web-session-tabs-sync/terminal-surfaces.ts:169) rebuilds a tab's layout from the host's picture and never carries buffersByLeafId or scrollbackRefsByLeafId forward — despite already receiving existingLayout as a parameter. The host publishes no scrollback of its own, so every republish silently drops the client's only copy.

A fix there was attempted and reverted during this investigation. That revert is not evidence against it. It was measured on a harness that was deleting the client profile between launches, so nothing downstream of persistence could have registered an effect either way — it was never actually tested. It should be re-evaluated once persistence is fixed, since it sits on the same path and would otherwise undo the repair on the next host republish.

Not the cause

mergeDirectSshRemoteWorkspaceSession was investigated and fixed defensively in #21285, but it is reached only via applyDirectSshRemoteWorkspaceSnapshot (direct SSH). This topology syncs through web-session-tabs-sync and never traverses it. Direct SSH additionally has a daemon-backed restore that repaints the scrollback regardless — confirmed by disabling the park capture entirely in the Docker SSH lane and watching the token still come back.

Activity

  1. nwparker commented on Sep 17, 2026

    @nwparker
    ContributorAuthor

    The measurement primitive this needs is now cut as its own PR: #21300 (quitPreservingProfile() on PairedElectronClient, test infrastructure only). With that landed, the repro on repro/parked-scrollback-restart runs off a helper rather than an inline composition.

    Reminder for whoever picks this up: run the repro on top of #21285's branch. The park capture only exists there, so on plain main storeAtPark reads 0 and the experiment is moot rather than green.

  2. nwparker commented on Sep 17, 2026

    @nwparker
    ContributorAuthor

    One router, three consumers

    Filing this here because #21295 is the closest home, but the defect is not specific to this bug — it is one router with (so far) three consumers, and it should eventually be fixed once rather than per-consumer.

    src/renderer/src/lib/workspace-session-host-persistence.ts:196-198:

    const repoHostId = repoId ? repoHostById.get(repoId) : undefined
    if (!repoHostId) {
      return LOCAL_EXECUTION_HOST_ID
    }

    When the repo catalog has not hydrated, every worktreeKeyed / tabKeyed field routes to the local partition regardless of which host actually owns the rows. Known consumers:

    1. tabsByWorktree ('worktreeKeyed', workspace-session-host-field-ownership.ts:28) — an SSH worktree's tab rows can land in local.
    2. terminalLayoutsByTabId ('tabKeyed', :46) — the layouts, and therefore the park scrollback captured into them by fix(terminal): a park must not discard the only copy of a remote pane's scrollback #21285.
    3. parkedScrollbackByTabId ('tabKeyed') — the client-local park scrollback field on wip/park-scrollback-local-field, which inherits the same routing. It is omitted from the remote projection either way, so this does not affect upload volume — but it can still land in the wrong partition during catalog lag, exactly as the layouts it shadows can.

    Related but not the same defect: the stale-agent-resume bug (#21288) is sleepingAgentSessionsByPaneKey, classified 'sleepingAgentKeyed' (:50) — the only class in that map that merges every partition without retaining provenance. That one bypasses this router entirely. Worth stating explicitly because the two were conflated during investigation and the distinction is what made the two fixes independent.

    The asymmetry worth preserving if anyone fixes the router: shouldPreserveTerminalScrollbackBuffers (workspace-session-terminal-buffers.ts:33-38) resolves the same unhydrated-catalog window toward "remote", deliberately, because a worktree wrongly judged local parks with no scrollback copy at all. worktree-runtime-owner.ts:170-204 resolves it to 'local'. Both are labelled "fail open"; they point opposite ways, and each is correct for its own decision. A router fix should not flatten them to one default.

  3. AmethystLiang commented on Sep 18, 2026

    @AmethystLiang
    Contributor

    thanks for reporting. looking into it

  4. added
    bugSomething isn't working
    orca-remote-serverRemote Orca Server / orca serve / paired remote runtime
    on Sep 19, 2026
  5. added theissue type on Sep 19, 2026
  6. OrcaWin commented on Oct 9, 2026

    @OrcaWin
    Collaborator

    Fixed by #21367: a parked remote pane's scrollback is now saved to disk and comes back after a restart. If you still get a blank pane after relaunching on a current build, please reopen with details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions