diff options
Diffstat (limited to 'packages/app/src/context')
| -rw-r--r-- | packages/app/src/context/permission.tsx | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/packages/app/src/context/permission.tsx b/packages/app/src/context/permission.tsx index d82a8392c..a0ad1ee05 100644 --- a/packages/app/src/context/permission.tsx +++ b/packages/app/src/context/permission.tsx @@ -1,9 +1,11 @@ -import { onCleanup } from "solid-js" +import { createMemo, onCleanup } from "solid-js" import { createStore } from "solid-js/store" import { createSimpleContext } from "@opencode-ai/ui/context" import type { Permission } from "@opencode-ai/sdk/v2/client" import { persisted } from "@/utils/persist" import { useGlobalSDK } from "@/context/global-sdk" +import { useGlobalSync } from "./global-sync" +import { useParams } from "@solidjs/router" type PermissionRespondFn = (input: { sessionID: string @@ -21,7 +23,16 @@ function shouldAutoAccept(perm: Permission) { export const { use: usePermission, provider: PermissionProvider } = createSimpleContext({ name: "Permission", init: () => { + const params = useParams() const globalSDK = useGlobalSDK() + const globalSync = useGlobalSync() + + const permissionsEnabled = createMemo(() => { + if (!params.dir) return false + const [store] = globalSync.child(params.dir) + return store.config.permission !== undefined + }) + const [store, setStore, _, ready] = persisted( "permission.v3", createStore({ @@ -106,6 +117,7 @@ export const { use: usePermission, provider: PermissionProvider } = createSimple disableAutoAccept(sessionID: string) { disable(sessionID) }, + permissionsEnabled, } }, }) |
