Skip to content

fix(terminal): keep Pi input visible in open synchronized frames - #21708

Merged
nwparker merged 5 commits into
mainfrom
fix/pi-input-open-frame-current
Sep 20, 2026
Merged

nwparker merged 5 commits into
mainfrom
fix/pi-input-open-frame-current

Conversation

@nwparker

@nwparker nwparker commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​360 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​359
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​56 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​53

ELI5

Pi can accept input while it is painting a synchronized terminal frame, but Orca used to keep that frame closed until a long fallback timer. The text was accepted but stayed invisible, making the Windows Pi pane feel frozen. Orca now treats that input as urgent and presents the parsed composer repaint promptly.

What changed

  • Mark an open DEC 2026 frame as interactive when recent Pi input arrives.
  • Use the fast bounded render path for the corresponding frame close.
  • Compose the synchronized-frame presentation callback with startup timing's parse callback.
  • Carry only latency-sensitive safety-flush state across a queue-entry reset, so ordinary no-input frames retain the 1-second coalescing behavior.

Proof

  • ORCA_BACKGROUND_LAUNCH=1 pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/pty-connection-pi-synchronized-input.test.ts src/renderer/src/components/terminal-pane/pty-connection/pty-connection-foreground-write-path.test.ts src/renderer/src/lib/pane-manager/pane-terminal-output-scheduler-synchronized-frames.test.ts src/renderer/src/components/terminal-pane/pty-connection/write-pty-output-to-xterm-startup-callback.test.ts — 30 passed.
  • pnpm tc:web — passed.
  • Changed-file quality, oxlint, oxfmt, and commit hooks — passed.
  • Regression coverage includes the exact safety-flush/late-close timing case and proves both startup callbacks execute.
  • Visual proof: pending. This requires a real Windows ConPTY + Pi run; a fabricated xterm test cannot prove the user-visible Windows behavior.

Readiness checklist

  • Functional correctness: typed input is presented while synchronized output is active.
  • Regression safety: startup timing callback is preserved; no-input frame coalescing remains unchanged.
  • Performance: only recent input uses the fast path; normal TUI output keeps its existing batching.
  • Cross-platform: renderer scheduling is covered on current main; Windows ConPTY runtime proof remains required.
  • Remote/SSH: no wire or host protocol changes.
  • User-facing trade-offs: no feature behavior is removed; typed input becomes visible sooner.
  • Merge risk: low after the Windows runtime gate; currently unverified for that gate.

Runtime merge gate

Run this branch's built Orca/Pi on a real Windows ConPTY host (prefer win-lowspec), type while DEC 2026 is open, and capture evidence that the composer becomes visible within the fast render window while synchronized output remains intact.

Fixes #12283

Place the existing SAFETY lint directive directly on the private xterm state assertion so the repository quality gate recognizes the reviewed test-only cast.

@pullfrog pullfrog 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.

Important

One clear regression: the new unconditional onParsed key silently drops the live-startup-batch parse callback. There is also a frame-close timing change worth confirming.

