Skip to content

fix(terminal): bound paired-client renderer work - #12081

Merged
OrcaWin merged 1 commit into
mainfrom
fix-remote-side-effect-backpressure
Aug 2, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
fix-remote-side-effect-backpressure

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • coalesce decorative terminal title frames independently for each paired desktop subscriber before RPC serialization and encryption
  • preserve semantic title, agent, bell, completion, and query facts plus every local synthetic animation frame
  • gate legacy paired-host output before hidden xterm scheduling when the host lacks output-pause support, then restore one authoritative snapshot on reveal
  • extend the remote hidden-retention reliability contract with deterministic current/current and legacy protocol oracles

Reproduction

The pre-fix 64-PTY title harness delivered 576 client events after the first semantic frame. The fixed path delivers zero after convergence while retaining all 640 local frames.

The pre-fix legacy protocol harness kept hidden bytes on the xterm path and never requested a reveal snapshot. The fixed path performs no hidden xterm writes, restores the authoritative snapshot once, and continues live output.

Verification

  • 17 paired-terminal test files: 2,044 passed, 1 existing skip
  • Node, web, and CLI typechecks
  • full lint, code-quality, max-lines, localization, skill-manifest, and reliability checks
  • headed isolated desktop host plus encrypted paired web client: passed
  • isolated headless orca serve host: both parking and cold-activation scenarios passed

Behavior and risk

Current hosts keep host-side output pause and ordinary parking unchanged. Visible terminals and local title animation are unchanged. Older hosts still transport hidden raw bytes because they cannot understand the pause opcode, but the client no longer feeds those bytes through xterm; reveal pays one bounded snapshot repaint to recover exact visible state.

@Jinwoo-H
Jinwoo-H force-pushed the fix-remote-side-effect-backpressure branch from b462c1f to 86459ea Compare August 2, 2026 07:52
@coderabbitai

coderabbitai Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The runtime now filters decorative title events independently for each listener while preserving non-title terminal facts. The renderer separates remote output gating from pause support, handles Mode-2031 subscription facts, skips hidden output, and restores serialized output after visibility returns. Tests cover paired-client title delivery and legacy hosts that cannot pause output. Reliability-gate documentation adds assertions, evidence runs, performance bounds, known gaps, and demotion conditions.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the summary and verification, but it omits the required Screenshots, AI Review Report, and Security Audit sections. Add the missing template sections and document screenshots status, AI review findings including cross-platform checks, and the security audit results.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 describes the primary change: limiting renderer work for paired terminal clients.
✨ 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.

@OrcaWin

OrcaWin commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@greptile-apps

greptile-apps Bot commented Aug 2, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes two independent but related over-delivery problems in the paired-terminal renderer path. Both are verified by new deterministic unit tests and the updated headed/headless integration oracles.

  • Per-client title deduplication: terminalSideEffects events are now filtered through a per-listener gate before delivery to each paired desktop subscriber. Decorative spinner frames (same Braille-stripped content and agent status as the last delivered frame) are suppressed at the JSON-serialization boundary, while semantic transitions (working→idle, bell, completion) and local animation batches remain unaffected. The terminalSideEffectTitleGateKeysByClientEventListener map is populated on subscribe and cleaned up on both listener removal and PTY disposal.
  • Legacy host hidden-output gating: When transport.setOutputPaused returns false (host does not support the pause opcode), pty-connection.ts now sets remoteOutputGatedPtyId to locally suppress xterm writes while hidden, and triggers a single authoritative serializeBuffer snapshot on reveal — the same restoration path used by capable hosts.

Confidence Score: 5/5

Safe to merge — both change paths are narrow and independently tested; no shared state regressions identified.

