Skip to content

feat(desktop): re-enable proactive notifications at Balanced by default (focus + insights) - #11479

Merged
kodjima33 merged 3 commits into
mainfrom
kodjima33/notifications-balanced-default
Aug 13, 2026
Merged

kodjima33 merged 3 commits into
mainfrom
kodjima33/notifications-balanced-default

Conversation

@kodjima33

@kodjima33 kodjima33 commented Aug 13, 2026 •

Copy link
Copy Markdown
Collaborator

Re-enable proactive notifications at Balanced by default

Summary

Replaces the notifications-off-by-default migration (48239de8, PR #7681) with a one-time balanced-by-default re-enable:

  • Users at Off — and fresh installs with no stored level — move to frequency 3 (Balanced) once at launch. Any explicit opt-in level (1–5) is kept.
  • Turning notifications off after the migration sticks: the run-once flag (notificationsBalancedByDefaultMigrationDone) guarantees no re-enable on later launches.
  • Per-assistant toggles are untouched, so only the default-on categories fire: Live Suggestions (focus nudges) and Insight. Task and Memory notifications stay opt-in.
  • The backend push rides the existing pending-sync journal (beginNotificationSettingsSync) and the shared NotificationSettingsSyncQueue (moved from the Settings pane into NotificationService, now taking enabled: Bool?): a failed PATCH (offline, signed out during onboarding) is retried by the next Settings load, and the launch push is ordered behind any frequency change the user makes right after startup, so a slow migration PATCH can never overwrite a newer user choice.
  • The backend default (get_notification_settings → frequency 0) is deliberately unchanged, so users on current stable builds are unaffected. Beta picks this up with the next beta release; stable inherits it automatically when that release is promoted to stable — no backend flip or second change needed.

Product invariants affected

  • INV-AUTH-1 — path-matched only (OmiApp.swift launch sequence swaps one migration call; NotificationService.swift settings-sync statics). No auth/session behavior changes.

Verification

  • xcrun swift test --package-path Desktop --filter UserNotificationCallbackBridgeTests — 11/11 pass, including two new regression tests: fresh-install/off users migrate to Balanced exactly once and write the key (so backend off-default cannot hydrate 0 over it); explicit user levels are never overridden; a user who re-disables after the migration is never re-enabled.
  • Real path: built and ran a named dev bundle (omi-notif-balanced, dev backend, seeded account). On first launch the migration set notification_frequency=3, set the flag, and the backend PATCH completed (pending-sync journal cleared). Settings → Notifications & Privacy shows master ON, Frequency Balanced, Live Suggestions ON, Insight ON, Task OFF, Memory OFF — hydrated from the server, confirming the round-trip. State survived two relaunches. Re-verified end-to-end after routing the push through the shared queue (reset migration state, relaunched: frequency=3, flag set, queued PATCH completed).
  • Independent agent review: approved ("correct, tightly scoped, well-tested"); its one actionable finding — the bare-Task push being unordered vs user PATCHes — is fixed in the second commit. Its second note (a fresh install on a second machine pushes Balanced over an explicit non-zero level set elsewhere) is accepted intent: a fresh beta install re-enabling at Balanced is the point of this change.
  • Server-authoritative hydration observed working: a locally forged frequency (0) with no pending journal entry was corrected back to the server value on Settings load — the identical path that keeps a real user's slider choice authoritative across devices.
  • UNVERIFIED end-to-end: dragging the slider to Off through the real UI and relaunching (custom SwiftUI slider is not reachable cursor-free); the guard for that path is unit-tested (testBalancedDefaultMigrationNeverOverridesAnExplicitUserChoice) and the slider/persistence code is untouched by this PR.

Rider: unblocks a red main

A third commit repairs APIClientAssistantSettingsTests (added in 38d3b8e yesterday), which asserted that the shipped default task prompt fits its sync bound — never true (~13.7k chars vs the 10k backend bound since at least June), so the desktop Swift suite was red on main and blocked this PR's gate and the hourly release train. The tests now assert the shipped contract (oversized default prompt is omitted from sync; all three assistants share the 10k bound); the intended bound raise with its backend-deploy sequencing is tracked in #11481.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 5 files

Confidence score: 2/5

  • In desktop/macos/Desktop/Sources/ProactiveAssistants/Services/NotificationService.swift, queued migration retries are not account-bound, so a sign-out/account switch can apply one user’s pending Balanced state to another account; this is the highest-risk regression because it can mutate the wrong user state — bind each queued journal entry to its author and validate identity before replay.
  • In desktop/macos/Desktop/Sources/OmiApp.swift, the completion marker can be written before the PATCH is journaled, so an app termination in that window can leave backend notifications Off while future launches permanently skip the migration — persist pending-sync intent before marking completion (or make completion contingent on durable journaling).
  • In desktop/macos/changelog/unreleased/20260813-notifications-balanced-default.json, the changelog format doesn’t match the repo’s single verb-led sentence convention; low product risk, but it can cause release-note inconsistency — rewrite as one concise user-facing sentence.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="desktop/macos/Desktop/Sources/ProactiveAssistants/Services/NotificationService.swift">

<violation number="1" location="desktop/macos/Desktop/Sources/ProactiveAssistants/Services/NotificationService.swift:25">
P1: When a user signs out or switches accounts while this migration is queued, the retry can apply the previous account's pending Balanced state to the newly signed-in account. Bind each queued journal entry to its authorization owner and discard or rebase it when the owner changes before retrying.</violation>
</file>

<file name="desktop/macos/changelog/unreleased/20260813-notifications-balanced-default.json">

<violation number="1" location="desktop/macos/changelog/unreleased/20260813-notifications-balanced-default.json:2">
P3: Per the changelog convention in AGENTS.md/README, entries should be a single verb-led user-perspective sentence ("Fixed X", "Added Y", "Improved Z"). This entry is a multi-clause descriptive statement joined by em-dash/semicolons, unlike the surrounding fragments which open with a verb. Phrase it from the user's perspective with a leading verb, e.g. "Re-enabled proactive notifications at Balanced by default, keeping them limited to focus suggestions and insights while task and memory stay opt-in."</violation>
</file>

<file name="desktop/macos/Desktop/Sources/OmiApp.swift">

<violation number="1" location="desktop/macos/Desktop/Sources/OmiApp.swift:345">
P2: If the app terminates after this migration writes the completion marker but before it journals the PATCH, the backend remains Off and the next launch skips the migration permanently. Persist the pending-sync intent before marking the migration complete, or make startup recover whenever the local migration state is not acknowledged by the backend.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic


/// `enabled: nil` leaves the master toggle untouched server-side (used by the
/// launch migration, which only moves the frequency).
func enqueue(enabled: Bool?, frequency: Int, revision: Int) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: When a user signs out or switches accounts while this migration is queued, the retry can apply the previous account's pending Balanced state to the newly signed-in account. Bind each queued journal entry to its authorization owner and discard or rebase it when the owner changes before retrying.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Sources/ProactiveAssistants/Services/NotificationService.swift, line 25:

<comment>When a user signs out or switches accounts while this migration is queued, the retry can apply the previous account's pending Balanced state to the newly signed-in account. Bind each queued journal entry to its authorization owner and discard or rebase it when the owner changes before retrying.</comment>

<file context>
@@ -10,6 +10,33 @@ private struct UNCompletionHandlerBox: @unchecked Sendable {
+
+  /// `enabled: nil` leaves the master toggle untouched server-side (used by the
+  /// launch migration, which only moves the frequency).
+  func enqueue(enabled: Bool?, frequency: Int, revision: Int) {
+    let previous = tail
+    tail = Task {
</file context>

// Proactive notifications are back ON by default at Balanced (focus/insight
// categories only). Run the one-time migration before any assistant can fire;
// turning notifications off again in Settings sticks.
NotificationService.migrateToBalancedDefaultIfNeeded()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: If the app terminates after this migration writes the completion marker but before it journals the PATCH, the backend remains Off and the next launch skips the migration permanently. Persist the pending-sync intent before marking the migration complete, or make startup recover whenever the local migration state is not acknowledged by the backend.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Sources/OmiApp.swift, line 345:

<comment>If the app terminates after this migration writes the completion marker but before it journals the PATCH, the backend remains Off and the next launch skips the migration permanently. Persist the pending-sync intent before marking the migration complete, or make startup recover whenever the local migration state is not acknowledged by the backend.</comment>

<file context>
@@ -339,10 +339,10 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate, @unchecked S
+    // Proactive notifications are back ON by default at Balanced (focus/insight
+    // categories only). Run the one-time migration before any assistant can fire;
+    // turning notifications off again in Settings sticks.
+    NotificationService.migrateToBalancedDefaultIfNeeded()
 
     // Force macOS to use the correct app icon (bypasses icon cache).
</file context>

@@ -0,0 +1,3 @@
{
"change": "Proactive notifications are on by default again at Balanced — focus suggestions and insights only; task and memory notifications stay opt-in, and your own frequency choice is kept"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Per the changelog convention in AGENTS.md/README, entries should be a single verb-led user-perspective sentence ("Fixed X", "Added Y", "Improved Z"). This entry is a multi-clause descriptive statement joined by em-dash/semicolons, unlike the surrounding fragments which open with a verb. Phrase it from the user's perspective with a leading verb, e.g. "Re-enabled proactive notifications at Balanced by default, keeping them limited to focus suggestions and insights while task and memory stay opt-in."

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/changelog/unreleased/20260813-notifications-balanced-default.json, line 2:

<comment>Per the changelog convention in AGENTS.md/README, entries should be a single verb-led user-perspective sentence ("Fixed X", "Added Y", "Improved Z"). This entry is a multi-clause descriptive statement joined by em-dash/semicolons, unlike the surrounding fragments which open with a verb. Phrase it from the user's perspective with a leading verb, e.g. "Re-enabled proactive notifications at Balanced by default, keeping them limited to focus suggestions and insights while task and memory stay opt-in."</comment>

<file context>
@@ -0,0 +1,3 @@
+{
+  "change": "Proactive notifications are on by default again at Balanced — focus suggestions and insights only; task and memory notifications stay opt-in, and your own frequency choice is kept"
+}
</file context>

One-time client migration replaces the off-by-default migration: users at
Off (or fresh installs) move to frequency 3 (Balanced); any explicit opt-in
level is kept, and turning notifications off after the migration sticks.
Per-assistant toggles are untouched, so only the default-on categories
(Live Suggestions, Insight) fire; Task and Memory stay opt-in. The backend
push rides the pending-sync journal so a failed push is retried by the next
Settings load instead of being hydrated away.

Backend default stays 0, so current stable builds are unaffected: beta picks
this up on the next beta release, and stable inherits it automatically when
that release is promoted to stable.
…TCHes

Moves NotificationSettingsSyncQueue from the Settings pane into
NotificationService and routes the balanced-by-default migration push
through it with enabled: nil. A slow launch push can no longer land
after — and overwrite — a frequency change the user makes right after
startup, and the wire shape stays frequency-only like the old migration.

Independent-review finding; verified by relaunching the dev bundle with
reset migration state: frequency=3, flag set, queued PATCH completed
(pending-sync journal cleared).
The prompt-bound test repair landed on main via #11504; what remains here
is the down-only test-quality ratchet the checker asked for (55/148 -> 54/147).
Verification: python3 scripts/check_desktop_test_quality.py -> OK at 54/147.
@kodjima33
kodjima33 force-pushed the kodjima33/notifications-balanced-default branch from 34dcddd to 59556fe Compare August 13, 2026 17:11
@kodjima33
kodjima33 merged commit 56dddbd into main Aug 13, 2026
26 checks passed
@kodjima33
kodjima33 deleted the kodjima33/notifications-balanced-default branch August 13, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant