Skip to content

fix(terminal): safely converge revealed inline-TUI panes - #9503

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/issue-9079-hidden-terminal-scroll
Jul 20, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/issue-9079-hidden-terminal-scroll

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Converges cold-parked and hidden-mounted inline TUI panes after snapshot replay without requiring a manual resize.
  • Restores deferred live-output scroll intent, verifies the applied PTY grid, and avoids replay-covered duplicate rows after deadline abandonment.
  • Supersedes fix(terminal): converge revealed inline-TUI panes without a manual resize #9148 with a visibility-owned RenderService release and an opt-in, cancellable fit retry that resolves on bounded exhaustion instead of hanging reattach.

Screenshots

No visual change.

Testing

  • pnpm lint — changed-file oxlint passes; the full command is currently blocked by the pre-existing non-exhaustive switch at src/renderer/src/components/skills/skill-freshness-group.tsx:101.
  • pnpm typecheck
  • pnpm test — 472 focused terminal tests pass; the full suite was not run.
  • pnpm build — electron-vite build --mode e2e passes; the full release build was not run.
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Additional validation:

  • 6/6 inline-TUI Electron convergence scenarios pass, including six heavy cold-park/reveal cycles with 8,000 seed lines, sustained output, WebGL paint checks, applied PTY-size checks, and 6x CPU throttling.
  • 116 adjacent scheduler, replay, render-pause, and PTY-size tests pass.
  • Scheduler throughput bench passes.
  • Max-lines and reliability gates pass.

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

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Updates 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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main terminal convergence fix.
Description check ✅ Passed The description follows the template and covers summary, screenshots, testing, AI review, security, and notes with substantial detail.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: da3db3be-ac43-462e-9a72-20802b6d72b3

📥 Commits

Reviewing files that changed from the base of the PR and between 7adda25 and 7d92984.

📒 Files selected for processing (10)
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/replay-guard.ts
  • src/renderer/src/lib/pane-manager/pane-fit-continuation-retry.ts
  • src/renderer/src/lib/pane-manager/pane-fit.test.ts
  • src/renderer/src/lib/pane-manager/pane-fit.ts
  • src/renderer/src/lib/pane-manager/pane-terminal-foreground-render-settle.test.ts
  • src/renderer/src/lib/pane-manager/pane-terminal-foreground-render-settle.ts
  • tests/e2e/fixtures/codex-inline-live-block-fixture.cjs
  • tests/e2e/terminal-inline-tui-reveal-convergence.spec.ts

Comment on lines +6360 to +6366
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
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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().

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