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.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
Keep new notification kinds on for saved lists; refuse empty Mac release notes
Lin (kwant bot)73cef4333df9
diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.ymlindex 8e572cd5..7169b309 100644--- a/.github/workflows/mac.yml+++ b/.github/workflows/mac.yml@@ -10,7 +10,7 @@ name: mac# sign it with the release key (secrets TAURI_SIGNING_PRIVATE_KEY / _PASSWORD) and a full release# publishes it with latest.json, which installed apps read from releases/latest/download/latest.json.# Pull requests and manual runs never see the release key: they sign with a throwaway key, so the-# same steps run without the secret. A full release needs a "## [Mac x.y.z]" CHANGELOG section,+# same steps run without the secret. A full release needs a non-empty "## [Mac x.y.z]" CHANGELOG section,# which becomes the update's notes.on:workflow_dispatch:@@ -67,8 +67,8 @@ jobs:if [ "$version" != "$base" ]; then echo "prerelease=true"; else echo "prerelease=false"; fi >> "$GITHUB_OUTPUT"# a full release's update notes are its CHANGELOG sectionif [ "$version" = "$base" ]; then- python3 -c 'import sys; sys.path.insert(0, "scripts"); import mac_latest_json as m; m.changelog_section(open("CHANGELOG.md").read(), sys.argv[1])' "$version" \- || { echo "::error::CHANGELOG.md has no \"## [Mac $version]\" section for the update notes"; exit 1; }+ python3 scripts/mac_latest_json.py --check-notes --version "$version" --changelog CHANGELOG.md \+ || { echo "::error::CHANGELOG.md needs a non-empty \"## [Mac $version]\" section for the update notes"; exit 1; }fidmg:@@ -117,7 +117,7 @@ jobs:run: |set -euo pipefailopenssl rand -hex 16 > "$RUNNER_TEMP/ci-updater.password"- npx --yes @tauri-apps/cli@2 signer generate --ci -w "$RUNNER_TEMP/ci-updater.key" -p "$(cat "$RUNNER_TEMP/ci-updater.password")" > /dev/null+ npx --yes @tauri-apps/[email protected] signer generate --ci -w "$RUNNER_TEMP/ci-updater.key" -p "$(cat "$RUNNER_TEMP/ci-updater.password")" > /dev/nullcp "$RUNNER_TEMP/ci-updater.key.pub" "$RUNNER_TEMP/updater.pub"- name: Release updater keyif: startsWith(github.ref, 'refs/tags/mac-v')@@ -144,7 +144,7 @@ jobs:TAURI_SIGNING_PRIVATE_KEY_PASSWORD=$(cat "$RUNNER_TEMP/ci-updater.password")export TAURI_SIGNING_PRIVATE_KEY TAURI_SIGNING_PRIVATE_KEY_PASSWORDfi- npx --yes @tauri-apps/cli@2 build --ci --target universal-apple-darwin --bundles app,dmg \+ npx --yes @tauri-apps/[email protected] build --ci --target universal-apple-darwin --bundles app,dmg \--config '{"bundle":{"createUpdaterArtifacts":true}}' -- --locked# The installed app only accepts an update whose signature matches the key built into it and# whose signed version matches latest.json (requireSignedVersion). Checked here with the same@@ -158,7 +158,7 @@ jobs:ls -l "$tarball" "$tarball.sig"version=$(python3 -c 'import json; print(json.load(open("'"$GITHUB_WORKSPACE"'/apps/mac/tauri.conf.json"))["version"])')python3 -m venv "$RUNNER_TEMP/sigvenv"- "$RUNNER_TEMP/sigvenv/bin/pip" install --quiet pynacl+ "$RUNNER_TEMP/sigvenv/bin/pip" install --quiet pynacl==1.6.2"$RUNNER_TEMP/sigvenv/bin/python" -I "$GITHUB_WORKSPACE/scripts/minisign_verify.py" \--pubkey "$RUNNER_TEMP/updater.pub" --file "$tarball" --signature "$tarball.sig" --version "$version"# the archive holds kwant.app and nothing elsediff --git a/scripts/mac_latest_json.py b/scripts/mac_latest_json.pyindex faa8097a..7104d380 100644--- a/scripts/mac_latest_json.py+++ b/scripts/mac_latest_json.py@@ -36,6 +36,15 @@ def changelog_section(changelog: str, version: str) -> str:raise ValueError(f"CHANGELOG.md has no '## [Mac {version}]' section")+def release_notes(changelog: str, version: str) -> str:+ """The update notes for a full release: its CHANGELOG section, which must say something+ besides `### ` headings."""+ notes = changelog_section(changelog, version)+ if not any(line.strip() and not line.startswith("#") for line in notes.splitlines()):+ raise ValueError(f"the CHANGELOG section for {version} is empty")+ return notes++def latest_json(version: str, signature: str, url: str, notes: str, pub_date: str) -> dict:if not VERSION.match(version):raise ValueError(f"'{version}' is not a release version (x.y.z); prereleases get no latest.json")@@ -58,15 +67,21 @@ def latest_json(version: str, signature: str, url: str, notes: str, pub_date: stdef main(argv=None) -> int:ap = argparse.ArgumentParser(description=__doc__.splitlines()[0])ap.add_argument("--version", required=True)- ap.add_argument("--signature", required=True, help="the .sig file the Tauri build wrote")- ap.add_argument("--url", required=True, help="where the release serves the .app.tar.gz")+ ap.add_argument("--check-notes", action="store_true",+ help="only check that the CHANGELOG section exists and isn't empty")+ ap.add_argument("--signature", help="the .sig file the Tauri build wrote")+ ap.add_argument("--url", help="where the release serves the .app.tar.gz")ap.add_argument("--changelog", default="CHANGELOG.md")ap.add_argument("--pub-date", help="RFC 3339; default now (UTC)")args = ap.parse_args(argv)+ if not args.check_notes and not (args.signature and args.url):+ ap.error("--signature and --url are required unless --check-notes")pub_date = args.pub_date or datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")try:with open(args.changelog, encoding="utf-8") as f:- notes = changelog_section(f.read(), args.version)+ notes = release_notes(f.read(), args.version)+ if args.check_notes:+ return 0with open(args.signature, encoding="utf-8") as f:signature = f.read()doc = latest_json(args.version, signature, args.url, notes, pub_date)diff --git a/scripts/test_mac_latest_json.py b/scripts/test_mac_latest_json.pyindex c8e942ba..e6e3f4e0 100644--- a/scripts/test_mac_latest_json.py+++ b/scripts/test_mac_latest_json.py@@ -51,6 +51,29 @@ class ChangelogSection(unittest.TestCase):self.assertEqual(m.changelog_section(CHANGELOG, "0.1.1"), "### Added\n- Older things.")self.assertEqual(m.changelog_section(CHANGELOG, "0.1.10"), "- Not 0.1.1.")+ def test_empty_notes_are_refused(self):+ changelog = "## Unreleased\n\n## [Mac 0.2.0] - 2026-11-01\n\n### Added\n\n## [Mac 0.1.2]\n- Old.\n"+ with self.assertRaises(ValueError):+ m.release_notes(changelog, "0.2.0")+ with self.assertRaises(ValueError):+ m.release_notes("## [Mac 0.2.0]\n\n## [Mac 0.1.2]\n- Old.\n", "0.2.0")+ self.assertEqual(m.release_notes(changelog, "0.1.2"), "- Old.")++ def test_check_notes_cli(self):+ with tempfile.TemporaryDirectory() as d:+ path = os.path.join(d, "CHANGELOG.md")+ with open(path, "w", encoding="utf-8") as f:+ f.write("## [Mac 0.2.0]\n### Fixed\n\n## [Mac 0.1.2]\n- Old.\n")+ with contextlib.redirect_stderr(io.StringIO()) as err:+ self.assertEqual(m.main(["--check-notes", "--version", "0.2.0", "--changelog", path]), 1)+ self.assertIn("empty", err.getvalue())+ with contextlib.redirect_stderr(io.StringIO()):+ self.assertEqual(m.main(["--check-notes", "--version", "0.3.0", "--changelog", path]), 1)+ out = io.StringIO()+ with contextlib.redirect_stdout(out):+ self.assertEqual(m.main(["--check-notes", "--version", "0.1.2", "--changelog", path]), 0)+ self.assertEqual(out.getvalue(), "", "a check writes no feed")+def test_missing_section_fails(self):with self.assertRaises(ValueError):m.changelog_section(CHANGELOG, "0.1.3")diff --git a/src/server/continuity.rs b/src/server/continuity.rsindex 3b5f5564..16f1c268 100644--- a/src/server/continuity.rs+++ b/src/server/continuity.rs@@ -1140,16 +1140,58 @@ pub async fn notify_settings_view(state: &AppState) -> (String, Vec<String>) {)}-/// Kinds the user wants to hear about; all of them unless set.+/// The kinds the saved `notify_on` list was chosen from. Kinds missing here came later and+/// count as on until the person unticks them.+pub const NOTIFY_KNOWN_SETTING: &str = "notify_known";+/// Kinds added after `notify_on` lists were first saved but before `notify_known` existed: a list+/// saved without `notify_known` was chosen from every kind but these.+const KINDS_SINCE_FIRST_LIST: [&str; 1] = ["app_update"];++/// Kinds the user wants to hear about; all of them unless set. A kind added after the list was+/// saved is on, so a new event isn't silently off for everyone who ever saved the settings.pub async fn notify_on(state: &AppState) -> Vec<String> {- state- .db- .get_setting("notify_on")- .await- .ok()- .flatten()- .and_then(|v| serde_json::from_str::<Vec<String>>(&v).ok())- .unwrap_or_else(|| NOTIFY_KINDS.iter().map(|k| k.to_string()).collect())+ let db = &state.db;+ let read = |key: &'static str| async move {+ db.get_setting(key)+ .await+ .ok()+ .flatten()+ .and_then(|v| serde_json::from_str::<Vec<String>>(&v).ok())+ };+ let Some(saved) = read("notify_on").await else {+ return NOTIFY_KINDS.iter().map(|k| k.to_string()).collect();+ };+ let known = read(NOTIFY_KNOWN_SETTING).await.unwrap_or_else(|| {+ NOTIFY_KINDS+ .iter()+ .filter(|k| !KINDS_SINCE_FIRST_LIST.contains(k))+ .map(|k| k.to_string())+ .collect()+ });+ effective_kinds(&saved, &known)+}++/// `saved` plus every kind that isn't in `known`, in `NOTIFY_KINDS` order.+pub fn effective_kinds(saved: &[String], known: &[String]) -> Vec<String> {+ NOTIFY_KINDS+ .iter()+ .filter(|k| saved.iter().any(|s| s == *k) || !known.iter().any(|s| s == *k))+ .map(|k| k.to_string())+ .collect()+}++/// Kinds this server can't raise, so its settings page doesn't offer them: the web app leaves+/// them out of a save, which must not read as the person turning them off.+fn unavailable_kinds(state: &AppState) -> Vec<&'static str> {+ if state.app_update.status().supported {+ Vec::new()+ } else {+ vec!["app_update"]+ }+}++fn all_kinds() -> Vec<String> {+ NOTIFY_KINDS.iter().map(|k| k.to_string()).collect()}/// Checks a webhook URL: https with a host, no credentials in it.@@ -1190,11 +1232,24 @@ pub async fn save_notify_settings(.await.map_err(|_| "could not save settings".to_string())?;}- if let Some(list) = on {+ if let Some(mut list) = on {+ // Kinds this server doesn't offer keep the person's earlier choice+ let current = notify_on(state).await;+ list.retain(|k| !unavailable_kinds(state).contains(&k.as_str()));+ for k in unavailable_kinds(state) {+ if current.iter().any(|c| c == k) {+ list.push(k.to_string());+ }+ }+ let list = effective_kinds(&list, &all_kinds());let value = serde_json::to_string(&list).unwrap_or_else(|_| "[]".into());db.set_setting("notify_on", &value).await.map_err(|_| "could not save settings".to_string())?;+ let known = serde_json::to_string(&all_kinds()).unwrap_or_else(|_| "[]".into());+ db.set_setting(NOTIFY_KNOWN_SETTING, &known)+ .await+ .map_err(|_| "could not save settings".to_string())?;}Ok(())}diff --git a/tests/app_update_test.rs b/tests/app_update_test.rsindex e4ad3a6e..379ed0a6 100644--- a/tests/app_update_test.rs+++ b/tests/app_update_test.rs@@ -15,7 +15,7 @@ use kwnt::{router::LayaRouter,server::{app_update_routes,- continuity::{SelfScope, TurnOrigin},+ continuity::{self, SelfScope, TurnOrigin},create_router, mcp_runtime, AppState,},tools::ToolRunner,@@ -240,3 +240,73 @@ async fn notifies_once_per_version() {Some("0.1.3"));}++/// Whether `notify_once` for a fresh version reaches the UI.+async fn update_notification_delivered(e: &Env, version: &str) -> bool {+ let mut events = e.state.event_sender.subscribe();+ assert!(app_update_routes::notify_once(&e.state, version).await);+ while let Ok(ev) = events.try_recv() {+ if matches!(ev, RuntimeEvent::Notify { ref kind, .. } if kind == "app_update") {+ return true;+ }+ }+ false+}++fn kinds(list: &[&str]) -> Vec<String> {+ list.iter().map(|k| k.to_string()).collect()+}++#[tokio::test]+async fn app_update_is_on_for_lists_saved_before_it_existed() {+ let e = setup(Some(Arc::new(FakeUpdater::default()))).await;+ // What a person who saved their notification settings before #78 has stored+ e.state.db.set_setting("notify_on", r#"["turn_finished","approval_needed"]"#).await.unwrap();+ let on = continuity::notify_on(&e.state).await;+ assert_eq!(on, kinds(&["turn_finished", "approval_needed", "app_update"]));+ assert!(update_notification_delivered(&e, "0.1.2").await);+ let (_, s) = call(&e.app, "GET", "/api/settings", None).await;+ assert!(s["notify_on"].as_array().unwrap().contains(&json!("app_update")), "the switch shows on: {s}");+}++#[tokio::test]+async fn an_explicit_untick_sticks_and_new_kinds_stay_on() {+ let e = setup(Some(Arc::new(FakeUpdater::default()))).await;+ e.state.db.set_setting("notify_on", r#"["turn_finished"]"#).await.unwrap();+ // The Mac app's settings page offers app_update; the person unticks it+ continuity::save_notify_settings(&e.state, None, Some(kinds(&["turn_finished", "question_asked"]))).await.unwrap();+ assert_eq!(continuity::notify_on(&e.state).await, kinds(&["turn_finished", "question_asked"]));+ assert!(!update_notification_delivered(&e, "0.1.2").await);+ // A later save that doesn't touch notify_on keeps it off+ continuity::save_notify_settings(&e.state, Some(String::new()), None).await.unwrap();+ assert!(!update_notification_delivered(&e, "0.1.3").await);+ // Kinds this list was chosen from are remembered, so only kinds added later default on+ let known: Vec<String> =+ serde_json::from_str(&e.state.db.get_setting(continuity::NOTIFY_KNOWN_SETTING).await.unwrap().unwrap()).unwrap();+ assert!(known.contains(&"app_update".to_string()));+ let all_but_update: Vec<String> =+ continuity::NOTIFY_KINDS.iter().filter(|k| **k != "app_update").map(|k| k.to_string()).collect();+ assert_eq!(+ continuity::effective_kinds(&kinds(&["turn_finished"]), &kinds(&["turn_finished", "app_update"])),+ all_but_update+ );+}++#[tokio::test]+async fn saving_off_the_mac_app_keeps_the_app_update_choice() {+ // Off the Mac app the settings page leaves app_update out of the save (#79)+ let e = setup(None).await;+ continuity::save_notify_settings(&e.state, None, Some(kinds(&["turn_finished"]))).await.unwrap();+ assert_eq!(continuity::notify_on(&e.state).await, kinds(&["turn_finished", "app_update"]), "default on survives");++ // Turned off in the Mac app, then saved from the VPS: still off+ e.state.db.set_setting("notify_on", r#"["turn_finished"]"#).await.unwrap();+ let all = serde_json::to_string(&continuity::NOTIFY_KINDS).unwrap();+ e.state.db.set_setting(continuity::NOTIFY_KNOWN_SETTING, &all).await.unwrap();+ assert_eq!(continuity::notify_on(&e.state).await, kinds(&["turn_finished"]));+ continuity::save_notify_settings(&e.state, None, Some(kinds(&["turn_finished", "approval_needed"]))).await.unwrap();+ assert_eq!(continuity::notify_on(&e.state).await, kinds(&["turn_finished", "approval_needed"]));+ // and a client there can't switch it on either+ continuity::save_notify_settings(&e.state, None, Some(kinds(&["turn_finished", "app_update"]))).await.unwrap();+ assert_eq!(continuity::notify_on(&e.state).await, kinds(&["turn_finished"]));+}diff --git a/tests/continuity_test.rs b/tests/continuity_test.rsindex 2572ea32..d6067539 100644--- a/tests/continuity_test.rs+++ b/tests/continuity_test.rs@@ -1578,7 +1578,7 @@ async fn webhook_setting_is_https_only_and_masked() {let (_, s) = req(&app, "GET", "/api/settings", None).await;assert_eq!(s["notify_webhook_url"], "••••••••");assert!(!s.to_string().contains("secret-topic"));- assert_eq!(s["notify_on"], json!(["routine_failed"]));+ assert_eq!(s["notify_on"], json!(["routine_failed", "app_update"]), "off the Mac app a save keeps app_update as it was");// Sending the mask back keeps itreq(