summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--packages/app/src/context/notification.tsx25
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,