Skip to content

docs(tui-agent-config): correct the OpenCode readiness-budget rationale - #22593

Merged
nwparker merged 1 commit into
mainfrom
nwparker/opencode-readiness-comment-fix
Sep 24, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/opencode-readiness-comment-fix

Conversation

@nwparker

@nwparker nwparker commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 0 0 0 0
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1

ELI5

A comment I merged yesterday explains why OpenCode gets a longer startup wait on Windows. The explanation was wrong. The fix it justifies is still correct — this just replaces the reason with the one I actually measured.

What Changed

Comment only. One Why: block in src/shared/tui-agent-config.ts.

Before (merged with #22546):

ConPTY never forwards DECSET 2004 (terminal-agent-paste-bracketing.ts), so on Windows this signal cannot fire at all and the budget becomes the fixed settle delay before the blind process-ownership paste.

After:

measured on two Windows hosts (ConPTY dll backend, as pinned by local-pty-utils), opencode does not enable bracketed paste until ~4.8s and its composer is not ready until ~10s — so the 8s default expired first and the draft was pasted blind, mid-startup (#22479). The signal itself fired every time in those runs, so the budget was the problem, not a dropped escape.

Why

I verified #22546's premise on two real Windows hosts (build 10.0.26200) after merging it, through the repo's own node-pty with useConptyDll: true — the backend local-pty-utils.ts:174-175 pins for Orca's terminals:

VARIANT dll      2004h_idx=31 25h_after=44  order_ok=true
VARIANT system   2004h_idx=83 25h_after=306 order_ok=true

And from a real OpenCode 1.18.16 TUI:

<ESC>[?1049h<ESC>[>4;1m<ESC>[?2027h<ESC>[?2004h<ESC>[?1000h...
EVENT t+4933ms DECSET_2004h
EVENT t+9591ms SHOWCURSOR_25h_AFTER_2004h

?2004h arrives in order and the readiness signal fires. Three runs: ready at 10086 / 9783 / 9989 ms — every one past the 8s default, none near 20s. So the 20s budget is right and has ~2x headroom; the stated cause was not.

Where the wrong claim came from, since it's worth not repeating: terminal-agent-paste-bracketing.ts:8 says 2004 "can be lost by remote replay or ConPTY" — careful, hedged, and not contradicted by this measurement. A test name in the same area reads "ConPTY never forwarded DECSET 2004". I turned the hedged claim plus the test name into an absolute one and built an explanation on it. This PR does not touch either of those; it only stops the OpenCode entry from asserting something stronger than the evidence supports.

I am also deliberately not asserting the converse. These runs show ConPTY forwarding 2004 on this Windows build and backend. That does not prove it never drops it, so the comment now says what was observed rather than what is universally true.

Linked Issue

Refs #22479 — follow-up to #22546, no behaviour change.

Visual Proof

N/A — comment-only; no code path, no UI.

Testing

pnpm test src/shared/tui-agent-config.test.ts src/main/runtime/orca-runtime.test.ts → 2 files, 1304 passed. pnpm tc clean. pnpm run check:code-quality:changed → 0 findings.

No behavioural change, so nothing new to pin; the 20s budget stays covered by the runtime test added in #22546 (gives OpenCode the 20s main-runtime startup readiness budget).

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Zero runtime impact: the constant is unchanged at 20_000.
  • Cross-platform, SSH/remote, mobile, security, performance: unaffected.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test pass locally

The comment merged with #22546 claimed ConPTY never forwards DECSET 2004 and
that the signal therefore cannot fire on Windows. Verification on two real
Windows hosts refuted that: the sequence arrives in order on both ConPTY
backends, and the readiness signal fired in every run.

The budget was the actual problem — opencode does not enable bracketed paste
until ~4.8s and its composer is not ready until ~10s, so the 8s default expired
first and the draft was pasted blind. Same fix, accurate reason.

Note the claim that seeded this: terminal-agent-paste-bracketing.ts says 2004
"can be lost by remote replay or ConPTY", which is careful and not contradicted
here; the absolutism was mine.
@coderabbitai

coderabbitai Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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: 97f2ffbe-4d3e-4335-a8f5-c068a8527dda

📥 Commits

Reviewing files that changed from the base of the PR and between 5802b54 and 948f581.

📒 Files selected for processing (1)
  • src/shared/tui-agent-config.ts

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


📝 Walkthrough

Walkthrough

The opencode configuration comment now states that the cursor-gated paste signal fired in measured Windows runs, but the 8-second readiness budget expired before the composer was ready. The configured timeout remains 20 seconds.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 948f5

This updates the explanation for the existing OpenCode timeout without changing startup behavior; no merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the comment-only change that corrects the OpenCode readiness-budget rationale.
Description check ✅ Passed The description is complete and relevant. It explains the measured issue, the change, the reason, linked issue, testing, lack of visual impact, and unchanged runtime behavior. Minor template details s…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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
  • 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.

@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 critical issues — the rationale fix is accurate and well-scoped. One informational note below about the same overclaim that still lives in two untouched comments.

Reviewed changes

  • OpenCode readiness rationale corrected: replaces the claim that ConPTY never forwards DECSET 2004 (so the readiness signal can't fire on Windows and the budget is just a blind-paste settle delay) with the measured reason — bracketed paste at ~4.8s and composer ready at ~10s means the 8s default expired first and the draft pasted blind, while the signal itself fired each run (#22479).

The new rationale cross-checks cleanly: src/shared/tui-agent-config.ts is comment-only, the constant stays 20_000, local-pty-utils.ts:174-175 does pin useConptyDll: true, and terminal-agent-paste-bracketing.ts:8 carries only the hedged "can be lost by remote replay or ConPTY" claim that the PR correctly leaves alone. The scoping to "those runs" is appropriately not-universal.

ℹ️ The same absolute overclaim survives in two other comments

The PR's own measurement (ConPTY dll backend forwards ?2004h in order, and the signal fired every run) directly contradicts two other comments that assert the opposite as universal fact. This is pre-existing text the PR does not touch, so it does not block; flagging it because the PR's whole point is to stop asserting more than the evidence supports.

Technical details
# Stale "ConPTY never forwards DECSET 2004" absolutes

## Affected sites
- `src/renderer/src/lib/agent-paste-draft.ts:128-130` — "On Windows this is the ONLY path: ConPTY does not forward DECSET 2004, so no 2004-anchored ready signal can ever fire." Contradicted by the PR's measurement on the dll backend.
- `src/renderer/src/lib/agent-paste-draft-readiness-budget.test.ts:99` — "Regression (#22479): ConPTY never forwards DECSET 2004, so on Windows this is the only path opencode can take."
- `src/renderer/src/components/terminal-pane/terminal-agent-paste-bracketing.test.ts:163` — same wording; the PR body already acknowledges this test name.

## Required outcome
- None blocking. If the author wants the correction to be complete, reword these to the hedged form used at `terminal-agent-paste-bracketing.ts:8` ("can be lost by remote replay or ConPTY") rather than asserting the signal can never fire on Windows.

## Open questions for the human
- Whether these are tracked separately, or intentionally left as historical descriptions of the #22479 regression scenario.

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

@nwparker
nwparker merged commit 795b64b into main Sep 24, 2026
31 checks passed
@nwparker
nwparker deleted the nwparker/opencode-readiness-comment-fix branch September 24, 2026 03:29
flosrn pushed a commit to flosrn/orca that referenced this pull request Sep 25, 2026
…le (stablyai#22593)

The comment merged with stablyai#22546 claimed ConPTY never forwards DECSET 2004 and
that the signal therefore cannot fire on Windows. Verification on two real
Windows hosts refuted that: the sequence arrives in order on both ConPTY
backends, and the readiness signal fired in every run.

The budget was the actual problem — opencode does not enable bracketed paste
until ~4.8s and its composer is not ready until ~10s, so the 8s default expired
first and the draft was pasted blind. Same fix, accurate reason.

Note the claim that seeded this: terminal-agent-paste-bracketing.ts says 2004
"can be lost by remote replay or ConPTY", which is careful and not contradicted
here; the absolutism was mine.

(cherry picked from commit 795b64b)
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