Repository navigation
fix(native-chat): read OMP ask fields wrapped in a matching <label for> - #52501
Conversation
[Medium impact] The PR appears safe to merge. SummaryReads controls inside a matching
No actionable issues found. Tests were inspected, not run. Reviews (2) · Last reviewed commit: "fix(native-chat): read OMP ask fields wr..." · Reviewed by Greptile |
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
OmpAskFormReader.label() returned early for any <label for> naming a control before checking whether the label wraps controls, so a field inside such a label was dropped (and a form with only that field parsed to null, showing no question card). Run the early return only for labels that hold no control, matching OMP html-form v19.3.0 (oh-my-pi 2f6adc9d69). Fixes stablyai#52500 Co-authored-by: Neil <[email protected]>
cd0488f to
154be24
Compare
ELI5
When the OMP agent asks you something, it sends a small web form. If a text box sat inside the label that also pointed at that same box by name, Orca skipped the box, so the question never showed up. OMP 19.3.0 now reads those boxes, and so does Orca, so the question card appears.
What Changed
askform, a field inside a<label for>that names it, such as<label for="n">Anything to add? <input id="n" name="n"></label>, was dropped. When it was the form's only field,parseAskFromToolInput/parseInteractivePromptreturnednull, so no card appeared in desktop native chat or on mobile while OMP waited in the terminal. In mixed forms the question was missing from the list and from the dashboard's ask summary.OmpAskFormReader.label()(src/shared/native-chat/input/questions/omp-ask-form-sections.ts) returned early for every<label for>that is its control'slabelFortarget, before checking whether the label holds a control. That early return now runs only for labels that hold no control (a detached label, which still titles its control and stays out of the text flow). The reader's upstream version comment moves to v19.3.0.Why
Orca's reader mirrors OMP's html-form rules so the card shows what OMP's terminal asks. OMP fixed this exact rule in v19.3.0 (oh-my-pi commit
2f6adc9d69, "fix(ask): preserved controls wrapped by matching labels"); this change moves the same check the same way, which fixes the root cause in the reader itself rather than patching parse results.Alternative considered: keep the v19.2.1 rule for older OMP. On 19.2.1 a form whose only field is wrapped this way fails at once ("no named controls"), so there is no working case to preserve.
Linked Issue
Fixes #52500
Visual Proof
A throwaway fixture (not part of this PR) passes the OMP
askinput above through the realparseInteractivePromptintoNativeChatInteractiveCard. The card component itself is unchanged; mobile reads the form with the same parser.main): no cardTesting
Reproduced with the new test in
omp-ask-form-input.test.ts: onmainit fails (expected null to deeply equal { questions: [ { …(3) } ] }, 1 failed / 9 passed); with this change 10/10 pass.The test also covers a wrapped
<label for>next to a detached<label for>placed after its control, and expects exactly['Anything to add?', 'Who owns this?'], matching OMP 19.3.0'swrapping and detached labels with for each appear oncetest.Upstream parity: ran OMP's real
parseHtmlForm(oh-my-pi origin/main) and Orca's reader on 11 edge-case forms (wrapped textarea with a default body, wrapped select, input with a value, wrapped radios,fornaming a different control, nested labels, duplicate labels, label in a table cell, mixed forms). This branch matches upstream on all 11;maindiffers on 8.vitest run src/shared/native-chat/input: 8 files, 42 tests pass. oxlint, oxfmt, anti-slop oxlint, native-plugins oxlint, ast-grep and the changed-code quality gate are clean on both files.Platform: macOS (shared TypeScript, no platform APIs).
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
Performance
None, because the reader does the same work per label (one check moved), and parse results are memoized per form HTML, so it runs once per unique ask. Measured (tsx, old vs new reader): a typical 3-field form is unchanged within noise (~0.008 ms). A 2000-field form of wrapped
<label for>fields goes from ~0.45 ms to ~2.25 ms mean only because those 2000 fields are now read instead of dropped, the same cost as an existing 2000-field plain-label form (~2.5 ms). No I/O, subprocesses, polling, or renderer/store/cache changes, so no per-tab fanout.Risk
Level: Low
<label for>that wraps a control behaves differently: that control is now read. Labels without a control inside behave as before.Review
askforms with a<label for>around its control.Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
The rule follows oh-my-pi's html-form parser (MIT, can1357/oh-my-pi, v19.3.0).
Original fix by @Aeternologist in #52501.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)