Skip to content

feat(omp): discover and switch native-chat models on desktop and mobile - #20612

Merged
nwparker merged 13 commits into
mainfrom
nwparker/omp-model-options-review
Sep 19, 2026
Merged

nwparker merged 13 commits into
mainfrom
nwparker/omp-model-options-review

Conversation

@nwparker

@nwparker nwparker commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1142 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1137
Prod 21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​439 $\color{#cf222e}{\Huge{\mathbf{−}}}$​76 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​363

OMP chats now show the hook-reported model and discover configured alternatives on desktop and mobile. Picking a model sends an Orca extension command that calls OMP’s supported setModel API; it no longer relies on /model <selector>, which the current TUI does not consume.

The command is enabled only after the running host advertises it. Older hosts keep a read-only model display. Discovery uses the execution workspace’s existing RPC and rejects static fallback catalogs; host switches discard stale mobile results. Reports preserve lifecycle state and queued completion. OMP’s exact reported selector remains authoritative even when a custom or newly added model is missing from cached choices.

Addresses the OMP portion of #17603; Pi native-chat support and thinking-level options remain separate. Compared against #17609; co-author SudoAI-DEV credited.

Validation

  • Final independent review: 232 desktop/shared and 26 mobile tests plus actual SDK smoke passed. Its model-authority finding was fixed with four regressions that failed before the correction; 20 desktop/shared and 28 mobile tests, web/mobile typechecks, and the full changed-code quality gate passed afterward.

  • Implementation: 326 desktop/shared tests, 26 mobile tests, node/web/mobile typechecks and lint/format passed.

  • Parent implementation review: 49 desktop/shared and 26 mobile tests independently passed; real OMP SDK runtime switch rerun passed. Generated metadata type assertion replaced with checked types; focused tests passed afterward.

  • Real read-only OMP loader + SDK switched Sonnet 4.5 → 4.6 with zero model turns/messages. A real local HTTP listener received model_select and the command capability. Synthetic in-memory credentials; no model API request. Repeat with ORCA_BACKGROUND_LAUNCH=1 bun tests/tools/omp-model-runtime-smoke.mjs /path/to/oh-my-pi.

  • Hidden Electron picker regression passed (4.9s): discover two choices, select one, capture /orca-model anthropic/claude-sonnet-4-6 on a real PTY, then display the supplied host report. Discovery and status are fixture data; the actual OMP switch is separately verified above. Screenshots inspected.

  • Model reporting begins on lifecycle activity. An unconfirmed terminal dispatch retains the existing “Sent to the agent — not confirmed” presentation. No startup lifecycle status is fabricated.

Discovered choices Reported selection
Model choices Model report

@nwparker
nwparker marked this pull request as ready for review September 14, 2026 12:16
@coderabbitai

coderabbitai Bot commented Sep 14, 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: c470a1ca-4089-4275-9ab6-c970fddcef1f

📥 Commits

Reviewing files that changed from the base of the PR and between d2a159a24436eb9be283ddd0efcede3ffde8f775 and 3b9c71ff8a6c6fbdfde9b76b3de1bbb654eadf1f.

📒 Files selected for processing (4)
  • mobile/src/session/use-mobile-omp-model-discovery.test.ts
  • src/main/pi/agent-status-extension-omp-model.test.ts
  • src/main/pi/agent-status-extension-source.ts
  • src/main/pi/agent-status-handler-source.ts

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


📝 Walkthrough

Walkthrough

The change adds OMP model discovery and an OMP session-option catalog. It adds the orca-model runtime command and propagates model metadata through agent status events. Renderer and mobile native chat surfaces now display reported models, discover configured choices, and gate switching by reported capability. Tests cover parsing, status handling, UI behavior, PTY dispatch, and runtime reporting.

Priority: ➖ Normal

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description provides a detailed change summary, rationale, linked issue reference, visual proof, and validation results. However, it does not follow the required template and omits several require… Add the required template sections and complete each applicable item. Include an ELI5 summary, explicit What Changed and Why sections, a formal Linked Issue entry such as "Fixes #17603" if applicable, AI Disclosure, Review, Agent skill upst…
Docstring Coverage ⚠️ Warning Docstring coverage is 46.88% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 32 functions across 36 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: OMP model discovery and switching for native chat on desktop and mobile.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description provides a detailed change summary, rationale, linked issue reference, visual proof, and validation results. However, it does not follow the required template and omits several required sections, including ELI5, explicit What Changed and Why headings, AI Disclosure, Review, Agent skill upstream boundary, Notes, and the Checklist.

Resolution

Add the required template sections and complete each applicable item. Include an ELI5 summary, explicit What Changed and Why sections, a formal Linked Issue entry such as "Fixes #17603" if applicable, AI Disclosure, Review, Agent skill upstream boundary, Notes covering compatibility and performance, and the completed Testing and Checklist items.

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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: 183b5681-db52-4eed-ab33-f311e7f159d5

📥 Commits

Reviewing files that changed from the base of the PR and between b87a6c0 and bf73aa2.

📒 Files selected for processing (36)
  • mobile/src/session/mobile-omp-session-catalog.ts
  • mobile/src/session/mobile-session-option-records.ts
  • mobile/src/session/use-mobile-native-chat-controller.ts
  • mobile/src/session/use-mobile-native-chat-session-option-controller.ts
  • mobile/src/session/use-mobile-native-chat-session-options.test.ts
  • mobile/src/session/use-mobile-native-chat-session-options.ts
  • mobile/src/session/use-mobile-omp-model-discovery.test.ts
  • mobile/src/session/use-mobile-omp-model-discovery.ts
  • src/main/agent-hooks/server-pi-normalization.test.ts
  • src/main/pi/agent-status-extension-omp-model.test.ts
  • src/main/pi/agent-status-extension-source.ts
  • src/main/pi/agent-status-extension-test-harness.ts
  • src/main/pi/agent-status-handler-source.ts
  • src/main/pi/omp-model-command-source.test.ts
  • src/main/pi/omp-model-command-source.ts
  • src/renderer/src/components/native-chat/NativeChatComposer.test.tsx
  • src/renderer/src/components/native-chat/NativeChatComposer.tsx
  • src/renderer/src/components/native-chat/native-chat-pty-session-options.ts
  • src/renderer/src/components/native-chat/native-chat-retire-persisted-model.test.ts
  • src/renderer/src/components/native-chat/native-chat-structured-send-composition-clear.test.tsx
  • src/renderer/src/components/native-chat/omp-model-switch-capability.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-session-options.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-session-options.ts
  • src/renderer/src/store/slices/agent-status-live-entry-builder.ts
  • src/renderer/src/store/slices/agent-status-live-facts.ts
  • src/shared/agent-hook-listener/providers/pi-family-events.ts
  • src/shared/agent-model-probe-spec.ts
  • src/shared/agent-session-option-catalog-omp.test.ts
  • src/shared/agent-session-option-catalog-omp.ts
  • src/shared/agent-session-option-catalog.ts
  • src/shared/agent-status-types.ts
  • src/shared/native-chat-session-option-state.test.ts
  • src/shared/native-chat-session-option-state.ts
  • src/shared/omp-model-list-probe.ts
  • tests/e2e/omp-model-picker.spec.ts
  • tests/tools/omp-model-runtime-smoke.mjs

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

Comment on lines +198 to +200
useEffect(() => {
appliedReportedModelRef.current = null
}, [agent, targetPtyId, terminalTabId])

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Reset reported-model deduplication when the OMP session changes.

OMP can switch sessions in-process without changing agent, targetPtyId, or terminalTabId. If session A reports model A, the user dispatches model B, and session B reports A, this ref still contains A. The report effect then skips the new session report and leaves B displayed.

Reset this ref from the pane's OMP session identity or session-boundary signal, not only from the PTY scope.

@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.

Important

Two OMP-specific correctness issues: a hook-reported model can be cleared from the desktop picker when model discovery settles after the report, and the live-status entry builder can drop the live modelSwitchCommand capability while retaining a stale model. Details inline.

Reviewed changes

  • OMP catalog + probe: new agent-session-option-catalog-omp.ts (empty seed, authoritative discovery, --model launch, /orca-model mid-session) and omp-model-list-probe.ts parsing omp models --json; OMP added to the discovery-only probe specs.
  • Generated status extension: stamps model + model_switch_command: 'orca-model' on every OMP post, tracks the model per session, handles model_select, and registers an orca-model command that calls OMP's setModel.
  • Status plumbing: AgentStatusEntry/Payload.modelSwitchCommand threaded through normalization, the desktop live store, and the mobile host projection.
  • Desktop native chat: reads the hook-reported model from agentStatusByPaneKey[paneKey], reports it to the session-options surface, and gates modelApply.midSession on the advertised capability.
  • Mobile native chat: discovers OMP models over the git.discoverCommitMessageModels RPC and gates mid-session switching on modelSwitchCommand.
  • Tests/tooling: 14 new or updated test files, an e2e picker spec, and a real-SDK smoke script.

ℹ️ Mobile loses the switch capability on title-derived status projections

modelSwitchCommand reaches the client only when the full rich status wins. Three host projection paths rebuild the entry from a fixed field list and omit it: buildTitleOnlyStatus in runtime-mobile-agent-status-projection.ts:44-61, the synthetic done entry in runtime-mobile-session-projection.ts:233-247, and the last-resort entry in runtime-mobile-agent-status-builder.ts:139-157. An OMP pane whose PTY title renews the status (a normal interval, per the existing renewal tests) therefore arrives with modelSwitchCommand === undefined, so mobile-omp-session-catalog.ts:14-17 strips midSession and the picker becomes read-only even though the running extension still supports switching.

These files are untouched by this PR, so treat this as a follow-up rather than a blocker, but it undercuts the stated "enabled only after the host advertises it" behavior on mobile.

Technical details
# Mobile capability dropped on title-derived projections

## Affected sites
- `src/main/runtime/runtime-mobile-agent-status-projection.ts:44-61,82,100` — `buildTitleOnlyStatus` carries no `model`/`modelSwitchCommand`.
- `src/main/runtime/runtime-mobile-session-projection.ts:233-247` — idle-title synthetic `done` copies only `agentType`/`providerSession`.
- `src/main/runtime/runtime-mobile-agent-status-builder.ts:139-157` — identity-only fallback omits both.
- `mobile/src/session/mobile-omp-session-catalog.ts:14-17` — `undefined` strips `midSession`.

## Required outcome
A status entry built on any host projection path must carry the live capability (and ideally the model) when it was present on the evidence it was derived from, or the client needs another capability channel that is not subject to status degradation.

## Open questions for the human
Is the capability intended to be per-status-evidence or per-pane/extension lifetime? The field's own doc (`agent-status-types.ts:107-108`) describes it as a property of the installed extension, which argues for carrying it through minimal statuses.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

},
// Why: with no seed there is nothing to keep; a persisted id the host no longer
// lists is a fatal `--model` at launch, so discovery must be able to retire it.
discoveredModelsAreAuthoritative: true,

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.

