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.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
feat(push): notify relay-paired phones over APNs on actionable agent events
enes87b19e98e1c3
diff --git a/src/core/agent-status-mirror.ts b/src/core/agent-status-mirror.tsindex e59170a3e..3f0546a45 100644--- a/src/core/agent-status-mirror.ts+++ b/src/core/agent-status-mirror.ts@@ -412,14 +412,38 @@ let usageProvider: (() => MirrorUsage | undefined) | null = nulllet inboxEvents: InboxEvent[] = []const inboxNodes = new Map<string, InboxNodeNow>()let inboxSeq = 0+// Fires exactly when a NEW actionable inbox event is appended: approval/question POST-DEDUP (a+// re-asserted identical prompt returns before pushInboxEvent, so it never fires twice) and `done`+// on the turn edge. This is the seam the desktop push-notify service (src/core/push-notify.ts)+// hooks — it is fed the same events the phone's Inbox feed shows. A listener must never throw into+// production; wrapped below.+const inboxActionableListeners = new Set<(e: InboxEvent) => void>()++/**+ * Subscribe to newly-appended actionable inbox events (approval/question post-dedup, done on edge).+ * Returns an unsubscribe. Additive side-channel — does not change the feed or any disk write.+ */+export function onInboxActionable(cb: (e: InboxEvent) => void): () => void {+ inboxActionableListeners.add(cb)+ return () => inboxActionableListeners.delete(cb)+}function pushInboxEvent(e: Omit<InboxEvent, 'id'>): void {const id = `${e.ts}-${++inboxSeq}`- inboxEvents.push({ id, ...e })+ const full: InboxEvent = { id, ...e }+ inboxEvents.push(full)// Cap the feed from the front (oldest fall off).if (inboxEvents.length > INBOX_EVENTS_CAP) {inboxEvents = inboxEvents.slice(inboxEvents.length - INBOX_EVENTS_CAP)}+ // Notify actionable-event subscribers (only reached AFTER the dedup early-returns above it).+ for (const cb of inboxActionableListeners) {+ try {+ cb(full)+ } catch {+ // A subscriber must never break inbox production (or its siblings).+ }+ }}/** Mark a node's unresolved approval/question events resolved (it left blocked/waiting). */@@ -672,6 +696,7 @@ export function _resetForTest(): void {inboxEvents = []inboxNodes.clear()inboxSeq = 0+ inboxActionableListeners.clear()}/** Snapshot the in-memory map. Test-only. */diff --git a/src/core/push-notify.test.ts b/src/core/push-notify.test.tsnew file mode 100644index 000000000..2494aefe0--- /dev/null+++ b/src/core/push-notify.test.ts@@ -0,0 +1,280 @@+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'+import fs from 'fs'+import os from 'os'+import path from 'path'+import type { NormalizedAgentEvent } from '@shared/agents/normalize'+import { createPushNotify, type PushNotifyDeps, type PushHostIdentity } from './push-notify'+import {+ onInboxActionable,+ recordAgentEvent,+ initAgentStatusMirror,+ _resetForTest,+ type InboxEvent+} from './agent-status-mirror'++// ---- helpers -------------------------------------------------------------------------------++/** A manual actionable-event source standing in for `onInboxActionable`. */+function makeEmitter(): {+ subscribe: (cb: (e: InboxEvent) => void) => () => void+ emit: (e: InboxEvent) => void+} {+ const cbs = new Set<(e: InboxEvent) => void>()+ return {+ subscribe: (cb) => {+ cbs.add(cb)+ return () => cbs.delete(cb)+ },+ emit: (e) => {+ for (const cb of cbs) cb(e)+ }+ }+}++function iev(p: Partial<InboxEvent>): InboxEvent {+ return { id: 'id', ts: 1000, nodeId: 'n1', kind: 'approval', title: 'Approve write', ...p }+}++const IDENTITY: PushHostIdentity = {+ hostDeviceId: 'host-device-1',+ hostPublicKeyB64: 'PUBKEYB64==',+ hostLabel: 'niova',+ hasPairedPhone: true+}++let fetchMock: ReturnType<typeof vi.fn>+let clock: number++function baseDeps(over: Partial<PushNotifyDeps> = {}): PushNotifyDeps {+ return {+ subscribe: () => () => {},+ getHostIdentity: () => IDENTITY,+ mobilePushEnabled: () => true,+ isPackaged: () => true,+ env: {},+ fetchImpl: fetchMock as unknown as typeof fetch,+ now: () => clock,+ batchWindowMs: 2000,+ throttleMs: 5000,+ ...over+ }+}++function bodyOf(callIndex = 0): {+ hostDeviceId: string+ hostPublicKeyB64: string+ hostLabel: string+ events: Array<Record<string, unknown>>+} {+ return JSON.parse(fetchMock.mock.calls[callIndex][1].body)+}++// ---- actionable-hook seam (via the REAL mirror) --------------------------------------------++describe('onInboxActionable seam (agent-status-mirror)', () => {+ let dir: string+ beforeEach(() => {+ _resetForTest()+ dir = fs.mkdtempSync(path.join(os.tmpdir(), 'push-hook-'))+ initAgentStatusMirror(path.join(dir, 'agent-status.json'))+ })+ afterEach(() => {+ _resetForTest()+ fs.rmSync(dir, { recursive: true, force: true })+ })++ function ev(p: Partial<NormalizedAgentEvent>): NormalizedAgentEvent {+ return { nodeId: 'n1', agentId: 'claude', kind: 'state', ...p } as NormalizedAgentEvent+ }++ it('fires approval ONCE for a re-asserted identical prompt (dedup)', () => {+ const seen: InboxEvent[] = []+ onInboxActionable((e) => seen.push(e))+ recordAgentEvent(ev({ state: 'blocked', lastMessage: 'Approve write to /etc/hosts' }))+ recordAgentEvent(ev({ state: 'blocked', lastMessage: 'Approve write to /etc/hosts' }))+ expect(seen.filter((e) => e.kind === 'approval')).toHaveLength(1)+ expect(seen[0].title).toBe('Approve write to /etc/hosts')+ })++ it('fires again when the ask genuinely changes', () => {+ const seen: InboxEvent[] = []+ onInboxActionable((e) => seen.push(e))+ recordAgentEvent(ev({ state: 'blocked', lastMessage: 'Approve write to A' }))+ recordAgentEvent(ev({ state: 'blocked', lastMessage: 'Approve write to B' }))+ expect(seen.filter((e) => e.kind === 'approval')).toHaveLength(2)+ })++ it('fires done on the turn edge, once', () => {+ const seen: InboxEvent[] = []+ onInboxActionable((e) => seen.push(e))+ recordAgentEvent(ev({ nodeId: 'n2', state: 'working', newTurn: true }))+ recordAgentEvent(ev({ nodeId: 'n2', state: 'done', lastMessage: 'All set.' }))+ recordAgentEvent(ev({ nodeId: 'n2', state: 'done' })) // no second edge+ const dones = seen.filter((e) => e.kind === 'done')+ expect(dones).toHaveLength(1)+ expect(dones[0].detail).toBe('All set.')+ })++ it('a subscriber that throws never breaks production or siblings', () => {+ const seen: InboxEvent[] = []+ onInboxActionable(() => {+ throw new Error('boom')+ })+ onInboxActionable((e) => seen.push(e))+ expect(() => recordAgentEvent(ev({ state: 'waiting', lastMessage: 'Pick one' }))).not.toThrow()+ expect(seen).toHaveLength(1)+ expect(seen[0].kind).toBe('question')+ })+})++// ---- push-notify service -------------------------------------------------------------------++describe('createPushNotify', () => {+ beforeEach(() => {+ vi.useFakeTimers()+ fetchMock = vi.fn().mockResolvedValue({ ok: true })+ clock = 0+ })+ afterEach(() => {+ vi.useRealTimers()+ })++ it('batches events landing in the window into ONE POST', async () => {+ const em = makeEmitter()+ const h = createPushNotify(baseDeps({ subscribe: em.subscribe }))+ em.emit(iev({ nodeId: 'a', kind: 'approval', title: 'A' }))+ em.emit(iev({ nodeId: 'b', kind: 'question', title: 'B' }))+ em.emit(iev({ nodeId: 'c', kind: 'done', title: 'C' }))+ expect(fetchMock).not.toHaveBeenCalled() // still buffering+ await vi.advanceTimersByTimeAsync(2000)+ expect(fetchMock).toHaveBeenCalledTimes(1)+ expect(bodyOf().events).toHaveLength(3)+ h.stop()+ })++ it('per-node throttle drops a second event for the same node inside the window', async () => {+ const em = makeEmitter()+ const h = createPushNotify(baseDeps({ subscribe: em.subscribe }))+ em.emit(iev({ nodeId: 'a', title: 'first' }))+ em.emit(iev({ nodeId: 'a', title: 'second' })) // throttled (clock unchanged)+ await vi.advanceTimersByTimeAsync(2000)+ expect(bodyOf().events).toHaveLength(1)+ expect(bodyOf().events[0].title).toBe('first')+ // After the throttle window, the node can push again.+ clock = 5000+ em.emit(iev({ nodeId: 'a', title: 'third' }))+ await vi.advanceTimersByTimeAsync(2000)+ expect(fetchMock).toHaveBeenCalledTimes(2)+ expect(bodyOf(1).events[0].title).toBe('third')+ h.stop()+ })++ it('caps at 10 events per POST and sends the remainder next', async () => {+ const em = makeEmitter()+ const h = createPushNotify(baseDeps({ subscribe: em.subscribe }))+ for (let i = 0; i < 12; i++) em.emit(iev({ nodeId: `n${i}`, title: `t${i}` }))+ await vi.advanceTimersByTimeAsync(2000)+ expect(bodyOf(0).events).toHaveLength(10)+ await vi.advanceTimersByTimeAsync(2000)+ expect(fetchMock).toHaveBeenCalledTimes(2)+ expect(bodyOf(1).events).toHaveLength(2)+ h.stop()+ })++ it('emits the contract payload shape (host identity + trimmed event fields)', async () => {+ const em = makeEmitter()+ const h = createPushNotify(baseDeps({ subscribe: em.subscribe }))+ em.emit(+ iev({+ nodeId: 'node-9',+ agentId: 'claude',+ kind: 'approval',+ title: 'Approve write to /etc/hosts',+ detail: 'Edit needs sudo',+ ts: 1789,+ resolved: false+ })+ )+ await vi.advanceTimersByTimeAsync(2000)+ const [url, init] = fetchMock.mock.calls[0]+ expect(url).toBe('https://api.nodeterm.dev/v1/push/notify')+ expect(init.method).toBe('POST')+ const body = bodyOf()+ expect(body.hostDeviceId).toBe('host-device-1')+ expect(body.hostPublicKeyB64).toBe('PUBKEYB64==')+ expect(body.hostLabel).toBe('niova')+ expect(body.events[0]).toEqual({+ kind: 'approval',+ title: 'Approve write to /etc/hosts',+ detail: 'Edit needs sudo',+ nodeId: 'node-9',+ agentId: 'claude',+ ts: 1789+ })+ // The internal InboxEvent fields do not leak into the payload.+ expect(body.events[0]).not.toHaveProperty('id')+ expect(body.events[0]).not.toHaveProperty('resolved')+ h.stop()+ })++ it('honors NODETERM_API_BASE override', async () => {+ const em = makeEmitter()+ const h = createPushNotify(+ baseDeps({ subscribe: em.subscribe, env: { NODETERM_API_BASE: 'http://localhost:9999' } })+ )+ em.emit(iev({ nodeId: 'a' }))+ await vi.advanceTimersByTimeAsync(2000)+ expect(fetchMock.mock.calls[0][0]).toBe('http://localhost:9999/v1/push/notify')+ h.stop()+ })++ it('drops on network error without throwing (no retry queue)', async () => {+ fetchMock.mockRejectedValue(new Error('offline'))+ const em = makeEmitter()+ const h = createPushNotify(baseDeps({ subscribe: em.subscribe }))+ em.emit(iev({ nodeId: 'a' }))+ // The rejected fetch must not surface — flush swallows it (no retry queue).+ await vi.advanceTimersByTimeAsync(2000)+ expect(fetchMock).toHaveBeenCalledTimes(1)+ h.stop()+ })++ describe('inert gates (no POST)', () => {+ async function expectNoPost(over: Partial<PushNotifyDeps>): Promise<void> {+ const em = makeEmitter()+ const h = createPushNotify(baseDeps({ subscribe: em.subscribe, ...over }))+ em.emit(iev({ nodeId: 'a' }))+ await vi.advanceTimersByTimeAsync(2000)+ expect(fetchMock).not.toHaveBeenCalled()+ h.stop()+ }++ it('setting off', async () => {+ await expectNoPost({ mobilePushEnabled: () => false })+ })+ it('no relay host identity', async () => {+ await expectNoPost({ getHostIdentity: () => null })+ })+ it('no paired phone', async () => {+ await expectNoPost({ getHostIdentity: () => ({ ...IDENTITY, hasPairedPhone: false }) })+ })+ it('DO_NOT_TRACK', async () => {+ await expectNoPost({ env: { DO_NOT_TRACK: '1' } })+ })+ it('NODETERM_TELEMETRY_DISABLED', async () => {+ await expectNoPost({ env: { NODETERM_TELEMETRY_DISABLED: '1' } })+ })+ it('unpackaged without a local API base', async () => {+ await expectNoPost({ isPackaged: () => false, env: {} })+ })+ })++ it('stop() unsubscribes so later events are ignored', async () => {+ const em = makeEmitter()+ const h = createPushNotify(baseDeps({ subscribe: em.subscribe }))+ h.stop()+ em.emit(iev({ nodeId: 'a' }))+ await vi.advanceTimersByTimeAsync(2000)+ expect(fetchMock).not.toHaveBeenCalled()+ })+})diff --git a/src/core/push-notify.ts b/src/core/push-notify.tsnew file mode 100644index 000000000..7b6edc823--- /dev/null+++ b/src/core/push-notify.ts@@ -0,0 +1,186 @@+// Desktop → paired-phone APNs push (spec: nodeterm-server/docs/specs/2026-07-19-apns-push.md,+// "Desktop (nodeterm)" section).+//+// When an agent needs approval, asks a question, or finishes a turn, a paired iPhone should get a+// real APNs push even with the app backgrounded/killed. This service is fed by the SAME seam that+// produces the mobile Inbox feed — `onInboxActionable` in `agent-status-mirror.ts` — so it fires+// exactly on approval/question (post-dedup) and done (turn edge). It batches events in a short+// window and POSTs them to the backend, which fans out to the host's relay-paired phones.+//+// It lives in `src/core` (no electron imports) behind injected deps, so it is pure + unit-testable+// and both shells can boot it. In practice only the DESKTOP shell has a standing relay host+// identity + paired-phone registry to feed it — the Server Edition has neither, so it never+// constructs this (a documented, deliberate three-surfaces degrade; see src/server/index.ts).++import type { InboxEvent } from './agent-status-mirror'++const DEFAULT_API_BASE = 'https://api.nodeterm.dev'+// Batch actionable events landing close together into one POST (≤10 events/call per the contract).+const DEFAULT_BATCH_WINDOW_MS = 2000+// Per-node throttle — mirrors the local-notification throttle (5s/node): a chatty node can't+// spam pushes.+const DEFAULT_THROTTLE_MS = 5000+// Max events per POST (backend contract: events[≤10]).+const MAX_EVENTS_PER_CALL = 10+const FETCH_TIMEOUT_MS = 8000++/** The standing relay host's identity, needed for the backend's (hostDeviceId, hostId-from-pubkey)+ * auth. `hasPairedPhone` is what makes the service live at all — no paired phone ⇒ nowhere to fan+ * out to ⇒ inert. `null` from `getHostIdentity` (no relay host configured / key locked) is also+ * inert. */+export interface PushHostIdentity {+ hostDeviceId: string+ hostPublicKeyB64: string+ hostLabel: string+ hasPairedPhone: boolean+}++/** The per-event body the backend `/v1/push/notify` expects (a subset of InboxEvent). */+export interface PushNotifyEvent {+ kind: 'approval' | 'question' | 'done'+ title: string+ detail?: string+ nodeId: string+ agentId?: string+ ts: number+}++export interface PushNotifyDeps {+ /** Subscribe to actionable inbox events. In production this is `onInboxActionable`. */+ subscribe: (cb: (e: InboxEvent) => void) => () => void+ /** The standing relay host identity, or null when none is configured/available. */+ getHostIdentity: () => PushHostIdentity | null+ /** The `settings.mobilePushEnabled` gate (default on). */+ mobilePushEnabled: () => boolean+ /** `app.isPackaged` — dev never hits the prod API unless a local base is targeted. */+ isPackaged: () => boolean+ /** Override base URL. Defaults to `env.NODETERM_API_BASE || 'https://api.nodeterm.dev'`. */+ apiBase?: string+ /** Injectable env (DNT guards + local-dev base). Defaults to `process.env`. */+ env?: Record<string, string | undefined>+ /** Injectable fetch (tests mock it). Defaults to global `fetch`. */+ fetchImpl?: typeof fetch+ /** Injectable clock (tests). Defaults to `Date.now`. */+ now?: () => number+ batchWindowMs?: number+ throttleMs?: number+}++export interface PushNotifyHandle {+ /** Unsubscribe + cancel any pending flush. */+ stop(): void+ /** Test-only: force any buffered events to POST now. */+ _flushNow(): Promise<void>+}++/**+ * Wire the push-notify service. Subscribes to actionable inbox events, gates them (setting off /+ * no relay host / no paired phone / DNT / unpackaged all make it inert), throttles per node, and+ * batches the survivors into `POST {apiBase}/v1/push/notify`. Drops on any network error — there is+ * NO retry queue in v1. Everything is injected, so this is pure + unit-testable.+ */+export function createPushNotify(deps: PushNotifyDeps): PushNotifyHandle {+ const env = deps.env ?? process.env+ const apiBase = deps.apiBase ?? env.NODETERM_API_BASE ?? DEFAULT_API_BASE+ const fetchImpl = deps.fetchImpl ?? fetch+ const now = deps.now ?? Date.now+ const batchWindowMs = deps.batchWindowMs ?? DEFAULT_BATCH_WINDOW_MS+ const throttleMs = deps.throttleMs ?? DEFAULT_THROTTLE_MS++ const buffer: PushNotifyEvent[] = []+ const lastPushAt = new Map<string, number>()+ let batchTimer: ReturnType<typeof setTimeout> | null = null++ // Same build + DO_NOT_TRACK gate as check.ts: dev never hits the prod API unless a local server+ // is targeted explicitly.+ function allowed(): boolean {+ if (env.DO_NOT_TRACK || env.NODETERM_TELEMETRY_DISABLED) return false+ if (!deps.isPackaged() && !env.NODETERM_API_BASE) return false+ return true+ }++ /** Live identity IFF the service is enabled and there's a paired phone to reach; else null. */+ function liveIdentity(): PushHostIdentity | null {+ if (!allowed()) return null+ if (!deps.mobilePushEnabled()) return null+ const id = deps.getHostIdentity()+ if (!id || !id.hasPairedPhone) return null+ return id+ }++ function scheduleFlush(): void {+ if (batchTimer) return+ batchTimer = setTimeout(() => {+ batchTimer = null+ void flush()+ }, batchWindowMs)+ batchTimer.unref?.()+ }++ function onEvent(e: InboxEvent): void {+ // Cheap gate first: if the service is inert, don't buffer anything.+ if (!liveIdentity()) return+ const t = now()+ // Per-node throttle: at most one push per node per `throttleMs` (mirrors the local notify+ // throttle). Recorded at accept time — a declined event costs no throttle window.+ if (t - (lastPushAt.get(e.nodeId) ?? -Infinity) < throttleMs) return+ lastPushAt.set(e.nodeId, t)+ buffer.push({+ kind: e.kind,+ title: e.title,+ ...(e.detail ? { detail: e.detail } : {}),+ nodeId: e.nodeId,+ ...(e.agentId ? { agentId: e.agentId } : {}),+ ts: e.ts+ })+ scheduleFlush()+ }++ async function flush(): Promise<void> {+ if (buffer.length === 0) return+ // Re-check the gate at flush: identity/setting can change during the batch window.+ const id = liveIdentity()+ if (!id) {+ buffer.length = 0+ return+ }+ const events = buffer.splice(0, MAX_EVENTS_PER_CALL)+ // More than one call's worth accumulated in the window — send the rest right after.+ if (buffer.length > 0) scheduleFlush()++ const body = {+ hostDeviceId: id.hostDeviceId,+ hostPublicKeyB64: id.hostPublicKeyB64,+ hostLabel: id.hostLabel,+ events+ }+ const ctrl = new AbortController()+ const timer = setTimeout(() => ctrl.abort(), FETCH_TIMEOUT_MS)+ try {+ await fetchImpl(`${apiBase}/v1/push/notify`, {+ method: 'POST',+ headers: { 'content-type': 'application/json' },+ body: JSON.stringify(body),+ signal: ctrl.signal+ })+ } catch {+ // Drop on any network error — v1 has no retry queue (the phone still polls the mirror).+ } finally {+ clearTimeout(timer)+ }+ }++ const unsubscribe = deps.subscribe(onEvent)++ return {+ stop() {+ unsubscribe()+ if (batchTimer) {+ clearTimeout(batchTimer)+ batchTimer = null+ }+ buffer.length = 0+ },+ _flushNow: flush+ }+}diff --git a/src/main/index.ts b/src/main/index.tsindex 2f2515e13..899b60527 100644--- a/src/main/index.ts+++ b/src/main/index.ts@@ -1,6 +1,6 @@import { join, resolve, posix } from 'path'import { readFile } from 'fs/promises'-import { homedir } from 'os'+import { homedir, hostname } from 'os'import { randomUUID } from 'crypto'import { app, BrowserWindow, dialog, ipcMain, Notification, powerMonitor, shell, systemPreferences } from 'electron'import { IPC } from '../shared/ipc'@@ -27,8 +27,11 @@ import {setMirrorSettingsProvider,setMirrorUsageProvider,buildMirrorUsage,+ onInboxActionable,type MirrorSettings} from '../core/agent-status-mirror'+import { createPushNotify } from '../core/push-notify'+import { getDeviceId } from '../core/device-id'import { initRemoteStatusPush } from './remote-ssh/remote-status-push'import { initCanvasSync } from '../core/canvas-sync'import { retainUntilDismissed } from './notifications'@@ -87,6 +90,7 @@ import { killRelayHostsByPeerKey } from './remote/relay-host'import { initRelayHost } from './remote/relay-host-service'import { createRevoker } from './remote/revocation'import { loadApprovedDevices, saveApprovedDevices } from './remote/approved-devices'+import { publicKeyToB64 } from './remote/e2ee'import { connectRelayClient, type RelayClientSession } from './remote/relay-client'import { decodeOffer } from './remote/pairing'import { loadOrCreatePeerKeyPair } from './remote/peer-identity'@@ -693,6 +697,43 @@ app.whenReady().then(async () => {.map((a) => ({ id: a.id, dir: claudeConfigDirFor(a.id) }))}})+ // Desktop → paired-phone APNs push (spec: apns-push). Feeds off the SAME actionable-event seam+ // the mobile Inbox uses (`onInboxActionable`), so it fires exactly on approval/question (post-+ // dedup) + done (turn edge). It's inert unless a phone has been paired (an approved device is+ // pinned) — that's the "standing relay host configured/paired" gate. The host public key+ // (identity every paired phone pinned) + paired flag load async and refresh on a cheap interval,+ // so a mid-run pairing / keyring-unlock is picked up without re-wiring; the getter is sync.+ let pushHostKeyB64: string | null = null+ let pushHasPairedPhone = false+ const refreshPushIdentity = async (): Promise<void> => {+ try {+ pushHostKeyB64 = publicKeyToB64((await loadOrCreateKeyPair()).publicKey)+ } catch {+ // Keyring locked / transient read error: keep the last-known key (never clobber identity).+ }+ try {+ pushHasPairedPhone = (await loadApprovedDevices()).pubkeys.length > 0+ } catch {+ pushHasPairedPhone = false+ }+ }+ void refreshPushIdentity()+ const pushIdentityTimer = setInterval(() => void refreshPushIdentity(), 60_000)+ pushIdentityTimer.unref?.()+ createPushNotify({+ subscribe: onInboxActionable,+ getHostIdentity: () =>+ pushHostKeyB64+ ? {+ hostDeviceId: getDeviceId(),+ hostPublicKeyB64: pushHostKeyB64,+ hostLabel: hostname(),+ hasPairedPhone: pushHasPairedPhone+ }+ : null,+ mobilePushEnabled: () => settingsStore.get().mobilePushEnabled !== false,+ isPackaged: () => app.isPackaged+ })// And push each connected SSH project's slice of it onto its host// (`~/.nodeterm/agent-status-<projectId>.json`): hook events tunnel from the host to THIS// process, so that file is the only agent-status source a phone browsing the host directlydiff --git a/src/renderer/components/settings/sections/NotificationsSection.tsx b/src/renderer/components/settings/sections/NotificationsSection.tsxindex 8c5d7c655..0190cf1ca 100644--- a/src/renderer/components/settings/sections/NotificationsSection.tsx+++ b/src/renderer/components/settings/sections/NotificationsSection.tsx@@ -10,12 +10,17 @@ const ROWS = {notify: {title: 'Notify when a turn finishes in the background',keywords: ['notify', 'notification', 'claude', 'background', 'turn', 'done']+ },+ mobilePush: {+ title: 'Send push notifications to your paired phone',+ keywords: ['push', 'phone', 'mobile', 'apns', 'ios', 'notification', 'approval']}}const ENTRIES = Object.values(ROWS)export function NotificationsSection({ isActive }: { isActive: boolean }): React.JSX.Element {const notifyOnClaudeDone = useSettings((s) => s.settings.notifyOnClaudeDone)+ const mobilePushEnabled = useSettings((s) => s.settings.mobilePushEnabled)const update = useSettings((s) => s.update)// The OS refused our test notification (macOS permission denied). macOS never re-prompts// once the app's record exists, so the only way back is the System Settings pane.@@ -63,6 +68,19 @@ export function NotificationsSection({ isActive }: { isActive: boolean }): React</div>)}</SearchableRow>+ <SearchableRow {...ROWS.mobilePush}>+ <FieldRow+ label="Send push notifications to your paired phone"+ description="Fires when an agent needs approval, asks a question, or finishes — only if you've paired a phone."+ control={+ <Switch+ checked={mobilePushEnabled}+ ariaLabel="Mobile push notifications"+ onChange={(on) => update({ mobilePushEnabled: on })}+ />+ }+ />+ </SearchableRow></SettingsSection>)}diff --git a/src/server/index.ts b/src/server/index.tsindex 7e2b7cb88..314ad6736 100644--- a/src/server/index.ts+++ b/src/server/index.ts@@ -177,6 +177,15 @@ export async function startServer(}})wireAgentStatus(platform)+ // Desktop → paired-phone APNs push (spec: apns-push) is DELIBERATELY not wired here. The push+ // service (`src/core/push-notify.ts`) fans actionable inbox events out to a host's relay-PAIRED+ // phones, keyed by the standing relay host's identity (public key + hostDeviceId) and the+ // pinned-device registry. The Server Edition has no standing relay host — no host keypair, no+ // approved-devices store, no host-token mint (all live in src/main/remote/) — so there is no+ // identity to sign the fan-out and no paired-phone list to reach. A phone talks to a server-+ // edition host over SSH and keeps polling the mirror. So the service would be permanently inert+ // here; we leave it unwired rather than construct a no-op. (Three-surfaces rule: documented+ // desktop-only.)// `installHooks: false` (tests) skips the merge into the user's real ~/.claude et al —// the hook it would write points into `dataDir`, which a test then deletes.if (config.installHooks !== false) {diff --git a/src/shared/types.ts b/src/shared/types.tsindex 1ee74d4bc..31a677a44 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -558,6 +558,10 @@ export interface Settings {/** Keep a standing relay host connection so a paired phone can reach this Mac from anywhere* (end-to-end encrypted). Pro-only; default off. Toggle in Settings → Phone. */phoneAccessEnabled: boolean+ /** Send APNs push notifications to relay-paired phones when an agent needs approval, asks a+ * question, or finishes a turn (spec: apns-push). Default on — it only fires for users who+ * have paired a phone. Toggle in Settings → Notifications. */+ mobilePushEnabled: boolean/** Dictation (desktop/server). Written as a whole object by the renderer. */speech: SpeechSettings}@@ -597,6 +601,7 @@ export const DEFAULT_SETTINGS: Settings = {claudePermissionMode: 'auto',telemetryEnabled: false,phoneAccessEnabled: false,+ mobilePushEnabled: true,speech: { engine: 'whisper', model: 'tiny', language: 'auto', shortcut: 'Cmd+Alt+D' },}