diff options
| author | Adam <[email protected]> | 2026-01-21 05:15:13 -0600 |
|---|---|---|
| committer | Adam <[email protected]> | 2026-01-21 05:15:19 -0600 |
| commit | 64c80f1b512b5bf03a9132d39db71decfab10dc3 (patch) | |
| tree | 6c2087aed830fc38322cf772a4af76b3022516f5 /packages/app/src | |
| parent | 7b8fad620257c7030d3f783b2d623cc5a59c4727 (diff) | |
| download | opencode-64c80f1b512b5bf03a9132d39db71decfab10dc3.tar.gz opencode-64c80f1b512b5bf03a9132d39db71decfab10dc3.zip | |
fix(app): don't show notification on session if active
Diffstat (limited to 'packages/app/src')
| -rw-r--r-- | packages/app/src/context/notification.tsx | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/packages/app/src/context/notification.tsx b/packages/app/src/context/notification.tsx index 976f6e5c0..58e7fbf83 100644 --- a/packages/app/src/context/notification.tsx +++ b/packages/app/src/context/notification.tsx @@ -1,5 +1,6 @@ import { createStore } from "solid-js/store" import { createEffect, onCleanup } from "solid-js" +import { useParams } from "@solidjs/router" import { createSimpleContext } from "@opencode-ai/ui/context" import { useGlobalSDK } from "./global-sdk" import { useGlobalSync } from "./global-sync" @@ -7,7 +8,7 @@ import { usePlatform } from "@/context/platform" import { useLanguage } from "@/context/language" import { useSettings } from "@/context/settings" import { Binary } from "@opencode-ai/util/binary" -import { base64Encode } from "@opencode-ai/util/encode" +import { base64Decode, base64Encode } from "@opencode-ai/util/encode" import { EventSessionError } from "@opencode-ai/sdk/v2" import { Persist, persisted } from "@/utils/persist" import { playSound, soundSrc } from "@/utils/sound" @@ -44,6 +45,7 @@ function pruneNotifications(list: Notification[]) { export const { use: useNotification, provider: NotificationProvider } = createSimpleContext({ name: "Notification", init: () => { + const params = useParams() const globalSDK = useGlobalSDK() const globalSync = useGlobalSync() const platform = usePlatform() @@ -73,10 +75,15 @@ export const { use: useNotification, provider: NotificationProvider } = createSi const unsub = globalSDK.event.listen((e) => { const directory = e.name const event = e.details - const base = { - directory, - time: Date.now(), - viewed: false, + const time = Date.now() + const activeDirectory = params.dir ? base64Decode(params.dir) : undefined + const activeSession = params.id + const viewed = (sessionID?: string) => { + if (!activeDirectory) return false + if (!activeSession) return false + if (!sessionID) return false + if (directory !== activeDirectory) return false + return sessionID === activeSession } switch (event.type) { case "session.idle": { @@ -89,7 +96,9 @@ export const { use: useNotification, provider: NotificationProvider } = createSi playSound(soundSrc(settings.sounds.agent())) append({ - ...base, + directory, + time, + viewed: viewed(sessionID), type: "turn-complete", session: sessionID, }) @@ -115,7 +124,9 @@ export const { use: useNotification, provider: NotificationProvider } = createSi const error = "error" in event.properties ? event.properties.error : undefined append({ - ...base, + directory, + time, + viewed: viewed(sessionID), type: "error", session: sessionID ?? "global", error, |
