Skip to content

fix(native-chat): read OMP's HTML-form ask questions - #51108

Merged
nwparker merged 1 commit into
stablyai:mainfrom
Aeternologist:fix/omp-html-form-ask
Nov 27, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
Aeternologist:fix/omp-html-form-ask

Conversation

@Aeternologist

@Aeternologist Aeternologist commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

OMP agents now ask their questions as a small web form instead of a list. Orca only understood the list, so the phone (and the desktop native chat view) just said "Awaiting user input" and never showed that a question was waiting. Orca now reads the form, so the question card shows again.

What Changed

  • Before: with OMP 18.18.3 or newer, an ask call left the session at a bare "Awaiting user input" row with no prompt card, on mobile and in the desktop native chat view. The transcript counted the call as an ordinary tool ("Used 1 tool").
  • After: Orca reads the form's questions and options, so the OMP card ("Answer this OMP question in the terminal") appears again, as it did with older OMP. You still answer in the terminal, same as before.
  • Mechanism:
    • omp-ask-form-input.ts registers a parser for OMP's ask tool in QUESTION_TOOL_PARSERS (native-chat-ask.ts), next to the Codex one. It works without a DOM, because the phone (Hermes) has none.
    • omp-ask-form-markup.ts builds a lenient element tree (implied </p>, </li>, </option>, table cells, entities). It empties inline media before parsing, so a large data: image or <svg> does not push the controls past the cap.
    • omp-ask-form-sections.ts splits the form into sections, text blocks and fields, the way OMP's own html-form parser does.
    • Each named field gets its question the way OMP words it: its own label, else the text right before it, else its fieldset legend, else a lone option's label, else its name. checked/selected options (and a single select's first enabled option) are marked Recommended. Disabled options, unnamed controls, hidden inputs and buttons are dropped.
    • Hostile input is bounded. The source is cut to 256 KB, and after media is removed the parser reads at most 16,000 chars (the live-status prompt cap). Scans only move forward and nesting is iterative, so deep nesting cannot overflow the stack. Tag and entity lookups never resolve through the prototype.
    • Results are cached per input object (WeakMap, re-read if html changes in place) and per html string (BoundedMap). A fresh status or transcript snapshot that brings the same form back does not parse it again.
    • When mobile transcript sanitizing finds an oversized OMP form, it sends the parsed questions[] instead of html it can't shorten. The ask reader already falls back to questions[]. fitInteractivePrompt now returns null early when even the shortest cut does not fit.
    • The shared entity decoding and quoted-attribute-aware tag-end scan move to src/shared/text/ (html-entities.ts, html-start-tag-end.ts). Page metadata (html-head-tags.ts) now uses them in place of its own private copies.
  • Inputs without html (OMP before 18.18.3) still use the questions[] parser.
  • Removed registerQuestionTool, an export with no callers.

Why

The root cause is OMP 18.18.3 changing its ask input from questions[] to one HTML form ({ html }). This is checked against upstream oh-my-pi docs/tools/ask.md and packages/coding-agent/src/tools/html-form/. Orca's host still forwards the raw tool input as interactivePrompt, and the shared parsers returned null for the new shape, so no surface could tell a question was pending.

Alternatives considered:

  • Treat any OMP ask as a question without reading it. This brings the card back but loses the question text.
  • Use an HTML/DOM library. The mobile app runs on Hermes with no DOM, and OMP's own parser (@oh-my-pi/pi-utils) depends on native bindings. A small reader that follows OMP's rules keeps shared code dependency-free.

Linked Issue

Fixes #51107

Visual Proof

Before: the phone with OMP 19.2.1. After: an OMP 18.18.3+ ask form ({ html }) passed through parseInteractivePrompt into the phone's MobileNativeChatPromptCard, rendered with react-native-web at 390x844. The OMP card appears again. The After images are not device screenshots.

Before (device) After, dark After, light
Phone transcript: Used 1 tool, then a bare Awaiting user input row and no question card Mobile prompt card: Answer this OMP question in the terminal, dark theme Mobile prompt card: Answer this OMP question in the terminal, light theme

