diff options
| author | Adam <[email protected]> | 2025-12-16 12:25:15 -0600 |
|---|---|---|
| committer | Adam <[email protected]> | 2025-12-16 12:53:12 -0600 |
| commit | 20e3a74badabc07cb23223c8d8d2bc7052b31a39 (patch) | |
| tree | 7e16899fe08bf2c246ec85df082113f8a9669ca1 | |
| parent | ff690350b1ac5ec4f415d9d3eabaeb839196fa1c (diff) | |
| download | opencode-20e3a74badabc07cb23223c8d8d2bc7052b31a39.tar.gz opencode-20e3a74badabc07cb23223c8d8d2bc7052b31a39.zip | |
fix: defensive audio init
| -rw-r--r-- | packages/desktop/src/context/notification.tsx | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/packages/desktop/src/context/notification.tsx b/packages/desktop/src/context/notification.tsx index 4c1a39fb2..d2c5bae4c 100644 --- a/packages/desktop/src/context/notification.tsx +++ b/packages/desktop/src/context/notification.tsx @@ -31,8 +31,16 @@ export type Notification = TurnCompleteNotification | ErrorNotification export const { use: useNotification, provider: NotificationProvider } = createSimpleContext({ name: "Notification", init: () => { - const idlePlayer = makeAudioPlayer(idleSound) - const errorPlayer = makeAudioPlayer(errorSound) + let idlePlayer: ReturnType<typeof makeAudioPlayer> | undefined + let errorPlayer: ReturnType<typeof makeAudioPlayer> | undefined + + try { + idlePlayer = makeAudioPlayer(idleSound) + errorPlayer = makeAudioPlayer(errorSound) + } catch (err) { + console.log("Failed to load audio", err) + } + const globalSDK = useGlobalSDK() const globalSync = useGlobalSync() @@ -60,7 +68,7 @@ export const { use: useNotification, provider: NotificationProvider } = createSi const match = Binary.search(syncStore.session, sessionID, (s) => s.id) const isChild = match.found && syncStore.session[match.index].parentID if (isChild) break - idlePlayer.play() + idlePlayer?.play() setStore("list", store.list.length, { ...base, type: "turn-complete", @@ -76,7 +84,7 @@ export const { use: useNotification, provider: NotificationProvider } = createSi const isChild = match.found && syncStore.session[match.index].parentID if (isChild) break } - errorPlayer.play() + errorPlayer?.play() setStore("list", store.list.length, { ...base, type: "error", |
