Skip to content

The open-source app everyone uses to manage agents at work

refactor(ui): record why sign-out resets rather than removes (#11473)

Tonio0023c5c4a6b9
diff --git a/ui/src/hooks/useSignOut.ts b/ui/src/hooks/useSignOut.ts
index 1a61ec164a..a7d5c3ef78 100644
--- a/ui/src/hooks/useSignOut.ts
+++ b/ui/src/hooks/useSignOut.ts
@@ -77,6 +77,23 @@ export function useSignOut({ onSignedOut }: UseSignOutOptions = {}) {
// across the whole sign-out/sign-in cycle. Reset notifies them, so the
// old data is gone from the cache *and* from everything reading it.
//
+ // Measured against query-core 5.101.4 rather than reasoned about:
+ // removal produced 0 notifications and left the observer holding the
+ // signed-out account's session; reset produced 3 and null. The
+ // consequence of the former is not just stale reads — the redirect in
+ // CloudAccessGate fires on the session going empty, and it never runs.
+ //
+ // The opposite advice holds for a *local* reset of a key an observer is
+ // still mounted against. Reset rewinds the update counters
+ // `isFetchedAfterMount` derives from while that observer keeps its
+ // bind-time baseline, so the flag can never read true again and anything
+ // gated on it withholds forever. `AppsConnect` is the consumer to check
+ // against: it gates its render on that flag for two queries.
+ //
+ // Sign-out is not that case. It resets the session too, so `AppsConnect`
+ // — which sits behind a route — unmounts on the redirect and remounts
+ // with a fresh baseline.
+ //
// Not awaited: the refetches this kicks off are expected to 401 now that
// the session is gone, and the sign-out button should not sit pending
// while they fail.