Skip to content

fix(desktop): account-scope isolation and state ownership architecture - #33

Merged
fannnzhang merged 5 commits into
mainfrom
fix/desktop-account-scope-lifecycle
Aug 12, 2026
Merged

fannnzhang merged 5 commits into
mainfrom
fix/desktop-account-scope-lifecycle

Conversation

@fannnzhang

Copy link
Copy Markdown
Contributor

Summary

  • Account boundary: sole leaveAccountScope on logout/switch/auth-invalid; wipe workspace digests, UI selection, topic cursors, RQ cache; outbox rows stamp immutable accountId and are claimed only by the current account; host hit_ cleared on leave with hostCredentialAccountId gating Host online; single-flight hydrateAuth; instanceCrashed updates project aggregates.
  • Timeline ownership: sole timeline-write funnel for messagesByConversation (Hub live, hydrate, optimistic/delivery); account-scope generation guards late writers after leave; send path never marks sent unless outbox acked.
  • Architecture phases 2–6: IM lifecycle moved to store/im/ so shared/lib no longer imports stores; cloud-auth + daemon-status ports; domain types in shared/domain/; unused catalog RQ hooks removed; host ensure decision machine extracted; Hub-primary rail unread retained/docs aligned; CLAUDE.md project instructions included.

Commits

  1. 113aaf8 account-scope leave / outbox / host isolation
  2. 561bc29 timeline write funnel
  3. a1b367a phases 2–6 ownership, domain types, host ensure
  4. aa19c5e adversarial-review fixes (settlement, gen guards, cleanup)

Test plan

  • cd apps/desktop && pnpm check:all (tsc, unit tests, biome, file-sizes, px-text)
  • cargo check -p minos-daemon -p minos-desktop (host clear credential path; run earlier in branch)
  • Manual: A login load → sign out → B login shows no A projects/digests/selection; offline outbox for A does not flush under B
  • Manual: Linked send only marks sent after Hub ack; timeout keeps non-sent delivery
  • Manual: Host online only after current-account host register post leave

Introduce leaveAccountScope as the sole account boundary so A→logout→B cannot
retain workspace digests, UI selection, topic cursors, or RQ cache. Stamp
immutable outbox accountId and claim only the current account; clear host hit_
on leave and gate Host online on hostCredentialAccountId. Single-flight
hydrateAuth avoids refresh-token reuse revoke; instanceCrashed threads projects
for Sidebar aggregates.
Route Hub live apply, snapshot reconcile, loadTimeline hydrate/older pages,
and optimistic send/delivery patches through store/workspace/timeline-write.
Clear unread id dedupe on bridge stop; document the funnel in architecture-desktop.
- Move IM lifecycle/sync/inbound/digest ensure into store/im; shared/lib no longer imports Zustand stores
- Add cloud-auth + daemon-status ports to break account↔workspace cycles
- Extract collaboration domain types; keep mock-data as fixtures/presentation
- Delete unused catalog RQ UI hooks; document RQ as store-loader transport
- Hub-primary rail unread already enforced; keep resolveRailUnread tests
- Deduplicate send/retry via deliverMessage; split host ensure decision machine
…anup

- Never mark user bubbles sent on outbox timeout; throw until acked
- Guard timeline funnel writes with account-scope generation
- Scope reclaimStaleInflight by accountId; drop unused session RQ hooks
- Add pure settlement/generation regression tests; include CLAUDE.md
…ning

Surface timeout/errors as failed (WeChat-style retry) while allowing later
outbox ack to upgrade the bubble to sent. Serialize host credential clear
via a controller so leave aborts stale apply. Split cloud-realtime map and
IM agent/outbox post modules to satisfy file-size gates; harden outbox,
realtime epoch, and conversation UI selection paths.
@fannnzhang
fannnzhang merged commit 47f5dbc into main Aug 12, 2026
5 checks passed
@fannnzhang
fannnzhang deleted the fix/desktop-account-scope-lifecycle branch August 12, 2026 02:23
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