Compare commits

...

2 Commits

Author SHA1 Message Date
Kit Langton
4ed3336b23 Merge branch 'dev' into fix/interrupt-double-sound 2026-03-10 20:26:56 -04:00
Kit Langton
02a7b0637d fix(app): suppress idle sound after interrupt 2026-03-10 20:25:58 -04:00

View File

@@ -132,6 +132,28 @@ export const { use: useNotification, provider: NotificationProvider } = createSi
const [index, setIndex] = createStore<NotificationIndex>(buildNotificationIndex(store.list))
const meta = { pruned: false, disposed: false }
const idleSuppressMs = 5000
const idleSuppressedUntilBySession = new Map<string, number>()
const idleSuppressKey = (directory: string, sessionID?: string) => {
if (!sessionID) return
return `${directory}:${sessionID}`
}
const markIdleSuppressed = (directory: string, sessionID?: string) => {
const key = idleSuppressKey(directory, sessionID)
if (!key) return
idleSuppressedUntilBySession.set(key, Date.now() + idleSuppressMs)
}
const shouldSuppressIdle = (directory: string, sessionID?: string) => {
const key = idleSuppressKey(directory, sessionID)
if (!key) return false
const until = idleSuppressedUntilBySession.get(key)
if (until === undefined) return false
idleSuppressedUntilBySession.delete(key)
return until > Date.now()
}
const updateUnseen = (scope: "session" | "project", key: string, unseen: Notification[]) => {
setIndex(scope, "unseen", key, unseen)
@@ -290,12 +312,15 @@ export const { use: useNotification, provider: NotificationProvider } = createSi
if (event.type !== "session.idle" && event.type !== "session.error") return
const directory = e.name
const time = Date.now()
if (event.type === "session.error") {
markIdleSuppressed(directory, event.properties.sessionID)
}
if (event.type === "session.idle") {
handleSessionIdle(directory, event, time)
if (shouldSuppressIdle(directory, event.properties.sessionID)) return
handleSessionIdle(directory, event, Date.now())
return
}
handleSessionError(directory, event, time)
handleSessionError(directory, event, Date.now())
})
onCleanup(() => {
meta.disposed = true