refactor: unify model selection with the TUI

Align the manager's model selection with the OpenCode TUI: one
model.json-backed preference store, one provider catalog, one ordering
and default-ownership rule, and one set of availability, ref-formatting
and variant helpers shared across chat, schedules, agents and the goal
auditor.

- Add a shared TUI-compatible model-preference module and make the
  backend model.json store match its format.
- Consolidate the frontend provider catalog, availability check, model
  ref formatter and variant persistence into single owners.
- Drive chat, schedule, agent and goal-auditor model lists from a shared
  useModelSections hook and buildModelSections, following TUI ordering.
- Extract a shared ModelCombobox with a taller list, and list models the
  TUI way in ModelQuickSelect.
- Add a shared isRecord util and model-selection comparison helpers.
This commit is contained in:
Chris Scott committed 2026-10-06 20:44:27 -04:00
1 parent 3d143568c1
commit 65b72e55ae
82 files changed
+4418 -2624

No files matched your search

+25 -1
View File
@@ -90,6 +90,24 @@ describe('useRefreshMessage', () => {
expect(mocks.switchSessionAgent).not.toHaveBeenCalled()
})
it('preserves the session variant when resending with the same full ref', async () => {
setSession(sessionInfo({
model: { providerID: 'anthropic', id: 'claude-sonnet-4', variant: 'high' },
}))
const { result } = renderRefresh()
await result.current.mutateAsync({
assistantMessageID: 'assistant-1',
userMessageContent: 'edited text',
model: 'anthropic/claude-sonnet-4#high',
agent: 'build',
})
expect(mocks.switchSessionModel).not.toHaveBeenCalled()
expect(mocks.switchSessionAgent).not.toHaveBeenCalled()
})
it('switches the model before resending when the edited message model changed', async () => {
setSession(sessionInfo())
@@ -125,6 +143,12 @@ describe('useRefreshMessage', () => {
})
expect(mocks.switchSessionAgent).toHaveBeenCalledWith('test-session', 'plan')
expect(mocks.switchSessionModel).not.toHaveBeenCalled()
expect(mocks.switchSessionModel).toHaveBeenCalledWith('test-session', {
providerID: 'anthropic',
id: 'claude-sonnet-4',
})
expect(mocks.switchSessionAgent.mock.invocationCallOrder[0]).toBeLessThan(
mocks.switchSessionModel.mock.invocationCallOrder[0],
)
})
})