opencode
opencode copied to clipboard
feat(tui): OSC 9 desktop notifications for toasts (#4454)
Summary
Implements OSC 9 desktop notifications for important TUI events, as proposed in #4454.
- Add a small OSC 9 helper for emitting terminal notifications from the TUI.
- Wire desktop notifications through the existing toast system so any
toast.show(...)can surface a desktop notification. - Gate notifications behind
config.tui.notifications.desktop(defaulting to enabled when unset).
Implementation Details
OSC 9 helper
- New file
packages/opencode/src/cli/cmd/tui/util/osc.tsexposes:-
osc9(text: string)which writesESC ] 9;{text} BELto stdout, wrapped for tmux when$TMUXis set.
-
- This keeps OSC 9 usage encapsulated and aligned with how Codex/Claude use terminal notifications.
Toast integration
-
packages/opencode/src/cli/cmd/tui/ui/toast.tsx:-
ToastProvidernow readssync.data.config.tui.notifications.desktopviauseSync. -
toast.show(...)callssendDesktopNotification(summary)once per toast (using the toasttitleor a default"Notification"). - If
config.tui.notifications.desktop === false, desktop notifications are suppressed but visual toasts still render.
-
- This keeps OSC 9 as a purely TUI concern and avoids sprinkling notification calls around the codebase.
Session toasts as first OSC 9 triggers
-
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx:- Track
statusandpermissionsperroute.sessionIDand detect transitions:-
non-idle -> idle→ show "Agent finished / Session is now idle" toast. -
permissions.length: 0 -> >0→ show "Permission required / Review and approve requested actions" toast.
-
- Because these go through
toast.show(...), they also trigger OSC 9 notifications (when enabled), matching the behavior described in #4454.
- Track
@rekram1-node do you think this could be added soon? I am not sure if it's the type of feature that needs architectural stuff or not