Testing

  • I manually tested these changes locally

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

  • Every added test fails without this change and avoids the test anti-patterns

  • omp-ask-form-input.test.ts: an OMP form goes through parseInteractivePrompt (live status) and parseAskFromToolInput (transcript) to the expected questions (returns null without this change). It also covers hostile nesting without stack overflow, the 16,000-char read cap, prototype-safe tag and entity names, re-reading an input whose html changes in place, controls after a large inline image or drawing, single-select preselection, an unquoted attribute value containing ', and cache reuse across fresh snapshots.

  • native-chat-rpc-block-sanitize.test.ts: an oversized OMP form reaches mobile as readable questions[], and a small one stays as html.

  • Original author: replayed a real ask input captured from OMP 19.2.1 through parseInteractivePrompt and resolveNativeChatTerminalTurn. They also diffed the results against OMP 19.2.1's own parseHtmlForm/fieldQuestions on 27 forms: 26 match exactly. The one difference is &rarr;, which Orca decodes and OMP shows literally.

  • Re-ran on the squashed commit (macOS): the vitest files above plus NativeChatQuestionCard.test.tsx, NativeChatSubagentSheet.test.tsx, html-head-tags.test.ts and link-preview-page-metadata.test.ts. 7 files, 33 tests pass. The CI static gates on the touched files are clean: anti-slop oxlint, code-quality native plugins, ast-grep, the changed-code quality gate and oxfmt.

Performance

The parser runs only when an ask tool input carries html, on agent status updates (main/mobile) and on pending-ask scans of transcript rows. Measured with bun on an M-series Mac:

Case Cost
Typical form, cold parse 0.10 ms
Same input object (cached) 0.0001 ms
Fresh object, same html (cached) 0.0013 ms
Non-OMP tools and the questions[] fallback 0.0004 to 0.0007 ms, unchanged path
Worst adversarial case (30k unclosed <option>, 270 KB) 6.7 ms
Other adversarial cases (50k nested <div>, unclosed <p>/quotes, < spam, 20k nested <fieldset>, entity floods, a 250 KB base64 image) 0.2 to 2.2 ms each

No adversarial case comes near 16 ms. There is no new I/O, subprocess, polling or store/selector change. Each session's update parses only its own prompt, so the work does not grow with the number of sessions (at N=200 sessions, one update is still one parse, then a cache hit). Cache memory is bounded: 1,024 entries and 256 x 16,000 chars by html, plus a WeakMap keyed by input object.

Risk

Level: Low

The change only affects OMP ask inputs that carry html, which Orca could not read before. If the reader gets a form wrong, the card shows imperfect question text. Answering still happens in OMP's terminal UI, which is unchanged. Older OMP (questions[]) and other agents' question tools keep their parsers. Page metadata now uses the shared entity decoder and tag-end scanner, with its tests unchanged and passing. To back out, revert the commit; there is no persisted state.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

The form-reading rules follow oh-my-pi's html-form parser (MIT, can1357/oh-my-pi), so the phone shows the questions OMP's terminal UI shows. This PR is the original fix by @Aeternologist in #51108, squashed with maintainer follow-ups (hostile-input bounds, linear scans, caching, media stripping, shared entity helpers). Authorship is preserved.

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)
  • I stated the risk: what could break, for whom, and how to back it out
  • 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)

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The question parser now supports OMP ask inputs that contain an HTML form. It converts form controls into questions and preserves option selections, multi-select settings, and required states. The parser is registered for the OMP ask tool. The changes also remove the exported registerQuestionTool function and add parser and size-handling tests.

Severity of issue fixed: Medium

Merge Risk: Moderate · up to 54c8b

