Skip to content

fix: prompt state is per-account (rating, history seed, remote resolutions) - #12312

Merged
kodjima33 merged 1 commit into
mainfrom
kodjima33/prompt-state-per-account
Aug 27, 2026
Merged

kodjima33 merged 1 commit into
mainfrom
kodjima33/prompt-state-per-account

Conversation

@kodjima33

@kodjima33 kodjima33 commented Aug 27, 2026 •

Copy link
Copy Markdown
Collaborator

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

Review in cubic

…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
kodjima33 merged commit c48562c into main Aug 27, 2026
8 checks passed
@kodjima33
kodjima33 deleted the kodjima33/prompt-state-per-account branch August 27, 2026 19:48
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
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