MCPcopy
hub / github.com/anomalyco/opencode / handleSessionError

Function handleSessionError

packages/app/src/context/notification.tsx:354–385  ·  view source on GitHub ↗
(
    directory: string,
    event: { properties: { sessionID?: string; error?: EventSessionError["properties"]["error"] } },
    time: number,
  )

Source from the content-addressed store, hash-verified

352 }
353
354 const handleSessionError = (
355 directory: string,
356 event: { properties: { sessionID?: string; error?: EventSessionError["properties"]["error"] } },
357 time: number,
358 ) => {
359 const sessionID = event.properties.sessionID
360 void lookup(directory, sessionID).then((session) => {
361 if (meta.disposed) return
362 if (session?.parentID) return
363
364 if (settings.sounds.errorsEnabled()) {
365 void playSoundById(settings.sounds.errors())
366 }
367
368 const error = "error" in event.properties ? event.properties.error : undefined
369 append({
370 directory,
371 time,
372 viewed: viewedInCurrentSession(directory, sessionID),
373 type: "error",
374 session: sessionID ?? "global",
375 error,
376 })
377 const description =
378 session?.title ??
379 (typeof error === "string" ? error : language.t("notification.session.error.fallbackDescription"))
380 const href = sessionID ? `/${base64Encode(directory)}/session/${sessionID}` : `/${base64Encode(directory)}`
381 if (settings.notifications.errors()) {
382 void platform.notify(language.t("notification.session.error.title"), description, href)
383 }
384 })
385 }
386
387 const unsub = serverSDK().event.listen((e) => {
388 const event = e.details

Callers 1

Calls 5

playSoundByIdFunction · 0.90
base64EncodeFunction · 0.90
viewedInCurrentSessionFunction · 0.85
lookupFunction · 0.70
appendFunction · 0.70

Tested by

no test coverage detected