Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

feat(windows): tray model, taskbar overlay badge and AppUserModelID helpers

reviewcedf732e08f2
diff --git a/src/main/app-identity.test.ts b/src/main/app-identity.test.ts
new file mode 100644
index 000000000..7a48171e4
--- /dev/null
+++ b/src/main/app-identity.test.ts
@@ -0,0 +1,58 @@
+import { describe, expect, it } from 'vitest'
+import { readFileSync } from 'fs'
+import { join } from 'path'
+import { APP_USER_MODEL_ID, appUserModelIdFor, notificationSettingsTarget } from './app-identity'
+
+const repo = join(__dirname, '../..')
+
+describe('APP_USER_MODEL_ID', () => {
+ it('equals package.json build.appId — the id the NSIS installer stamps on the shortcut', () => {
+ const pkg = JSON.parse(readFileSync(join(repo, 'package.json'), 'utf-8'))
+ expect(APP_USER_MODEL_ID).toBe(pkg.build.appId)
+ })
+})
+
+describe('appUserModelIdFor', () => {
+ it('uses the build appId for a packaged Windows app', () => {
+ expect(appUserModelIdFor({ platform: 'win32', isPackaged: true, execPath: 'C:\\x\\nodeterm.exe' })).toBe(
+ APP_USER_MODEL_ID
+ )
+ })
+ it('uses execPath in a Windows dev run (no shortcut carries the build id there)', () => {
+ expect(appUserModelIdFor({ platform: 'win32', isPackaged: false, execPath: 'C:\\dev\\electron.exe' })).toBe(
+ 'C:\\dev\\electron.exe'
+ )
+ })
+ it('sets nothing on macOS or Linux', () => {
+ for (const platform of ['darwin', 'linux']) {
+ expect(appUserModelIdFor({ platform, isPackaged: true, execPath: '/x' })).toBeNull()
+ }
+ })
+})
+
+describe('notificationSettingsTarget', () => {
+ it('keeps the macOS deep link byte-identical', () => {
+ expect(notificationSettingsTarget('darwin')).toBe(
+ 'x-apple.systempreferences:com.apple.Notifications-Settings.extension'
+ )
+ })
+ it('opens Windows Settings → Notifications', () => {
+ expect(notificationSettingsTarget('win32')).toBe('ms-settings:notifications')
+ })
+ it('has nothing to open on Linux', () => {
+ expect(notificationSettingsTarget('linux')).toBeNull()
+ })
+})
+
+describe('main/index.ts wiring (source guard)', () => {
+ const src = readFileSync(join(__dirname, 'index.ts'), 'utf-8')
+ it('sets the AppUserModelID before the single-instance lock / ready', () => {
+ const set = src.indexOf('app.setAppUserModelId(')
+ expect(set).toBeGreaterThan(-1)
+ expect(set).toBeLessThan(src.indexOf('app.requestSingleInstanceLock()'))
+ expect(set).toBeLessThan(src.indexOf('app.whenReady()'))
+ })
+ it('routes the notification-settings deep link through notificationSettingsTarget', () => {
+ expect(src).toMatch(/IPC\.appOpenNotificationSettings[\s\S]{0,120}notificationSettingsTarget\(process\.platform\)/)
+ })
+})
diff --git a/src/main/app-identity.ts b/src/main/app-identity.ts
new file mode 100644
index 000000000..81b536ef2
--- /dev/null
+++ b/src/main/app-identity.ts
@@ -0,0 +1,41 @@
+// Windows app identity for toasts, and the per-OS notification-settings deep link.
+// Pure + Electron-free (the caller passes platform/isPackaged/execPath) so it is testable anywhere.
+
+/**
+ * The AppUserModelID Windows attributes our toasts, taskbar button and jump list to. It MUST equal
+ * package.json `build.appId`: the NSIS installer stamps that id onto the Start-menu shortcut
+ * (app-builder-lib's installer.nsh `SetLnkAUMI`), and Windows only delivers a toast — attributed,
+ * with our name and icon — when the process's AUMID matches a shortcut's. Without an explicit call
+ * Electron falls back to a generated `electron.app.<name>` id that matches nothing, so toasts were
+ * dropped or mis-attributed with no error at all (Windows never emits Notification 'failed').
+ * `app-identity.test.ts` pins the two together.
+ */
+export const APP_USER_MODEL_ID = 'com.nodeterm.app'
+
+/**
+ * The id to pass to `app.setAppUserModelId`, or null where there is nothing to set.
+ * - Off Windows: null (the concept does not exist; macOS/Linux behavior is untouched).
+ * - Packaged: the build appId, matching the installer's shortcut.
+ * - Dev (`electron .`): `process.execPath`, Electron's documented dev value — there is no
+ * shortcut for the build id in a dev checkout, and using it would attribute a dev instance's
+ * toasts to an installed nodeterm on the same machine.
+ */
+export function appUserModelIdFor(opts: {
+ platform: NodeJS.Platform | string
+ isPackaged: boolean
+ execPath: string
+}): string | null {
+ if (opts.platform !== 'win32') return null
+ return opts.isPackaged ? APP_USER_MODEL_ID : opts.execPath
+}
+
+/**
+ * The OS notification-settings page to deep-link to so a user can re-enable notifications, or
+ * null where there is no such page we can open. A main-side constant — never routed through the
+ * renderer-facing openExternal allowlist (which is http(s)-only on purpose).
+ */
+export function notificationSettingsTarget(platform: NodeJS.Platform | string): string | null {
+ if (platform === 'darwin') return 'x-apple.systempreferences:com.apple.Notifications-Settings.extension'
+ if (platform === 'win32') return 'ms-settings:notifications'
+ return null
+}
diff --git a/src/main/taskbar-badge.test.ts b/src/main/taskbar-badge.test.ts
new file mode 100644
index 000000000..87b71d681
--- /dev/null
+++ b/src/main/taskbar-badge.test.ts
@@ -0,0 +1,81 @@
+import { describe, expect, it } from 'vitest'
+import { badgeLabel, planBadge, rasterizeBadge } from './taskbar-badge'
+
+describe('planBadge', () => {
+ it('macOS: only the Dock string, same as before', () => {
+ expect(planBadge('darwin', 3, 0, false)).toEqual({ dock: '3' })
+ expect(planBadge('darwin', 0, 3, false)).toEqual({ dock: '' })
+ })
+ it('Windows: count 0 clears the overlay and never flashes', () => {
+ expect(planBadge('win32', 0, 2, false)).toEqual({ overlay: null, flash: false })
+ })
+ it('Windows: a rise while unfocused flashes; while focused it does not', () => {
+ expect(planBadge('win32', 2, 1, false)).toEqual({
+ overlay: { label: '2', description: '2 unread sessions' },
+ flash: true
+ })
+ expect(planBadge('win32', 2, 1, true).flash).toBe(false)
+ })
+ it('Windows: a fall or a resend of the same count does not flash', () => {
+ expect(planBadge('win32', 1, 2, false).flash).toBe(false)
+ expect(planBadge('win32', 2, 2, false).flash).toBe(false)
+ })
+ it('Linux: nothing', () => {
+ expect(planBadge('linux', 5, 0, false)).toEqual({})
+ })
+})
+
+describe('badgeLabel', () => {
+ it('caps at 9+', () => {
+ expect(badgeLabel(1)).toBe('1')
+ expect(badgeLabel(9)).toBe('9')
+ expect(badgeLabel(10)).toBe('9+')
+ expect(badgeLabel(250)).toBe('9+')
+ })
+})
+
+describe('rasterizeBadge', () => {
+ const px = (buf: Buffer, size: number, x: number, y: number) => {
+ const i = (y * size + x) * 4
+ return { b: buf[i], g: buf[i + 1], r: buf[i + 2], a: buf[i + 3] }
+ }
+ it.each([16, 32])('is a size×size BGRA buffer (%i px)', (size) => {
+ expect(rasterizeBadge('3', size).length).toBe(size * size * 4)
+ })
+ it('is transparent at the corners and opaque red at the rim of the disc', () => {
+ const buf = rasterizeBadge('1', 16)
+ expect(px(buf, 16, 0, 0).a).toBe(0)
+ expect(px(buf, 16, 15, 15).a).toBe(0)
+ expect(px(buf, 16, 8, 1)).toEqual({ b: 0x30, g: 0x3b, r: 0xff, a: 255 })
+ })
+ it('premultiplies the anti-aliased edge (no channel exceeds alpha)', () => {
+ const buf = rasterizeBadge('1', 16)
+ for (let i = 0; i < buf.length; i += 4) {
+ expect(Math.max(buf[i], buf[i + 1], buf[i + 2])).toBeLessThanOrEqual(buf[i + 3])
+ }
+ })
+ it('draws white glyph pixels inside the disc, for one digit and for 9+', () => {
+ for (const label of ['8', '9+']) {
+ for (const size of [16, 32]) {
+ const buf = rasterizeBadge(label, size)
+ let white = 0
+ for (let i = 0; i < buf.length; i += 4) if (buf[i] === 255 && buf[i + 1] === 255 && buf[i + 3] === 255) white++
+ expect(white).toBeGreaterThan(0)
+ // Glyph pixels never land on the transparent corners.
+ expect(px(buf, size, 0, 0).a).toBe(0)
+ }
+ }
+ })
+ it('the two-glyph label still fits inside a 16 px disc', () => {
+ const buf = rasterizeBadge('9+', 16)
+ for (let y = 0; y < 16; y++)
+ for (let x = 0; x < 16; x++) {
+ const p = px(buf, 16, x, y)
+ if (p.r === 255 && p.g === 255) {
+ const dx = x + 0.5 - 8
+ const dy = y + 0.5 - 8
+ expect(dx * dx + dy * dy).toBeLessThan(64)
+ }
+ }
+ })
+})
diff --git a/src/main/taskbar-badge.ts b/src/main/taskbar-badge.ts
new file mode 100644
index 000000000..5f75dcddc
--- /dev/null
+++ b/src/main/taskbar-badge.ts
@@ -0,0 +1,115 @@
+// The unread-sessions badge, per platform: the macOS Dock badge (unchanged), and on Windows a
+// taskbar OVERLAY icon plus a taskbar flash when the count rises while the window is in the
+// background. Linux gets nothing (its only API, `app.setBadgeCount`, is Unity-launcher-only).
+//
+// Pure + Electron-free: the plan and the overlay bitmap are computed here and applied by the
+// `appSetBadge` handler in main/index.ts, so every branch is testable on a Linux CI box.
+
+export interface BadgePlan {
+ /** macOS: the Dock badge text ('' clears). Absent = do not touch the Dock. */
+ dock?: string
+ /** Windows: the overlay to draw (`null` clears it). Absent = do not touch the overlay. */
+ overlay?: { label: string; description: string } | null
+ /** Windows: flash the taskbar button (it stops on its own once the window is focused). */
+ flash?: boolean
+}
+
+/** The overlay text: the count up to 9, then "9+" (two glyphs is all a 16px circle holds). */
+export function badgeLabel(count: number): string {
+ return count > 9 ? '9+' : String(count)
+}
+
+export function planBadge(
+ platform: NodeJS.Platform | string,
+ count: number,
+ prevCount: number,
+ focused: boolean
+): BadgePlan {
+ const n = Number.isFinite(count) && count > 0 ? Math.floor(count) : 0
+ if (platform === 'darwin') return { dock: n > 0 ? String(n) : '' }
+ if (platform === 'win32') {
+ return {
+ overlay: n > 0 ? { label: badgeLabel(n), description: n === 1 ? '1 unread session' : `${n} unread sessions` } : null,
+ // Only a RISE means "something new finished while you were away" — a falling count is the
+ // user catching up, and re-flashing on every badge sync would be noise.
+ flash: n > prevCount && !focused
+ }
+ }
+ return {}
+}
+
+// 3×5 bitmap glyphs (rows top→bottom, bit 2 = left column). Only what `badgeLabel` can produce.
+const GLYPHS: Record<string, number[]> = {
+ '0': [7, 5, 5, 5, 7],
+ '1': [2, 6, 2, 2, 7],
+ '2': [7, 1, 7, 4, 7],
+ '3': [7, 1, 7, 1, 7],
+ '4': [5, 5, 7, 1, 1],
+ '5': [7, 4, 7, 1, 7],
+ '6': [7, 4, 7, 5, 7],
+ '7': [7, 1, 1, 1, 1],
+ '8': [7, 5, 7, 5, 7],
+ '9': [7, 5, 7, 1, 7],
+ '+': [0, 2, 7, 2, 0]
+}
+
+/** Badge red (macOS system red, the color users already read as "unread"). */
+const RED = { r: 0xff, g: 0x3b, b: 0x30 }
+
+/**
+ * Rasterize the overlay: an anti-aliased red disc with the label in white, as a size×size
+ * PREMULTIPLIED BGRA buffer — the layout `nativeImage.createFromBitmap` expects on Windows
+ * (Skia's N32 on little-endian). One char draws at scale size/8, two chars at size/14, so "9+"
+ * still fits inside the disc at 16 px.
+ */
+export function rasterizeBadge(label: string, size: number): Buffer {
+ const buf = Buffer.alloc(size * size * 4)
+ const c = size / 2
+ const radius = size / 2
+ const SS = 4 // supersamples per axis for the disc edge
+ for (let y = 0; y < size; y++) {
+ for (let x = 0; x < size; x++) {
+ let hits = 0
+ for (let sy = 0; sy < SS; sy++) {
+ for (let sx = 0; sx < SS; sx++) {
+ const dx = x + (sx + 0.5) / SS - c
+ const dy = y + (sy + 0.5) / SS - c
+ if (dx * dx + dy * dy <= radius * radius) hits++
+ }
+ }
+ const a = hits / (SS * SS)
+ const i = (y * size + x) * 4
+ buf[i] = Math.round(RED.b * a)
+ buf[i + 1] = Math.round(RED.g * a)
+ buf[i + 2] = Math.round(RED.r * a)
+ buf[i + 3] = Math.round(255 * a)
+ }
+ }
+ const chars = [...label].filter((ch) => GLYPHS[ch])
+ if (chars.length === 0) return buf
+ const scale = Math.max(1, Math.floor(size / (chars.length === 1 ? 8 : 14)))
+ const gw = 3 * scale
+ const gh = 5 * scale
+ const totalW = chars.length * gw + (chars.length - 1) * scale
+ const x0 = Math.floor((size - totalW) / 2)
+ const y0 = Math.floor((size - gh) / 2)
+ chars.forEach((ch, k) => {
+ const rows = GLYPHS[ch]
+ const gx = x0 + k * (gw + scale)
+ for (let row = 0; row < 5; row++) {
+ for (let col = 0; col < 3; col++) {
+ if (!(rows[row] & (4 >> col))) continue
+ for (let py = 0; py < scale; py++) {
+ for (let px = 0; px < scale; px++) {
+ const x = gx + col * scale + px
+ const y = y0 + row * scale + py
+ if (x < 0 || y < 0 || x >= size || y >= size) continue
+ const i = (y * size + x) * 4
+ buf[i] = buf[i + 1] = buf[i + 2] = buf[i + 3] = 255
+ }
+ }
+ }
+ }
+ })
+ return buf
+}
diff --git a/src/main/tray-model.test.ts b/src/main/tray-model.test.ts
new file mode 100644
index 000000000..7e3cb6f79
--- /dev/null
+++ b/src/main/tray-model.test.ts
@@ -0,0 +1,58 @@
+import { describe, expect, it } from 'vitest'
+import { join } from 'path'
+import { normalizeUnread, trayIconPath, trayMenuModel, trayStateKey, trayTooltip } from './tray-model'
+
+describe('trayMenuModel', () => {
+ it('has Open first and Quit last, both enabled with their actions', () => {
+ const m = trayMenuModel({ unread: 0, phoneAccess: true })
+ expect(m[0]).toEqual({ type: 'normal', label: 'Open nodeterm', enabled: true, action: 'open' })
+ expect(m[m.length - 1]).toEqual({ type: 'normal', label: 'Quit nodeterm', enabled: true, action: 'quit' })
+ })
+ it('shows the phone-access status as a disabled row', () => {
+ const labels = (s: boolean) =>
+ trayMenuModel({ unread: 0, phoneAccess: s }).filter((i) => i.type === 'normal' && !i.enabled)
+ expect(labels(true)).toEqual([{ type: 'normal', label: 'Phone access: on', enabled: false }])
+ expect(labels(false)).toEqual([{ type: 'normal', label: 'Phone access: off', enabled: false }])
+ })
+ it('adds an unread row only when there is something unread', () => {
+ const has = (n: number) =>
+ trayMenuModel({ unread: n, phoneAccess: true }).some((i) => i.type === 'normal' && /unread/.test(i.label))
+ expect(has(0)).toBe(false)
+ expect(trayMenuModel({ unread: 1, phoneAccess: true })).toContainEqual({
+ type: 'normal',
+ label: '1 unread session',
+ enabled: false
+ })
+ expect(trayMenuModel({ unread: 3, phoneAccess: true })).toContainEqual({
+ type: 'normal',
+ label: '3 unread sessions',
+ enabled: false
+ })
+ })
+})
+
+describe('trayTooltip / trayStateKey / normalizeUnread', () => {
+ it('tooltips the unread count', () => {
+ expect(trayTooltip({ unread: 0, phoneAccess: true })).toBe('nodeterm')
+ expect(trayTooltip({ unread: 2, phoneAccess: true })).toBe('nodeterm — 2 unread sessions')
+ })
+ it('keys identical states identically so a resend rebuilds nothing', () => {
+ expect(trayStateKey({ unread: 2, phoneAccess: true })).toBe(trayStateKey({ unread: 2, phoneAccess: true }))
+ expect(trayStateKey({ unread: 2, phoneAccess: true })).not.toBe(trayStateKey({ unread: 2, phoneAccess: false }))
+ expect(trayStateKey({ unread: 2, phoneAccess: true })).not.toBe(trayStateKey({ unread: 3, phoneAccess: true }))
+ })
+ it('clamps junk IPC counts to 0', () => {
+ expect(normalizeUnread(-1)).toBe(0)
+ expect(normalizeUnread(NaN)).toBe(0)
+ expect(normalizeUnread('3')).toBe(0)
+ expect(normalizeUnread(4.7)).toBe(4)
+ })
+})
+
+describe('trayIconPath', () => {
+ it('reads resources/icon.png when packaged and build/icon.png in dev', () => {
+ const base = { resourcesPath: '/r', devBuildDir: '/b', join }
+ expect(trayIconPath({ ...base, isPackaged: true })).toBe(join('/r', 'icon.png'))
+ expect(trayIconPath({ ...base, isPackaged: false })).toBe(join('/b', 'icon.png'))
+ })
+})
diff --git a/src/main/tray-model.ts b/src/main/tray-model.ts
new file mode 100644
index 000000000..86b37e56a
--- /dev/null
+++ b/src/main/tray-model.ts
@@ -0,0 +1,64 @@
+// Pure model for the Windows/Linux background-mode tray (./tray.ts owns the Electron Tray).
+// Electron-free so the menu's labels, enabled states and actions are testable on any CI box.
+
+/** What the tray shows. Deliberately small: it is fed from facts main already holds (the unread
+ * count the renderer sends for the Dock badge, and the phone-access setting) — no new feed, so a
+ * hook-event burst can never rebuild the menu. */
+export interface TrayState {
+ unread: number
+ phoneAccess: boolean
+}
+
+export type TrayAction = 'open' | 'quit'
+
+export type TrayMenuItem =
+ | { type: 'separator' }
+ | { type: 'normal'; label: string; enabled: boolean; action?: TrayAction }
+
+function unreadLabel(n: number): string {
+ return n === 1 ? '1 unread session' : `${n} unread sessions`
+}
+
+/** Clamp the renderer-sent count: an IPC payload is not a type. */
+export function normalizeUnread(n: unknown): number {
+ return typeof n === 'number' && Number.isFinite(n) && n > 0 ? Math.floor(n) : 0
+}
+
+export function trayMenuModel(state: TrayState): TrayMenuItem[] {
+ const items: TrayMenuItem[] = [
+ { type: 'normal', label: 'Open nodeterm', enabled: true, action: 'open' },
+ { type: 'separator' }
+ ]
+ const unread = normalizeUnread(state.unread)
+ if (unread > 0) items.push({ type: 'normal', label: unreadLabel(unread), enabled: false })
+ items.push({ type: 'normal', label: `Phone access: ${state.phoneAccess ? 'on' : 'off'}`, enabled: false })
+ items.push({ type: 'separator' })
+ // Quit goes through the ordinary app.quit() → before-quit path (confirm dialog included), so a
+ // tray quit tears down exactly what ⌘Q / Ctrl+Q does.
+ items.push({ type: 'normal', label: 'Quit nodeterm', enabled: true, action: 'quit' })
+ return items
+}
+
+export function trayTooltip(state: TrayState): string {
+ const unread = normalizeUnread(state.unread)
+ return unread > 0 ? `nodeterm — ${unreadLabel(unread)}` : 'nodeterm'
+}
+
+/** Identity of a state for rebuild de-duplication: the menu is rebuilt only when this changes. */
+export function trayStateKey(state: TrayState): string {
+ return `${normalizeUnread(state.unread)}|${state.phoneAccess ? 1 : 0}`
+}
+
+/**
+ * Where the tray icon lives. The packaged app carries `icon.png` in resources on every platform
+ * (package.json top-level `extraResources`, which electron-builder concatenates with the
+ * platform-specific lists); dev reads the generated `build/icon.png` (`npm run make-icon`).
+ */
+export function trayIconPath(opts: {
+ isPackaged: boolean
+ resourcesPath: string
+ devBuildDir: string
+ join: (...parts: string[]) => string
+}): string {
+ return opts.isPackaged ? opts.join(opts.resourcesPath, 'icon.png') : opts.join(opts.devBuildDir, 'icon.png')
+}
diff --git a/src/main/tray.ts b/src/main/tray.ts
new file mode 100644
index 000000000..611a32c68
--- /dev/null
+++ b/src/main/tray.ts
@@ -0,0 +1,60 @@
+// Windows/Linux background-mode tray (docs: CLAUDE.md "Window lifecycle"). Created only when
+// background mode resolves on (`resolveBackgroundOnClose`), never on macOS — the Dock is the
+// analogue there. All decisions live in the pure ./tray-model; this file is the Electron glue.
+
+import { Menu, Tray, nativeImage } from 'electron'
+import { trayMenuModel, trayStateKey, trayTooltip, type TrayAction, type TrayState } from './tray-model'
+
+export interface BackgroundTray {
+ /** Re-render if (and only if) the state's identity changed. */
+ update(state: TrayState): void
+ destroy(): void
+}
+
+export function createBackgroundTray(opts: {
+ iconPath: string
+ initial: TrayState
+ onAction: (action: TrayAction) => void
+}): BackgroundTray {
+ // 16 logical px with a 2x representation for HiDPI notification areas. A missing dev icon
+ // (make-icon not run) yields an empty image: the tray still exists and its menu still works.
+ const src = nativeImage.createFromPath(opts.iconPath)
+ let image = src
+ if (!src.isEmpty()) {
+ image = src.resize({ width: 16, height: 16, quality: 'best' })
+ const x2 = src.resize({ width: 32, height: 32, quality: 'best' })
+ image.addRepresentation({ scaleFactor: 2, width: 32, height: 32, buffer: x2.toPNG() })
+ }
+ const tray = new Tray(image)
+ let lastKey = ''
+ const render = (state: TrayState): void => {
+ const key = trayStateKey(state)
+ if (key === lastKey || tray.isDestroyed()) return
+ lastKey = key
+ tray.setToolTip(trayTooltip(state))
+ tray.setContextMenu(
+ Menu.buildFromTemplate(
+ trayMenuModel(state).map((item) =>
+ item.type === 'separator'
+ ? { type: 'separator' as const }
+ : {
+ label: item.label,
+ enabled: item.enabled,
+ click: item.action ? () => opts.onAction(item.action as TrayAction) : undefined
+ }
+ )
+ )
+ )
+ }
+ render(opts.initial)
+ // Windows: a left click restores the window (right click opens the menu). On Linux most
+ // StatusNotifier hosts open the menu on any click, where "Open nodeterm" does the same job.
+ tray.on('click', () => opts.onAction('open'))
+ tray.on('double-click', () => opts.onAction('open'))
+ return {
+ update: render,
+ destroy: () => {
+ if (!tray.isDestroyed()) tray.destroy()
+ }
+ }
+}
diff --git a/src/renderer/components/settings/sections/NotificationsSection.tsx b/src/renderer/components/settings/sections/NotificationsSection.tsx
index 278e39fec..9b2165a72 100644
--- a/src/renderer/components/settings/sections/NotificationsSection.tsx
+++ b/src/renderer/components/settings/sections/NotificationsSection.tsx
@@ -5,6 +5,8 @@ import { SearchableRow } from '../SearchableRow'
import { FieldRow } from '../FieldRow'
import { Switch } from '@renderer/ui/Switch'
import { Button } from '@renderer/ui/Button'
+import { isMacPlatform, isWindowsPlatform } from '@shared/platform-utils'
+import { notificationsBlockedCopy } from '@renderer/lib/notificationsBlockedCopy'
import { checkCustomSfx, playSfx } from '@renderer/lib/sfx'
import { readAsBase64 } from '@renderer/terminal/file-drop'
import {
@@ -147,6 +149,9 @@ function CustomSoundRow({ kind, volume }: { kind: AlertSoundKind; volume: number
)
}
+// The OS-refusal repair row's wording follows the OS whose notification center refused us.
+const blockedCopy = notificationsBlockedCopy(isMacPlatform() ? 'mac' : isWindowsPlatform() ? 'windows' : 'other')
+
export function NotificationsSection({ isActive }: { isActive: boolean }): React.JSX.Element {
const notifyOnClaudeDone = useSettings((s) => s.settings.notifyOnClaudeDone)
const soundEffects = useSettings((s) => s.settings.soundEffects)
@@ -197,10 +202,12 @@ export function NotificationsSection({ isActive }: { isActive: boolean }): React
/>
{osBlocked && (
<div className="mt-2 flex items-center gap-3 text-[13px] text-[color:var(--caution)]">
- macOS is blocking notifications for this app.
- <Button onClick={() => void window.nodeTerminal.openNotificationSettings()}>
- Open System Settings
- </Button>
+ {blockedCopy.message}
+ {blockedCopy.button && (
+ <Button onClick={() => void window.nodeTerminal.openNotificationSettings()}>
+ {blockedCopy.button}
+ </Button>
+ )}
</div>
)}
</SearchableRow>
diff --git a/src/renderer/lib/notificationsBlockedCopy.test.ts b/src/renderer/lib/notificationsBlockedCopy.test.ts
new file mode 100644
index 000000000..9cdd9f8fa
--- /dev/null
+++ b/src/renderer/lib/notificationsBlockedCopy.test.ts
@@ -0,0 +1,20 @@
+import { describe, expect, it } from 'vitest'
+import { notificationsBlockedCopy } from './notificationsBlockedCopy'
+
+describe('notificationsBlockedCopy', () => {
+ it('keeps the macOS copy byte-identical', () => {
+ expect(notificationsBlockedCopy('mac')).toEqual({
+ message: 'macOS is blocking notifications for this app.',
+ button: 'Open System Settings'
+ })
+ })
+ it('names Windows and its Notification settings page', () => {
+ expect(notificationsBlockedCopy('windows')).toEqual({
+ message: 'Windows is blocking notifications for this app.',
+ button: 'Open Notification settings'
+ })
+ })
+ it('offers no button where main has no settings page to open', () => {
+ expect(notificationsBlockedCopy('other').button).toBeNull()
+ })
+})
diff --git a/src/renderer/lib/notificationsBlockedCopy.ts b/src/renderer/lib/notificationsBlockedCopy.ts
new file mode 100644
index 000000000..ee9d6e350
--- /dev/null
+++ b/src/renderer/lib/notificationsBlockedCopy.ts
@@ -0,0 +1,11 @@
+// Copy for Settings → Notifications' "the OS refused our notification" repair row. The button
+// opens `notificationSettingsTarget(platform)` main-side (src/main/app-identity.ts), which exists
+// on macOS and Windows only — so `button` is null exactly where that handler would open nothing.
+
+export type CopyPlatform = 'mac' | 'windows' | 'other'
+
+export function notificationsBlockedCopy(p: CopyPlatform): { message: string; button: string | null } {
+ if (p === 'mac') return { message: 'macOS is blocking notifications for this app.', button: 'Open System Settings' }
+ if (p === 'windows') return { message: 'Windows is blocking notifications for this app.', button: 'Open Notification settings' }
+ return { message: 'The system is blocking notifications for this app.', button: null }
+}