Skip to content

feat(macos): proactive integration nudges + per-integration use-case onboarding - #11729

Merged
Git-on-my-level merged 20 commits into
BasedHardware:mainfrom
Archit-lal:feat/proactive-integration-nudges
Aug 19, 2026
Merged

Git-on-my-level merged 20 commits into
BasedHardware:mainfrom
Archit-lal:feat/proactive-integration-nudges

Conversation

@Archit-lal

@Archit-lal Archit-lal commented Aug 17, 2026 •

Copy link
Copy Markdown
Collaborator

What

When you bring an app to the front that Omi can connect to but you haven't connected yet, Omi offers the connection once — on a floating-bar card that says what the integration would do for you and what Omi would read.

Every integration also gets real onboarding copy. The Apps-tab connector sheets previously described a mechanism ("Import email history and follow-ups") above a Connect button; they now render a What you get section — three concrete things you can do afterwards, plus a plain statement of what Omi reads — from the same catalog the nudge reads. One source of truth, so a nudged user and a browsing user are told the same thing.

The integration catalog

IntegrationNudges/IntegrationNudgeCatalog.swift covers every connectable surface the macOS app has.

Integration Route Fires when you open
Google Calendar import calendar Calendar.app, Fantastical, Notion Calendar
Gmail import email a Gmail tab, or Mimestream
Local Files import local-files Finder
Apple Notes import apple-notes Notes.app
X import x an X tab
ChatGPT (memory import) import chatgpt — copy only
Claude (memory import) import claude — copy only
ChatGPT (MCP) export chatgpt ChatGPT.app or a ChatGPT tab
Claude (MCP) export claude Claude.app or a Claude tab
Gemini export gemini a Gemini tab
Notion export notion Notion.app
Obsidian export obsidian Obsidian.app
Claude Code / Codex / OpenClaw / Hermes / Agents export — copy only

Entries marked "copy only" carry onboarding copy but never nudge: a terminal window is not evidence that Claude Code is running in it, and asking someone sitting in ChatGPT to go export a memory file is a worse offer than the MCP connector on the same tool.

LinkedIn, Slack, Todoist, Asana, ClickUp, Google Tasks, Apple Health, Apple Reminders have no macOS connector, so they are deliberately absent — a nudge for an integration that doesn't exist is worse than silence. Todoist/Asana/ClickUp/Google Tasks exist on backend + mobile only; Apple Health and Apple Reminders are mobile-only.

Design decisions worth reviewing

Not a ProactiveAssistant. That pipeline only runs while screen monitoring is active, which requires Screen Recording. Connecting Gmail is exactly the setup a user does before granting broad capture, so gating the offer on capture would hide it from the people who need it most. The coordinator owns a plain NSWorkspace activation observer — the same shape as TrialBannerService — and needs no permissions at all for native-app triggers.

Delivery bypasses NotificationService. Its frequency slider ships at 0 (Off) after the off-by-default migration, so routing through it would leave this feature dark for nearly everyone. The master Notifications toggle is honored explicitly in the policy instead, the floating bar's own snooze is enforced by showNotification, and the feature carries its own budgets.

Budgets, not a frequency dial (IntegrationNudgePolicy, fully unit-tested): 3s dwell, 3-day per-integration cooldown, 3 lifetime nudges per integration, 30-minute global cooldown, 2 per rolling day, 7-day snooze on "Not now", permanent opt-out on "Never". Connecting resets an integration's history so a later disconnect can pitch again; opting out survives that.

The card keeps the standard 6s dismissal. An earlier revision gave it 14s — three buttons and three lines of copy is more to read than the usual one-sentence card — but that meant editing the shared asyncAfter timeout, which SwiftLint flags and whose baseline is down-only. A longer or dismissal-free card is worth doing as its own change, alongside the notchEndCard that has the same problem.

One known limitation, deliberately not fixed here. Export status is only partly owner-scoped: memoryExportConnectedAt is machine-global, so a second account on one Mac can have an export nudge suppressed by the first account's connection. Those keys back the Apps tab's shipped status rows and re-scoping them is a storage migration with its own review. The failure direction is a missed offer, never a wrong one — the same way every other unknown in this feature resolves — and it's documented at the call site.

Window titles never leave the machine. Browser-site matching happens locally and only the catalog's bounded trigger_id is emitted. Titles are not read at all for apps the user excluded from Rewind capture.

hasEverSynced vs isConnected (INV-INT-1). The Apps tab keeps its functional-probe-backed status. The nudge asks a different question — "have they already heard and taken this pitch?" — and reads the persisted answer. Using the probe would mean a user whose Gmail cookie expired gets pitched as if they had never set it up, which fights the tab's own reconnect affordance. The distinction is documented at both call sites.

Product invariants

  • INV-AUTH-1 — nudge history is owner-scoped and re-scoped on runtimeOwnerDidChange; no new session-invalidation path.
  • INV-CHAT-1 — unchanged; the card routes to the Apps tab, not chat.
  • INV-INT-1 — see hasEverSynced above. No new anchoring heuristic, no new automation; accepting opens the existing connector sheet through DesktopAutomationPresentationCoordinator, so there is no second connect path to drift.
  • INV-MEM-1 — unchanged; markConnected gains only a nudge-history reset.

Failure-Class: none

Line-Count-Exception: desktop/macos/Desktop/Sources/DesktopAutomationBridge.swift | 4577 -> 4602 | +25 for two thin QA action registrations; their bodies live in IntegrationNudges/IntegrationNudgeAutomation.swift, and every action in this file is registered here by design
Line-Count-Exception: desktop/macos/Desktop/Sources/FloatingControlBar/FloatingControlBarView.swift | 2708 -> 2713 | +5 for the card-type dispatch only; the card view itself is IntegrationNudges/IntegrationNudgeCard.swift
Line-Count-Exception: desktop/macos/Desktop/Sources/FloatingControlBar/FloatingControlBarWindow.swift | 5240 -> 5255 | +15: an exhaustive notification-action switch (so a future case cannot silently fall through to the conversation opener), the trigger id threaded into the accept handler, and one guard keeping connector copy out of the chat journal
Line-Count-Exception: desktop/macos/Desktop/Sources/MainWindow/Pages/AppsPage.swift | 3433 -> 3463 | +30 for one hasEverSynced accessor reading persisted keys, the value section, and threading the connect surface; the file's split is unrelated work
Line-Count-Exception: desktop/macos/Desktop/Sources/OmiApp.swift | 1597 -> 1606 | +9 to start the coordinator, with the comment explaining why it sits outside the signed-in branch
Line-Count-Exception: desktop/macos/Desktop/Sources/MemoryExportService.swift | 1581 -> 1604 | +19 to reset nudge history on connect from both authoritative paths (markConnected and the OAuth grant refresh that ChatGPT/assisted-Claude actually take), with the owner captured before the main-actor hop

