Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions packages/app/src/components/settings-general.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,16 @@ export const SettingsGeneral: Component = () => {

const linux = createMemo(() => platform.platform === "desktop" && platform.os === "linux")
const dir = createMemo(() => decode64(params.dir))
const serverSync = useServerSync()
const serverSdk = useServerSDK()
const globalAutoAccept = createMemo(() => {
const perm = (serverSync().data.config as any)?.permission
if (perm === "allow") return true
if (perm && typeof perm === "object" && perm["*"] === "allow") return true
return false
})
const accepting = createMemo(() => {
if (globalAutoAccept()) return true
const value = dir()
if (!value) return false
if (!params.id) return permission.isAutoAcceptingDirectory(value)
Expand Down Expand Up @@ -123,9 +132,6 @@ export const SettingsGeneral: Component = () => {

const themeOptions = createMemo<ThemeOption[]>(() => theme.ids().map((id) => ({ id, name: theme.name(id) })))

const serverSync = useServerSync()
const serverSdk = useServerSDK()

const [shells] = createResource(
async () => {
const sdk = serverSdk()
Expand Down Expand Up @@ -321,7 +327,7 @@ export const SettingsGeneral: Component = () => {
description={language.t("toast.permissions.autoaccept.on.description")}
>
<div data-action="settings-auto-accept-permissions">
<Switch checked={accepting()} disabled={!dir()} onChange={toggleAccept} />
<Switch checked={accepting()} disabled={!dir() || globalAutoAccept()} onChange={toggleAccept} />
</div>
</SettingsRow>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export type { ShellOption, ShellSelectOption } from "./general-controller-behavi
export function createPermissionScopeController(sessionID: Accessor<string | undefined>) {
const permission = usePermission()
const serverSync = useServerSync()
const globalAutoAccept = createMemo(() => {
const perm = (serverSync().data.config as any)?.permission
if (perm === "allow") return true
if (perm && typeof perm === "object" && perm["*"] === "allow") return true
return false
})
const directory = createMemo(() => {
const id = sessionID()
if (!id) return undefined
Expand All @@ -33,12 +39,13 @@ export function createPermissionScopeController(sessionID: Accessor<string | und

return {
accepting: createMemo(() => {
if (globalAutoAccept()) return true
const id = sessionID()
const dir = directory()
if (!id || !dir) return false
return permission.isAutoAccepting(id, dir)
}),
enabled: createMemo(() => !!directory()),
enabled: createMemo(() => !globalAutoAccept() && !!directory()),
set: (checked: boolean) => {
const id = sessionID()
const dir = directory()
Expand Down
Loading