Repository navigation
feat(desktop): re-enable proactive notifications at Balanced by default (focus + insights) - #11479
Conversation
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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" | |||
There was a problem hiding this comment.
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.
34dcddd to
59556fe
Compare
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:notificationsBalancedByDefaultMigrationDone) guarantees no re-enable on later launches.beginNotificationSettingsSync) and the sharedNotificationSettingsSyncQueue(moved from the Settings pane intoNotificationService, now takingenabled: 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.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
OmiApp.swiftlaunch sequence swaps one migration call;NotificationService.swiftsettings-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.omi-notif-balanced, dev backend, seeded account). On first launch the migration setnotification_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).Taskpush 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.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.