summaryrefslogtreecommitdiffhomepage
path: root/packages/desktop/src/context
diff options
context:
space:
mode:
authorAdam <[email protected]>2025-12-15 10:13:29 -0600
committerAdam <[email protected]>2025-12-15 10:22:06 -0600
commit8ce0966987a0de46d64307c02f729a290f2f3cf3 (patch)
tree0491fa32dbf6ea602004a712ba88ddef7da10ec4 /packages/desktop/src/context
parent8cb26b606645e2d71826dc22acaf1f26a707f0c9 (diff)
downloadopencode-8ce0966987a0de46d64307c02f729a290f2f3cf3.tar.gz
opencode-8ce0966987a0de46d64307c02f729a290f2f3cf3.zip
wip(desktop): progress
Diffstat (limited to 'packages/desktop/src/context')
-rw-r--r--packages/desktop/src/context/global-sync.tsx4
-rw-r--r--packages/desktop/src/context/notification.tsx21
2 files changed, 19 insertions, 6 deletions
diff --git a/packages/desktop/src/context/global-sync.tsx b/packages/desktop/src/context/global-sync.tsx
index bebce64d7..77640c090 100644
--- a/packages/desktop/src/context/global-sync.tsx
+++ b/packages/desktop/src/context/global-sync.tsx
@@ -100,7 +100,7 @@ export const { use: useGlobalSync, provider: GlobalSyncProvider } = createSimple
async function loadSessions(directory: string) {
globalSDK.client.session.list({ directory }).then((x) => {
- const oneHourAgo = Date.now() - 60 * 60 * 1000
+ const fourHoursAgo = Date.now() - 4 * 60 * 60 * 1000
const nonArchived = (x.data ?? [])
.slice()
.filter((s) => !s.time.archived)
@@ -109,7 +109,7 @@ export const { use: useGlobalSync, provider: GlobalSyncProvider } = createSimple
const sessions = nonArchived.filter((s, i) => {
if (i < 5) return true
const updated = new Date(s.time.updated).getTime()
- return updated > oneHourAgo
+ return updated > fourHoursAgo
})
const [, setStore] = child(directory)
setStore("session", sessions)
diff --git a/packages/desktop/src/context/notification.tsx b/packages/desktop/src/context/notification.tsx
index 705551944..9843066ea 100644
--- a/packages/desktop/src/context/notification.tsx
+++ b/packages/desktop/src/context/notification.tsx
@@ -2,6 +2,8 @@ import { createStore } from "solid-js/store"
import { createSimpleContext } from "@opencode-ai/ui/context"
import { makePersisted } from "@solid-primitives/storage"
import { useGlobalSDK } from "./global-sdk"
+import { useGlobalSync } from "./global-sync"
+import { Binary } from "@opencode-ai/util/binary"
import { EventSessionError } from "@opencode-ai/sdk/v2"
import { makeAudioPlayer } from "@solid-primitives/audio"
import idleSound from "@opencode-ai/ui/audio/staplebops-01.aac"
@@ -32,6 +34,7 @@ export const { use: useNotification, provider: NotificationProvider } = createSi
const idlePlayer = makeAudioPlayer(idleSound)
const errorPlayer = makeAudioPlayer(errorSound)
const globalSDK = useGlobalSDK()
+ const globalSync = useGlobalSync()
const [store, setStore] = makePersisted(
createStore({
@@ -57,22 +60,32 @@ export const { use: useNotification, provider: NotificationProvider } = createSi
}
switch (event.type) {
case "session.idle": {
+ const sessionID = event.properties.sessionID
+ const [syncStore] = globalSync.child(directory)
+ const match = Binary.search(syncStore.session, sessionID, (s) => s.id)
+ const isChild = match.found && syncStore.session[match.index].parentID
+ if (isChild) break
idlePlayer.play()
- const session = event.properties.sessionID
setStore("list", store.list.length, {
...base,
type: "turn-complete",
- session,
+ session: sessionID,
})
break
}
case "session.error": {
+ const sessionID = event.properties.sessionID
+ if (sessionID) {
+ const [syncStore] = globalSync.child(directory)
+ const match = Binary.search(syncStore.session, sessionID, (s) => s.id)
+ const isChild = match.found && syncStore.session[match.index].parentID
+ if (isChild) break
+ }
errorPlayer.play()
- const session = event.properties.sessionID ?? "global"
setStore("list", store.list.length, {
...base,
type: "error",
- session,
+ session: sessionID ?? "global",
error: "error" in event.properties ? event.properties.error : undefined,
})
break