Repository navigation
A dashboard session that outlives its token says so and signs in again without losing the page - #210
Merged
Merged
Conversation
zlareb1
force-pushed
the
fix/dashboard-token-refresh
branch
from
November 3, 2026 20:46
9bdfa96 to
81b64d8
Compare
The dashboard's SSO token lives an hour with no refresh, and only boot's whoami check sent a dead token to the gate: past expiry every view showed the 401 as its own error. The shared request path now ends the session on a 401 for the stored token, and the SSO gate starts sign-in again by itself once in five minutes, returning to the same page. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
A mid-session refusal puts the sign-in gate over the page instead of unmounting it, and never leaves for SSO by itself, so nothing typed is lost; the same person signing in again carries on there. An auth-off install drops a stale stored token instead of showing a gate. whoami answering anything but 200 throws, so a replica still loading keys no longer clears a good token. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The overlay could not take input under an open modal, let shortcuts act under it, and lost the page on an SSO click. A bar over the page now says the session expired; signing in happens in a new tab, whose token this tab takes through the storage event (the same person carries on with the identity read again, anyone else reloads). A refusal before boot has an identity shows the gate with the expired reason, and boot asks whoami again while a replica answers 503. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Every signed-in tab hears another tab store or drop the token: dropped ends its session too, stored carries on only once whoami confirms the same person (anyone else reloads). The card is pinned in the toast viewport, so it stays above and audible over a modal, and Modal ignores a press there as the inspector already did. A reload after the session ended keeps the expired reason through a session-storage note. An expired token reads "Your session expired — sign in again." in a view's error. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…nly once confirmed Signing out marks the browser, so another tab that loses the token reloads to a plain sign-in instead of an expired-session gate whose SSO would sign the person back in. A token stored elsewhere is taken only if it is still the stored one when whoami answers, and a healthy tab that cannot confirm it stays as it is. Boot treats a token dropped while whoami answered as refused, and tries the page again when whoami stays 503. A revoked token reads as an ended session too, except behind a proxy. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…er reloads at most three times Boot ignores the session-ended note once the person signed out, so the gate is a plain sign-in. A whoami that stays 503 reloads the page at most three times, never in proxy mode. Auth-off keeps a stored token again. The task sheet, like Modal and the inspector, stays open on a press on the toasts (one shared check). The gate, the card and the views all say "Your session ended". The card loads with its first use. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…or a click The card is imported eagerly: a lazy chunk removed by a deploy would reload the long-lived tab it is there to keep. A token a #token= link brought that the server refuses shows its own notice and starts no SSO, so a break-glass link stays put while the identity provider is down. Boot starts again when another tab stores a token while whoami answers, and a token another tab dropped then reads as an ended session. With auth off a view keeps the server's words. The reload after a lasting 503 is gone: the toast says why, and the token stays. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The early list_mine read could be refused before whoami answered and set the gate to "expired", whose SSO starts by itself, ahead of boot's "refused" for a sign-in link's token. Before boot has an identity a refusal now only drops the token and notes it; boot shows the gate with the reason. The boot test refuses the early read too, first. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… at once A token stored elsewhere that the server refuses ends this tab's session and keeps its page; one whose claims name someone else reloads before whoami is asked. The sign-out mark lasts until the next sign-in, and boot also catches a token stored while a tab with none waited for whoami. A refusal that ended the session reads as an ended session whatever its words. A refused sign-in link leaves no note when boot then fails. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…gain after a 503 A 401 for a token the call carried reads as the ended session also when another refusal ended it a moment before, so the wording no longer depends on the server's words. An ended tab that could not confirm another tab's token asks again after 30 s. A sign-in link's token is compared as stored (no whitespace). The docs say a keyboard user closes an open dialog to reach the card, and the card is one line. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…aced by a new token goes again The storage listener registers with the module, so no change between boot and the first render is lost, and it hears a sign-out even when this tab's token was already gone. A 401 for a token another tab replaced meanwhile sends the call again, once, with the new token. The 30 s recheck is cancelled by the next change. With SSO on, the card's new tab goes straight to the identity provider. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The one retry after a 401 now needs the new token to name the same subject and org; any other token never carries this page's call, which fails as the ended session instead. The retry is one logical call in the view's count, a retried call refused again reads as ended too, and the card is announced once by the viewport's live region. A sign-out mark acts only once this tab's token is gone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…nds without one The same-person retry is gone: a call another tab's sign-in raced fails as the ended session, and Retry sends it, so no call ever goes out under a token this tab has not checked. With auth off, the call whose 401 dropped a stale token goes again without it. A refused sign-in link keeps its reason when whoami then fails, reloadPage runs once however many changes ask, and an empty org claim compares as "". Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…n-in says to retry Each call checks the stored token's claims against the person whose page it is (kept in step with whoami) and goes out only under theirs, so the moment before this tab hears of another tab's sign-in cannot send under someone else. A call raced by the same person's sign-in elsewhere says "You signed in again in another tab — retry". With auth off every concurrent call a stale token got refused goes again without it. The card's chunk is fetched as the app loads. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
An auth-off install's stand-in identity is no owner a token can match, so the check would have refused every call under a leftover token: it now passes with auth off, where the 401 path drops the token. The ui.vitals row goes out only under the page's person's token too. "You signed in again" is said only when the new token is the same person's; anyone else's reads as the ended session while the tab reloads. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…retries stop on a new token Should the session card's chunk fail as the app loads, the card renders nothing, and each view's error still says the session ended. whoami's retries stop once the stored token changes, so none carries another tab's token, and boot waits about five seconds (the server's Retry-After) before giving up on a 503. Two test assertions that could not fail are gone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ut and the error page send only the page's own When the stored token changes while whoami is being retried, the retry answers "not authenticated" for the old one and boot's own check starts again with the new token, instead of leaving the gate. Sign out revokes only the page's person's token, and the error page's health read sends it only then; the listener uses the same check. Tests cover a sign-in link that whoami alone refuses and the vitals row under the page's own token. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…or path still names its reason Sign out returns before marking or clearing anything when the stored token is not the page's person's: another tab signed them in a moment ago, and the reload that follows opens their page. When boot's whoami fails after the early read refused the token, the gate still says the session ended (or that the link's token was refused). Two comments name the card and the "refused" reason. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… the token after its wait Boot's error path names an ended session only when this boot itself lost the token, so an earlier load's note does not send a Reload during an outage to the identity provider. whoamiWhenReady checks the stored token again after its one-second wait, before the next ask. Signing out under another person's token says another account is signed in. The page owner is boot's whoami answer itself. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The session-ended note now holds the gate's reason: a token with a sign-in session (sid) is "expired" and the SSO gate starts the sign-in again, while a minted token is "ended" and waits for a click, since it may be the way in while the identity provider is down. The refused-token notice fits a link and an SSO return alike, signOut has one doc comment, and the error page's health test checks the read was made. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
When another tab drops or replaces the token, this tab's gate reason comes from the token stored before (the storage event's old value), so a sign-in session's token resumes SSO by itself in every tab. The signed-in-elsewhere refusal no longer waits to read the response body. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
With main's latest additions the shell's index chunk passed its 120 kB budget. The cross-tab token handler now ships in the session card's chunk, which the app fetches as it loads (a chunk that cannot load reloads the page, which decides on the stored token), and the health problems banner, shown only on a degraded deployment, loads as its own chunk and shows nothing when that chunk cannot load. The index chunk is 118.6 kB of its 120 kB. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The page-owner check refused every call under a stored token whose claims it could not read, so the whole dashboard read as a session that ended. Such a token names no one: the call goes, and the server's answer to it decides. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…eloads The cross-tab handler now runs after its chunk loads, so a change it hears late that is no longer the stored token defers to the newer one and never clears a token stored after it. A token the server confirms for someone other than this page's person reloads the page, and a stale chunk that the reload handler takes shows no card or banner. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
fix/dashboard-token-refresh
branch
from
November 3, 2026 21:34
3300318 to
8bec729
Compare
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.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
When the dashboard's sign-in token expires or is revoked mid-session, a card now says so over the page and any open dialog, instead of each page showing "Sign-in rejected: token expired"; signing in again in a new tab lets the page carry on as it was. With SSO on, a page loaded after a sign-in session expired starts the sign-in again by itself and returns to that page.
Why
The dashboard's SSO token lives
oauth_access_token_ttl_seconds(one hour by default) and has no refresh. Only the boot-timewhoamicheck sent a dead token to the sign-in screen. A tab open past the token's expiry kept the token, so every read afterwards answered 401AUTH_INVALID: token expired: Signature has expired, and each view showed that as its own error ("Couldn't load collections", "Couldn't load documents"). No view refreshed the token: none could, because this token has no refresh path.collection.listvalidates the same token as every other op.Reproduced against a local server with a token that expires a few seconds after it is minted (past the 30 s leeway): the Library shows "Couldn't load documents · Sign-in rejected: token expired: Signature has expired".
The fix:
api.ts::requestis the path every authenticated call takes. A 401 for the token the request carried calls the handler App registers.Modaland the task sheet now ignore them too, through one shared check (keepOpenOnToasts), so pressing the card never dismisses a dialog. Nothing else changes: an open dialog keeps what was typed (checked in a browser with the Add document dialog), and the view underneath stays mounted. The gate, the card and a view's own error for such a call (an expired, revoked or missing token) all say "Your session ended — sign in again." instead of "Sign-in rejected: …". Behind a proxy it keeps the server's words, since there is no session there and a missing header is the proxy's fault.storageevents on the token and the sign-out mark from the moment the app loads, so no change before the first render is lost.ui.vitalsrow, sign-out (which leaves another person's token alone entirely, and says another account is signed in) and the error page's health read also check the stored token's claims against the person whose page it is, kept in step withwhoami, so nothing of this page goes out under someone else's token, not even in the moment before the tab hears of the change. With auth off there is no person to match, and the check stays off.whoamiwith it, retrying on 503. The answer counts only if that token is still the stored one. If the server confirms it, the card goes away andlist_mineis read again, so changed roles take effect. If the server refuses it, this tab's session ends and the page stays. Ifwhoamicannot answer, a healthy tab stays as it was, and an ended one keeps its card and asks again 30 s later while that token is still the stored one.whoamianswers, with the reason it alone knows: "refused" for a token a sign-in link brought, "expired" for a sign-in session's token (it carriessid), "ended" for any other, such as a minted one. This includes the case where the earlylist_mineread is refused whilewhoamiis still answering, even ifwhoamithen says yes. A session-storage note keeps that reason across a Reload, even though the token is already gone. Boot ignores the note right after a sign-out, so signing out from a page that shows the card lands on a plain sign-in, and when boot fails it names the reason only if this boot itself lost the token, so a Reload during an outage starts no sign-in by itself. With SSO on, the gate then starts the sign-in by itself for "expired" only, at most once in five minutes per tab, and returns to the page through the existing return-to-start path. A token that a#token=link brought and the server refused shows "The token this sign-in brought was refused" and waits for a click, and so does a minted token once it expires, so neither a provider that returns refused tokens nor a break-glass token used while the provider is down can loop or send the person to a provider that is down. If another tab stores a different token while boot waits forwhoami, including whilewhoamikeeps answering 503, boot starts again with that token.whoamierrors.whoamithrows on any status other than 200; behind a proxy, a 401 or 403 still means signed out. While the server answers 503, boot retries up to five times a second apart (the server's ownRetry-Afteris 5 s), stopping if the stored token changes, and if it is still 503 the sign-in screen shows with the existing toast ("Loom is unavailable right now — try again in a moment"), and the token is kept for the next load. A replica whose keyring is still loading answers 503 on purpose so the client keeps its token, but the client used to read it as "signed out" and clear a good token.Scope and risk
Modalignores a press on the toast viewport, so a press on an ordinary toast no longer dismisses a dialog either.Compatibility, rollout and rollback
loom_sso_resumed_v1,loom_session_ended_v1) and theloom_signed_out_v1stamp in local storage.Tests
frontend/src/api.request.test.ts: a 401 for the stored token ends the session and still rejects the call. Three 401s in flight together end it once. A 403, a 401 that races a newly stored token, and a 401 for a request sent without a stored token do not end it.frontend/src/flows/TokenGate.test.tsx:resumeSsoOnceallows one automatic sign-in per five minutes. An expired SSO gate remembers the page and callsgoToSso; a first visit waits for a click.frontend/src/App.boot.test.tsx, wherewhoamianswers for the token it is sent:whoamiconfirms it, removes the card without a reload;reloadPageis asserted);whoami;whoamianswers keeps the card;list_mine401 whilewhoamianswers yes still shows the gate with the expired reason, and the app does not come up without a token;#token=link shows the "refused" gate, and SSO does not start, even when the earlylist_mineread is refused first;whoamireloads, also whilewhoamianswers 503;whoamialone refuses shows the "refused" gate and starts no SSO;whoami503 is retried and the token is kept.frontend/src/lib/format.test.ts: an expired, revoked, ended or missing bearer reads as an ended session, except with auth off; a wrong password still reads "Sign-in rejected".frontend/src/api.request.test.ts: signing out marks the browser until the next sign-in, which clears the mark, and leaves another person's token alone;ErrorBoundary.test.tsx: the health read sends no token naming someone else; a call refused for a token another tab replaced meanwhile is not sent again and says to retry; a call under a token naming someone other than the page's person is never sent, and neither is theui.vitalsrow (lib/vitals.test.ts); with auth off, every concurrent refused call goes again without the token.npm run build,npm run budgetandmake lintpass on the head rebased on main.🤖 Generated with Claude Code