diff options
| author | Adam <[email protected]> | 2025-12-27 20:40:25 -0600 |
|---|---|---|
| committer | Adam <[email protected]> | 2025-12-27 20:40:25 -0600 |
| commit | 1b5bf32ce560f44dd558f3951121c3f4b0560e85 (patch) | |
| tree | 14a0f32dacd9deaf6bdd57bf5ccf03d6a9b8747e /packages/app/src | |
| parent | 2e972b3fdc4b7f3ccb2224f693391a8f11572c3c (diff) | |
| download | opencode-1b5bf32ce560f44dd558f3951121c3f4b0560e85.tar.gz opencode-1b5bf32ce560f44dd558f3951121c3f4b0560e85.zip | |
chore: permissions ux
Diffstat (limited to 'packages/app/src')
| -rw-r--r-- | packages/app/src/pages/layout.tsx | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/packages/app/src/pages/layout.tsx b/packages/app/src/pages/layout.tsx index bd368bb6c..0b4e040b7 100644 --- a/packages/app/src/pages/layout.tsx +++ b/packages/app/src/pages/layout.tsx @@ -41,7 +41,7 @@ import { } from "@thisbeyond/solid-dnd" import type { DragEvent } from "@thisbeyond/solid-dnd" import { useProviders } from "@/hooks/use-providers" -import { showToast, Toast } from "@opencode-ai/ui/toast" +import { showToast, Toast, toaster } from "@opencode-ai/ui/toast" import { useGlobalSDK } from "@/context/global-sdk" import { useNotification } from "@/context/notification" import { Binary } from "@opencode-ai/util/binary" @@ -118,13 +118,15 @@ export default function Layout(props: ParentProps) { }) onMount(() => { - const seenPermissions = new Set<string>() + const seenSessions = new Set<string>() + const toastBySession = new Map<string, number>() const unsub = globalSDK.event.listen((e) => { if (e.details?.type !== "permission.updated") return const directory = e.name const permission = e.details.properties - if (seenPermissions.has(permission.id)) return - seenPermissions.add(permission.id) + const sessionKey = `${directory}:${permission.sessionID}` + if (seenSessions.has(sessionKey)) return + seenSessions.add(sessionKey) const currentDir = params.dir ? base64Decode(params.dir) : undefined const currentSession = params.id if (directory === currentDir && permission.sessionID === currentSession) return @@ -133,7 +135,7 @@ export default function Layout(props: ParentProps) { if (directory === currentDir && session?.parentID === currentSession) return const sessionTitle = session?.title ?? "New session" const projectName = getFilename(directory) - showToast({ + const toastId = showToast({ persistent: true, icon: "checklist", title: "Permission required", @@ -144,7 +146,6 @@ export default function Layout(props: ParentProps) { onClick: () => { navigate(`/${base64Encode(directory)}/session/${permission.sessionID}`) }, - dismissAfter: true, }, { label: "Dismiss", @@ -152,8 +153,33 @@ export default function Layout(props: ParentProps) { }, ], }) + toastBySession.set(sessionKey, toastId) }) onCleanup(unsub) + + createEffect(() => { + const currentDir = params.dir ? base64Decode(params.dir) : undefined + const currentSession = params.id + if (!currentDir || !currentSession) return + const sessionKey = `${currentDir}:${currentSession}` + const toastId = toastBySession.get(sessionKey) + if (toastId !== undefined) { + toaster.dismiss(toastId) + toastBySession.delete(sessionKey) + seenSessions.delete(sessionKey) + } + const [store] = globalSync.child(currentDir) + const childSessions = store.session.filter((s) => s.parentID === currentSession) + for (const child of childSessions) { + const childKey = `${currentDir}:${child.id}` + const childToastId = toastBySession.get(childKey) + if (childToastId !== undefined) { + toaster.dismiss(childToastId) + toastBySession.delete(childKey) + seenSessions.delete(childKey) + } + } + }) }) function sortSessions(a: Session, b: Session) { |
