Skip to content

fix(native-chat): answer OMP ask questions with navigation keys - #26688

Closed
jairuspace wants to merge 3 commits into
stablyai:mainfrom
jairuspace:fix/omp-native-chat-ask-answers
Closed

jairuspace wants to merge 3 commits into
stablyai:mainfrom
jairuspace:fix/omp-native-chat-ask-answers

Conversation

@jairuspace

@jairuspace jairuspace commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When OMP (Oh My Pi) asks a question in Orca's chat view, on desktop or on the phone, clicking an answer used to either pick the wrong choice or leave OMP stuck waiting. That happened because Orca typed the answer as text, and OMP's question box doesn't read typed text. Now Orca presses the same keys a person would press in the terminal: arrows to move, Space to tick a box, and Enter to choose.

What Changed

Before: For OMP, the chat card sent the answer like a chat message: clear the line, paste the label (for example B), then press Enter. OMP's ask dialog moves a highlight with the arrow keys, has no number shortcuts, and ignores pasted text. So the Enter acted on whatever row was highlighted:

  • One question: OMP received the highlighted row (its recommended option, or the first one), not the option the user picked.
  • Several questions: question 1 got its highlighted row, the dialog then sat on question 2, OMP hung, and the chat card stayed open. A 5-question report from the mobile app showed exactly this.
  • A lone multi-select question: Enter confirmed an empty selection, so OMP recorded the question as cancelled by the user.
  • OMP marks multi-select questions with multi: true and Orca only read multiSelect (and OpenCode's multiple), so those questions showed up as single-select cards.

After:

  • shouldStepNativeChatAskAnswer now includes omp. OMP answers go through the same paced key-by-key sender that Claude, Codex and OpenCode already use, on desktop and on mobile.
  • The new buildOmpAskAnswerKeys follows OMP's dialog (OMP ≥ 18.2.0):
    • First, it clears any leftover text in OMP's input box with the shared widest clear, AGENT_TUI_CLEAR_INPUT_MAX (Ctrl+U/Ctrl+K, 40 lines). While that box holds text, OMP sends the dialog's keys to it, so the first Enter would send the leftover text to OMP as a new message. The dialog ignores both keys.
    • For each row it moves to, it presses Up enough times to reach the top row, because OMP starts the highlight on the recommended row. Then it presses Down to the target row.
    • Single-select: Enter picks the row and OMP moves to the next question. Free text goes to "Other (type your own)": Enter opens its editor, the text is pasted, and Enter submits it. A skipped question gets Right.
    • Multi-select: Space ticks each picked row (in OMP 18.x Enter doesn't tick; it confirms and moves on). Then Right moves on. If there's free text, it goes through "Other" instead, and submitting it moves on by itself, so no Right is sent after it.
    • One final Enter, only when the dialog has a Review tab, which means more than one question or any multi-select question.
  • buildNativeChatAskAnswerKeys(agent, …) picks each agent's key builder: Codex, OMP, or Claude-style (Claude, OpenClaude and OpenCode). Desktop and mobile both call it, so the choice lives in one place.
  • When Orca reads a question, multi: true now counts as multi-select, alongside multiSelect and OpenCode's multiple.

Supported OMP versions: 18.2.0 and later. The ask dialog's keys work the same from 18.2.0 through 18.8.7, the latest release. Single-select answers also work on 17.x. On 17.x and 18.0.x, multi-select questions answered with free text still don't go through, because those versions don't move on after the "Other" editor closes.

Why

Nothing in OMP's dialog accepts the answer as text, so the paste-and-Enter path can't work for it. Pressing keys is the only way the dialog takes input.

  • Moving to the top row first means the keys don't depend on which row OMP highlighted. The alternative was to read OMP's recommended value and move from there, which ties the answer to OMP's starting cursor and adds a field to the shared question type. Pressing Up on the top row does nothing, so the extra presses are harmless.
  • Right instead of Enter to leave a multi-select question: it moves on from any row, while Enter on the "Other" row would open the editor. Right also behaves the same on OMP 17.x and 18.0.x.
  • Clearing leftover text reuses the clear that desktop and mobile already share. Orca can't see how long OMP's draft is, so it uses the widest shared clear:
    • OMP turns any paste over 10 lines into one attachment token, which a single Ctrl+U removes.
    • Only 40 or more lines typed one at a time would go past it.
    • OMP's only clear-all key is Ctrl+C, which cancels the dialog.

Linked Issue

Fixes #26692 (also covers #26198, which was merged into it)

Visual Proof

N/A: no layout or visual change. The fix changes which keys are sent to the terminal. The before/after results are listed under Testing.

Testing

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

Correction: an earlier version of this PR said it was checked against OMP 18.8.6's dialog. That check actually loaded a stale 17.2.12 copy of OMP's source, which is how the multi-select bug that shryu1994 and CodeRabbit reported got through. Everything below runs the matching OMP version.

1. Real omp 18.8.6 binary in a terminal, no model needed. A small OMP extension command opens ctx.ui.askDialog, the same dialog the ask tool uses, and writes OMP's result to a file. A driver runs omp --extension … in a pseudo-terminal, types the command, and writes Orca's key groups 400 ms apart. That's faster than Orca's 1 s pacing, so it's a stricter test. The table shows what OMP returned for each answer:

Scenario OMP returned
one question, recommended row 2, pick A A
one question, pick C C
one question, free text "my own"
5 questions, each on a different recommended row B, C, A, C, B
two questions, first skipped (none), A
lone multi-select, A + C A + C
lone multi-select, A + free text A + "D"
multi-select, then a single-select B, C
multi-select with free text, then a single-select A + "x", B
leftover one-line text in OMP's input box, pick B B, leftover text not sent
leftover three-line text, two questions B, A, leftover text not sent
leftover 60-line pasted text, pick C C, leftover text not sent

In all three leftover-text cases, OMP showed its own "Finish or clear the current prompt to answer" notice before the keys arrived. Nothing was sent as a chat message.

2. The same scenarios plus 30- and 45-line leftover-text cases (13 in total) against each OMP version's own dialog code, installed from npm:

OMP Result
18.8.7 12/13
18.8.6 12/13
18.6.1 12/13
18.2.0 12/13
17.2.12 10/13: both multi-select + free-text cases stay open (as described under supported versions), plus the 45-line case

The 30-line leftover-text case passes on every version. The one failure on every version is a deliberate case with 45 lines typed one at a time, beyond the 40-line clear.

3. Before (paste + Enter), on 18.8.6:

  • One question, user picks B → OMP receives the highlighted row
  • Two or more questions → the dialog waits on question 2
  • Lone multi-select → OMP reports the question as cancelled

Automated checks:

  • Unit tests cover the OMP key builder: single-select, free text, Space toggles, no Right after free text, the final Enter only with a Review tab, the leading clear, and a skipped question. They also cover which builder each agent gets and the multi parsing.
  • A new mobile test (use-mobile-native-chat-answer-send-omp.test.ts) checks that the phone sends OMP's key groups one at a time, paced, and never pastes the label. It's a separate file because the existing test file is at the line limit.
  • Desktop:
    • pnpm test src/shared/ src/renderer/src/components/native-chat/: 16,090 tests pass. All 25 failures are in the |bun| project, in 8 files this PR doesn't touch (utf8-byte-limits, agent-image-paste, check-job-log-byte-cap, git-diff-transport-budget and four remote-runtime-* socket tests). This machine has Bun 1.3.14 and CI pins 1.4.2 in config/.bun-version. The node project passes in full.
    • pnpm typecheck and pnpm run check:code-quality:changed pass.
    • Every pnpm lint step passes on this branch except one: the native code-quality step reports five import/no-cycle warnings in untouched mobile transport and terminal files. Those appear only when mobile/node_modules is installed, and the same five warnings appear on a clean main checkout.
  • Mobile: pnpm install --frozen-lockfile, pnpm typecheck, pnpm lint and pnpm format:check pass. pnpm test passes except mobile-e2ee-v2-client-session.test.ts, which fails the same way on a clean main checkout.
  • pnpm build completes the desktop build. Only the native macOS computer-use helper fails, at its universal-binary lipo step: this machine has a single-architecture install, and that step needs pnpm install:release. This change doesn't touch it.
  • Tested on macOS. The real-binary and per-version checks drive OMP's own terminal UI, which reads the same keys on every platform.

4. Live, in the desktop app (dev build of this branch, real model, OMP 18.8.6): single choice (a non-recommended option), multi-select and typed free text were all delivered correctly from the chat card, and OMP carried on with the turn. Submitting takes several seconds, because of the shared 1 s pacing between key groups (details in the PR comments). Not yet tested live: the phone, which needs a mobile build of this branch.

AI Disclosure

Written with Claude (Anthropic) in Oh My Pi. The analysis uses OMP's tagged source for each version. Testing used the published npm packages and the real omp binary.

Review

An AI review of the diff covered correctness against OMP's dialog source, cross-platform, SSH and remote, agent compatibility, mixed versions, performance, UI, and security. Reviewer feedback from shryu1994 and CodeRabbit is addressed in this revision.

  • Correctness: the key plan matches OMP's AskDialogComponent from 18.2.0 through 18.8.7. Shown by the real-binary run and the per-version runs above.
  • Fixed in this revision:
    • Multi-select now ticks with Space, because Enter confirms and moves on in 18.x.
    • No Right is sent after "Other" free text, which moves on by itself.
    • The final Enter is sent only when the dialog ends on its Review tab.
    • Leftover text in OMP's input box is cleared first, using the widest shared clear (CodeRabbit follow-up).
  • Other agents and mixed versions: Claude, OpenClaude, Codex, OpenCode and Grok send exactly the same keys as before. Keys are built on the client and go through the existing raw PTY path, so nothing changes on the wire. An older mobile app keeps the paste path, which was already broken for OMP.
  • Platform, SSH and security: keys go out the same way as the existing Claude, Codex and OpenCode answers: escape sequences, Space, CR and bracketed paste over the existing verified, paced sender. That adds no new macOS, Linux, Windows or SSH-specific path. Free text is cleaned by the existing paste sanitizers.
  • Performance and UI: key groups go out 1 s apart. A 5-question answer takes about 11 s and stays inside the card's existing "submitting" state. OMP multi-select questions now show as checkboxes.
  • Remaining risk: if the card is stale (the dialog is already gone, for example because the user answered in the terminal), the Up keys recall OMP's message history and Enter could re-send an old message. Orca removes the card once OMP records the tool result, so the window is small.

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

  • SSH and remote: this uses the existing paced, verified PTY sender, so remote panes behave the same as Claude and Codex answers already do.
  • Mixed versions: nothing changes on the wire. Only the keys the client sends change.
  • Cross-platform: the keys are standard VT arrow keys, Space, CR and control characters, which OMP's terminal UI reads the same way on every platform.

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). The failures that remain are listed under Testing and also happen on main or in untouched native code.

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 94b149fa-b859-47b0-be5d-37cd8b58ac80

📥 Commits

Reviewing files that changed from the base of the PR and between 4ce926e and 420a659.


📒 Files selected for processing (2)
  • src/renderer/src/components/native-chat/native-chat-interactive-prompt.test.ts
  • src/shared/native-chat-ask.ts

🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/native-chat/native-chat-interactive-prompt.test.ts

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



📝 Walkthrough

Walkthrough

The change adds OMP-specific answer-key generation for native chat selector prompts. Parsing now recognizes multi: true as enabling multi-select. Agent-based dispatch selects the OMP, Codex, or Claude key builder. Renderer and mobile send paths use this dispatch, and OMP is included in selector answer-stepping support. Tests cover OMP key sequences, dispatch, parsing, and answer stepping.


Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 420a6

OMP answers are routed through paced selector keys on desktop and mobile. The reported OMP 17.2.12 custom-text cases remain unverified, but no actionable current-head failure is established.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 63.64% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Direct issue [#26692] requires correct OMP ask answers for selected, skipped, free-text, multi-select, and multi-question prompts. buildOmpAskAnswerKeys clears the draft, homes each row, sends OMP…
Out of Scope Changes check Passed The changed source and tests stay within [#26692]. They add OMP key construction, OMP routing, multi-select parsing, desktop and mobile delivery integration, and focused automated coverage. No unrelat…
Title check Passed The title clearly and concisely identifies the main change: fixing OMP ask-question handling with navigation keys.
Description check Passed The description is complete and closely follows the repository template. It explains the user impact, implementation, rationale, linked issue, testing, compatibility, risks, and checklist status. It a…


  • Fix all pre-merge checks with AI
  • Autopilot · 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: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5f4e59c4-99b5-4303-bf55-53751891f4b7
📥 Commits

Reviewing files that changed from the base of the PR and between bb44f74 and 5dd1320d67442c62099cffdfa1ba4b193bb7b2f1.

📒 Files selected for processing (8)
  • mobile/src/session/use-mobile-native-chat-answer-send.ts
  • src/renderer/src/components/native-chat/native-chat-interactive-prompt.test.ts
  • src/renderer/src/components/native-chat/native-chat-interactive-prompt.ts
  • src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts
  • src/shared/native-chat-agent-support.test.ts
  • src/shared/native-chat-agent-support.ts
  • src/shared/native-chat-ask.test.ts
  • src/shared/native-chat-ask.ts

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

Comment thread src/shared/native-chat-ask.ts Resolved
Comment thread src/shared/native-chat-ask.ts Resolved
@jairuspace
jairuspace force-pushed the fix/omp-native-chat-ask-answers branch from c200276 to 4ce926e Compare October 9, 2026 16:23
@jairuspace

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Incremental review skipped.

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.

@jairuspace

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@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: 4f4ee79b-dd11-4b14-bd10-d746a1db75be
📥 Commits

Reviewing files that changed from the base of the PR and between bd85767 and 4ce926e.

📒 Files selected for processing (9)
  • mobile/src/session/use-mobile-native-chat-answer-send-omp.test.ts
  • mobile/src/session/use-mobile-native-chat-answer-send.ts
  • src/renderer/src/components/native-chat/native-chat-interactive-prompt.test.ts
  • src/renderer/src/components/native-chat/native-chat-interactive-prompt.ts
  • src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts
  • src/shared/native-chat-agent-support.test.ts
  • src/shared/native-chat-agent-support.ts
  • src/shared/native-chat-ask.test.ts
  • src/shared/native-chat-ask.ts

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

Comment thread src/shared/native-chat-ask.ts Resolved
@jairuspace

Copy link
Copy Markdown
Contributor Author

Live test in the desktop app (dev build of this branch, macOS, OMP 18.8.6, real model): started OMP in a terminal, switched the tab to chat view, and had OMP call ask with several questions. Everything was answered correctly from the chat card:

  • ✅ single choice: a non-recommended option was delivered
  • ✅ multi-select: the ticked set was delivered
  • ✅ typed free text ("Other") was delivered
  • ✅ the card dismissed itself and OMP carried on with the turn

Noticeably slow to submit. After pressing Submit, the card spins for several seconds before it dismisses. This is the existing answer sender's pacing: every key group goes out NATIVE_CHAT_QUESTION_STEP_MS (1 s) apart. The 3-question test above needed 13 groups (clear, colour 2, fruits 5, typed answer 4, final Enter), so it took about 12.5 s.

There's room to speed this up for OMP. OMP's input buffer splits a single write into separate keys and applies each one immediately. The real-binary harness already passes every scenario at 400 ms gaps, and a move plus Enter/Space could share one write. I've kept the shared 1 s pacing in this PR so OMP uses the same sender as Claude and Codex, and I'm happy to tighten OMP's pacing here or in a follow-up if maintainers prefer.

Two things I found while testing, which this PR doesn't change:

  • An OMP session started directly in the chat UI runs as omp acp, and over ACP OMP only offers ask when the client advertises form elicitation. Orca doesn't, so those sessions have no ask tool at all. Filed as [Feature]: Support ACP form elicitation so OMP sessions started in the chat UI get the ask tool #26924.
  • A terminal tab whose OMP session was restored from before an app restart can offer "Switch to chat view" but then shows "No conversation here", because its status isn't tied to the tab's pane. That screen also has no visible way back except ⌘⇧J or the tab's right-click menu. Fresh OMP tabs work. I'll file this separately with the details.

Still not covered: the phone. The answer path there uses the same shared key builder, and a unit test covers its pacing. A live check needs a mobile build of this branch, because the store app doesn't include the change.

@daniellp-rubio

Copy link
Copy Markdown
Contributor

Verified this PR against OMP 18.11.0 (the latest release, newer than the 18.8.7 checked above) on Windows, and adding a mobile field report.

Field report (iPhone app). Orca 1.4.226 on Windows 11, Orca iOS app, OMP 18.11.0. On a 4-question ask card, whatever I tap on the phone never reaches OMP. The dialog stays open and the agent stays blocked. Typed chat messages from the phone do arrive. This matches this issue. Current main (e8c7b32a90) still leaves omp out of shouldStepNativeChatAskAnswer, so the phone still uses paste + Enter for OMP.

OMP 18.11.0's dialog. Diffed packages/tui/src/overlays/ask-dialog.ts between 18.8.7 and 18.11.0 (npm @oh-my-pi/pi-tui). The keys this PR relies on behave the same: Up/Down, Space toggles, Enter commits or advances, Right, and the Review tab. The only new input is app.ask.hide (Alt+H), which this PR never sends.

Driving OMP 18.11.0's real AskDialogComponent. The keys go through OMP's own StdinBuffer, so each PTY write is split into keys the way the TUI does it. The key groups come from this PR's buildOmpAskAnswerKeys (branch merged onto main). The "Other" editor is simulated with the dialog's onPrompt callback. This is component-level, not the full binary.

Scenario Expected This PR Paste + Enter (today)
1 q, recommended C, pick A A A C
1 q, recommended A, pick C C C A
1 q, free text "my own" "my own" B (recommended)
5 q, different recommended rows B, C, A, C, B B, C, A, C, B dialog stays open
2 q, first skipped (none), A (none), A dialog stays open
lone multi-select A + C A + C A + C (none)
lone multi-select A + free text A + "D" A + "D" (none)
multi-select, then single-select B, C B, C dialog stays open
multi-select + free text, then single A + "x", B A + "x", B dialog stays open
4 q × 3 options (my phone case) Las dos, Ampliar, Probar, Ampliar same dialog stays open

10/10 pass with this PR. The paste path reproduces the bug in every row.

Merge with current main: one conflict, in src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts. main no longer passes settings (getSettingsForAgentTabRuntimeOwner) to sendNativeChatAskAnswer / sendNativeChatMessage. Fix: drop the const settings = … line and keep this PR's comment, // Selector TUIs ignore pasted labels; each agent's selector takes its own key sequence. With that resolution, native-chat-ask.test.ts, native-chat-agent-support.test.ts and native-chat-interactive-prompt.test.ts pass, 59/59 (vitest 5.0.3, Node 22, Windows).

Not covered: the mobile test file (no mobile deps installed here) and a live run on the phone, which needs a mobile build of this branch. Since the phone builds these keys itself, phone users only get the fix from an app release. A merge plus a mobile release would unblock OMP from the phone.


AI assistance disclosure: prepared with Claude via OMP. The field report is my own. The diff, harness, merge and test runs were done locally on Windows, and the limits are stated above.

@nwparker

Copy link
Copy Markdown
Contributor

Superseded by #31440, now merged. Thank you for the original contribution; contributor credit is preserved in the merge commit.

Verification against the OMP source exposed state-dependent failures in keyboard-driven submission, so the replacement deliberately offers Answer in terminal and prevents automated OMP question-answer/cancel writes. Automatic semantic card answering remains open in #26692.

@nwparker nwparker closed this Oct 21, 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]: Chat view: answering an OMP ask question picks the wrong option or hangs OMP

3 participants