The changes are well-scoped: the per-listener title gate is a pure additive filter over an existing delivery loop with correct init/cleanup on subscribe and PTY disposal, and the legacy host gating simply extends an already-exercised snapshot-restore path to a class of host that previously fell through an early-return branch. New unit tests cover the 64-PTY decorative bound, late-subscriber recovery, semantic-fact preservation, and the full legacy hidden-output shape.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
src/main/runtime/orca-runtime.ts Adds per-listener title deduplication gate for terminalSideEffects client events; renames makeMobileTitleGateKey to makeDecorativeTitleGateKey; cleanly separates excluded-listener logic from new title-gate logic; PTY tracker disposal propagates correctly to all listener maps.
src/renderer/src/components/terminal-pane/pty-connection.ts Splits remoteOutputPausedPtyId into remoteOutputGatedPtyId + remoteOutputFactConsumerPtyId to separate output gating from side-effect consumer registration; legacy hosts (supported=false) now gate hidden xterm writes locally and trigger snapshot restore on reveal; capable-host path behaviorally unchanged.
src/main/runtime/orca-runtime.test.ts Adds a 64-PTY x 10-frame synthetic title test validating zero decorative client events after first semantic frame, per-client late-subscriber recovery, semantic bell and idle transitions on both clients, and full local frame preservation.
src/renderer/src/components/terminal-pane/pty-connection.test.ts Adds a legacy-host test that validates hidden xterm writes are suppressed when setOutputPaused returns false, a single authoritative snapshot is written on reveal, and post-reveal live data flows normally.
config/reliability-gates.jsonc Updates invariant, oracle, coverage notes, demotion rule, and red/green evidence to cover the 64-PTY title bound and legacy no-output-pause gating; adds three new evidence runs; adds a gap note about legacy packaged-host full-headed oracle coverage.

Reviews (1): Last reviewed commit: "fix(terminal): bound remote hidden rende..." | Re-trigger Greptile

@OrcaWin
OrcaWin merged commit 4a76565 into main Aug 2, 2026
43 checks passed
@OrcaWin
OrcaWin deleted the fix-remote-side-effect-backpressure branch August 2, 2026 08:02

@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 Plus

Run ID: bd915f04-a42c-4ae0-a71d-ae7e6ed17275

📥 Commits

Reviewing files that changed from the base of the PR and between a14ada1 and 86459ea.

📒 Files selected for processing (5)
  • config/reliability-gates.jsonc
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts

Comment on lines +14207 to +14218
expect(transport.setOutputPaused).toHaveBeenLastCalledWith(false)
expect(transport.serializeBuffer).toHaveBeenCalledWith({ scrollbackRows: 5000 })
callbacks.onData?.(live, {
seq: hidden.length + live.length,
rawLength: live.length
})
await flushAsyncTicks(20)

const written = pane.terminal.write.mock.calls.map((call) => String(call[0])).join('')
expect(written).toContain(snapshot)
expect(written).toContain(live)
expect(written).not.toContain(hidden)

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Assert the single-snapshot bound.

toHaveBeenCalledWith passes if the connection serializes more than once. Add an exact call-count assertion after the live chunk.

Based on PR objectives, reveal must restore one authoritative snapshot.

Proposed test assertion
     expect(written).toContain(snapshot)
     expect(written).toContain(live)
     expect(written).not.toContain(hidden)
+    expect(transport.serializeBuffer).toHaveBeenCalledTimes(1)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
expect(transport.setOutputPaused).toHaveBeenLastCalledWith(false)
expect(transport.serializeBuffer).toHaveBeenCalledWith({ scrollbackRows: 5000 })
callbacks.onData?.(live, {
seq: hidden.length + live.length,
rawLength: live.length
})
await flushAsyncTicks(20)
const written = pane.terminal.write.mock.calls.map((call) => String(call[0])).join('')
expect(written).toContain(snapshot)
expect(written).toContain(live)
expect(written).not.toContain(hidden)
expect(transport.setOutputPaused).toHaveBeenLastCalledWith(false)
expect(transport.serializeBuffer).toHaveBeenCalledWith({ scrollbackRows: 5000 })
callbacks.onData?.(live, {
seq: hidden.length + live.length,
rawLength: live.length
})
await flushAsyncTicks(20)
const written = pane.terminal.write.mock.calls.map((call) => String(call[0])).join('')
expect(written).toContain(snapshot)
expect(written).toContain(live)
expect(written).not.toContain(hidden)
expect(transport.serializeBuffer).toHaveBeenCalledTimes(1)

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