Repository navigation
fix: prompt state is per-account (rating, history seed, remote resolutions) - #12312
Merged
Merged
Conversation
…ions Cross-review caught the #9821 account-switch-bleed class: every prompt key (question count, submitted rating, dismissed, history-seed marker, remote prompt resolutions) was device-global, so one account's answer suppressed prompts for every later account on the Mac. All state now lives under owner-scoped ScopedDefaultsKeys; the first scoped access migrates the pre-scoping global keys to the signed-in account (single-account Macs keep their state, nobody gets re-prompted) and removes them. The remote engine's question count is now literally RatingPromptManager.questionCount — one owner-scoped ledger accessor. PromptStateAccountScopingTests (3): rating submission does not suppress the next account and survives switching back; remote resolutions are per-account; legacy global state migrates to the first account only. Full prompt suites 23/23. Failure-Class: none
kodjima33
added a commit
that referenced
this pull request
Aug 27, 2026
## Why Follow-up to #12312 (per-account prompt state): storage was owner-scoped, but the cached `isVisible`/`current` published state persisted across an account switch until the next question or flag reload. ## What `RatingPromptManager.ownerDidChange()` (clears thank-you, recomputes from the new owner's keys) and `RemotePromptEngine.ownerDidChange()` (drops the slot without writing a resolution, re-evaluates, refetches). DesktopHomeView's owner-keyed `.task(id: currentOwnerId)` — the app's established owner-transition seam (same pattern as the chat-first capability task) — invokes both on every transition; the rating manager additionally observes `.userDidSignOut` for the sign-out leg. ## Verification Two new `PromptStateAccountScopingTests` exercise the transition with a VISIBLE prompt and no manual flag reload or extra question: the armed rating bar disappears the moment the owner flips to B and returns when it flips back to A; a visible remote banner survives the switch unresolved, B's dismissal doesn't stick to A. All prompt suites 25/25; swift build clean. Failure-Class: none
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Cross-review caught the #9821 account-switch-bleed class in the new prompt surfaces: all rating/remote-prompt state was device-global, so one account's answer or dismissal suppressed prompts for every later account on the same Mac.
What
Every key (question count, submitted rating, dismissed, history-seed marker, per-prompt remote resolutions) is now owner-scoped via ScopedDefaultsKey. First scoped access migrates the pre-scoping global keys to the currently signed-in account (single-account Macs keep their state — nobody who already answered gets re-prompted) and deletes the globals. The remote engine's question count is now literally
RatingPromptManager.questionCount— one owner-scoped ledger.Verification
PromptStateAccountScopingTests(3): submit on account A → account B starts clean, asks 3 questions, sees the prompt; switching back preserves A's submission; remote prompt dismissed by A is still offered to B; legacy global state migrates to the first account only, second account starts clean. All prompt suites 23/23. swift build clean.Failure-Class: none