Repository navigation
fix(orcad): keep terminal models at the daemon's live depth and bound provider snapshot waits - #35679
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 3 minutes. View limit details
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. Comment |
orcad's per-PTY headless terminal model kept 5,000 rows of scrollback, but orcad has no renderer to reveal from: requested snapshots read the daemon first and subscribe snapshots read at most 1,000 rows. The model now mirrors the daemon's live window, from the same resolver the daemon uses. The execution-context reseed also awaited its provider snapshot with no bound, so a provider that never answered held every live chunk queued behind it. It now uses the authoritative snapshot timeout. Refs #34410 Refs #33870
serializeProviderTerminalBuffer now applies the authoritative snapshot timeout when a caller passes none, so no reader can wait on a provider that never answers. The execution-context reseed relies on that bound; when its capture times out it keeps the PTY provider-preferred and reseeds again once the capture lands, instead of staying on the provider path. Refs #34410 Refs #33870
…odel on none awaitProviderTerminalBuffer reports the capture still running when the bounded wait gives up, instead of callers inferring it from the acquisition map. The execution-context reseed retries once when that capture lands with a snapshot, and stops preferring the provider when it lands with none, so a slow provider can neither loop reseeds nor pin the PTY to the provider path. Refs #34410 Refs #33870
[Medium impact] The changes affect terminal history and provider snapshot reads across runtime workflows. The PR still needs a fix before merging because reconnects can receive a partial terminal screen after a reseed times out. Findings
SummaryThis PR lowers orcad’s terminal history depth and bounds waits for provider snapshots.
|
| if (!snapshot) { | ||
| seedTimedOut = late !== null |
There was a problem hiding this comment.
Reconnect restores a partial screen
After an execution-context reseed times out, queued output now runs on an empty model. Keeping providerSnapshotPreferredPtys set does not stop snapshot readers from using it: serializeTerminalBufferFromAvailableState falls through to serializeHeadlessTerminalBuffer when the provider times out and no renderer answers.
On orcad, a reconnect can therefore receive a partial screen and missing history. Cursor-relative output can also appear in the wrong place because the model never received the earlier screen. Keep releasing queued writes, but prevent snapshot readers from returning this unseeded model until a seed succeeds or the provider confirms there is no snapshot.
Knowledge Base Used: Terminal runtime and interaction
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
b698eab to
bcabc53
Compare
ELI5
orcad, the Orca server that runs on remote hosts, keeps its own in-memory copy of every terminal. That copy held 5x more history than the terminal daemon it mirrors. Nothing on a server ever reads that extra history, so it was wasted memory on every terminal. Separately, one step waited on the daemon with no time limit. While it waited, every byte of new output piled up behind it in memory.
What Changed
serializeProviderTerminalBuffernow applies the authoritative snapshot timeout (8s) to every caller that doesn't pass its own. Before, those callers waited only on the daemon client's 30s request timeout, plus a 5s durable-history deadline. The timeout lives in that one function, so every caller gets it. The newawaitProviderTerminalBufferalso reports the capture that is still running when the wait gives up.No wire or protocol changes. Mixed client and server versions are unaffected.
Why
orcad runs on remote hosts and holds one copy per terminal, so 5,000 rows each grows quickly with many terminals. This is part of the #34410 / #33870 investigation into orcad freezing under memory pressure.
Alternatives considered:
Measured with a scripted 50-terminal flood in vitest, origin/main vs this branch:
Refs #34410
Refs #33870
Thanks to @tux86 and @taichimori-netizen for the reports.
Linked Issue
Refs #34410, Refs #33870. This PR is part of the fix for each; it does not close them.
Visual Proof
N/A. This changes no UI: it lowers server-side memory and bounds an internal wait.
Testing
Automated tests added.
src/main/runtime/headless-terminal-memory-bound.test.tscovers:Each test fails on the base, either by assertion or by hanging until the test timeout.
Full static job passes locally.
Unit tests selected by import graph (
src/main) pass. The only failures also fail on the base commit: real-git, filesystem-watcher, packaged-CLI, orcad forked-child, and timing-sensitive tests.Managed-orcad Docker specs: 9 passed, 1 skipped (
ssh-orcad-terminal-journeys,-terminal-network-outage,-terminal-reconnect-idle-frame,-terminal-root-owner,-terminal-browser-link,-relay-tab-only-shell;-phone-feed-listskips outside an ORCA_SIDEBAR_INPUTS=main build), with a locally built linux-arm64 orcad template. The full 40-spec lane runs in CI.Platforms: macOS host with a Linux (arm64) Docker SSH host.
Review
Independent Codex and Opus reviews on the final head report no P0–P2 findings.
Agent skill upstream boundary
Notes
terminal readnow gets about 1,000 plus a screen. The daemon's live window is the same size.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)