mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
feat(frontend): add mobile composer tools menu and base branch select
This commit is contained in:
1 parent
fac23b1f1a
commit
4a2e695ec2
21 files changed
+819
-158
No files matched your search
@@ -23,6 +23,16 @@ const isSameModel = (left: ModelSelection, right: ModelSelection) => (
|
||||
left.providerID === right.providerID && left.modelID === right.modelID
|
||||
)
|
||||
|
||||
export function useOpenCodeModelState(directory?: string, enabled = true) {
|
||||
return useQuery({
|
||||
queryKey: [...modelStateQueryKey, directory],
|
||||
queryFn: () => getOpenCodeModelState(),
|
||||
staleTime: 30000,
|
||||
placeholderData: keepPreviousData,
|
||||
enabled,
|
||||
})
|
||||
}
|
||||
|
||||
export function useModelSelection(directory?: string): UseModelSelectionResult {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
@@ -37,12 +47,7 @@ export function useModelSelection(directory?: string): UseModelSelectionResult {
|
||||
getModelString
|
||||
} = useModelStore()
|
||||
|
||||
const { data: modelState, isLoading: isModelStateLoading } = useQuery({
|
||||
queryKey: [...modelStateQueryKey, directory],
|
||||
queryFn: () => getOpenCodeModelState(),
|
||||
staleTime: 30000,
|
||||
placeholderData: keepPreviousData,
|
||||
})
|
||||
const { data: modelState, isLoading: isModelStateLoading } = useOpenCodeModelState(directory)
|
||||
|
||||
const { data: configModelString, isLoading: isConfigModelLoading } = useQuery({
|
||||
queryKey: ['opencode', 'config', 'model', directory],
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { useSessionPermissionMode, useSetSessionPermissionMode } from '@/hooks/useSessionPermissionMode'
|
||||
|
||||
export function usePermissionModeToggle(sessionID: string, directory: string) {
|
||||
const { data, isError } = useSessionPermissionMode(sessionID)
|
||||
const setMode = useSetSessionPermissionMode(sessionID)
|
||||
|
||||
const loaded = data !== undefined
|
||||
const isAuto = data?.mode === 'auto'
|
||||
const lockedReason = data?.lockedReason ?? null
|
||||
const disabled = !loaded || lockedReason !== null || setMode.isPending
|
||||
|
||||
const label = !loaded
|
||||
? isError
|
||||
? 'Permissions: unavailable'
|
||||
: 'Permissions: loading'
|
||||
: lockedReason === 'child'
|
||||
? 'Inherited from parent session'
|
||||
: lockedReason === 'schedule'
|
||||
? "Scheduled runs use the schedule's permission configuration"
|
||||
: isAuto
|
||||
? 'Permissions: accept everything'
|
||||
: 'Permissions: ask every time'
|
||||
|
||||
const toggle = () => {
|
||||
if (disabled) return
|
||||
setMode.mutate({ directory, mode: isAuto ? 'ask' : 'auto' })
|
||||
}
|
||||
|
||||
return { isAuto, disabled, label, toggle }
|
||||
}
|
||||
Reference in new issue
Block a user