mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +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
@@ -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