Opting OMP into discoveredModelsAreAuthoritative makes untrackRetiredModel() clear the tracked model whenever a discovery list omits it, without checking that the tracked value came from a hook report. A reported selector absent from the (possibly stale) omp models --json result is exactly that case, and the reported-model effect then refuses to re-apply the unchanged report, so the row disappears permanently for that value. The PR's own tests only cover discovery landing before the report.

Technical details
# Reported OMP model cleared by later discovery

## Affected sites
- `src/shared/agent-session-option-catalog-omp.ts:26` — opts OMP into authoritative membership.
- `src/renderer/src/components/native-chat/native-chat-pty-session-options.ts:87-100` — `untrackRetiredModel()` clears the tracked model without checking `record.model.source`.
- `src/renderer/src/components/native-chat/use-native-chat-session-options.ts:220-224` — `appliedReportedModelRef.current === matched` blocks re-applying the same report after the clear.
- `src/renderer/src/components/native-chat/native-chat-session-option-enrichment.ts:99-112` — discovery settles asynchronously and calls `replaceModels` for authoritative catalogs.
- `src/renderer/src/components/native-chat/use-native-chat-session-options.test.ts:108-141` — resolves discovery first, so it never exercises report-then-discovery.

## Sequence
1. Probe pending → `initialModels` undefined → `modelsAreDiscovered = false`; the hook report applies `custom/current` with source `reported`.
2. Probe settles without `custom/current` → `replaceModels` → `untrackRetiredModel` clears the tracked model.
3. The report effect does not re-run (`reportedModel` and `surface` identities unchanged), and the ref guard blocks it even if it did.