Verification

  • xcrun swift build -c debug --package-path Desktop — clean
  • xcrun swift test --package-path Desktop — full desktop suite green
  • Live on a named bundle (omi-int-nudge), signed in:
    • integration_nudge_evaluate run against every catalog trigger through the real matcher + connection inspector + policy: Apple Notes, Finder, Notion, ChatGPT.app, Calendar.app, Obsidian all matched their integration with would_nudge=true; a Chrome window titled "LinkedIn" correctly matched nothing.
    • The card was presented through the real floating-bar path and captured (capture_floating_bar_png): Gmail brand mark, title, pitch, data-scope line, Connect / Not now / Never.
    • A real NSWorkspace activation of Notes delivered the card and persisted its budget (integrationNudge.v1.shownCount.import:apple-notes.<uid> = 1); a second activation was suppressed with connector_cooldown and presented nothing.
    • The Connect handler routed main window → Apps tab → the matching connector sheet, with its What you get section rendered.

Not verified by me: clicking the card with a real mouse. The machine's screen was locked for most of the session and computer-use access was declined, so the Connect button was exercised through its own handler rather than a synthetic click.

Review follow-ups (second commit)

  • Stale identity across awaits (cubic P1, real): reading the active window title and inspecting an export destination are both slow enough for the user to switch apps mid-flight, and the evaluation kept its pre-await identity — so a "Connect Apple Notes" card could land while the user was in Slack. Task cancellation does not help, because it never interrupts an await already in progress. The frontmost lookup and both async lookups are now injected, and three regression tests move the frontmost app (and the owner) during each await; reverting either guard fails exactly those three.

  • Recognition, attribution and budget accounting (third commit, nine more findings — all real): browser keywords were plain substrings, so x.com matched max.com and "Twitter" matched any page discussing Twitter; Edge Beta/Dev/Canary, Brave Nightly, Opera GX and ChatGPT Atlas were rejected before title matching; the connect window stored a bare id, letting a ChatGPT export nudge credit a ChatGPT import connect; .queued spent a lifetime offer on a card that may never reach the screen (now spent from the bar's onPresented); the Actioned event lost which trigger produced the card; ChatGPT and assisted Claude never reset nudge history because they reach connectedAt through the grant refresh, not markConnected; that reset could hit the wrong account across a fire-and-forget hop; the Settings copy said "once" for up to three offers and mislabelled the reset; and two tests guarded nothing (one compared a derivation to itself, and the analytics emitters bypassed AnalyticsManager's capture seam).

  • Attribution window (cubic P2): kept as-is, with the semantics now stated outright and pinned by two tests.

  • Later passes (commits 11–14): "Not now" stopped snoozing when a future-timestamp sanitizer was applied to snoozedUntil, which is a deadline — sanitizing is now limited to instants that can only be past, with a regression test; a queued card the bar did draw briefly spent no budget, which would have let one integration be offered repeatedly for free; the Integration Nudge Suppressed event was removed rather than tuned a fourth time, since every reason is derivable from the budgets plus the Shown events and the dominant states hold for days while Finder is activated constantly — its removal also deleted the session-token and dedup plumbing that existed only to bound it; nudge copy is no longer written into the user's conversation history; a browser re-check whose window title is unchanged now skips all its work; and the grouped "ChatGPT / Codex" sheet no longer shows ChatGPT's outcomes to someone picking Codex.

  • Restored deleted tests; telemetry join (tenth commit): a bulk edit removing the dead dwell parameter had also deleted the four regression tests proving the stale-identity fix — the seam they used was left behind unused, which is how the review caught it; they are restored. Also: nudge events emitted connector_id as the catalog telemetry id while the connect funnel emits the bare id under the same name, so the two families could not join (both are the bare id now, with a bounded route dimension); a queued card could spend the lifetime budget after the user had left the app; a late queue eviction reported into an unrelated window session, since the bar retains its callbacks across activations; a routine Gmail sync threw away an export cache it could not have invalidated; and a return XCTFail(...) inside nested loops aborted a whole catalog test rather than one case.

  • Owner resolved per access (ninth commit, five findings): the deferred re-scope still raced the transition fence, so the store now resolves the owner on every access and has no window to race; the attribution window and the export-status cache survived an account switch and are dropped on owner change; cooldown and snooze emitted on every activation for three and seven days respectively and are now ambient, leaving only the momentary set — the daily/global caps and a bar that could not draw; and an inline comment described a comparison that is not there.

  • Owner re-scope and report-once (eighth commit, five findings, all in the seventh commit's own code): runtimeOwnerDidChange is posted during revocation, so reading the owner synchronously in that handler returned nil and left the nudge store permanently unscoped — every read and write a no-op for the rest of the session; bar_unavailable was reported twice because the bar calls onDropped and then returns the refusal; snoozed/cooldown emitted on every browser re-check, and each reason is now reported once per watch session; a comment still described the owner guard removed in the previous commit; and the test presenter did not honour the bar's drop contract, which is why the double report was invisible.

  • Session recognition and ambient telemetry (seventh commit, eight findings from a fourth pass): shouldKeepWatching only continued on "nothing matched", so a user whose Gmail is already connected settled on a Gmail tab and was never offered ChatGPT after switching — alreadyConnected being the most common outcome, this quietly disabled browser nudges for the set-up users the export integrations target; the browser-chrome strip list named the Chromium browsers, which do not append their name on macOS, and omitted Firefox/Zen/Vivaldi, which do; signed-out and mid-onboarding emitted a suppressed event on every Finder activation; a queued card later dropped was invisible because the presenter passed no onDropped; "already connected" paid a full MCP config scan every activation and is now cached for a minute; the owner guard compared a raw default against a resolved runtime owner; and stop()/setFeatureEnabled had no callers.

  • Browser recognition rewritten (sixth commit): the fifth commit's switch to domain keywords broke recognition outright — a window title is the page's document.title, never its URL, so x.com/chatgpt.com/claude.ai/notion.so matched nothing a browser produces (verified live). Matching is now anchored to the end of the title, which is where sites put their own name ("Home / X", "Inbox (12) - [email protected] - Gmail", "ChatGPT"), and still rejects "ChatGPT vs Claude — a comparison". Notion web and Google Calendar web lose their triggers rather than getting a guess — Notion's titles are the page name alone, and Calendar leads with its name exactly as an article about it would; both keep their desktop apps. Also: the trigger-reachability test synthesized the keyword into a title so it matched by construction (which is why five dead triggers passed it) and now runs a fixture of real observed titles; dwellTooShort was unreachable and is gone, with dwell enforced where it actually happens; .notSignedIn at delivery bypassed the reporting helper; a bar that could not take the card produced no event at all and now reports bar_unavailable; and the settings card sat outside the master-notifications gate it depends on.

  • Recognition precision, gate ordering and telemetry volume (fifth commit, seven findings from a second local review — all real): bare product-name keywords (Notion, ChatGPT, Claude, Gemini) fired on any page mentioning the tool, so browser keywords are domains now, with Gmail keeping a separator form because its real title carries no domain; the export connection check — a scan of every local MCP config — ran before the policy could say "this user pressed Never"; a cached active-window snapshot up to two seconds old could have its title pinned to the newly-activated app, so the title is now used only when its own appName agrees; permanent suppressions (optedOut, connectorLifetimeCap) re-emitted a funnel event on every activation forever; the e2e flow asserted a cooldown its own earlier step never recorded, because the QA present path bypassed the coordinator — it now goes through the real delivery path; the class doc claimed a floating-bar snooze gate that does not exist, in the very paragraph justifying the NotificationService bypass; and the Settings toggle had two writers on one key.

  • Feature-off, loop, and attribution scope (fourth commit, seven findings from a local review of the above — all real): with suggestions switched off the feature still ran the Accessibility window-title read, inspected connectors and emitted suppressed telemetry on every activation, because the toggle was only consulted inside the policy — it is now read in handleActivation before any inspection; the browser re-check loop ran all six rounds regardless of the answer, so one Gmail activation emitted one Shown plus five Suppressed, and each evaluation now returns an Outcome where only an unrecognized window is worth re-checking; the attribution window was recorded for export routes whose connect emits no funnel, so five of the eight nudgeable entries recorded a claim nothing could consume; isConnected constructed a fresh ImportConnectorStatusStore per evaluation, whose init runs a legacy-key migration — dozens of main-actor defaults writes for a read-only question; dwellTooShort was unreachable because both call sites passed the constant, and now receives real elapsed time; the workspace observers drove the singleton rather than the instance that installed them; and a comment still promised the auto-dismiss that was reverted. It credits only the integration it names, for five minutes; an unrelated connect in between does not close it, because a user who accepted the Gmail nudge and finished the Gmail connect from the tab two minutes later was still moved by the nudge. The previous comment described it as a claim on one sheet, which is what made this ambiguous.

🤖 Generated with Claude Code

Product invariants affected

  • INV-AUTH-1
  • INV-CHAT-1
  • INV-INT-1
  • INV-MEM-1

Live verification on a real Mac (2026-08-18/19)

Built as a named bundle (omi-int-nudge), signed in as a real account, every app opened by hand. Cards were captured from the live floating bar; macOS screen capture cannot see that window, so these come from the app's own in-process capture of the same rendering.

Detection — verified

Each row is a real foreground activation on the machine, not a fixture.

Integration Opened Card shown
Google Calendar Calendar.app yes
Apple Notes Notes.app yes
Local Files Finder yes
Obsidian Obsidian.app yes
Gmail Chrome, real inbox tab yes
X Chrome, x.com yes
Gemini Chrome, gemini.google.com yes
Claude Claude.app yes — fired unprompted during normal use

Negative controls, all correctly silent: a LinkedIn feed, a blog article about Gmail, Notion in a browser tab, and a new tab.

Known defect — ChatGPT web never matches

chatgpt_web matches a browser-title suffix of ChatGPT. The live title is:

ChatGPT: Chat, Work, Create & Code with AI

It contains ChatGPT but does not end with it, so the rule misses and no card is shown. The unit test fed the matcher the string "ChatGPT", which passes — the fixture was invented, the real title differs. Not patched here on purpose: matching the marketing copy breaks whenever OpenAI edits it, and a prefix match would reintroduce the "page about the tool" false positives that suffix-anchoring exists to prevent. It needs a deliberate decision.

claude_web has the same shape and is unverified — Claude fired from the desktop app, not from a tab.

Crash found and fixed — WorkHistoryHandleExtractor

Pressing Connect on a card crashed the app, five times, with one signature:

EXC_BREAKPOINT (SIGTRAP)
  _dispatch_assert_queue_fail
  swift_task_checkIsolatedSwift
  VStack.init(alignment:spacing:content:)
  AppGridSection.body.getter

Root cause is in the stack, not in the nudge code. WorkHistoryHandleExtractor.liveSnapshot ran AXUIElementCopyAttributeValue against NSWorkspace.shared.frontmostApplication from a cooperative background thread. When Omi itself is frontmost, that is an in-process accessibility query, which AppKit services synchronously on the calling thread by driving NSHostingView.accessibilityChildren() — evaluating SwiftUI bodies right there, off the main actor. Any @MainActor state a body touches then trips Swift 6's isolation check.

Connecting from a card makes Omi frontmost, so it hit this every time, but the hazard is general: a plain dock click into Omi reaches the same path. Fixed by refusing to run the AX query against our own pid.

Attribution, measured rather than assumed: a fresh launch navigating straight to the Apps tab never crashed (2/2), while Connect-from-card crashed 5/5 before the fix. After the fix the same action completed and routed correctly, with no new crash reports.

Verification is thin: one successful Connect click post-fix, because the shipped budgets (30-minute global cooldown, 2/day) make rapid repeats slow. The fix is root-caused from the trace rather than guessed, and an earlier speculative fix — swapping a DispatchQueue.main.async for Task { @MainActor in } — was tried, failed to change the crash, and was reverted rather than left in.

No regression test ships with it: the path depends on NSWorkspace, live accessibility permission, and which app is frontmost, so any test would be non-hermetic and could not run in CI. It was verified by live reproduction instead.

Value verified through chat

Asked in the app, answered from integration data and checked against source:

  • X — recalled the correct post and its date (27 May 2026).
  • Local Files — 6,832 Python files with the real folders, from the on-device index.

Not verified

  • Completing a connection for Gmail, Google Calendar, X, and the ChatGPT/Claude MCP exports. All need an OAuth sign-in, which was out of scope for this session. The nudge, the click, and the routing to the correct connector sheet are verified for these; the sign-in that follows is not.
  • "Connected integrations stop nudging", end to end. The already_connected suppression was observed directly for Local Files while it was genuinely connected (33,774 files indexed), and disconnecting it made the offer return — but the full connect-then-reopen loop was not completed for any integration.
  • Notion and the ChatGPT desktop app are not installed on the test machine, so their app-launch rules were never exercised.

…onboarding

When you bring an app Omi integrates with to the front and have not connected
it, Omi now offers the connection once, on a floating-bar card that names what
the integration would do for you and what Omi would read.

`IntegrationNudges/IntegrationNudgeCatalog.swift` is the single source of truth
for every integration's value proposition, and the Apps-tab connector sheets
render the same copy — so a user who is nudged and a user who browses the tab
are told the same thing. Previously the sheets showed a one-line description of
a mechanism ("Import email history and follow-ups") above a Connect button,
which is not a reason to connect.

Design notes:
- Not a `ProactiveAssistant`: that pipeline requires Screen Recording, and
  connecting Gmail is exactly what a user does before granting broad capture.
- Delivery bypasses `NotificationService` because its frequency slider ships at
  0 (Off); the master Notifications toggle is honored explicitly instead, and
  the policy carries its own budgets (3s dwell, 3-day per-integration cooldown,
  3 lifetime per integration, 30-minute global cooldown, 2/day, 7-day snooze,
  permanent opt-out).
- Accepting opens the real connector sheet through the existing automation
  presentation coordinator, not a nudge-only connect path.
- Telemetry keys on catalog trigger ids, never on window titles or bundle ids.

Verification: full desktop Swift suite green; live on a named bundle a real
NSWorkspace activation of Notes delivered the card and persisted its budget,
a repeat activation was suppressed with `connector_cooldown`, and the Connect
handler routed to the Apps tab with the matching connector sheet open.

Co-Authored-By: Claude Opus 5 <[email protected]>

@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 36 files

Confidence score: 3/5

  • In desktop/macos/Desktop/Sources/IntegrationNudges/IntegrationConnectionInspector.swift, export-history state can leak across account switches (A → B), so B’s nudge may be incorrectly suppressed based on A’s status; this risks missed guidance for the active user — scope persisted export status by owner (or fetch owner-scoped snapshots before evaluating).
  • In desktop/macos/Desktop/Sources/IntegrationNudges/IntegrationConnectOrigin.swift, the .apps early return can leave a stale claim when another connector is connected first, causing a later Apps-tab connect of the nudged connector to be misattributed; this can skew origin tracking and downstream behavior — clear/reset the claim on this path before returning.
  • In desktop/macos/Desktop/Sources/AnalyticsManager.swift, nudge event methods bypass the test-capture boundary, so event names/payloads cannot be asserted in tests; this raises regression risk for instrumentation changes — add a nudge capture seam and boundary tests that exercise all three production methods.

You’re at about 96% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact [email protected].

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/IntegrationNudges/IntegrationConnectOrigin.swift">

<violation number="1" location="desktop/macos/Desktop/Sources/IntegrationNudges/IntegrationConnectOrigin.swift:38">
P2: When a different connector is connected before the nudged one, this guard returns `.apps` without clearing the claim. A later Apps-tab connect of the nudged connector within five minutes is then falsely reported as `.nudge`; consume or discard the claim on every connect attempt.</violation>
</file>

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

<violation number="1" location="desktop/macos/Desktop/Sources/AnalyticsManager.swift:283">
P2: These methods bypass AnalyticsManager’s test-capture boundary, so tests cannot verify that nudge events emit the correct names and payloads. Add a nudge capture seam and boundary tests that call all three production methods.</violation>
</file>

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

<violation number="1" location="desktop/macos/Desktop/Sources/IntegrationNudges/IntegrationConnectionInspector.swift:24">
P2: After switching from account A to B, this branch can suppress B's nudge using A's export history. Scope export status persistence by owner, or make the service return an owner-scoped status snapshot before using it for nudging.</violation>
</file>

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

Re-trigger cubic

Comment on lines +38 to +43
guard let claim,
claim.connectorID == connectorID,
now.timeIntervalSince(claim.claimedAt) < claimLifetime
else { return .apps }
self.claim = nil
return .nudge

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: When a different connector is connected before the nudged one, this guard returns .apps without clearing the claim. A later Apps-tab connect of the nudged connector within five minutes is then falsely reported as .nudge; consume or discard the claim on every connect attempt.

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

<comment>When a different connector is connected before the nudged one, this guard returns `.apps` without clearing the claim. A later Apps-tab connect of the nudged connector within five minutes is then falsely reported as `.nudge`; consume or discard the claim on every connect attempt.</comment>

<file context>
@@ -0,0 +1,49 @@
+    forConnectorID connectorID: String,
+    now: Date = Date()
+  ) -> IntegrationConnectTelemetry.Surface {
+    guard let claim,
+      claim.connectorID == connectorID,
+      now.timeIntervalSince(claim.claimedAt) < claimLifetime
</file context>
Suggested change
guard let claim,
claim.connectorID == connectorID,
now.timeIntervalSince(claim.claimedAt) < claimLifetime
else { return .apps }
self.claim = nil
return .nudge
guard let claim else { return .apps }
self.claim = nil
guard claim.connectorID == connectorID,
now.timeIntervalSince(claim.claimedAt) < claimLifetime
else { return .apps }
return .nudge


case .exportDestination(let destinationID):
guard let destination = MemoryExportDestination(rawValue: destinationID) else { return false }
let statuses = await MemoryExportService.shared.allStatuses()

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: After switching from account A to B, this branch can suppress B's nudge using A's export history. Scope export status persistence by owner, or make the service return an owner-scoped status snapshot before using it for nudging.

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

<comment>After switching from account A to B, this branch can suppress B's nudge using A's export history. Scope export status persistence by owner, or make the service return an owner-scoped status snapshot before using it for nudging.</comment>

<file context>
@@ -0,0 +1,28 @@
+
+    case .exportDestination(let destinationID):
+      guard let destination = MemoryExportDestination(rawValue: destinationID) else { return false }
+      let statuses = await MemoryExportService.shared.allStatuses()
+      return statuses[destination]?.hasConnection ?? false
+    }
</file context>

