Files
opencode-manager/frontend/src/hooks/useProviders.ts
T
Chris Scott 65b72e55ae 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.
2026-10-06 20:44:27 -04:00

17 lines
478 B
TypeScript

import { keepPreviousData, useQuery } from '@tanstack/react-query'
import { getProviders } from '@/api/providers'
interface UseProvidersOptions {
enabled?: boolean
}
export function useProviders(directory?: string, options: UseProvidersOptions = {}) {
return useQuery({
queryKey: ['opencode', 'providers', directory],
queryFn: () => getProviders(directory),
enabled: options.enabled ?? true,
staleTime: 30000,
placeholderData: keepPreviousData,
})
}