Repository navigation
feat(omp): discover and switch native-chat models on desktop and mobile - #20612
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between d2a159a24436eb9be283ddd0efcede3ffde8f775 and 3b9c71ff8a6c6fbdfde9b76b3de1bbb654eadf1f. 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe change adds OMP model discovery and an OMP session-option catalog. It adds the Priority: ➖ Normal 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation 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 ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 183b5681-db52-4eed-ab33-f311e7f159d5
📒 Files selected for processing (36)
mobile/src/session/mobile-omp-session-catalog.tsmobile/src/session/mobile-session-option-records.tsmobile/src/session/use-mobile-native-chat-controller.tsmobile/src/session/use-mobile-native-chat-session-option-controller.tsmobile/src/session/use-mobile-native-chat-session-options.test.tsmobile/src/session/use-mobile-native-chat-session-options.tsmobile/src/session/use-mobile-omp-model-discovery.test.tsmobile/src/session/use-mobile-omp-model-discovery.tssrc/main/agent-hooks/server-pi-normalization.test.tssrc/main/pi/agent-status-extension-omp-model.test.tssrc/main/pi/agent-status-extension-source.tssrc/main/pi/agent-status-extension-test-harness.tssrc/main/pi/agent-status-handler-source.tssrc/main/pi/omp-model-command-source.test.tssrc/main/pi/omp-model-command-source.tssrc/renderer/src/components/native-chat/NativeChatComposer.test.tsxsrc/renderer/src/components/native-chat/NativeChatComposer.tsxsrc/renderer/src/components/native-chat/native-chat-pty-session-options.tssrc/renderer/src/components/native-chat/native-chat-retire-persisted-model.test.tssrc/renderer/src/components/native-chat/native-chat-structured-send-composition-clear.test.tsxsrc/renderer/src/components/native-chat/omp-model-switch-capability.test.tssrc/renderer/src/components/native-chat/use-native-chat-session-options.test.tssrc/renderer/src/components/native-chat/use-native-chat-session-options.tssrc/renderer/src/store/slices/agent-status-live-entry-builder.tssrc/renderer/src/store/slices/agent-status-live-facts.tssrc/shared/agent-hook-listener/providers/pi-family-events.tssrc/shared/agent-model-probe-spec.tssrc/shared/agent-session-option-catalog-omp.test.tssrc/shared/agent-session-option-catalog-omp.tssrc/shared/agent-session-option-catalog.tssrc/shared/agent-status-types.tssrc/shared/native-chat-session-option-state.test.tssrc/shared/native-chat-session-option-state.tssrc/shared/omp-model-list-probe.tstests/e2e/omp-model-picker.spec.tstests/tools/omp-model-runtime-smoke.mjs
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
| useEffect(() => { | ||
| appliedReportedModelRef.current = null | ||
| }, [agent, targetPtyId, terminalTabId]) |
There was a problem hiding this comment.
🎯 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.
There was a problem hiding this comment.
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,--modellaunch,/orca-modelmid-session) andomp-model-list-probe.tsparsingomp 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, handlesmodel_select, and registers anorca-modelcommand that calls OMP'ssetModel. - Status plumbing:
AgentStatusEntry/Payload.modelSwitchCommandthreaded 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 gatesmodelApply.midSessionon the advertised capability. - Mobile native chat: discovers OMP models over the
git.discoverCommitMessageModelsRPC and gates mid-session switching onmodelSwitchCommand. - 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.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, |
There was a problem hiding this comment.
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 } : {}), |
There was a problem hiding this comment.
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.d2a159a to
70c7336
Compare
There was a problem hiding this comment.
ℹ️ 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'ssession_filestamp (#20615) and session-owner handler (#20611) into the generated status-extension source; the only generated-source edits are trailing commas and a merged duplicateui?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_fileto the expected hook payloads. - Mobile discovery test: replaced the
ReactTestRendererimport with a localTestRenderertype andrenderer!withrenderer?..
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)', | |||
There was a problem hiding this comment.
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.
70c7336 to
3b9c71f
Compare
|
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 |
Report the running OMP provider/model and discover available choices on the execution host for desktop and mobile. Register an extension command to switch through the OMP API because its TUI does not accept /model args. Advertise that command in status so older hosts remain read-only. Addresses the OMP portion of #17603; Pi chat enablement remains separate. Model reporting begins on lifecycle activity; no startup status is invented. Co-authored-by: SudoAI-DEV <[email protected]>
3b9c71f to
c2e68de
Compare
|
Rebased onto current Fresh verification on the rebased branch:
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. |
|
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 |
There was a problem hiding this comment.
ℹ️ 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:#20624now ships an identicalsrc/shared/omp-model-list-probe.ts, so the PR stops adding its own copy and imports the shared one. No behavioral change.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| models: [], | ||
| defaultModelId: 'grok-4.6' | ||
| }, | ||
| omp: { |
There was a problem hiding this comment.
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.
|
Pullfrog has completed successfully. GitHub now reports this rebased PR |

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-6on 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.