mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
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:
1 parent
3d143568c1
commit
65b72e55ae
82 files changed
+4418
-2624
No files matched your search
@@ -185,11 +185,11 @@ describe('PromptInput command submission', () => {
|
||||
model: { providerID: 'anthropic', modelID: 'claude-sonnet-4' },
|
||||
modelString: 'anthropic/claude-sonnet-4',
|
||||
setModel: vi.fn(),
|
||||
setActiveModel: vi.fn(),
|
||||
setActiveAgent: vi.fn(),
|
||||
recentModels: [],
|
||||
favoriteModels: [],
|
||||
toggleFavorite: vi.fn(),
|
||||
isModelStateLoading: false,
|
||||
isModelReady: true,
|
||||
})
|
||||
mocks.useVariants.mockReturnValue({ hasVariants: false, currentVariant: null, cycleVariant: mocks.cycleVariant })
|
||||
mocks.useSessionAgent.mockReturnValue({ agent: 'build' })
|
||||
@@ -233,6 +233,28 @@ describe('PromptInput command submission', () => {
|
||||
other.remove()
|
||||
})
|
||||
|
||||
it('disables submit and does not run a command while the model is not ready', async () => {
|
||||
mocks.useModelSelection.mockReturnValue({
|
||||
model: null,
|
||||
modelString: null,
|
||||
setModel: vi.fn(),
|
||||
setActiveAgent: vi.fn(),
|
||||
recentModels: [],
|
||||
favoriteModels: [],
|
||||
toggleFavorite: vi.fn(),
|
||||
isModelReady: false,
|
||||
})
|
||||
renderComponent()
|
||||
|
||||
const input = await screen.findByPlaceholderText('Send a message...')
|
||||
fireEvent.change(input, { target: { value: '/review' } })
|
||||
|
||||
const sendButton = screen.getByTitle('Send')
|
||||
expect(sendButton).toBeDisabled()
|
||||
fireEvent.click(sendButton)
|
||||
expect(mocks.runCommand).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('sends parsed command attachments and offsets to runCommand without injecting the selected agent', async () => {
|
||||
const { container } = renderComponent()
|
||||
|
||||
|
||||
Reference in new issue
Block a user