Repository navigation
fix(agents): stop claiming an unconfirmed OpenCode handoff succeeded - #22546
Conversation
There was a problem hiding this comment.
Important
The "never claim an unconfirmed handoff succeeded" rule is wired only on the local-terminal branch. The paired/web-host branch still reports success after the same blind ConPTY paste, and the PR note that its readiness "runs on the remote host" is not accurate — the scan runs in the client renderer. Details inline.
Reviewed changes
- Blind-paste signal:
pasteDraftWhenAgentReady/pasteDraftToAgentPtyWhenReadynow call a newonUnconfirmedDeliverywhen readiness never resolves but the process-ownership fallback still pastes; plumbed throughdeliverLaunchPromptToAgentTaband the launch funnel asonPromptDeliveryUnconfirmed. - Hedged continuation:
launchAgentSessionContinuationsets a local flag from that callback and shows a warning toast with a Copy prompt action instead of the success toast; the existing failure toast gains the same action. - OpenCode budget:
opencode/opencode2getdraftPasteReadyTimeoutMs: 20_000(was the 8s default), matching Codex. - i18n + tests: new
deliveryUnconfirmed/copyPromptstrings, plus tests pinning the no-DECSET-2004 ConPTY path, the blind-paste flag, and the hedged toast.
ℹ️ Nitpicks
mimo-codecarries the samerender-cursor-after-bracketed-pastesignal asopencode(2004-anchored, no quiet window) but stays on the 8s default, so on a Windows host it reaches the same blind-paste path this PR is treating. The new config comment also calls codex "the other quiet-window-less signal" when three agents share that shape. If leavingmimo-codealone is deliberate (its startup stream is unvalidated), a one-line note would keep the next reader from reading the comment as OpenCode-only.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| forcePaste: true, | ||
| onTimeout: timeoutNotice.onTimeout | ||
| onTimeout: timeoutNotice.onTimeout, | ||
| ...(onPromptDeliveryUnconfirmed ? { onUnconfirmedDelivery: onPromptDeliveryUnconfirmed } : {}) |
There was a problem hiding this comment.
onPromptDeliveryUnconfirmed is forwarded only on the local-terminal branch; the paired/web-host branch above drops it. A web-hosted OpenCode handoff therefore still writes the prompt blind (the client-side readiness scan never sees DECSET 2004 from the host) and reports success, because handleCreation calls onPromptDelivered on the true that the paste helper returns. The PR note that this route's readiness "runs on the remote host" is not accurate — the scanner is waitForAgentDraftInputReadyOnTab/waitForAgentDraftInputReady in this renderer, reading the streamed host bytes.
Technical details
# Web-host route is not covered by the unconfirmed signal
## Affected sites
- `src/renderer/src/lib/launch-agent-in-new-tab.ts:181-197` — `launchAgentInWebHostTab` receives `onPromptDelivered` but not `onPromptDeliveryUnconfirmed`.
- `src/renderer/src/lib/launch-agent-web-host-tab.ts:48,119-121` — only `onPromptDelivered` exists; `handleCreation` fires it on the boolean the paste returned.
- `src/renderer/src/runtime/web-runtime-terminal-creation.ts:35-41` — `deliverLaunchPromptToAgentTab` is called without `onUnconfirmedDelivery`.
- `src/renderer/src/lib/agent-draft-readiness.ts:56-91` — readiness is scanned client-side (`isRemoteRuntimePtyId` subscribes to streamed host bytes), so a host that drops DECSET 2004 (Windows ConPTY) never resolves `ready`.
- `agent-paste-draft.ts:116-134` — readiness never resolving still reaches the process-ownership paste, which returns `true` on an accepted write.
## Required outcome
- A user on a paired/headless Windows host that drops DECSET 2004 must not see "Session context sent …" for a paste the client never confirmed.
- Either thread the callback through the web-host chain, or correct the exclusion note so the invariant's boundary is explicit and accurate.
## Suggested approach
- Add `onPromptDeliveryUnconfirmed` to the `launchAgentInWebHostTab` args, pass it from `launch-agent-in-new-tab.ts`, forward it through `createWebRuntimeAgentSessionTerminal` into the existing `deliverLaunchPromptToAgentTab` call, and gate `handleCreation`'s `onPromptDelivered?.()` on it the way the terminal branch does.
- `web-runtime-session-terminal-host-authority.test.ts:581-587` pins the current five-field call shape, so that assertion needs the new key.|
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 configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughOpenCode launch configurations now use a 20-second readiness timeout. Paste helpers signal when they write a prompt without observing the agent composer, and the terminal launch route forwards that signal. Session continuation distinguishes unconfirmed delivery from confirmed delivery, shows a warning with a Copy prompt action, and adds the same action to delivery-failure notifications. Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to A Windows user continuing a session through a paired host can still be told the prompt was delivered when delivery was not confirmed. Fix the web-host notification path before merging. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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: Advanced
Run ID: d4d716e2-8843-4796-837a-2d3d823b3fed
📒 Files selected for processing (10)
src/renderer/src/i18n/locales/en.jsonsrc/renderer/src/lib/agent-launch-prompt-delivery.tssrc/renderer/src/lib/agent-paste-draft-readiness-budget.test.tssrc/renderer/src/lib/agent-paste-draft.test.tssrc/renderer/src/lib/agent-paste-draft.tssrc/renderer/src/lib/launch-agent-in-new-tab.tssrc/renderer/src/lib/launch-agent-session-continuation.test.tssrc/renderer/src/lib/launch-agent-session-continuation.tssrc/shared/draft-paste-ready-scanner.test.tssrc/shared/tui-agent-config.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| { agent: agentLabel } | ||
| ) | ||
| ), | ||
| copyPromptToastAction(prompt) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the timeout notice and its notification-state contract.
rg -n -C 18 -F 'createPasteReadinessTimeoutNotice' src/renderer/src
rg -n -C 8 'failureNotified|wasNotified' \
src/renderer/src/lib/launch-agent-in-new-tab.ts \
src/renderer/src/lib/launch-agent-session-continuation.tsRepository: stablyai/orca
Length of output: 15810
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- timeout notice ---'
cat -n src/renderer/src/lib/launch-agent-paste-timeout-notice.ts
printf '%s\n' '--- continuation relevant range ---'
sed -n '1,210p' src/renderer/src/lib/launch-agent-session-continuation.ts
printf '%s\n' '--- delivery helper binding ---'
rg -n -C 14 'notifyDeliveryFailed|notifyDeliveryUnconfirmed|copyPromptToastAction|failureNotified|wasNotified' src/renderer/src/lib/launch-agent-session-continuation.ts src/renderer/src/lib/launch-agent-paste-timeout-notice.tsRepository: stablyai/orca
Length of output: 19685
Add Copy prompt to the readiness-timeout notice.
createPasteReadinessTimeoutNotice.onTimeout shows a toast without an action and then marks the failure as notified. The continuation therefore skips notifyDeliveryFailed, which is the only current path that adds copyPromptToastAction(prompt). A readiness timeout can leave the user without the Copy prompt recovery action.
Pass the delivered prompt to the timeout notice and attach the action for prompt submissions.
Suggested fix
--- a/src/renderer/src/lib/launch-agent-in-new-tab.ts
+++ b/src/renderer/src/lib/launch-agent-in-new-tab.ts
@@
agent,
- submitted: submitPastedPrompt
+ submitted: submitPastedPrompt,
+ prompt: pasteDraftAfterLaunch
})--- a/src/renderer/src/lib/launch-agent-paste-timeout-notice.ts
+++ b/src/renderer/src/lib/launch-agent-paste-timeout-notice.ts
@@
tabId: string
agent: TuiAgent
submitted: boolean
+ prompt?: string
@@
- toast.message(
+ const prompt = args.prompt
+ const copyPromptAction =
+ args.submitted && prompt
+ ? {
+ action: {
+ label: translate('components.agentSessionContinuation.copyPrompt', 'Copy prompt'),
+ onClick: () => {
+ void window.api.ui.writeClipboardText(prompt)
+ }
+ }
+ }
+ : undefined
+ toast.message(
translate(
'auto.lib.launch.agent.in.new.tab.a5a1f7033f',
"Your {{value0}} wasn't sent — paste it once the agent is ready.",
{ value0: args.submitted ? 'prompt' : 'notes' }
- )
+ ),
+ copyPromptAction
)…as written blind "Continue in New Session…" to OpenCode reported success even when the prompt never reached the TUI (#22479). The paste-after-ready helper falls back to a blind write when the composer-ready signal never arrives and only the agent process is known to exist; that write was indistinguishable from a real delivery, so the continuation showed its success toast. - pasteDraftWhenAgentReady / pasteDraftToAgentPtyWhenReady report the blind fallback via onUnconfirmedDelivery, plumbed to launchAgentInNewTab as onPromptDeliveryUnconfirmed. - The session continuation hedges instead of claiming success, and both the failure and the hedged notice offer "Copy prompt". - OpenCode gets Codex's 20s composer budget. Both are quiet-window-less signals anchored on DECSET 2004, which ConPTY never forwards, so on Windows that budget is the settle delay before the blind paste.
cf66e10 to
a6c586d
Compare
The main-runtime startup-draft budget test used `opencode` as its stand-in for "an agent without an override", which this branch invalidates by giving OpenCode 20s. It failed with "expected vi.fn() to not be called at all, but actually been called 1 times" — the readiness signal now legitimately arrives inside budget. Point it at `claude`, which still takes the 8s default, and add a companion pinning OpenCode's 20s: a readiness signal at t+10s, past the old default, must now deliver the draft. Removing the override makes that companion fail.
…le (#22593) 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.
…tablyai#22546) * fix(opencode): stop claiming a handoff prompt was delivered when it was written blind "Continue in New Session…" to OpenCode reported success even when the prompt never reached the TUI (stablyai#22479). The paste-after-ready helper falls back to a blind write when the composer-ready signal never arrives and only the agent process is known to exist; that write was indistinguishable from a real delivery, so the continuation showed its success toast. - pasteDraftWhenAgentReady / pasteDraftToAgentPtyWhenReady report the blind fallback via onUnconfirmedDelivery, plumbed to launchAgentInNewTab as onPromptDeliveryUnconfirmed. - The session continuation hedges instead of claiming success, and both the failure and the hedged notice offer "Copy prompt". - OpenCode gets Codex's 20s composer budget. Both are quiet-window-less signals anchored on DECSET 2004, which ConPTY never forwards, so on Windows that budget is the settle delay before the blind paste. * test(runtime): retarget the 8s startup budget test off OpenCode The main-runtime startup-draft budget test used `opencode` as its stand-in for "an agent without an override", which this branch invalidates by giving OpenCode 20s. It failed with "expected vi.fn() to not be called at all, but actually been called 1 times" — the readiness signal now legitimately arrives inside budget. Point it at `claude`, which still takes the 8s default, and add a companion pinning OpenCode's 20s: a readiness signal at t+10s, past the old default, must now deliver the draft. Removing the override makes that companion fail. (cherry picked from commit b7a4fee)
…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)

ELI5
"Continue in New Session" to OpenCode opens OpenCode but, on Windows, the handoff prompt is never typed in. Orca still says it worked. Two things were wrong: Orca gives up waiting for OpenCode's input box too early on Windows and types blindly into a half-started app, and when that happens it reports success anyway. Now it waits longer, and if it can't confirm the prompt landed it says so and offers to copy it.
What Changed
Before: the prompt is pasted at T+8s regardless of whether OpenCode's composer exists yet; the bytes are discarded; Orca shows "Session context sent to OpenCode in a new session."
After: OpenCode gets a 20s readiness budget (matching Codex), and when Orca pastes without ever observing the composer it says so — "Orca could not confirm OpenCode received the session context…" — with a Copy prompt action on both that notice and the existing failure toast.
Mechanism:
agent-paste-draft.ts—pasteDraftWhenAgentReady/pasteDraftToAgentPtyWhenReadyfire a newonUnconfirmedDeliverywhen they paste blind, matching the existingonTimeoutcallback shape.agent-launch-prompt-delivery.ts,launch-agent-in-new-tab.ts— plumbed through asonPromptDeliveryUnconfirmed. Additive; no existing caller changes behaviour.launch-agent-session-continuation.ts— an unconfirmed delivery no longer claims success. The Copy action uses sonner'saction(the shapeCrashReportDialogSurfacealready uses) andwindow.api.ui.writeClipboardText. No new modal.tui-agent-config.ts—draftPasteReadyTimeoutMs: 20_000foropencode/opencode2.Why
Fixes #22479.
The reported evidence does not mean what the report concluded, and that is worth recording. The daemon log line
{"event":"startup-command-delivery","written":false,"hasCommand":true,"commandLength":8,"viaShellArgs":true,"queuedByShellReadyBarrier":false}looks like "the prompt was lost before launch" —
commandLength: 8is exactly"opencode". It is in fact correct behaviour. ForpromptDelivery: 'submit-after-ready',planLaunchAgentStartupPromptdeliberately launches the agent bare vialaunchEmpty()and carries the prompt separately, so the launch command is just the binary name.viaShellArgs: trueis PowerShell's-EncodedCommandpath,written: falseonly means the daemon didn't also type it into stdin, andqueuedByShellReadyBarrier: falseis right because PowerShell emits no ready marker. The daemon log has nothing to say about the prompt, which travels the renderer's paste-after-ready path and is never logged there.Actual root cause — corrected after measuring on real Windows.
My original claim was that ConPTY never forwards DECSET 2004, so the readiness signal could not resolve. That is wrong. Measured on two Windows hosts (build 10.0.26200) through the repo's own
node-pty, withuseConptyDll: truepinned exactly aslocal-pty-utils.ts:174-175sets it for Orca's terminals:And from a real OpenCode TUI (1.18.16) spawned the same way:
?2004his present and in the right order. Therender-cursor-after-bracketed-pastesignal fires correctly — it is just late.The real mechanism is a budget that was sized on macOS. OpenCode on Windows needs ~10s to mount its composer, and does not even enable bracketed paste until ~4.8s. Three consecutive runs on the slower host:
?2004hopencodehad nodraftPasteReadyTimeoutMsoverride, so it tookDEFAULT_DRAFT_PASTE_READY_TIMEOUT_MS = 8000. Every run overruns it; none approaches 20s. So the fix in this PR is right and the new budget has ~2x headroom on the slow host — but for a different reason than I first gave.(The measurement's t0 is the
pty.spawn()call, while Orca's timer starts at or after PTY creation, so if anything it flatters the 8s budget — and 8s still loses.)The false toast is the same bug's second half:
sendBracketedPasteToAgentreturns true because the write was accepted, sodelivered: truefiresonPromptDelivered.This likely also explains #20695 (Cursor: lands but unsubmitted) and #14505 (lands as a draft) — the same blind paste landing at a luckier moment.
Why not just raise the timeout: that alone would be a guess dressed as a fix. The honest-reporting change is what guarantees a user is never told the handoff worked when Orca cannot tell.
Linked Issue
Fixes #22479
Visual Proof
N/Afor a before/after screenshot — I have no Windows machine, and the failure is Windows-only, so any macOS capture would show the working path and prove nothing. Staging a macOS screenshot of a Windows bug would be misleading rather than useful.The behavioural proof is in the tests below, which pin the ConPTY condition directly: with no DECSET 2004 in the stream, the opencode/codex/default signals never resolve.
Testing
Platforms: macOS for the unit tests; the timing above was measured on two real Windows hosts (build 10.0.26200) via
orca --environment.New tests pin:
onUnconfirmedDelivery, while the signal path does notSuites:
pnpm test src/renderer/src/lib src/shared/draft-paste-ready-scanner*.test.ts src/shared/tui-agent-*.test.ts→ 588 files, 6072 passed, 1 skipped.pnpm tcclean.pnpm run check:code-quality:changed→ 0 new findings across 23 changed files.agent-paste-draft.test.tswas at themax-linesceiling, so new coverage went intoagent-paste-draft-readiness-budget.test.ts. Nomax-linessuppression was added.Now verified on Windows: DECSET 2004 arrives, the signal fires, and 20s clears the measured ~10s readiness with roughly 2x headroom.
Still not verified: the end-to-end "Continue in New Session…" UI repro. OpenCode 2 is not installed on either Windows host, and driving the v1 equivalent would have required creating a real git worktree and branch on the user's machine, so the check stopped there rather than mutating it. The measured timing explains the report without it: readiness never resolves inside 8s → blind paste → prompt lost → success toast anyway.
No non-2004 anchor is needed after all, since 2004 does arrive. If OpenCode startup ever exceeds 20s on slower hardware this will regress, and the honest-reporting half is what keeps that from being silent.
AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
?2004hreaches the renderer and the signal fires in ~2s.isOpenCode2LaunchCommandis a red herring here — it only selects the hook endpoint, andopenCodeAgentcorrectly resolves to'opencode'for the reporter's 1.17.13.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm testpass locally