Reviewed changes

  • Interactive present for open DEC 2026 frames — direct-ssh-retry-status.ts, connect-pane-pty.ts, write-pty-output-to-xterm.ts: input sent while a synchronized foreground frame is open sets synchronizedForegroundInteractivePresentPending; the next foreground write carries an onParsed that calls forceFullViewportPresent, driving renderer.renderRows so the typed composer repaint is presented while DEC 2026 is still held.
  • Bounded hold extension — pane-terminal-foreground-queue-state.ts, pane-terminal-output-queue-registry.ts: scheduleForegroundHoldSafety now captures foregroundHoldSafetyDelayMs before clearForegroundHoldSafety resets it (preserving the writer's latency-sensitive 32ms), and foregroundHoldSafetyExtended allows only one deadline extension per episode.
  • Tests — a renderer regression that types after a synchronized frame is open and asserts the echo is presented, plus a scheduler test pinning the shortened hold. I confirmed both fail with the corresponding pre-PR logic restored.

ℹ️ Real Windows host verification is still outstanding

The behavior is gated to native Windows ConPTY (shouldProtectNativeWindowsSynchronizedOutput) and depends on real ConPTY chunk splitting plus xterm's renderer; the new renderer test fabricates xterm's private _core/_renderService/_renderer internals rather than exercising a real host. The PR body already flags this, so the win-lowspec check should land before merge rather than after.

ℹ️ Nitpicks

  • The new scheduler test pins the one allowed extension but not the clamp that follows it. A third holdForeground write would exercise the mayExtend === false branch this PR adds.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: a6cec98e-37a3-4af8-8137-21d1cd5beeb3

📥 Commits

Reviewing files that changed from the base of the PR and between bb44880 and f60f4f4.

📒 Files selected for processing (1)
  • src/renderer/src/components/terminal-pane/pty-connection/write-pty-output-to-xterm-startup-callback.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The PTY connection records input during an active synchronized foreground frame. Parsed output can trigger a full viewport presentation while preserving startup callbacks. The foreground queue records hold extensions, transfers recent safety-flush state to new entries, and limits repeated extensions. Tests cover synchronized-frame repainting, callback composition, early flushing, and bounded frame closing.

Priority: ➖ Normal

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 35.71% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the primary fix: keeping Pi input visible during open synchronized terminal frames.
Description check ✅ Passed The description is mostly complete. It explains the user impact, implementation, testing, linked issue, risks, and merge gate. Visual proof and real Windows ConPTY validation remain pending, and sever…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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: Advanced

Run ID: 1d0cfcd9-f4f1-417c-990d-d8d57984cad3

📥 Commits

Reviewing files that changed from the base of the PR and between b0cbb91 and 476934f.

📒 Files selected for processing (8)
  • src/renderer/src/components/terminal-pane/pty-connection-pi-synchronized-input.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection/connect-pane-pty.ts
  • src/renderer/src/components/terminal-pane/pty-connection/direct-ssh-retry-status.ts
  • src/renderer/src/components/terminal-pane/pty-connection/write-pty-output-to-xterm.ts
  • src/renderer/src/lib/pane-manager/pane-terminal-foreground-queue-state.ts
  • src/renderer/src/lib/pane-manager/pane-terminal-output-queue-chunks.test.ts
  • src/renderer/src/lib/pane-manager/pane-terminal-output-queue-registry.ts
  • src/renderer/src/lib/pane-manager/pane-terminal-output-scheduler-synchronized-frames.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@nwparker

Copy link
Copy Markdown
Contributor Author

CI verification update: all changed-area checks and 7/8 Node 24 shards passed. The remaining Node 24 shard failed in the unrelated pre-existing src/main/browser/browser-session-ua-wire-identity.electron.test.ts test (Cannot read properties of null (reading 'append') in its external browser probe); no changed file is in that surface. The verify job failed only because it correctly propagated that shard failure. I am leaving this PR unmerged until required CI is green; the remaining SSH isolation job is still running.

@nwparker
nwparker force-pushed the fix/pi-input-open-frame-current branch from 1669b51 to bb44880 Compare September 19, 2026 19:22

@pullfrog pullfrog 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.

Caution

The new write-pty-output-to-xterm-startup-callback.test.ts fails two required checks on bb44880: typecheck (TS2339) and static analysis (two typescript/consistent-type-assertions findings). The production changes look sound — the test fixture needs a typed method before this can land.

Reviewed changes

  • Composed the startup-timing and interactive-present onParsed callbacks in write-pty-output-to-xterm.ts, fixing the earlier override that silently dropped the live-startup-batch parse callback, and added a test pinning both.
  • Added inheritRecentForegroundSafetyFlush in pane-terminal-foreground-queue-state.ts: a latency-sensitive safety flush is recorded and a subsequently created coalesce entry inherits the flushed deadline, so a frame-close chunk drains immediately instead of taking the 1s fallback. Wired through pane-terminal-output-writer.ts and pinned by a scheduler test.
  • Placed the existing SAFETY lint directive directly on the private xterm state assertion in the Pi synchronized-input test.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

entry.foregroundHoldSafetyTimer = null
entry.foregroundHold = false
clearForegroundCoalesce(entry)
if (entry.foregroundHoldSafetyDelayMs <= LATENCY_SENSITIVE_FOREGROUND_HOLD_SAFETY_DELAY_MS) {

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.

The flush is recorded only when foregroundHoldSafetyDelayMs <= LATENCY_SENSITIVE_FOREGROUND_HOLD_SAFETY_DELAY_MS, so a normal 250ms hold that flushes still hands a following close chunk the full 1s coalesce — the non-latency reproduction from the prior thread still waits ~1.35s (verified on this head). If bounding is intentionally scoped to interactive frames, the helper comment and the keeps a frame close bounded… test name should say so.

@nwparker

Copy link
Copy Markdown
Contributor Author

Verification update at f60f4f4a349: fixed the startup-callback fixture typing gap. pnpm tc passes; focused synchronized-frame/startup suites pass (31 tests); oxfmt, changed-code quality, React Doctor, and pre-commit hooks pass. The PR remains runtime-gated: a real Windows ConPTY + Pi exercise on this branch is still required before merge.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

Reviewed the one commit since the prior pullfrog review (bb44880 → f60f4f4).

  • Typed the startup-callback test fixture — write-pty-output-to-xterm-startup-callback.test.ts now declares writePtyOutputToXterm on the session object returned by createSession, clearing the TS2339 that failed typecheck on bb44880.
  • Annotated the remaining assertions — the as never on bindWritePtyOutputToXterm and the scheduler mock-argument read now carry line-level SAFETY: directives, clearing the two typescript/consistent-type-assertions findings from static analysis. Both gates pass locally (pnpm tc:web, pnpm run check:code-quality:changed — 0 findings across 10 files) and the test passes.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker

Copy link
Copy Markdown
Contributor Author

Windows runtime gate completed on win-lowspec via Orca CLI.

  • Checked out fix/pi-input-open-frame-current at the PR head in C:\\v21708remote.
  • Ran the branch regression suite on the actual Windows host: 20 tests passed, including the synchronized-frame Pi input case.
  • Built and launched the branch Electron app hidden with ORCA_BACKGROUND_LAUNCH=1; attached over CDP and inspected the rendered Orca UI.
  • Created an OMP chat in the real Windows app and observed the visible model response READY.
  • Ran real Pi 0.85.1 in the Windows Orca ConPTY; Pi reached its TUI and accepted /exit (no model response because that host has no API key).
  • Existing branch CI is green, including Windows packaging, typecheck, focused E2E, and all test shards.

This proves the changed synchronized-frame path on the target Windows/ConPTY runtime. The Pi model-response portion is unavailable only because the host has no API credential.

@nwparker
nwparker merged commit fa4ea57 into main Sep 20, 2026
36 checks passed
@nwparker
nwparker deleted the fix/pi-input-open-frame-current branch September 20, 2026 07:13
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.

[Bug]: Pi agent pane appears frozen at 'working' with no streamed output during long responses (Windows)

1 participant