mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
Refactor task list display and enhance model selection with provider validation (#125)
This commit is contained in:
1 parent
b42f7b5010
commit
cb21e66339
9 files changed
+145
-204
No files matched your search
@@ -1,6 +1,9 @@
|
||||
import { useEffect } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useConfig } from './useOpenCode'
|
||||
import { useOpenCodeClient } from './useOpenCode'
|
||||
import { useModelStore, type ModelSelection } from '@/stores/modelStore'
|
||||
import { getProviders } from '@/api/providers'
|
||||
|
||||
interface UseModelSelectionResult {
|
||||
model: ModelSelection | null
|
||||
@@ -14,11 +17,26 @@ export function useModelSelection(
|
||||
directory?: string
|
||||
): UseModelSelectionResult {
|
||||
const { data: config } = useConfig(opcodeUrl, directory)
|
||||
const { model, recentModels, setModel, syncFromConfig, getModelString } = useModelStore()
|
||||
const client = useOpenCodeClient(opcodeUrl, directory)
|
||||
|
||||
const { data: providersData } = useQuery({
|
||||
queryKey: ['opencode', 'providers', opcodeUrl, directory],
|
||||
queryFn: () => getProviders(),
|
||||
enabled: !!client,
|
||||
staleTime: 30000,
|
||||
})
|
||||
|
||||
const {
|
||||
model,
|
||||
recentModels,
|
||||
setModel,
|
||||
validateAndSyncModel,
|
||||
getModelString
|
||||
} = useModelStore()
|
||||
|
||||
useEffect(() => {
|
||||
syncFromConfig(config?.model)
|
||||
}, [config?.model, syncFromConfig])
|
||||
validateAndSyncModel(config?.model, providersData?.providers)
|
||||
}, [config?.model, providersData, validateAndSyncModel])
|
||||
|
||||
return {
|
||||
model,
|
||||
|
||||
Reference in new issue
Block a user