## Required outcome
A hook-reported (source `reported`) selector absent from the discovered list must remain the picker's current row and stay selectable, while discovery still governs the *persisted* launch default (`retirePersistedModelMissingFromDiscovery`). Retirement should distinguish a persisted/seeded id from a live reported one.

## Open questions for the human
Should a reported-but-unlisted selector be adoptable as a launch default, or only displayed?

agentType: identity.agentType,
model:
payload.model ?? (existing?.agentType === identity.agentType ? existing.model : undefined),
...(payload.modelSwitchCommand ? { modelSwitchCommand: payload.modelSwitchCommand } : {}),

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.

model falls back to the existing row when a payload omits it, but modelSwitchCommand has no fallback and is dropped. On an in-process OMP session switch the extension deliberately omits the model (and with it the capability) on the new session's first post, so the pane keeps the previous session's model while losing the switch capability — the picker renders read-only and setOption rejects even though the extension still advertises orca-model. If the new session never reports a model, both persist.

Technical details
# modelSwitchCommand dropped while model is retained

## Affected sites
- `src/renderer/src/store/slices/agent-status-live-entry-builder.ts:233-235` — asymmetric fallback for `model` vs `modelSwitchCommand`.
- `src/renderer/src/store/slices/agent-status-live-reducer.ts:88` — replaces the whole pane entry, so the dropped field does not merge back.
- `src/main/pi/agent-status-extension-source.ts:98-104,85-87` — `trackModelSession` clears `modelMetadata`, so a model-omitting post is intentional.
- `src/renderer/src/components/native-chat/use-native-chat-session-options.ts:85-87` — capability false strips `midSession` (`native-chat-pty-session-options.ts:66-69`).

