Repository navigation
fix(terminal): safely converge revealed inline-TUI panes - #9503
Conversation
📝 WalkthroughWalkthroughUpdates terminal replay and deferred reattachment handling to preserve snapshot continuity, viewport intent, render state, and PTY sizing. Adds pane-fit continuation retries for unmeasurable layouts. Extends replay rendering with visibility-aware render-pause release behavior. Adds unit tests for fitting and rendering, integration coverage for reattachment edge cases, and Playwright scenarios using a streaming inline TUI fixture to verify reveal convergence across hidden, parked, resized, throttled, and rapidly switched panes. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: da3db3be-ac43-462e-9a72-20802b6d72b3
📒 Files selected for processing (10)
src/renderer/src/components/terminal-pane/pty-connection.test.tssrc/renderer/src/components/terminal-pane/pty-connection.tssrc/renderer/src/components/terminal-pane/replay-guard.tssrc/renderer/src/lib/pane-manager/pane-fit-continuation-retry.tssrc/renderer/src/lib/pane-manager/pane-fit.test.tssrc/renderer/src/lib/pane-manager/pane-fit.tssrc/renderer/src/lib/pane-manager/pane-terminal-foreground-render-settle.test.tssrc/renderer/src/lib/pane-manager/pane-terminal-foreground-render-settle.tstests/e2e/fixtures/codex-inline-live-block-fixture.cjstests/e2e/terminal-inline-tui-reveal-convergence.spec.ts
| const replayedSeq = typeof replayingSnapshot?.seq === 'number' ? replayingSnapshot.seq : null | ||
| let pendingData = '' | ||
| for (const chunk of pendingChunks) { | ||
| const sliced = | ||
| replayedSeq === null ? chunk.data : getChunkDataAfterSnapshot(chunk, replayedSeq) | ||
| pendingData += sliced ?? chunk.data | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Confirm getChunkDataAfterSnapshot's null contract and how other drains handle it.
rg -nP -C6 'function getChunkDataAfterSnapshot' src/renderer/src/components/terminal-pane/pty-connection.ts
rg -nP -C3 "return null" src/renderer/src/components/terminal-pane/pty-connection.ts | rg -n 'getChunkDataAfterSnapshot|rawLength'Repository: stablyai/orca
Length of output: 699
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file=src/renderer/src/components/terminal-pane/pty-connection.ts
echo '--- getChunkDataAfterSnapshot and related drain logic ---'
sed -n '6020,6075p' "$file"
echo
echo '--- pending replay write path around the reported lines ---'
sed -n '6348,6375p' "$file"
echo
echo '--- drainPendingLiveChunksAfterSnapshot references ---'
rg -n -C4 'drainPendingLiveChunksAfterSnapshot|refetch|salvage|rawLength !== chunk.data.length|getChunkDataAfterSnapshot' "$file"Repository: stablyai/orca
Length of output: 10927
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file=src/renderer/src/components/terminal-pane/pty-connection.ts
echo '--- replay loop context ---'
sed -n '6310,6385p' "$file"
echo
echo '--- definition / population of pendingChunks and replayingSnapshot ---'
rg -n -C5 'pendingChunks|replayingSnapshot|hiddenOutputRestoreReplayingSnapshot|hiddenOutputRestorePendingChunks' "$file"Repository: stablyai/orca
Length of output: 13237
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file=src/renderer/src/components/terminal-pane/pty-connection.ts
echo '--- call sites for abandonHiddenOutputRestoreAndDrainPendingForeground ---'
rg -n -C4 'abandonHiddenOutputRestoreAndDrainPendingForeground\(' "$file"
echo
echo '--- nearby invariants / comments around replayed snapshot and abandonment ---'
sed -n '5208,5235p' "$file"
echo
echo '--- search for notes about duplicate rows / fallback drain ---'
rg -n -C3 'duplicate|fallback drain|must not write snapshot-covered|renderer-only OSC stripping|mappable' "$file"Repository: stablyai/orca
Length of output: 11685
Avoid writing unmappable replay chunks in full.
In abandonHiddenOutputRestoreAndDrainPendingForeground, sliced ?? chunk.data turns the null unmappable-slice case into a full replay, which can reintroduce bytes already covered by the snapshot. Drop that chunk or take the same refetch/salvage path used in drainPendingLiveChunksAfterSnapshot().
Co-authored-by: OrcaWin <[email protected]>
Summary
Screenshots
No visual change.
Testing
pnpm lint— changed-file oxlint passes; the full command is currently blocked by the pre-existing non-exhaustive switch atsrc/renderer/src/components/skills/skill-freshness-group.tsx:101.pnpm typecheckpnpm test— 472 focused terminal tests pass; the full suite was not run.pnpm build—electron-vite build --mode e2epasses; the full release build was not run.Additional validation:
AI Review Report
Reviewed replay ordering, deferred-live parsing, scroll-intent revisions, fit cancellation and exhaustion, RenderService pause ownership, PTY identity and stream-generation staleness, mobile and remote-runtime resize ownership, SSH applied-size behavior, and replay sequence slicing.
The review flagged three merge risks in #9148 and changed them: RenderService release is now opt-in and rechecks visibility at parse completion; fit retry is limited to hidden snapshot and reattach reveal transactions; bounded fit exhaustion resolves failure and cannot claim stale snapshot dimensions. Ordinary forced-refresh output does not inspect RenderService internals.
Cross-platform review covered Windows synchronous DOM refresh behavior, macOS Electron validation, Linux/Wayland CI expectations, SSH and remote-runtime PTY identity, mobile size ownership, platform-neutral paths, and raw-mode fixture cleanup. Fresh CI is still required for non-macOS runtime evidence.
Security Audit
No new dependencies, authentication, secrets, external network access, or production command execution are introduced. The only new process fixture is e2e-only and shell paths are JSON-quoted. Production changes reuse existing PTY size IPC and renderer-local xterm state. IPC results are treated as optional and all resize/repaint actions are guarded by disposal, visibility, PTY identity, stream generation, remote-runtime, and mobile-ownership checks.
Notes