Skip to content

fix(agent-launch): re-press Enter while dsh's launchpad still holds the prompt - #33316

Merged
nwparker merged 2 commits into
mainfrom
nwparker/agint-33229
Oct 25, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/agint-33229

Conversation

@nwparker

@nwparker nwparker commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​110 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​110
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​58 $\color{#cf222e}{\Huge{\mathbf{−}}}$​20 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​38

ELI5

When Orca starts DeepSeek Harness (dsh) with a task, it pastes the task into dsh's opening screen (the "launchpad") and presses Enter. dsh draws that screen before its session has opened. Until the session opens it ignores Enter, shows "still starting — press Enter to send once it is ready", and leaves the text where it is. So the task just sat there.

Now Orca checks again about once a second. While the launchpad still shows this task and no turn has started, it presses Enter again. It never pastes twice, and it stops as soon as dsh starts the turn. It also stops when the launchpad is no longer on screen, for example when dsh's first-run guide covers it.

Stacked on #33295. This PR reuses #33295's held-prompt resubmit loop instead of adding a second retry mechanism. Merge #33295 first; GitHub then retargets this PR to main.

Root cause (upstream refs)

@deepseek-harness-tui/dsh-tui 0.17.0 (npm tarball):

  • lib/types/screens/Chat.js:2509-2514 refusedAtStartup: while channel.ready === false, a plain-text submit gets the startup-not-ready notice and is refused. lib/types/i18n.js:375 is the notice text ("… is still starting — press Enter to send once it is ready").
  • lib/types/screens/Chat.js:601-605: the first-run guide (onboardingOnBoot) is held until ready and then opens over the launchpad. lib/types/onboardingPrefs.js:105 offers the guide whenever ~/.dsh-tui/onboarding.json is missing.
  • lib/types/screens/Launchpad.js:834-842: the launchpad composer is a borderStyle: "round" box with a ❯ prefix. Its placeholder (launchpad-placeholder) sits right of the caret. Orca's generic draft reader did not recognize that boxed shape.

The dsh-composer-prompt signal means the composer is ready for a paste. It does not mean dsh will accept Enter yet. dsh exposes no byte-level signal for submit-ready. Its only turn-start evidence is the title and OSC 7501;state=working:app=dsh-tui.

Review of #33229 (why this replaces it)

#33229 (by @wuuli) found the right root cause, and its idea of re-pressing only Enter is correct. Two problems remain:

  1. A second retry mechanism. It adds submitRetryUntilTurnStart and its own loop next to submitRetryDelayMs/resubmitAgentPromptAfterRetryDelay, which fix(agent-prompt): press Enter again while a Windows Codex composer still holds a dispatch #33295 rewrites into resubmitHeldAgentPrompt. The two PRs conflict on the same lines and would leave two parallel Enter-retry policies.
  2. It sends Enter without checking the screen. Retries stop only on a turn start or a permission prompt. On a first run, dsh opens its guide once the session is ready, and every later Enter acts on the guide ("Enter act on this step / go next"). This reproduced with a raw-PTY driver against real dsh-tui 0.17.0: the blind Enters landed on the guide's "Check again" step. This is the same class of bug as [Bug]: dsh-tui 0.15 onboarding receives supervised task input before chat readiness; same-terminal reuse times out #29131. Its 5.5 s budget was also too short on this machine, where a cold boot took about 14–24 s from the glyph to ready.

What changed

  • tui-agent-config: dsh gets submitRetryDelayMs: 1000 plus a new submitRetryBudgetMs: 30_000, which only applies to a launch into a composer Orca just saw ready.
  • getAgentPromptHeldSubmitBudgetMs: returns the larger of the Windows paste-burst budget and the launch budget, still capped at AGENT_PROMPT_EFFECT_TIMEOUT_MS.
  • terminal-composer-draft: recognizes a boxed single-line ❯ composer (╭─╮ above │ ❯ text │). The draft is the text left of the cursor, so the empty launchpad's placeholder does not count. As a result, #33295's isHeldAgentPromptDraft gate also works for dsh.
  • resubmitHeldAgentPrompt: for dsh there is no blind first retry, because the draft reader can see its launchpad. If the draft is gone, it stops right away instead of waiting out the budget, because dsh paints its draft immediately.
  • The input_accepted checkpoint bytesWritten now counts every Enter (from fix(agent-launch): submit dsh launch prompts once its launchpad is live #33229).
  • autohand config compacted to one line to stay under the 300-line cap (as fix(agent-launch): submit dsh launch prompts once its launchpad is live #33229 did).

How verified

  • Real dsh through Orca's runtime (OrcaRuntimeService + node-pty running dsh-tui . 0.17.0 / dsh 0.2.1-rc.2, isolated HOME/DSH_HOME, macOS arm64):
  • New dsh-launch-prompt-resubmit.test.ts replays three real dsh-tui 0.17 captures (launchpad holding the draft while starting, first-run guide, empty launchpad) through the real runtime. The first test fails on fix(agent-prompt): press Enter again while a Windows Codex composer still holds a dispatch #33295 alone.
  • pnpm tc, pnpm run check:code-quality:changed, and 128 related test files (2418 tests, incl. serializer transcript replay, composer-draft, prompt-submission, launch-prompt specs) pass.

Risk

  • The boxed-composer branch in the shared draft detector could also match another TUI that draws ╭───╮ directly above │ ❯ text with a visible cursor. If it does, that text is a typed draft anyway. The empty and placeholder cases return null, so the IME placeholder mask is unchanged.
  • In terminal reads, the dsh launchpad row now projects as ❯ with the text in draft, as other agents' drafts already do.
  • In the worst case (slow or never-ready session), the launch RPC can wait up to the existing 30 s effect cap before it returns input_accepted.
  • Windows/SSH not run here. The path is the same PTY write, and \r and the draft reader are transport-independent.
  • [Bug]: dsh-tui 0.15 onboarding receives supervised task input before chat readiness; same-terminal reuse times out #29131's other half (worker dispatch reporting accepted while the guide is up, and the reuse timeout) is not addressed here.

Fixes #33227
Related: #29131, supersedes #33229

Co-authored-by: Xulin Wu (@wuuli)

@nwparker
nwparker force-pushed the nwparker/agint-33229 branch from 86c4ebb to ceb8940 Compare October 25, 2026 06:35
@nwparker
nwparker changed the base branch from nwparker/agint-11343 to main October 25, 2026 06:57
…he prompt

dsh-tui 0.17 paints its launchpad composer before its session opens and refuses
Enter until then, keeping the draft, so a launch prompt sat in the launchpad
after Orca's single Enter (#33227). Reuse the held-prompt resubmit loop instead
of a parallel retry: dsh gets a 1 s cadence and a 30 s launch budget, and the
draft reader now knows its boxed composer, so Enter repeats only while the
launchpad visibly shows this prompt and never lands in the first-run guide that
covers it once the session is ready. The input_accepted checkpoint now counts
every Enter written.

Co-authored-by: Xulin Wu <[email protected]>
@nwparker
nwparker force-pushed the nwparker/agint-33229 branch from ceb8940 to de8c0f9 Compare October 25, 2026 06:58
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 26 seconds.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 68919b98-0aab-4ba4-9052-da9d478931c2
Commits

Reviewing files that changed from the base of the PR and between de8c0f9 and 2e2f3f7.

Files selected for processing: 1
  • src/shared/terminal-composer-draft.ts
Walkthrough

The runtime now detects the boxed DSH launchpad composer and uses a bounded retry policy for prompt submission. When the DSH session is still starting, the runtime can retry Enter without pasting the prompt again. The retry budget uses composer readiness and the DSH configuration. New regression tests use captured launchpad, startup, and first-run-guide screens to check prompt acceptance and submission counts.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Low · up to de8c0

Launching dsh with a prompt into a reused terminal may still leave the prompt unsent in the launchpad. In the first-run guide case, a single Enter can reach the guide. Both are bounded edge cases, so the change is mergeable with follow-up fixes.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description follows the repository template closely. It has the ELI5, What Changed, Why (root cause and the reason for replacing #33229), Testing with automated tests and manual verification on ma… Add a Visual Proof entry. The change alters terminal behavior, so attach a BEFORE and AFTER video or screenshot pair, or write N/A with a reason. Complete the AI Disclosure section if AI tools were used. Tick or resolve the Testing and Chec…
Docstring Coverage Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 7 files. (6 skipped: 6… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title "fix(agent-launch): re-press Enter while dsh's launchpad still holds the prompt" names the main change. The PR re-presses Enter for the dsh launchpad when the prompt is still held and no tur…
Linked Issues check Passed Linked issue #33227 asks that --agent dsh --prompt start execution once for short and long tasks. It asks for a retry that presses only Enter, never the paste, until a turn starts or a bounded budge…
Out of Scope Changes check Passed Every changed area connects to the objective of #33227 (dsh launch prompt submission), or is a supporting change:
- terminal-agent-prompt-resubmit.ts: dsh skips the blind first retry and stops when …
Full details: Title check

Explanation

The title "fix(agent-launch): re-press Enter while dsh's launchpad still holds the prompt" names the main change. The PR re-presses Enter for the dsh launchpad when the prompt is still held and no turn has started, and the diff adds the dsh retry configuration, the boxed composer draft detection, and the held-submit budget logic that support it. The title is specific and concise, and it follows a conventional commit style. It is a single sentence, but at 78 characters it is a little long.

Full details: Linked Issues check

Explanation

Linked issue #33227 asks that --agent dsh --prompt start execution once for short and long tasks. It asks for a retry that presses only Enter, never the paste, until a turn starts or a bounded budget ends.

Code at head:

  • resubmitHeldAgentPrompt (src/main/runtime/terminal/input/terminal-agent-prompt-resubmit.ts) writes only AGENT_PROMPT_SUBMIT. It never re-pastes. This matches the requested Enter-only retry.
  • Each retry waits submitRetryDelayMs (1000 ms for dsh per tui-agent-config.ts). It stops when agentPromptSettledWithin reports a turn start, and it stops at the heldBudgetMs deadline. The budget for dsh is the new submitRetryBudgetMs (30 s), applied through getAgentPromptHeldSubmitBudgetMs only when composerReady is true. This is a bounded budget.
  • For dsh, blind is false. Each retry first reads the draft with isHeldAgentPromptDraft, so Enter is sent only while the launchpad still shows this prompt. When the draft is gone, the loop returns at once. This covers the first-run guide case in the issue's related #29131 context.
  • detectBoxedComposerDraft in src/shared/terminal-composer-draft.ts lets the draft reader see the dsh boxed │ ❯ text │ composer. Without this, the draft gate would not hold for dsh. An empty placeholder returns null.

Limits of this assessment:

  • I did not inspect dsh-launch-prompt-resubmit.test.ts or the fixtures. The regression coverage and the real-PTY runs are taken from the PR description, not from my own run.
  • The issue's expected behavior also says a launch must not report the brief as handed over while it sits in the launchpad. This PR does not change the outcome reporting code. If the budget ends without a turn start, the existing verification and reporting still apply. That path is not shown by the diff to report differently.
  • getAgentPromptHeldSubmitBudgetMs was checked only through the PR summary, not by reading its source.
Full details: Out of Scope Changes check

Explanation

Every changed area connects to the objective of #33227 (dsh launch prompt submission), or is a supporting change:

  • terminal-agent-prompt-resubmit.ts: dsh skips the blind first retry and stops when the draft is gone. This is the core retry change.
  • terminal-agent-prompt.ts: composerReady is passed into the budget calculation. bytesWritten counts every Enter (the input_accepted checkpoint). This makes the receipt match the Enter count.
  • shared/agent-prompt-injection.ts: getAgentPromptHeldSubmitBudgetMs takes composerReady and returns the larger of the Windows paste budget and the dsh launch budget. Other agents have no submitRetryBudgetMs, so their budget is unchanged.
  • terminal-composer-draft.ts: boxed dsh composer detection. It is needed for the draft gate. The PR notes that this shared branch could match another TUI, which is a behavior risk, not an unrelated change.
  • tui-agent-config-types.ts and tui-agent-config.ts: new submitRetryBudgetMs field and dsh retry settings. The autohand entry is reformatted with no value change, which the PR says is needed to stay under the 300-line cap.
  • Test fixtures (__fixtures__/dsh-tui-0.17/*) and dsh-launch-prompt-resubmit.test.ts: captured screens and regression tests for the dsh launch path.

No change was found that is unrelated to #33227. #29131 worker-dispatch reporting is excluded by the PR and is not changed in the reviewed diff.

Full details: Description check

Explanation

The description follows the repository template closely. It has the ELI5, What Changed, Why (root cause and the reason for replacing #33229), Testing with automated tests and manual verification on macOS arm64, and Risk sections. It links the issue with 'Fixes #33227' and includes an upstream-refs section. Gaps: the 'Linked Issue' section uses 'Fixes #33227' rather than the template's format, the 'Visual Proof' section has no BEFORE/AFTER screenshot or video and no N/A statement, the 'AI Disclosure' section is blank, the 'Agent skill upstream boundary' checkbox is unchecked, the Testing checklist boxes are unchecked, and the Checklist items are not ticked. The author also does not state which platforms were tested beyond macOS arm64, although the Risk section notes Windows and SSH were not run.

Resolution

Add a Visual Proof entry. The change alters terminal behavior, so attach a BEFORE and AFTER video or screenshot pair, or write N/A with a reason. Complete the AI Disclosure section if AI tools were used. Tick or resolve the Testing and Checklist items, and state the agent skill upstream boundary choice. Confirm the Linked Issue format matches the template.

Full details: Docstring Coverage

Explanation

Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 7 files. (6 skipped: 6 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · Prevent the initial dsh Enter from reaching the first-run guide. · terminal-agent-prompt.ts:170

src/main/runtime/terminal/input/terminal-agent-prompt.ts:170
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Prevent the initial dsh Enter from reaching the first-run guide.

agentPromptSubmitJoinsPasteFrame returns true only for omp, so dsh writes the paste and the initial AGENT_PROMPT_SUBMIT separately. The guide test feeds the guide screen during the paste callback, then expects one Enter. That Enter can therefore reach the visible guide.

Use a guide-specific check before the initial dsh Enter. Do not treat a missing draft alone as proof that the guide is visible, because the blind initial submit remains necessary when the composer has not repainted. Change the guide test to expect zero Enters.


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a42fa57d-ef1b-4dea-b607-82d9f878e3ee
Commits

Reviewing files that changed from the base of the PR and between 75855c7 and de8c0f9.

Files selected for processing: 13
  • src/main/runtime/__fixtures__/dsh-tui-0.17/first-run-guide.meta.json
  • src/main/runtime/__fixtures__/dsh-tui-0.17/first-run-guide.txt
  • src/main/runtime/__fixtures__/dsh-tui-0.17/launchpad-draft-starting.meta.json
  • src/main/runtime/__fixtures__/dsh-tui-0.17/launchpad-draft-starting.txt
  • src/main/runtime/__fixtures__/dsh-tui-0.17/launchpad-empty.meta.json
  • src/main/runtime/__fixtures__/dsh-tui-0.17/launchpad-empty.txt
  • src/main/runtime/dsh-launch-prompt-resubmit.test.ts
  • src/main/runtime/terminal/input/terminal-agent-prompt-resubmit.ts
  • src/main/runtime/terminal/input/terminal-agent-prompt.ts
  • src/shared/agent-prompt-injection.ts
  • src/shared/terminal-composer-draft.ts
  • src/shared/tui-agent-config-types.ts
  • src/shared/tui-agent-config.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

return 0
}
const config = TUI_AGENT_CONFIG[agent]
const launchMs = composerReady ? (config.submitRetryBudgetMs ?? 0) : 0

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.

Minor · Functional Correctness · Quick win

🔎 Supported by static analysis

Script executed:

set -o pipefail
printf '%s\n' '--- changed file diff ---'
git diff --unified=80 75855c7ccd937b881de1cae37fb592873e20daad de8c0f95fbaeb245c6656820ffcf5ff190ec6a76 -- src/shared/agent-prompt-injection.ts
printf '%s\n' '--- relevant symbols and callers ---'
rg -n -F --glob '*.{ts,tsx}' -e 'getAgentPromptHeldSubmitBudgetMs' -e 'writeTerminalAgentPrompt' -e 'composerReady' src | head -240
printf '%s\n' '--- target file ---'
nl -ba src/shared/agent-prompt-injection.ts | sed -n '1,240p'

Repository: stablyai/orca

Length of output: 28208


Script executed:

printf '%s\n' '--- prompt writer ---'
nl -ba src/main/runtime/terminal/input/terminal-agent-prompt.ts | sed -n '1,240p'
printf '%s\n' '--- dsh config and readiness ---'
nl -ba src/shared/tui-agent-config.ts | sed -n '70,145p'
nl -ba src/main/runtime/launched-agent-composer-readiness.ts | sed -n '1,100p'
printf '%s\n' '--- launch method ---'
nl -ba src/main/runtime/rpc/methods/agent-launch-terminal-prompt.ts | sed -n '120,210p'
printf '%s\n' '--- dsh resubmit test ---'
nl -ba src/main/runtime/dsh-launch-prompt-resubmit.test.ts | sed -n '1,220p'
printf '%s\n' '--- prompt writer tests ---'
rg -n -F --glob '*.{test,spec}.ts' -e 'heldSubmitBudget' -e 'composerReady: false' -e 'submitRetryBudgetMs' src/main src/shared

Repository: stablyai/orca

Length of output: 27703


Script executed:

printf '%s\n' '--- all sendTerminalAgentPrompt call sites ---'
rg -n -F --glob '*.ts' -e 'sendTerminalAgentPrompt(' -e 'sendTerminalAgentPrompt:' src/main src/shared
printf '%s\n' '--- dsh configuration ---'
rg -n -C 12 -F --glob '*.ts' -e "dsh:" -e "'dsh'" src/shared/tui-agent-config.ts src/main
printf '%s\n' '--- freshLaunch plumbing ---'
rg -n -C 8 -F --glob '*.ts' -e 'freshLaunch' src/main/runtime src/main | head -260
printf '%s\n' '--- worker prompt contract ---'
nl -ba src/main/runtime/rpc/methods/orchestration/worker/worker-start-prompt-contract.test.ts | sed -n '1,130p'

Repository: stablyai/orca

Length of output: 42153


Script executed:

printf '%s\n' '--- resubmit loop ---'
nl -ba src/main/runtime/terminal/input/terminal-agent-prompt-resubmit.ts | sed -n '1,180p'
printf '%s\n' '--- blocking wait ---'
nl -ba src/main/runtime/rpc/methods/agent-launch-terminal-prompt.ts | sed -n '55,115p'
printf '%s\n' '--- retry budget config entries ---'
rg -n -C 4 -F --glob '*.ts' -e 'submitRetryBudgetMs' -e 'submitRetryDelayMs' src/shared/tui-agent-config.ts

Repository: stablyai/orca

Length of output: 10230


Keep dsh’s retry budget on reused launches.

The reused-terminal path passes freshLaunch: false, so writeTerminalAgentPrompt receives composerReady: false. With dsh, the zero budget makes resubmitHeldAgentPrompt return before it checks the held draft. A refused Enter can therefore leave the prompt unsent.

A fresh-launch readiness timeout returns before the writer, so this issue applies to reused launches rather than that timeout path.

Suggested fix
--- "a/src/shared/agent-prompt-injection.ts"
+++ "b/src/shared/agent-prompt-injection.ts"
@@ -87,7 +87,8 @@
     return 0
   }
   const config = TUI_AGENT_CONFIG[agent]
-  const launchMs = composerReady ? (config.submitRetryBudgetMs ?? 0) : 0
+  const launchMs =
+    composerReady || agent === 'dsh' ? (config.submitRetryBudgetMs ?? 0) : 0
   const pasteBurstMs =
     platform === 'win32' && config.windowsInputRecordPasteNewline
       ? pastePayload.length * WINDOWS_INPUT_RECORD_PASTE_MS_PER_CHAR
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
const launchMs = composerReady ? (config.submitRetryBudgetMs ?? 0) : 0
const launchMs =
composerReady || agent === 'dsh' ? (config.submitRetryBudgetMs ?? 0) : 0

…cad bundle

Box-drawing characters in regex literals reached the minified orcad entry,
which must stay ASCII; build them with String.raw \u escapes instead.
@nwparker
nwparker merged commit 23c5eec into main Oct 25, 2026
42 checks passed
nwparker added a commit that referenced this pull request Oct 25, 2026
…ker's first dispatch (#33499)

dsh worker dispatches (and other dsh agent-prompt sends) now get #33316's bounded Enter retry: dsh paints its launchpad before its session opens and refuses the first Enter with "still starting", so a fresh worker's task sat unsent. The retry only re-presses while the launchpad still holds the same prompt and stops once a turn starts.

Fixes #30778

Co-authored-by: Jinwoo Hong <[email protected]>
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]: dsh --prompt launch leaves the task in the launchpad (Enter arrives before the startup session is submit-ready)

1 participant