Description
On Ubuntu/GNOME, the numeric notification counter on the OpenCode dock (taskbar) icon increments on every completed turn and never goes back down, even after the notifications are read or cleared in the app.
The desktop renderer creates a web notification per turn and never closes it. On Linux, Electron maps each new Notification() to an org.freedesktop.Notifications.Notify call with replaces_id = 0 and no transient hint, so GNOME's notification daemon appends a new entry to the app's list for every notification. Ubuntu Dock's badge is the length of exactly that list (NotificationsMonitor.getAppNotificationsCount(appId), consumed by UnityIndicator._updateNotificationsCount() in appIconIndicators.js), so the counter only ever grows while the app runs and resets only when every notification is removed (Clear-all, or the app quitting and its D-Bus name vanishing).
Environment
- opencode version: 2.0.16 (packaged desktop app, Electron 44.4.3)
- OS: Ubuntu 26.04.1 LTS, GNOME Shell 50.1, Wayland
- Terminal: n/a (desktop app)
- Install/channel: release
.deb, installed to /opt/OpenCode
- Active plugins: none
Steps to reproduce
- Ubuntu with the default Ubuntu Dock (
show-icons-notifications-counter is on by default)
- Leave Settings → General → Notifications → Agent on (the default)
- Switch away from the OpenCode window and let a few turns complete in any session
- The counter on the OpenCode dock icon increments by one per completed turn
- Open the session and mark it viewed in-app — the OS counter does not decrease
Expected behavior
The dock indicator should reflect the app's actual unread/attention state, and reading a session or clearing notifications should bring it back down.
Actual behavior
The counter is monotonically increasing while the app runs. GNOME caps and expires entries per app (MAX_NOTIFICATIONS_PER_SOURCE = 10 in messageTray.js), so under a burst it plateaus rather than growing forever — it still never comes back down until the app quits or every notification is dismissed.
Additional context
Measured on the affected machine by reading the dock badge through the GNOME accessibility tree and the notification daemon's state:
| Action |
OpenCode dock counter |
| baseline |
7 |
send 3 notifications shaped exactly like the app's (desktop-entry=ai.opencode.desktop, sender-pid=<electron browser pid>) |
10 |
| close those 3 |
5 |
| send 12 in a burst |
10 (plateau) |
| close all |
0 |
Two control probes pin the cause:
- Sending the same payload without
desktop-entry/sender-pid app attribution does not move the OpenCode badge (the notifications land under a different source), so the badge is fed by the app-attributed entries.
- Passing the daemon-returned id back as
replaces_id replaced instead of appending (5 calls left 1 entry, counter stayed at 1). Passing a g_quark of a string tag did not replace (3 calls returned 3 distinct ids) — which is what Electron's libnotify path does when options.tag is set, so a JS tag alone will not fix this on GNOME.
Code path:
packages/desktop/src/renderer/index.tsx — platform.notify():
const notification = new Notification(title, { body: description ?? "", icon: "..." })
notification.onclick = () => { ...; notification.close() }
No tag, and close() is only ever reached by clicking the notification.
packages/app/src/context/notification.tsx — handleSessionIdle() and handleSessionError() call platform.notify(...) when settings.notifications.agent() / .errors() are on. These are the per-turn calls.
- Electron on Linux (
shell/browser/notifications/linux/libnotify_notification.cc) sends the D-Bus Notify with replaces_id = options.tag as a g_quark (0 when empty); GNOME's org.gnome.Shell.Notifications daemon creates a brand-new entry per call and returns a fresh id each time.
Suggested fixes (any one stops the growth):
- Renderer keeps the last notification handle per session and calls
close() on a previous one before showing the next, and/or when the session is marked viewed.
- Make completion notifications replace their predecessor — the only reliable form on GNOME is passing the daemon-returned id back as
replaces_id, which needs an explicit Electron/main-process path rather than a JS tag.
- Set the
transient hint on Linux so GNOME destroys the entry when the banner is hidden (note: it then no longer persists in GNOME's notification list either).
Workarounds (until fixed):
- Settings → General → Notifications → Agent: off
gsettings set org.gnome.shell.extensions.dash-to-dock show-icons-notifications-counter false
- Clear notifications in the GNOME panel, or quit the app, to reset the counter