## Required outcome
`modelSwitchCommand` is a property of the installed extension (process-global, see `agent-status-types.ts:107-108`), not of a single post, so an OMP pane whose prior row carried it should keep it when a same-agent payload omits it — mirroring the `model` fallback. Consider whether the retained `model` is also correct in this case.

@nwparker
nwparker force-pushed the nwparker/omp-model-options-review branch 2 times, most recently from d2a159a to 70c7336 Compare September 19, 2026 08:15

@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 critical issues — one formatting nit inline.

Reviewed changes

Reviewed the delta since the prior synchronized revision (d2a159a): a rebase onto newer main plus four test-only commits.

  • Rebase reconciliation: folded main's session_file stamp (#20615) and session-owner handler (#20611) into the generated status-extension source; the only generated-source edits are trailing commas and a merged duplicate ui? type.
  • OMP session-switch test: refactored to one shared session manager whose id mutates, matching OMP's in-process session switching.
  • Model status proof: added session_file to the expected hook payloads.
  • Mobile discovery test: replaced the ReactTestRenderer import with a local TestRenderer type and renderer! with renderer?..

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@@ -42,10 +45,12 @@ export function getPiAgentStatusExtensionSource(kind: PiAgentKind = 'pi'): strin
' const sessionId = sessionManager?.getSessionId?.()',
' const sessionFile = sessionManager?.getSessionFile?.()',
" runtimeOmpSessionMetadata = typeof sessionId === 'string' && sessionId && typeof sessionFile === 'string' && sessionFile ? { session_id: sessionId, session_file: sessionFile } : {}",
' trackModelSession(runtimeOmpSessionMetadata.session_id)',
' updateModelMetadata(ctx)',

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.

