Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

Mac app: App updates notification switch

Pixel (kwant bot)937ecdb60808
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1ddcd751..5208c930 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
shows why, with **Try again** and **Download manually**, and the current app keeps working.
Hiding the bar hides it for that version only. App settings → About shows the running version and
has **Check for updates**. Nothing shows outside the Mac app, and phones get only the About row.
+ In the Mac app, App settings → Notifications has an **App updates** switch for the update notification.
- **Vibration on Android phones.** The web app gives a short buzz when you send a message, answer a
question or approval card, press **Solve it**, **Done**, **Skip** or **Hand back**, and when a puzzle
is solved, with a different buzz for errors. A bot reply arriving while the app is on screen gives a
diff --git a/frontend/src/components/SettingsModal.tsx b/frontend/src/components/SettingsModal.tsx
index b3dd442c..09f83562 100644
--- a/frontend/src/components/SettingsModal.tsx
+++ b/frontend/src/components/SettingsModal.tsx
@@ -9,6 +9,8 @@ import {
MAX_LOCATION_CHARS,
NOTIFY_KINDS,
NotifyKind,
+ notifyKindsFor,
+ notifyOnToSave,
browserNotifyEnabled,
defaultTimeZone,
notificationPermission,
@@ -26,7 +28,7 @@ import { signedInDevicesVisible } from '../deviceSignIn';
import { ComputerModeControl, useComputerMode } from './ComputerModeSwitch';
import { useEngines } from '../useEngines';
import { LayaStatusRow } from './LayaStatus';
-import { AppUpdateAbout } from './AppUpdateBanner';
+import { AppUpdateAbout, useAppUpdate } from './AppUpdateBanner';
interface SettingsData {
anthropic_api_key: string;
@@ -91,6 +93,8 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, t
const [place, setPlace] = useState<{ timezone: string; location: string } | null>(null);
const [webhookUrl, setWebhookUrl] = useState('');
const [notifyOn, setNotifyOn] = useState<NotifyKind[]>(NOTIFY_KINDS.map((k) => k.id));
+ // The Mac app's update API answered: only then is there an App updates notification to switch
+ const appUpdates = useAppUpdate().model.status !== null;
const [browserNotify, setBrowserNotify] = useState(browserNotifyEnabled);
const [permission, setPermission] = useState(notificationPermission);
const [notifyEnv] = useState(() => readNotifyEnv());
@@ -215,7 +219,7 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, t
openai_api_key: openaiKey,
ollama_url: ollamaUrl,
notify_webhook_url: webhookUrl.trim(),
- notify_on: notifyOn,
+ notify_on: notifyOnToSave(notifyOn, appUpdates),
...(limits
? {
max_turns_per_agent: Number(limits.max_turns_per_agent),
@@ -666,7 +670,7 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, t
<div className="space-y-1.5" role="group" aria-labelledby="notify-kinds-label">
<p id="notify-kinds-label" className="text-xs font-medium text-zinc-400">Tell me when</p>
- {NOTIFY_KINDS.map((k) => (
+ {notifyKindsFor(appUpdates).map((k) => (
<label key={k.id} className="flex items-center gap-2 text-[11px] text-zinc-300">
<input
type="checkbox"
diff --git a/frontend/src/continuity.ts b/frontend/src/continuity.ts
index 061973c9..25f16012 100644
--- a/frontend/src/continuity.ts
+++ b/frontend/src/continuity.ts
@@ -112,7 +112,8 @@ export type NotifyKind =
| 'delegation_stalled'
| 'skill_proposed'
| 'question_asked'
- | 'human_step';
+ | 'human_step'
+ | 'app_update';
export const NOTIFY_KINDS: Array<{ id: NotifyKind; label: string }> = [
{ id: 'turn_finished', label: 'A bot finished replying' },
{ id: 'approval_needed', label: 'A bot needs your approval' },
@@ -124,6 +125,16 @@ export const NOTIFY_KINDS: Array<{ id: NotifyKind; label: string }> = [
{ id: 'human_step', label: 'A bot needs you in the browser' },
];
+/** Only the Mac app sends it (and only its server accepts it), so it is listed there alone. */
+export const APP_UPDATE_KIND: { id: NotifyKind; label: string } = { id: 'app_update', label: 'App updates' };
+
+/** The checkboxes under "Tell me when": App updates only in the Mac app. */
+export const notifyKindsFor = (appUpdates: boolean) => (appUpdates ? [...NOTIFY_KINDS, APP_UPDATE_KIND] : NOTIFY_KINDS);
+
+/** What to save: never app_update off the Mac app, whose server would refuse the unknown kind. */
+export const notifyOnToSave = (on: NotifyKind[], appUpdates: boolean) =>
+ appUpdates ? on : on.filter((k) => k !== APP_UPDATE_KIND.id);
+
/** Kinds also shown as an in-app toast while kwnt is visible (the others only matter in the background). */
export const TOAST_KINDS: NotifyKind[] = ['routine_failed', 'delegation_finished', 'delegation_stalled', 'skill_proposed', 'question_asked', 'human_step'];
diff --git a/frontend/tests/appUpdate.test.mjs b/frontend/tests/appUpdate.test.mjs
index fa3f9074..9dc3d39b 100644
--- a/frontend/tests/appUpdate.test.mjs
+++ b/frontend/tests/appUpdate.test.mjs
@@ -335,3 +335,29 @@ test('wired once: the banner in the shell, the About row in App settings, hidden
assert.match(src('components/SettingsModal.tsx'), /<AppUpdateAbout \/>/);
assert.match(src('components/AppUpdateBanner.tsx'), /if \(!view \|\| phone\) return null;/);
});
+
+const notify = await loadBundled(`export * from './src/continuity';`);
+
+test('App updates switch is listed only in the Mac app, after the other kinds', () => {
+ const ids = (on) => notify.notifyKindsFor(on).map((k) => k.id);
+ assert.ok(!ids(false).includes('app_update'));
+ assert.deepEqual(ids(false), notify.NOTIFY_KINDS.map((k) => k.id));
+ assert.equal(ids(true).at(-1), 'app_update');
+ assert.equal(notify.notifyKindsFor(true).at(-1).label, 'App updates');
+});
+
+test('app_update is saved in the Mac app and never sent to a server without it', () => {
+ const on = ['turn_finished', 'app_update'];
+ assert.deepEqual(notify.notifyOnToSave(on, true), on);
+ assert.deepEqual(notify.notifyOnToSave(on, false), ['turn_finished']);
+ // Switched off in the Mac app: stays off
+ assert.deepEqual(notify.notifyOnToSave(['turn_finished'], true), ['turn_finished']);
+});
+
+test('App settings shows the switch only when the update API is supported', () => {
+ const s = src('components/SettingsModal.tsx');
+ assert.match(s, /const appUpdates = useAppUpdate\(\)\.model\.status !== null;/);
+ assert.match(s, /notifyKindsFor\(appUpdates\)\.map/);
+ assert.match(s, /notify_on: notifyOnToSave\(notifyOn, appUpdates\)/);
+ assert.doesNotMatch(s, /\{NOTIFY_KINDS\.map/);
+});