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(claude): ask notification permission on first launch + Settings control

enesa7f8c61551d8
diff --git a/src/main/index.ts b/src/main/index.ts
index f73e98a83..27a25d4de 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -96,19 +96,25 @@ app.whenReady().then(() => {
// Show an OS notification — but only when the window is in the background. Clicking it
// brings the app forward and asks the renderer to focus the originating node.
- ipcMain.handle(IPC.appNotify, (_e, payload: { title: string; body: string; nodeId: string }) => {
- if (!mainWin || mainWin.isFocused() || !Notification.isSupported()) return false
- const n = new Notification({ title: payload.title, body: payload.body })
- n.on('click', () => {
- if (!mainWin) return
- if (mainWin.isMinimized()) mainWin.restore()
- mainWin.show()
- mainWin.focus()
- mainWin.webContents.send(IPC.appFocusNode, payload.nodeId)
- })
- n.show()
- return true
- })
+ ipcMain.handle(
+ IPC.appNotify,
+ (_e, payload: { title: string; body: string; nodeId: string; force?: boolean }) => {
+ if (!mainWin || !Notification.isSupported()) return false
+ // `force` (permission request / confirmation) shows even when focused; normal
+ // completion notifications only show when the window is in the background.
+ if (!payload.force && mainWin.isFocused()) return false
+ const n = new Notification({ title: payload.title, body: payload.body })
+ n.on('click', () => {
+ if (!mainWin) return
+ if (mainWin.isMinimized()) mainWin.restore()
+ mainWin.show()
+ mainWin.focus()
+ if (payload.nodeId) mainWin.webContents.send(IPC.appFocusNode, payload.nodeId)
+ })
+ n.show()
+ return true
+ }
+ )
ipcMain.handle(IPC.announcementsFetch, () => fetchAnnouncements())
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 0508dcbc8..c4e830d41 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -854,21 +854,27 @@ export function Canvas() {
}
}, [paletteOpen])
- // One-time consent: the first time a Claude turn finishes in the background, ask whether
- // to enable completion notifications (default off until accepted).
- const anyUnread = useClaudeStatus((s) => Object.values(s.byId).some((v) => v.unread))
- const notifyConsentAsked = useSettings((s) => s.settings.notifyConsentAsked)
+ // First-launch consent: ask once whether to enable Claude completion notifications. On
+ // accept we fire a forced notification to trigger the macOS permission prompt. Declining
+ // leaves them off — re-enable any time from Settings.
useEffect(() => {
- if (!anyUnread || notifyConsentAsked) return
+ if (useSettings.getState().settings.notifyConsentAsked) return
useSettings.getState().update({ notifyConsentAsked: true, notifyOnClaudeDone: false })
setConfirm({
- message: 'Notify you when Claude Code finishes while nodeterm is in the background?',
+ message:
+ 'Notify you when Claude Code finishes while nodeterm is in the background? You can change this any time in Settings.',
onConfirm: () => {
useSettings.getState().update({ notifyOnClaudeDone: true })
+ void window.nodeTerminal.notify({
+ title: 'Notifications enabled',
+ body: "You'll be told when Claude Code finishes in the background.",
+ nodeId: '',
+ force: true
+ })
setConfirm(null)
}
})
- }, [anyUnread, notifyConsentAsked])
+ }, [])
const addProject = useCallback(() => {
commitActiveToStore()
diff --git a/src/renderer/components/SettingsPanel.tsx b/src/renderer/components/SettingsPanel.tsx
index 46af602c8..211ce69a2 100644
--- a/src/renderer/components/SettingsPanel.tsx
+++ b/src/renderer/components/SettingsPanel.tsx
@@ -113,9 +113,18 @@ export function SettingsPanel({ onClose }: SettingsPanelProps) {
<input
type="checkbox"
checked={settings.notifyOnClaudeDone}
- onChange={(e) =>
- update({ notifyOnClaudeDone: e.target.checked, notifyConsentAsked: true })
- }
+ onChange={(e) => {
+ const on = e.target.checked
+ update({ notifyOnClaudeDone: on, notifyConsentAsked: true })
+ // Enabling triggers the macOS notification permission prompt.
+ if (on)
+ void window.nodeTerminal.notify({
+ title: 'Notifications enabled',
+ body: "You'll be told when Claude Code finishes in the background.",
+ nodeId: '',
+ force: true
+ })
+ }}
/>
</label>
</section>
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 8c0b3bf58..d35813436 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -301,6 +301,8 @@ export interface NotifyPayload {
body: string
/** Node to focus/center when the notification is clicked. */
nodeId: string
+ /** Show even when the window is focused (used to trigger the macOS permission prompt). */
+ force?: boolean
}
/** A Claude Code lifecycle hook event, forwarded from the main process. */