oxfmt --check flags trailing whitespace after the comma on this line and on line 78 (trackModelSession(sessionMetadata.session_id)); both spaces sit outside the string literals, so generated output is unaffected. pnpm format strips them.

@nwparker

Copy link
Copy Markdown
Contributor Author

Current CI recheck: the implementation's runtime smoke, focused tests, package, typecheck, cross-platform runtime, and E2E jobs pass. Required verification remains red only on current-main baseline failures: anti-slop flags shapes in src/renderer/src/components/browser-pane/ClientHostedBrowserPagePane.markup.test.tsx, and test shards fail the existing pane-title scan-budget assertion (2081 vs <1740). I am leaving this PR open and unmerged until required checks are green; no gate is being bypassed.

@nwparker
nwparker force-pushed the nwparker/omp-model-options-review branch from 3b9c71f to c2e68de Compare September 19, 2026 11:00
@nwparker

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (dcee2c5df3b) and force-updated to c2e68de3a32.

Fresh verification on the rebased branch:

  • Desktop/shared focused suite — 84 passed
  • Mobile focused suite — 28 passed
  • pnpm tc:node — passed
  • pnpm tc:web — passed
  • pnpm --dir mobile run typecheck — passed
  • pnpm run check:code-quality:changed — 0 findings across 35 changed files
  • Actual OMP SDK smoke using /Users/nwparker/projects/oh-my-pi — switched anthropic/claude-sonnet-4-5 to anthropic/claude-sonnet-4-6, 0 model turns/messages, and captured the expected model_select hook
  • Hidden Electron E2E — 1 passed: model picker dispatched orca-model through a real PTY and adopted the host report

The existing ELI5, screenshots, and no-startup-status trade-off explanation remain in the PR. Fresh GitHub checks are now running for the rebased head; I will leave it unmerged until required checks are green.

@nwparker

Copy link
Copy Markdown
Contributor Author

The rebased GitHub workflows are now green, including PR Checks (all test shards, static analysis, typecheck, packaging on macOS/Linux/Windows, E2E, relay integration), runtime verification on macOS/Linux/Windows, and Mobile Checks/RPC recording. The only remaining non-green gate is Pullfrog, still in_progress; no code check has failed. I’m leaving the PR unmerged until Pullfrog completes.

@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 critical issues — one rebase artifact inline.

Reviewed changes

Reviewed the delta since the prior pullfrog review (70c733681a): a rebase onto newer main plus the reconciliation it required. git range-diff pairs 12 of the 13 PR commits as byte-identical patches; the only content change is dropping the PR's now-duplicate OMP probe file.

  • Deferred OMP probe parsing to main: #20624 now ships an identical src/shared/omp-model-list-probe.ts, so the PR stops adding its own copy and imports the shared one. No behavioral change.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

models: [],
defaultModelId: 'grok-4.6'
},
omp: {

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.

main's #20624 now registers OMP in COMMIT_MESSAGE_AGENT_SPECS, so getCommitMessageAgentSpec('omp') returns before this fallback and the added omp entry is unreachable — getAgentModelProbeSpec's OMP branch below already derives the discovery spec from the generation spec. Dropping the block removes a second, silent source of truth for OMP discovery.

@nwparker

Copy link
Copy Markdown
Contributor Author

Pullfrog has completed successfully. GitHub now reports this rebased PR CLEAN; all required checks are green. It is ready for review/merge.

@nwparker
nwparker merged commit ae9c06c into main Sep 19, 2026
41 checks passed
@nwparker
nwparker deleted the nwparker/omp-model-options-review branch September 19, 2026 12:11
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.

1 participant