Skip to content

fix(orchestration): write OMP worker prompts with their Enter in one write - #21250

Closed
thieung wants to merge 2 commits into
stablyai:mainfrom
thieung:fix/omp-prompt-submit-joins-paste-frame
Closed

thieung wants to merge 2 commits into
stablyai:mainfrom
thieung:fix/omp-prompt-submit-joins-paste-frame

Conversation

@thieung

@thieung thieung commented Sep 17, 2026

Copy link
Copy Markdown

ELI5

When Orca starts an OMP worker it types the task into the agent's input box, waits half a second, then presses Enter. OMP shows a "what do you want to do with this big paste?" menu before the text ever reaches the box, so Orca's Enter presses that menu's first option instead of sending the task. The worker looks started but sits there holding the task in a little attachment chip. This PR presses Enter together with the paste for OMP, so the menu never appears.

What Changed

Before: worker-start on an OMP pane reports input_accepted, but the pane shows the whole Task prompt collapsed in the composer (📄 #1 … +144 lines) and no turn starts. The Dispatch stays ready / dispatched; a human has to press Enter once in the pane to get anything moving. Reproduced on 1.4.199 with OMP 18.1.19 (evidence in #21248).

After: the same dispatch starts the turn with no operator input. The paste frame and the Enter leave the runtime in one PTY write, and the settle delay is skipped for OMP only.

Mechanism: writeTerminalAgentPrompt wrote pastePayload, waited getAgentPromptSubmitDelayMs(...), then wrote '\r' as a second write. OMP only flags a paste as submitAfterPaste when the Enter arrives in the same input read as the paste terminator (ESC[201~); otherwise a paste at paste.largeMenuThreshold lines (default 100 — a Task prompt clears that with Orca's ~64-line dispatch preamble) opens OMP's Pasted N lines menu, which the later Enter then accepts. agentPromptSubmitJoinsPasteFrame(agent) now selects that path for omp, the payload write carries the submit byte, and the delay/submit tail is skipped for it. Every other agent keeps the exact previous behavior.

Why

Joining is the only signal OMP reads for "paste and submit"; a longer settle delay cannot help, because the Enter is not late — it is outside the paste frame. The alternatives were worse:

Linked Issue

Fixes #21248

Visual Proof

N/A — no UI surface changes; the change is which bytes reach the pane. Before/after terminal frames (composer chip vs started turn) are captured in #21248.

Testing

  • New agent prompt submission runtime > writes Enter inside the paste frame for an OMP worker: drives the real sendTerminalAgentPrompt with an omp launch agent and asserts exactly one PTY write containing the paste frame plus '\r' (previously two writes: paste, then Enter after the delay).

  • New joins Enter to the paste frame for OMP only in the shared module suite pins the per-agent scope (omp true; codex / claude / absent false).

  • Shared-module behavior re-verified locally against vitest 4.1.11 (predicate + payload composition).

  • Live before/after on macOS arm64: 144-line spec to an OMP pane stayed on a paste chip before, and 99-line vs 100-line replays confirmed the threshold in [Bug]: OMP worker-start prompt is never submitted — OMP's large-paste menu consumes the injected Enter (1.4.199 / OMP 18.1.19) #21248.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Implemented with an AI coding agent (Oh My Pi, deepseek-v4.1-flash) driving Orca's CLI for the reproduction; the reporter reviewed the diff and owns the linked issue.

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

  • Cross-platform: on Windows ConPTY the join is the safer shape — ConPTY ingests written bytes in order, so an Enter inside the same write cannot reach the child before the paste content, while the removed separate write could race ingest.
  • Remote/SSH: still one write through the same host-selected PTY path; no wire or API change.
  • Mobile / renderer: untouched.
  • Backwards compatibility: behavior changes only for omp panes; all other agents keep the delayed Enter.
  • Performance: one fewer PTY write and no settle delay for OMP.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • 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, and pnpm build pass (or CI will cover; local preferred)

…write

OMP holds a bracketed paste as a draft until Enter arrives in the same input
read: for a paste at paste.largeMenuThreshold lines (default 100) it opens its
"Pasted N lines" menu first, and the separate Enter Orca writes after the
settle delay then accepts that menu instead of submitting the Task. A worker
Task prompt reaches that size because Orca's dispatch preamble alone is ~64
lines, so the Dispatch reports input_accepted while the pane sits on a
collapsed paste chip.

Write the submit with the paste frame for OMP only and skip the settle delay
for it; every other agent keeps the existing delayed Enter, and codex (which
misreads a paste carrying its own Enter, stablyai#11343) stays out.

Fixes stablyai#21248

@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

  • One-write submit for OMP — writeTerminalAgentPrompt now writes ${pastePayload}${AGENT_PROMPT_SUBMIT} in the existing single PTY write and skips the render-gate/delay wait plus the separate suffix submit when the predicate is on (src/main/runtime/orca-runtime-write-terminal-agent-prompt.ts).
  • Per-agent predicate — new agentPromptSubmitJoinsPasteFrame(agent) returns true only for omp, keeping the prior two-write behavior for every other agent (src/shared/agent-prompt-injection.ts:97).
  • Regression tests — the runtime test pins exactly one PTY write containing the paste frame plus '\r' for an omp launchAgent; the shared test pins the predicate's per-agent scope.

I checked the omp-only scope against the upstream TUI forks: the large-paste menu and submitAfterPaste handling live in OMP's fork (@oh-my-pi/pi-tui), while Pi core (@earendil-works/pi-tui) and Prime Agent have only the inline [paste #N +M lines] marker path and no largeMenuThreshold, so leaving pi/prime-agent on the delayed Enter is correct. The getPtyAgent precedence (launchAgent ?? foregroundAgent) also matches the render gate's, so no gated render gate is created for an omp pane. Behavioral changes are confined to omp; the joined path still runs the pre-write permission/gate checks and the request-bound verification, so the receipt semantics are unchanged.

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

@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

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: 8db83ef8-b183-48ab-b2db-73916b096f5c

📥 Commits

Reviewing files that changed from the base of the PR and between ecd4630 and a92d043.

📒 Files selected for processing (1)
  • src/main/runtime/orca-runtime-write-terminal-agent-prompt.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/runtime/orca-runtime-write-terminal-agent-prompt.ts

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


📝 Walkthrough

Walkthrough

The change adds agentPromptSubmitJoinsPasteFrame, which returns true only for OMP. The runtime appends AGENT_PROMPT_SUBMIT to the paste payload for OMP, skips the render-gate wait and separate submit write, and preserves the existing flow for other agents. Tests cover the policy and verify one combined OMP PTY write.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to a92d0

OMP prompt submission now sends the paste and Enter together without changing the non-OMP submission flow. No actionable merge-blocking risk was identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: writing the OMP prompt and Enter in one write.
Description check ✅ Passed The description is complete and matches the repository template. It explains the user impact, mechanism, rationale, linked issue, testing, AI usage, compatibility considerations, and visual-proof exce…
Linked Issues check ✅ Passed The PR satisfies the coding requirements in [#21248]. agentPromptSubmitJoinsPasteFrame returns true only for omp. writeTerminalAgentPrompt appends AGENT_PROMPT_SUBMIT to the bracketed paste pa…
Out of Scope Changes check ✅ Passed The changed files support [#21248]. They implement OMP prompt submission, preserve other-agent behavior, prevent a related listener leak, and add focused tests. No unrelated product behavior appears i…
  • Fix all pre-merge checks with AI

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: f47088db-eb3f-46c2-bf9f-bbb2d91ca6a7

📥 Commits

Reviewing files that changed from the base of the PR and between a3046cd and ecd4630.

📒 Files selected for processing (4)
  • src/main/runtime/agent-prompt-submission-runtime.test.ts
  • src/main/runtime/orca-runtime-write-terminal-agent-prompt.ts
  • src/shared/agent-prompt-injection.test.ts
  • src/shared/agent-prompt-injection.ts

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

…it path

review feedback (CodeRabbit): the joined OMP path skipped the only
renderGate.dispose() call. The render gate is only created for claude/codex
panes and the join only applies to omp, so the two are disjoint today and no
listener leaks yet; disposing keeps a future agent that needs both paths from
registering a terminal-data listener for the life of the runtime.
@thieung

thieung commented Sep 17, 2026

Copy link
Copy Markdown
Author

Review feedback addressed in a92d043 (render-gate dispose on the joined path).

Verification on this head, in a sparse clone of the PR branch:

npx [email protected] run src/shared/agent-prompt-injection.test.ts
→ Test Files 1 passed (1) · Tests 19 passed (19)

That runs the real src/shared/terminal-input graph with the new joins Enter to the paste frame for OMP only case, so the predicate and payload composition are green on CI-runnable tests.

src/main/runtime/agent-prompt-submission-runtime.test.ts (the case pinning one PTY write containing the paste frame plus '\r') needs the full workspace install (zod, ws, native modules) and is left to repo CI; I could not run it from a sparse checkout.

Behavior is unchanged for every agent other than omp: the join only removes the settle delay and moves the submit byte into the existing single paste write, and the pre-write permission/gate checks plus the request-bound verification still run.

@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

This run covers a92d043, the one commit landed since the prior pullfrog review at ecd4630.

  • Disposed the render gate on the joined-submit path — writeTerminalAgentPrompt now calls renderGate?.dispose() when submitJoinsPasteFrame is true (src/main/runtime/orca-runtime-write-terminal-agent-prompt.ts:69). The first commit armed a gate and then skipped the only finally that unsubscribed it, so an agent that both joined the paste frame and had a render gate would have left its subscribeToTerminalData listener registered for the life of the runtime.
  • Restructured the wait branch — the new if (submitJoinsPasteFrame) / else if (renderGate) / else leaves the wait and delay behavior on the non-joined paths unchanged, and the joined path still skips both.

The fix is correctly scoped: createAgentPromptRenderGate is non-null only for claude/codex (the excluded set) and the join is omp-only, so this is defense against a future agent landing in both sets rather than an active leak today. dispose() clears the gate's timers and calls the subscription's unsubscribe, and it is reached at most once per call (the catch path throws before this branch). This addresses CodeRabbit's single actionable comment on the prior revision.

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

@nwparker

Copy link
Copy Markdown
Contributor

Secondary review: superseded by #21573

This PR correctly identifies the OMP large-paste submission symptom, but its joined-write baseline is sampled after prompt bytes are written. A fast OMP transition can therefore be missed, and one PTY write does not prove one child read on SSH/ConPTY.

The lower-risk replacement is #21573: it joins Enter to the bracketed-paste frame only for OMP and captures the activity baseline before the write. The existing focused tests and OMP source/runtime evidence are included there.

@nwparker

Copy link
Copy Markdown
Contributor

Superseded by merged PR #21573, which implements and verifies the same OMP large-paste prompt-submit fix. Closing this stale duplicate so the merged fix is the review target.

@nwparker

Copy link
Copy Markdown
Contributor

Superseded by merged PR #21573.

@nwparker nwparker closed this Sep 19, 2026
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]: OMP worker-start prompt is never submitted — OMP's large-paste menu consumes the injected Enter (1.4.199 / OMP 18.1.19)

2 participants