trigger: IntegrationNudgeTrigger,
shownCount: Int
) {
PostHogManager.shared.track(

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: These methods bypass AnalyticsManager’s test-capture boundary, so tests cannot verify that nudge events emit the correct names and payloads. Add a nudge capture seam and boundary tests that call all three production methods.

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

<comment>These methods bypass AnalyticsManager’s test-capture boundary, so tests cannot verify that nudge events emit the correct names and payloads. Add a nudge capture seam and boundary tests that call all three production methods.</comment>

<file context>
@@ -273,6 +273,56 @@ class AnalyticsManager {
+    trigger: IntegrationNudgeTrigger,
+    shownCount: Int
+  ) {
+    PostHogManager.shared.track(
+      IntegrationNudgeTelemetry.shownEventName,
+      properties: IntegrationNudgeTelemetry.shownPayload(
</file context>

Archit-lal and others added 19 commits August 17, 2026 02:57
Reading the active window title goes through the Accessibility API with a
timeout, and inspecting an export destination scans local MCP config files.
Either is slow enough for the user to switch apps mid-flight, and the evaluation
kept the identity it captured before the first await — so a card reading
"Connect Apple Notes" could land while the user was already in Slack.

Cancelling the task does not prevent this: cancellation never interrupts an
`await` already in progress, so the guard has to be an explicit re-check.

The frontmost lookup and both async lookups are now injected, which is what lets
the three regression tests move the frontmost app (and the signed-in owner)
*during* each await and assert no card is delivered. Reverting either guard
fails exactly those three.

Also states the connect-attribution window's semantics outright: it credits the
integration it names, for five minutes, and an unrelated connect in between does
not close it. That was ambiguous in the previous comment; it is now two tests.

Verification: xcrun swift test --filter "IntegrationNudge|IntegrationConnect" —
96 tests, 0 failures; the three new guards fail when the fix is reverted.

Co-Authored-By: Claude Opus 5 <[email protected]>
…ting

Nine findings from the automated review of the first two commits. Each is a
real defect in code this PR introduces:

- **`x.com` matched `max.com`.** Browser keywords were plain substrings, so
  every short keyword claimed a neighbourhood of unrelated sites. Matching is
  now token-bounded, and `"Twitter"` — which matched any page discussing
  Twitter — is replaced by the domains.
- **Missing browser variants.** Edge Beta/Dev/Canary, Brave Nightly, Opera GX
  and ChatGPT Atlas were rejected before title matching, silently disabling
  browser nudges for those users.
- **Cross-attribution between the two halves of the catalog.** The connect
  window stored a bare connector id, so an accepted ChatGPT *export* nudge could
  take credit for a ChatGPT *memory-import* connect. It now stores the route.
- **`.queued` spent the budget.** A queued card is admitted to a queue, not
  shown; a later drop burned one of the integration's three lifetime offers on a
  card nobody saw. The budget is now spent from the bar's `onPresented`
  callback.
- **Conversion was not attributable by trigger.** The Actioned event lost which
  trigger produced the card, so a native-app nudge and a browser-site nudge for
  the same integration were one row. `triggerID` now rides the action.
- **ChatGPT and assisted Claude never reset nudge history**, because they reach
  `connectedAt` through the grant refresh rather than `markConnected`. Both
  paths now clear it.
- **The reset could hit the wrong account.** It resolved the owner after a
  fire-and-forget main-actor hop; the owner is now captured before the hop and
  re-checked on the far side.
- **Settings copy said "once"** for what is up to three offers, and the reset
  button clears every integration's history rather than only hidden ones. Both
  now say what they do.
- **Two tests guarded nothing.** The catalog's nudgeable check compared a
  derivation to itself; it now asserts every declared trigger round-trips
  through the real matcher. The nudge analytics emitters bypassed
  AnalyticsManager's capture seam, so no test could see their event names — they
  now route through it, with boundary tests on all three.

Export status remains only partly owner-scoped: `memoryExportConnectedAt` is
machine-global, so a second account on one Mac can have an export nudge
suppressed by the first account's connection. Not fixed here — those keys back
the Apps tab's shipped status rows and re-scoping them is a storage migration
with its own review. The failure direction is a missed offer, never a wrong one;
documented at the call site.

Verification: xcrun swift test --package-path Desktop — 5508 tests, 0 failures.
SwiftLint 0 violations; desktop test-quality at baseline.

Co-Authored-By: Claude Opus 5 <[email protected]>
…window once

Seven findings from a local review of the previous commits. Each is real:

- **Switched off did all the work anyway.** The feature toggle was only read
  inside the policy, so with suggestions off every app activation still ran the
  Accessibility window-title read, inspected connectors, and emitted a
  suppressed event — and a frontmost browser re-read its title six more times.
  The toggle is now consulted in `handleActivation`, before any inspection, and
  `featureDisabled` no longer pollutes the funnel's denominator.
- **The re-check loop never stopped.** It ran all six rounds regardless of the
  answer, so one Gmail activation emitted one Shown plus five Suppressed. Each
  evaluation now returns an `Outcome`, and only an unrecognized window — a
  browser tab the user has not opened yet — is worth looking at again.
- **Export conversions could never be credited.** `consumeSurface` is called
  only from the import path, so for five of the eight nudgeable entries the
  attribution window was recorded and silently discarded. It is now opened only
  for imports, which are the routes that emit a connect funnel at all; export
  conversion is measured by `Integration Nudge Actioned`.
- **A read-only check was mutating.** `isConnected` built a fresh
  `ImportConnectorStatusStore` per evaluation, and its init runs a legacy-key
  migration — dozens of main-actor defaults writes per activation. The store is
  now reused per owner, and `hasEverSynced` reads the persisted keys directly so
  a retained instance cannot answer from a stale snapshot.
- **`dwellTooShort` was unreachable.** Both call sites passed the constant, so
  the gate could never fire and its telemetry reason could never appear.
  Evaluation now passes the real elapsed time since activation.
- **Observers drove the singleton** rather than the instance that installed
  them, which is wrong for a type with a fully injectable init. Now `[weak self]`.
- **A stale comment** promised a longer auto-dismiss that was reverted.

Verification: xcrun swift test --package-path Desktop — 5512 tests, 0 failures.
SwiftLint 0 violations.

Co-Authored-By: Claude Opus 5 <[email protected]>
…d telemetry

Seven more findings from a second local review. Each is real:

- **Bare product names matched any page mentioning the tool.** `"Notion"`,
  `"ChatGPT"`, `"Claude"`, `"Gemini"` fired on a blog post titled "ChatGPT vs
  Claude" or a GitHub page for `claude-code` — a wrong nudge, which the catalog
  itself says must never happen. Browser keywords are domains now. Gmail keeps a
  word form because its real title carries no domain ("Inbox (12) -
  [email protected] - Gmail"), so the separator makes it specific instead.
- **The expensive check ran before the cheap ones.** Inspecting an export
  destination scans and parses every local MCP config, and that ran before the
  policy could say "this user pressed Never". `decideWithoutConnectionState`
  settles everything that does not need connection state first.
- **A cached window title could be pinned to the wrong app.** The active-window
  lookup can answer from a snapshot up to two seconds old belonging to a
  different app, and its `appName` was discarded — so switching from a TextEdit
  window named "Gmail integration notes" into a browser could produce a Gmail
  nudge. The title is now used only when its own app agrees.
- **Permanent suppressions re-emitted forever.** A user who pressed "Never" on
  Notion emitted a suppressed event every time they focused Notion, for the life
  of the install, inflating the denominator that event exists to provide.
- **The e2e flow asserted a cooldown its own earlier step never recorded**,
  because the QA present path called `showNotification` directly and so never
  spent the budget. It now goes through the coordinator's real delivery path, so
  the flow's premise is true and the QA path cannot drift from production.
- **The class doc claimed a floating-bar snooze gate that does not exist** —
  and that paragraph is the justification for bypassing `NotificationService`,
  so it had to be accurate.
- **The Settings toggle had two writers** on one key (`@AppStorage` plus an
  explicit call), which only invites drift.

Verification: xcrun swift test --package-path Desktop — 5517 tests, 0 failures;
SwiftLint 0 violations. Live on a named bundle, the flow's own sequence now
holds: presenting Notion reports `delivered`, persists `shownCount = 1`, and a
following evaluate reports `would_nudge=false / connector_cooldown`.

Co-Authored-By: Claude Opus 5 <[email protected]>
The previous commit swapped browser keywords to domains to stop bare product
names firing on pages *about* a tool. That broke recognition outright: a window
title is the page's `document.title`, never its URL, so `x.com`, `chatgpt.com`,
`claude.ai`, `gemini.google.com` and `notion.so` matched nothing a browser
produces. Verified live — X, ChatGPT, Claude, Gemini and Notion web all stopped
being recognized.

What is reliable is where sites put their own name: at the end. X renders
"Home / X", Gmail "Inbox (12) - [email protected] - Gmail", ChatGPT just "ChatGPT".
Matching is now anchored to the end of the title, which keeps the real titles and
still rejects "ChatGPT vs Claude — a comparison". Browsers that append their own
product name are stripped first.

Two integrations lose their web trigger rather than getting a guess: Notion web
titles are the page name alone, and Google Calendar leads with its name exactly
as an article about it would. Both keep their desktop-app triggers.

Also from the same review:

- The trigger-reachability test synthesized the keyword into a title, so it
  matched by construction — which is precisely why five dead triggers passed it.
  It now runs a fixture of real observed titles per site, and a companion test
  asserts pages *about* each tool match nothing.
- `dwellTooShort` was unreachable: the coordinator sleeps the dwell and then
  passes an already-elapsed value, so the policy gate could never fire. Dwell is
  enforced where it actually happens — the sleep plus the frontmost re-check —
  and the dead gate, its input and its telemetry reason are gone.
- `.notSignedIn` at delivery time bypassed the reporting helper, so the one path
  that produces it emitted nothing.
- A bar that could not take the card produced neither a Shown nor a Suppressed
  event, making a whole class of never-delivered nudges invisible. It now
  reports `bar_unavailable`.
- The Integration Suggestions settings card sat outside the master-notifications
  gate it depends on, so with notifications off it showed as ON for a feature
  that cannot run.

Verification: xcrun swift test --package-path Desktop — 5508 tests, 0 failures;
SwiftLint 0 violations. Live on a named bundle, every real title above resolves
to its integration and every "page about the tool" resolves to nothing.

Co-Authored-By: Claude Opus 5 <[email protected]>
… events

Eight findings from a fourth review pass. Each is real:

- **One settled integration ended recognition for the whole browser session.**
  `shouldKeepWatching` only continued on "nothing matched", so a user whose
  Gmail is already connected settled at 3s on a Gmail tab and was never offered
  ChatGPT after switching tabs — with `alreadyConnected` being the most common
  outcome, this quietly disabled browser nudges for exactly the set-up users the
  export integrations target. Suppressions are now split into per-integration
  and global; only a global answer ends the session.
- **The browser-chrome strip list named the wrong browsers.** On macOS the
  Chromium browsers do not append their product name; Firefox, Zen and Vivaldi
  do, and none of them were stripped — so suffix matching failed on the browsers
  that need it most.
- **Signed-out and mid-onboarding emitted an event per activation.** Finder is a
  Local Files trigger and is activated constantly, so a signed-out user produced
  a suppressed event every few seconds for a state that cannot change until they
  sign in. Both are now part of the pre-inspection gate, so no work happens at
  all, and both are classified as ambient.
- **A queued card that was later dropped was invisible.** `showNotification`
  offers an `onDropped` callback and the presenter passed none, so the "owed but
  never drawn" class the code comments care about was silent. It now reports
  `bar_unavailable`.
- **"Already connected" paid a full MCP config scan on every activation.** The
  policy front-loads its cheap gates so an opted-out user never reaches the
  scan, but the most common terminal state can only be decided after it. Export
  statuses are cached for a minute and invalidated on connect.
- **The owner guard compared a raw default against a resolved runtime owner**,
  which differ by trimming, the non-production automation override, and the nil
  returned mid-transition — so it misfired on exactly the builds it is exercised
  on. Both sides now resolve the same way.
- **`stop()` and `setFeatureEnabled` had no callers**, reading as live control
  surfaces for a lifecycle nothing drives.

Accepted trade-off, not fixed: the card keeps the bar's standard 6s dismissal,
so a user who glances away can lose one of an integration's three lifetime
offers. Making this card persistent means either bypassing the owner-bound
delivery path (as the reach-error card does) or editing a shared timeout whose
SwiftLint baseline is down-only. Both are worse than the 6s.

Verification: xcrun swift test --package-path Desktop — 5509 tests, 0 failures;
SwiftLint 0 violations.

Co-Authored-By: Claude Opus 5 <[email protected]>
…during it

Five findings from a fifth review pass, all in code the previous commit added:

- **The owner re-scope always resolved to nil.** `runtimeOwnerDidChange` is
  posted while the revocation is still in progress, so reading the owner
  synchronously in that handler returned nil and left the store permanently
  unscoped — every nudge read and write a no-op for the rest of the session. The
  re-scope now waits for the transition to finish.
- **`bar_unavailable` was reported twice for one refusal.** `showNotification`
  invokes `onDropped` and *then* returns the refusal, so both paths reported.
- **Snoozed and cooldown emitted on every browser re-check.** They are
  deliberately non-ambient (a re-check can still find a different integration in
  another tab) but the answer for *this* integration does not change while the
  user sits on the tab. Each reason is now reported once per watch session.
- **A comment described an owner guard the code no longer implements.** The
  capture-before-hop comparison was removed in the previous commit because it
  compared a raw default against a resolved runtime owner; the comment stayed.
  It now states what the code does and what the residual risk is.
- **The test presenter did not honour the bar's drop contract** — it returned
  the refusal without calling `onDropped`, which is why the double report was
  invisible to the tests. The stub now matches, and two tests cover the
  once-per-refusal and once-per-session guarantees.

Verification: xcrun swift test --package-path Desktop — 5511 tests, 0 failures;
SwiftLint 0 violations.

Co-Authored-By: Claude Opus 5 <[email protected]>
…g it

Five findings from a sixth pass. The first is the same class of bug as the last
commit's, fixed properly this time:

- **The deferred owner re-scope still raced the transition fence.** Moving the
  re-read behind one runloop hop does not synchronize it with
  `endAuthorization()`, so it could still latch nil and leave the store unscoped
  for the session. The store now resolves the owner on every access, which has
  no window to race at all; `setOwnerID` and the re-scope are gone.
- **The attribution window and the export-status cache survived an account
  switch.** The claim is process-global with a five-minute life and the export
  cache was keyed on nothing, so user B's first minute could be answered with
  user A's connections. Both are dropped on owner change.
- **Cooldown and snooze emitted on every activation for days.** They are exactly
  the shape `isAmbient` exists to bound — three and seven days of the same
  answer — and their rate is already derivable from the Shown events plus these
  fixed budgets. What stays is the momentary set: the daily and global caps and
  a bar that could not draw, which is genuinely "we wanted to nudge and could
  not".
- **An inline comment described an owner comparison that is not there.**

Still accepted, not fixed: the card inherits the bar's 6s dismissal, so a user
who glances away can lose one of an integration's three lifetime offers. Both
alternatives are worse — bypassing the owner-bound delivery path, or editing a
shared timeout whose SwiftLint baseline is down-only.

Verification: xcrun swift test --package-path Desktop — 5511 tests, 0 failures;
SwiftLint 0 violations.

Co-Authored-By: Claude Opus 5 <[email protected]>
…etry correctly

The most important item here is a mistake of mine: a bulk edit removing the dead
`dwell` parameter also deleted the four regression tests that proved the
stale-identity fix — the ones that move the frontmost app and the signed-in owner
*during* each await. The seam they used was still there, unused, which is how the
review caught it. They are restored.

The rest, from the same pass:

- **Nudge events could not join the connect funnel.** They emitted
  `connector_id` as the catalog telemetry id (`export:notion`) while
  `IntegrationConnectTelemetry` emits the bare id (`notion`) under the same
  property name. `connector_id` is now the bare id in both, and a bounded
  `route` dimension disambiguates the two halves of the catalog.
- **A queued card could spend the budget after the user left.** `evaluate`
  re-verifies the frontmost window after each await, but a queued card is drawn
  whenever the bar gets to it, and nothing checked then. The card is the bar's to
  own by that point; the integration's lifetime budget is not, and is no longer
  spent for an app the user has left.
- **A late queue eviction reported into an unrelated window session**, because
  the bar retains the callbacks across activations. Both callbacks now carry a
  session token.
- **A routine Gmail sync threw away the export-status cache** it could not have
  invalidated.
- **`return XCTFail(...)` inside nested loops** aborted a whole catalog test
  rather than the one case, skipping every later entry's assertions.

Verification: xcrun swift test --package-path Desktop — 5515 tests, 0 failures;
SwiftLint 0 violations.

Co-Authored-By: Claude Opus 5 <[email protected]>
Rendering the real card on a real bar showed "Connect Google Calendar t…" and a
pitch cut mid-clause at "remember what…". The title said "Connect X to Omi",
which does not fit the bar for the longer display names — and "to Omi" is
redundant on Omi's own surface. The pitch gets a third line, because the longest
ones are a full sentence and cutting one mid-clause reads as a bug rather than
as brevity.

Verified by capturing the bar for Google Calendar, the longest content in the
catalog: title, pitch, data-scope line and all three actions now render in full.

Verification: xcrun swift test --package-path Desktop — 5515 tests, 0 failures;
SwiftLint 0 violations.

Co-Authored-By: Claude Opus 5 <[email protected]>
…w setting

`sessionToken` was dead: a bulk edit two commits ago silently failed to apply, so
the guards its comment described — "both callbacks compare against this before
doing anything" — did not exist. The comment claimed a protection the code did
not have, which is worse than not having it. Both callbacks now compare the
session they were created in, and the frontmost app is re-checked before a
queued card spends the budget.

Two tests cover it: a queued card drawn after the user switched apps spends
nothing, and a drop arriving after a new activation reports nothing into it.

Also: the new Integration Suggestions rows were missing from the Settings search
index, so searching "integration" or "suggestions" found nothing.

Verification: xcrun swift test --package-path Desktop — 5517 tests, 0 failures;
SwiftLint 0 violations.

Co-Authored-By: Claude Opus 5 <[email protected]>
The previous commit's frontmost check in `onPresented` was a regression: a queued
card that the bar *did* draw spent no budget and emitted nothing, so the same
integration could be offered again and again, each time free — the opposite of
what the budget is for. Presentation means the user saw the offer, whatever they
are looking at by the time the bar gets to it, so it always counts. The session
token stays where it belongs: on the drop path, which must not report a
suppression into whatever window session is current by then.

Also:

- **A backwards clock silenced every nudge.** The rolling day window already
  discarded future-dated deliveries, but `lastShownAt` and `lastAnyNudgeAt` did
  not, so a clock moving back left both permanently ahead of `now` and the
  cooldown gates — which compare elapsed time against a positive budget —
  refused everything until the skew passed.
- The telemetryID→entry lookup was open-coded in four places; it lives on the
  catalog next to `entry(for:route:)` now.

Verification: xcrun swift test --package-path Desktop — 5518 tests, 0 failures;
SwiftLint 0 violations.

Co-Authored-By: Claude Opus 5 <[email protected]>
The previous commit's future-timestamp sanitizer was applied to all four stored
dates, including `snoozedUntil` — which is a deadline and in the future by
definition. So "Not now" silently snoozed nothing. Sanitizing is now limited to
the two instants that can only ever be in the past, and the store's date reads
take the caller's clock so a test can pin them; the regression has one.

The suppressed event is removed rather than tuned again. Four review rounds
landed on the same shape of problem: every reason a recognized window produces no
card is either a deterministic function of the budgets in `IntegrationNudgePolicy`
plus the Shown events already recorded, or a state that holds for days while
Finder is activated dozens of times an hour. Emitting it was unbounded volume
that told the analysis nothing it could not derive. Its absence also removes the
session-token, per-session dedup and drop-callback plumbing that existed only to
bound it — a dropped card now simply leaves the budget unspent, so the next
activation offers it again.

Also removed an unreachable signed-out fallback in the store's key builder.

Verification: xcrun swift test --package-path Desktop — 5513 tests, 0 failures;
SwiftLint 0 violations.

Co-Authored-By: Claude Opus 5 <[email protected]>
…itle polls

Four findings from a fifth local pass:

- **Every nudge card was written into the user's conversation history.**
  `persistNotificationMessageIfNeeded` journals a proactive card because it is
  something Omi observed and the user may want to follow up on in chat. An
  integration offer is neither — "Omi can read your inbox…" is product copy
  about a connector, and landing it in the journal as though it were an
  observation is noise they cannot act on there.
- **The browser re-check re-read the active window six times regardless.** Each
  round costs an Accessibility resolve and contends for `ScreenCaptureService`'s
  single-flight lock, pushing Rewind's capture path onto cached window metadata.
  A round whose title is unchanged from the last now skips the match, the
  connection check and the decision entirely.
- **The store's write path re-read state on the wall clock** while passing the
  caller's clock to the transition, so the read and write halves of one
  operation could disagree.
- **The grouped "ChatGPT / Codex" sheet showed ChatGPT's three outcomes.**
  Claude and Claude Code are one tool with two connection mechanisms and share a
  pitch; ChatGPT and Codex are different products sharing a sheet, so there is no
  shared pitch to show.

Verification: xcrun swift test --package-path Desktop — 5513 tests, 0 failures;
SwiftLint 0 violations.

Co-Authored-By: Claude Opus 5 <[email protected]>
…t redundant re-check

- `integration_nudge_present` answered `presented: "true"` for a merely queued
  card, but a queued card spends no budget until the bar draws it — so the flow
  step asserting a cooldown afterwards was order-dependent on whether the bar
  happened to be busy. The action now reports `spent_budget` from the store, and
  the flow asserts that.
- The first browser re-check redid the match, the connection check and the
  decision that the initial evaluation had just made, because the title it
  decided from was discarded. It is handed forward now.

Verification: xcrun swift test --package-path Desktop — 5513 tests, 0 failures;
SwiftLint 0 violations.

Co-Authored-By: Claude Opus 5 <[email protected]>
…nvariant

The card's Connect / Not now / Never buttons were exercised only by hand. The
handlers behind them are where behaviour can actually regress, so drive those
through the coordinator's injected seams and assert the effect each button
promises the user -- including the effects the other two must not have:

- Connect routes to the real connector sheet, claims the connect that follows
  as `.nudge`, and spends no budget (a nudge accepted is not a nudge refused).
- Not now snoozes for exactly the snooze duration -- and the week has to end,
  or the button quietly means the same thing as Never.
- Never still holds a year later, after every cooldown in the policy.

Also assert an invariant no test covered: connecting clears the nudge budget
but must not clear `optedOut`. The grant refresh re-runs `recordConnected` on
every reconnect check while the sheet is open, so a clear that dropped the
opt-out would hand back nudges the user had turned off for good, repeatedly.

Verification:
  swift test --package-path Desktop
  -> Executed 5517 tests, 1 skipped, 0 failures (was 5513)
  swift-format wrapper clean; no production code changed.

Reviewed two P3 findings and did not act on either -- both are false positives:
`consumeSurface` has a single production call site, inside the import runner's
`start(...)`, so backing out of the sheet burns no attribution claim; and the
repeated nudge-history clear is idempotent, touching only the four per-connector
keys behind an `alreadyConnected` suppression that short-circuits first.
…cess

Pressing Connect on an integration-connect card crashed the app, five times
out of five, always with the same trap:

    EXC_BREAKPOINT (SIGTRAP)
      _dispatch_assert_queue_fail
      swift_task_checkIsolatedSwift
      VStack.init(alignment:spacing:content:)
      AppGridSection.body.getter

The cause is further down that stack, in this file rather than in the nudge
code. `liveSnapshot` ran `AXUIElementCopyAttributeValue` against
`NSWorkspace.shared.frontmostApplication` from a cooperative background
thread. When Omi itself is frontmost that is an *in-process* accessibility
query, and AppKit services those synchronously on the calling thread by
driving `NSHostingView.accessibilityChildren()` -- which evaluates SwiftUI
bodies right there, off the main actor. Any `@MainActor` state a body reads
(here `FontScaleSettings.shared`, via `scaledFont`) then trips Swift 6's
isolation check and traps.

Connecting from a card makes Omi frontmost, so that path hit it every time,
but the hazard is general: a plain dock click into Omi reaches the same code.

Attribution was measured, not assumed:
  - fresh launch, navigate straight to the Apps tab, no nudge: 0 crashes / 2
  - Connect from a card, before this change:                   5 crashes / 5
  - Connect from a card, after this change:  completed, routed to the Apps
    tab, no new crash reports

Verification:
  swift test --package-path Desktop
  -> Executed 5517 tests, 1 skipped, 0 failures
  make preflight -> 22 checks passed
  Live: rebuilt named bundle omi-int-nudge, pressed Connect on a real card.

No regression test: the path depends on `NSWorkspace`, a live Accessibility
grant, and which application is frontmost, so a test would be non-hermetic
and could not run in CI. Verified by live reproduction instead.

An earlier speculative fix -- swapping the nudge coordinator's
`DispatchQueue.main.async` for `Task { @mainactor in }` -- did not change the
crash and was reverted rather than left in the diff.

Failure-Class: none
@Git-on-my-level
Git-on-my-level merged commit b054493 into BasedHardware:main Aug 19, 2026
25 of 26 checks passed
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.

2 participants