OMP ask forms now render a question card, but some shapes still fail. A label that both names and wraps its control produces no card, and oversized string-encoded ask inputs can be truncated into invalid JSON. Fix these before merging, or accept them explicitly, since both leave the card as "Awaiting user input".

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(native-chat): read OMP's HTML-form ask questions" matches the main change. The PR adds a parser for OMP's HTML-form ask input, so the question card appears again on mobile and desktop n…
Description check Passed The description follows the repository template. It covers ELI5, What Changed, Why, Linked Issue (Fixes #51107), Visual Proof with before and after images, Testing, Performance, Risk with level, AI Di…
Linked Issues check Passed Objective [#51107]: when OMP ask input has the new { html } shape, the phone and desktop native chat must show the OMP question card, as they did for questions[]. The previous review found `nati…
Out of Scope Changes check Passed The parser files, the registration in native-chat-ask.ts, and the tests implement the #51107 objective. Supporting changes connect to the same path: the pi-family-tool-fields.ts comment corrects t…
Full details: Title check

Explanation

The title "fix(native-chat): read OMP's HTML-form ask questions" matches the main change. The PR adds a parser for OMP's HTML-form ask input, so the question card appears again on mobile and desktop native chat. The title is specific and uses the conventional prefix.

Full details: Description check

Explanation

The description follows the repository template. It covers ELI5, What Changed, Why, Linked Issue (Fixes #51107), Visual Proof with before and after images, Testing, Performance, Risk with level, AI Disclosure, Review, the upstream boundary checkbox, Notes, and the Checklist. It explains the mechanism, the alternatives considered, and the rollback path. The Visual Proof images are not device screenshots for the after state, but the author states this openly.

Full details: Linked Issues check

Explanation

Objective [#51107]: when OMP ask input has the new { html } shape, the phone and desktop native chat must show the OMP question card, as they did for questions[]. The previous review found native-chat-ask.ts registers parseOmpAskFormInput for ask in QUESTION_TOOL_PARSERS, and both live status and transcript parsing use that dispatch. The current summary adds the form reader (omp-ask-form-markup.ts, omp-ask-form-sections.ts, omp-ask-form-input.ts), which turns named fields into questions. The questions[] path is unchanged. Changes since the previous review add native-chat-rpc-block-sanitize.ts logic so an oversized OMP form keeps its questions when the input is shortened for transport. This keeps the card working on the wire path. The omp-ask-form-input.test.ts and native-chat-rpc-block-sanitize.test.ts cover these paths. I did not re-run the tests. The PR's replay and differential results are author-reported evidence, not re-executed here. Question text display is deferred to a follow-up PR and is not required by #51107.

Full details: Out of Scope Changes check

Explanation

The parser files, the registration in native-chat-ask.ts, and the tests implement the #51107 objective. Supporting changes connect to the same path: the pi-family-tool-fields.ts comment corrects the OMP ask input description; native-chat-rpc-block-sanitize.ts keeps OMP form questions within the transport limit; fitInteractivePrompt in agent-status-field-normalization.ts returns null when the smallest candidate fails fits, which guards that fitting path; html-head-tags.ts now reuses shared decodeHtmlEntities and htmlStartTagEnd, which the new reader needs. The registerQuestionTool removal has no callers per the author. Gap: the PR description does not mention the sanitize, status-normalization, or html-head-tags changes, and fitInteractivePrompt affects all agents' prompts. These changes appear tied to the ask-form path, but the description should state them. I could not confirm the absence of other importers of the removed decodeHtmlEntities export in html-head-tags.ts; the author reports typecheck passes.

  • 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

@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

  • 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: c0919485-55fc-479e-b1b4-d11a6a97f3e4
Commits

Reviewing files that changed from the base of the PR and between f0ddb49 and 0883679.

Files selected for processing: 6

  • src/shared/agent-hook-listener/providers/pi-family/pi-family-tool-fields.ts
  • src/shared/native-chat/input/native-chat-ask.ts
  • src/shared/native-chat/input/questions/omp-ask-form-input.test.ts
  • src/shared/native-chat/input/questions/omp-ask-form-input.ts
  • src/shared/native-chat/input/questions/omp-ask-form-markup.ts
  • src/shared/native-chat/input/questions/omp-ask-form-sections.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.

if (CLOSES_PARAGRAPH.has(name)) {
current = closeImplied(current, PARAGRAPH_END)
}
const implied = IMPLIED_END[name]

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 · Stability & Availability · Quick win

Guard the implied-close lookup with an own-property check.

IMPLIED_END is a plain object literal, so names such as constructor and toString resolve to inherited Object.prototype members. For <form><constructor><input name="answer"></constructor></form>, IMPLIED_END['constructor'] returns the inherited Object function. That value is truthy. closeImplied then reads rule.within, which is undefined, and calls .has on it. This throws a TypeError.

The exception has two outcomes:

  • The object-input path, parseAskFromToolInput with an object input, has no catch. The error propagates to its callers.
  • The status-string path, parseAskFromStatus, catches the error and returns null. The live question card is not built from that status.

Check own keys before applying a rule. Unknown tag names then remain ordinary elements. Rules for tags such as li and td keep their current behavior.

Suggested fix

--- "a/src/shared/native-chat/input/questions/omp-ask-form-markup.ts"
+++ "b/src/shared/native-chat/input/questions/omp-ask-form-markup.ts"
@@ -202,7 +202,9 @@
     if (CLOSES_PARAGRAPH.has(name)) {
       current = closeImplied(current, PARAGRAPH_END)
     }
-    const implied = IMPLIED_END[name]
+    const implied = Object.prototype.hasOwnProperty.call(IMPLIED_END, name)
+      ? IMPLIED_END[name]
+      : undefined
     if (implied) {
       current = closeImplied(current, implied)
     }
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

Suggested change
const implied = IMPLIED_END[name]
const implied = Object.prototype.hasOwnProperty.call(IMPLIED_END, name)
? IMPLIED_END[name]
: undefined

Comment on lines +132 to +133
if (target && this.labelFor.get(target) === label) {
return

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.

Major · Functional Correctness · Quick win

Read controls inside a label that also has for.

For <form><label for="answer">Answer<input id="answer" name="answer"></label></form>, the constructor adds the label to labelFor. This guard then returns before it reads the nested input.

The parser returns null, so this form still has no question card. Process the label's descendant controls before returning. Continue to suppress standalone detached-label text.

OMP 18.18.3 changed its `ask` tool input from `questions[]` to one HTML
form (`{ html }`). Orca's question parsers returned null for that shape,
so mobile and the desktop native chat view showed a bare "Awaiting user
input" row with no question card.

Register a DOM-free parser for OMP's `ask` that follows OMP's own
html-form rules (lenient element tree, sections, per-field question
wording, checked/selected options as recommended). Older inputs still
fall back to `questions[]`. Parsing is bounded on hostile input, inline
media is emptied before parsing, and results are cached per input object
and per html string. Mobile transcript sanitizing swaps an oversized html
form for its parsed `questions[]`. Shared entity decoding and tag-end
scanning move to src/shared/text and are reused by page metadata.

Fixes stablyai#51107

Co-authored-by: Neil <[email protected]>
@nwparker
nwparker force-pushed the fix/omp-html-form-ask branch from 0883679 to 54c8b28 Compare November 27, 2026 21:57

@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

  • 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: b1e69105-a5a1-4d2f-94b1-8163c033097d
Commits

Reviewing files that changed from the base of the PR and between 0883679 and 54c8b28.

Files selected for processing: 11

  • src/main/network/page-metadata/html-head-tags.ts
  • src/main/runtime/rpc/methods/native-chat/native-chat-rpc-block-sanitize.test.ts
  • src/main/runtime/rpc/methods/native-chat/native-chat-rpc-block-sanitize.ts
  • src/shared/agent-hook-listener/providers/pi-family/pi-family-tool-fields.ts
  • src/shared/agent-status/contracts/agent-status-field-normalization.ts
  • src/shared/native-chat/input/questions/omp-ask-form-input.test.ts
  • src/shared/native-chat/input/questions/omp-ask-form-input.ts
  • src/shared/native-chat/input/questions/omp-ask-form-markup.ts
  • src/shared/native-chat/input/questions/omp-ask-form-sections.ts
  • src/shared/text/html-entities.ts
  • src/shared/text/html-start-tag-end.ts
Files skipped from review as they are similar to previous changes: 1

  • src/shared/agent-hook-listener/providers/pi-family/pi-family-tool-fields.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.

}
const fitted = fitInteractivePrompt(encoded, (text) => text.length <= MOBILE_BLOCK_CHAR_CAP)
// OMP's html form cannot be shortened; its questions[] shape can, and the `ask` reader falls back to it.
const htmlForm = name === OMP_ASK_TOOL && isOmpAskFormInput(input)

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.

Major · Functional Correctness · Quick win

Decode string ask inputs before detecting OMP HTML forms.

isOmpAskFormInput accepts only objects. A form that arrives as a JSON string is parsed by parseAskFromToolInput, but htmlForm is false for it. Fitting then keeps the unchanged html field, so it returns null when the canonical JSON is longer than 4000 characters. The caller returns the original string, and the generic sanitizer truncates it into invalid JSON. The mobile card is lost, and the merge-base code has the same behavior for this input shape.

Decode a string input before the form check. Keep the object-input path unchanged.

Suggested fix

--- "a/src/main/runtime/rpc/methods/native-chat/native-chat-rpc-block-sanitize.ts"
+++ "b/src/main/runtime/rpc/methods/native-chat/native-chat-rpc-block-sanitize.ts"
@@ -97,18 +97,21 @@
   if (!ask) {
     return input
   }
   const encoded = typeof input === 'string' ? input : JSON.stringify(input)
   if (encoded.length <= MOBILE_BLOCK_CHAR_CAP) {
     return input
   }
   // OMP's html form cannot be shortened; its questions[] shape can, and the `ask` reader falls back to it.
-  const htmlForm = name === OMP_ASK_TOOL && isOmpAskFormInput(input)
-  const shortenable = htmlForm ? JSON.stringify({ questions: ask.questions }) : encoded
+  // A string input is JSON-encoded, so decode it before recognizing the form.
+  const decoded: unknown = typeof input === 'string' ? JSON.parse(input) : input
+  const htmlForm = name === OMP_ASK_TOOL && isOmpAskFormInput(decoded)
+  const questionsJson = JSON.stringify({ questions: ask.questions })
+  const shortenable = htmlForm ? questionsJson : encoded
   const fitted = fitInteractivePrompt(shortenable, (text) => text.length <= MOBILE_BLOCK_CHAR_CAP)
   if (fitted === null) {
     return htmlForm ? { questions: ask.questions } : input
   }
   return typeof input === 'string' ? fitted : JSON.parse(fitted)
 }
 
 function sanitizeToolInput(

Comment on lines +220 to +221
if (!fits(promptAtLimit(1))) {
return null

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

Remove the early return that can reject a prompt fitting at a larger limit.

On the WSL path, fitsProducerFrame counts UTF-8 bytes. The limit-1 candidate is not always the smallest. For a one-character compactable field and a two-character preview, the limit-1 candidate replaces preview with "…" (3 bytes). The unshortened "ab" takes 2 bytes. When the frame budget equals the unshortened candidate's size, the guard returns null before the search evaluates that candidate. fitWaitingInteractivePrompt then returns null. publishAgentHookEnvelope logs the envelope as unsendable and clears it, so the waiting card is not published.

The window is narrow. It requires a frame near capacity and short compactable fields. The guard only skips futile searches for prompts such as the OMP html form. The binary search returns null for those prompts without the guard, so the early return is not needed for correctness. Remove the guard:

Suggested fix

--- "a/src/shared/agent-status/contracts/agent-status-field-normalization.ts"
+++ "b/src/shared/agent-status/contracts/agent-status-field-normalization.ts"
@@ -216,11 +216,7 @@
     parsed === undefined
       ? truncatePreservingSurrogates(prompt, limit)
       : JSON.stringify(compactInteractivePromptValue(parsed, limit))
-  // Nothing fits when even the shortest cut does not (e.g. OMP's `html` form, which never shortens).
-  if (!fits(promptAtLimit(1))) {
-    return null
-  }
   let low = 1
   let high = prompt.length
   let fitted: string | null = null
   while (low <= high) {

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][Mobile]: OMP ask questions show only "Awaiting user input" on oh-my-pi 18.18.3+

2 participants