Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

feat(watchers): the first watcher asks for the notification permission while the user is there

purplea7c74ffcbdfe
diff --git a/src/lib/watchers/__tests__/watcher-run-guards.test.ts b/src/lib/watchers/__tests__/watcher-run-guards.test.ts
index c897b3eb..7c765307 100644
--- a/src/lib/watchers/__tests__/watcher-run-guards.test.ts
+++ b/src/lib/watchers/__tests__/watcher-run-guards.test.ts
@@ -49,3 +49,24 @@ describe('the cap of a watcher run', () => {
expect(usePermissionStore.getState().getEffectivePermissionForTool('shell_execute', 'terminal', 'phone-chat')).toBe('confirm')
})
})
+
+describe('the first watcher of an install', () => {
+ it('sends one quiet "set" notification, so the system asks for permission while the user is there', async () => {
+ const { vi } = await import('vitest')
+ const backend = await import('../../../api/backend')
+ const spy = vi.spyOn(backend, 'backendCall').mockResolvedValue(null as never)
+ const { useWatcherSettingsStore } = await import('../../../stores/watcherStore')
+ const { greetOnce } = await import('../tool-exec')
+ useWatcherSettingsStore.setState({ greeted: false, notify: true })
+ const made = { ...w, schedule: { kind: 'interval', minutes: 60 }, next_at: null } as Watcher
+ await greetOnce(made)
+ await greetOnce(made)
+ const notes = spy.mock.calls.filter(([cmd]) => cmd === 'watchers_notify')
+ expect(notes).toHaveLength(1)
+ expect(notes[0][1]).toMatchObject({ title: 'Watcher set', sound: false })
+ useWatcherSettingsStore.setState({ greeted: false, notify: false })
+ await greetOnce(made)
+ expect(spy.mock.calls.filter(([cmd]) => cmd === 'watchers_notify')).toHaveLength(1)
+ spy.mockRestore()
+ })
+})
diff --git a/src/lib/watchers/tool-exec.ts b/src/lib/watchers/tool-exec.ts
index a16b4aea..39fcbd7a 100644
--- a/src/lib/watchers/tool-exec.ts
+++ b/src/lib/watchers/tool-exec.ts
@@ -12,7 +12,7 @@ import { backendCall, isTauri } from '../../api/backend'
import { getProviderIdFromModel } from '../../api/providers/model-name'
import { useModelStore } from '../../stores/modelStore'
import { useAgentModeStore } from '../../stores/agentModeStore'
-import { useWatcherStore } from '../../stores/watcherStore'
+import { useWatcherStore, useWatcherSettingsStore } from '../../stores/watcherStore'
import { isPaidProvider } from '../send-window'
import { sendsToALanBackend } from '../lan-openai-slot'
import { asksAboutWatchers } from '../watcher-tool-names'
@@ -64,6 +64,17 @@ function clipTask(t: string): string {
return s.length > TASK_SHOWN ? `${s.slice(0, TASK_SHOWN - 1)}…` : s
}
+/** Once per install, while the user is at the computer: a short "set"
+ * notification, so the system asks for permission now and not with the
+ * first result. Only with notifications on. */
+export async function greetOnce(w: Watcher): Promise<void> {
+ const s = useWatcherSettingsStore.getState()
+ if (s.greeted || !s.notify) return
+ s.update({ greeted: true })
+ const next = w.next_at ? `next ${whenText(w.next_at, Date.now())}` : repeatText(w.schedule)
+ await backendCall('watchers_notify', { title: 'Watcher set', body: `${w.name} · ${next}. Results come here.`, sound: false }).catch(() => null)
+}
+
async function listing(): Promise<WatcherListing> {
const l = await backendCall<WatcherListing>('watchers_list')
useWatcherStore.getState().set(l)
@@ -118,6 +129,7 @@ export async function executeWatcherCreate(args: ToolArgs, run?: AgentRunContext
try {
const w = await backendCall<Watcher>('watchers_create', { spec })
void listing().catch(() => {})
+ void greetOnce(w)
const next = w.next_at ? whenText(w.next_at, Date.now()) : 'now'
return `Watcher "${w.name}" is set (id ${w.id.slice(0, 8)}): ${repeatText(w.schedule)}, next run ${next}. `
+ 'It runs as long as LU runs, also with the window closed, and ends when LU quits. The user sees it above the message box.'
diff --git a/src/stores/watcherStore.ts b/src/stores/watcherStore.ts
index 10240820..4d72a437 100644
--- a/src/stores/watcherStore.ts
+++ b/src/stores/watcherStore.ts
@@ -31,7 +31,13 @@ interface WatcherSettingsState {
sound: boolean
/** 'all': results and errors; 'errors': only when a run failed. */
notifyOn: WatcherNotifyOn
- update: (patch: Partial<Pick<WatcherSettingsState, 'notify' | 'sound' | 'notifyOn'>>) => void
+ /** The first watcher of this install has sent its "set" notification. On a
+ * Mac the first notification of an app brings the system's permission
+ * question, and the banner itself is then only filed away (live test
+ * 14.11.2026). So the question comes when the user makes a watcher and is
+ * at the computer, not with the first result at 3 a.m. */
+ greeted: boolean
+ update: (patch: Partial<Pick<WatcherSettingsState, 'notify' | 'sound' | 'notifyOn' | 'greeted'>>) => void
}
/** Settings → Agent → Watchers. Kept apart from the big settings blob: three
@@ -42,6 +48,7 @@ export const useWatcherSettingsStore = create<WatcherSettingsState>()(
notify: true,
sound: true,
notifyOn: 'all',
+ greeted: false,
update: (patch) => set(patch),
}),
{ name: 'lu-watcher-settings', version: 1, storage: safeJSONStorage() },