Repository navigation
fix(workspace): an expired client session no longer becomes the operator (#2261) - #2298
Merged
Merged
Conversation
…tor (#2261) #2258's stated residual. Expiry cannot end the platform credential — that would log an operator out of another tab over a client's idle timeout — so `endSession → signOut` cleared only the portal token, and `isPlatformSession` re-derived from the platform JWT still in the browser. The client's tab silently became the operator's, roster and all. #2258 rejected the issue's own suggestion (a "suppress the fallback" flag) on evidence: `auth.js` installs the platform JWT as an axios DEFAULT header and per-request headers MERGE over defaults, so a flag hides the operator's roster on screen while every workspace request still carries the operator's credential. That objection is about the WIRE, so this fixes the wire first and the flag becomes honest: 1. Every workspace call moves onto a dedicated instance (`portalHttp`) whose request interceptor decides the credential and strips whatever `axios.defaults` merged in; `authHeader` returns {} while suppressed. Asserted directly, both halves. (`streamPortalExecution` uses bare fetch with `authHeader` only, so it was already honest.) 2. `platformFallbackSuppressed` — set when a client session EXPIRES here, cleared by `signOut()`, by a client signing in again, and by the operator's explicit "Continue as <email>". In sessionStorage: it must survive a refresh of THIS tab and nothing wider, which is also what leaves an operator's other tab alone. The escape hatch is mandatory, not a nicety: the suppression fails closed, so it necessarily catches the operator when the browser is genuinely theirs. Three things surfaced while building it, each fixed rather than left: * **The 401 bounce had to move with the transport** — and off the wrong question. `main.js` decided with `onWorkspace && localStorage['token']`; workspace calls no longer reach it, so the operator bounce is re-registered through `setPlatformSessionLostHandler` and fires only when `isPlatformSession`. That is false in exactly the case the old predicate got wrong: a client at the OTP form on a browser holding an operator's JWT, where one mistyped digit would 401, bounce them to /login and destroy the operator's session (objection 3 in `workspace-session-signout.md`). Without the move, an operator whose JWT expired would have sat on "Failed to load your agents" forever. * **`sessionExpired` was never rendered.** The store has set it since ent#375 and no view read it, so an idle-out was indistinguishable from "you were never signed in" — the form just reappeared. It says which now. * **`resumePath` was never read either**, so the notice's "pick up where you left off" was a promise the app did not keep. The sign-in that consumes the expiry navigates there. The spec's axios mock returned ONE shared instance for every `create()`, so `api.js`'s PERF-269 dedupe wrapper was overwriting the store's `.get` — a stub on it was silently not the code path. `create()` now returns a fresh instance, like real axios. 37 tests in workspaceSession.spec.js (was 28): the four ACs, both bounce paths, the escape, marker lifecycle, and the private-mode degradation. Full frontend suite 940 passed, build clean. Related to #2261 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…#2261 review) Caught by /review on this PR. The request interceptor kept any `Authorization` it found on the config, which cannot distinguish "the store decided this" from "axios merged this in from defaults" — so the property the PR claimed (it strips an inherited platform JWT) was not the property the code had. It would have PRESERVED one. Verified empirically against the shipped axios (1.19.0): an instance created before `auth.js` mutates `axios.defaults.headers.common` does not inherit that mutation, so nothing is inherited today and the disclosure is closed by the move onto the instance. But a security property must not rest on a merge behaviour we neither control nor test, so the interceptor is now unconditional: delete any Authorization, then set it from the store, fail-closed when the store is unreachable. Two tests replace the one that asserted the wrong thing — an inherited header is discarded, and a live client session still authenticates (fail-closed is only correct when there is nothing to send) — plus tests/unit/axiosInstanceIsolation.spec.js, which pins the axios fact itself against real axios so a version bump that changes it is visible. Related to #2261 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
vybe
approved these changes
Aug 19, 2026
vybe
left a comment
Contributor
There was a problem hiding this comment.
Validated via /validate-pr: CI fully green (6 pytest seeds, e2e, build, gitleaks), security scans clean, feature-flow doc updated, regression specs named to the issue. Approving.
trinity-ability
pushed a commit
that referenced
this pull request
Aug 19, 2026
….js against #2298 Both PRs added state fields at the same insertion point (kept both), and #2298 (#2261) moved the store onto the dedicated portalHttp instance — this branch's two new asks calls move with it, exactly as the fetchAsks comment promised ('when that lands, these two calls move with the other 29'), and workspaceAsks.spec.js stubs portalHttp instead of the global axios (the workspaceSession.spec.js pattern). All 48 tests across the three affected specs pass. Co-Authored-By: Claude Fable 5 <[email protected]>
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.
Fixes #2261.
Summary
#2258's stated residual. Expiry cannot end the platform credential — that would log an operator out of another tab over a client's idle timeout — so
endSession → signOutcleared only the portal token andisPlatformSessionre-derived from the platform JWT still in the browser. The client's tab silently became the operator's.Why the flag the issue suggested works now
#2258 rejected it on evidence, and the evidence was about the wire:
auth.jsinstalls the platform JWT as anaxios.defaultsheader, per-request headers merge over defaults, so a flag hides the operator's roster on screen while every workspace request still carries the operator's credential. So this fixes the wire first:portalHttp) whose request interceptor decides the credential and strips whateveraxios.defaultsmerged in.authHeaderreturns{}while suppressed.platformFallbackSuppressed, set when a client session expires here;isPlatformSessionreturns false while set. sessionStorage — survives a refresh of this tab and nothing wider, which is also what leaves the operator's other tab alone.Neither half works alone, and that is the whole design.
streamPortalExecutionuses barefetchwithauthHeaderonly, so it was already honest and stays so.The escape hatch is mandatory, not a nicety. The suppression fails closed, so it necessarily catches the operator when the browser is genuinely theirs — "Continue as
<email>" is the one explicit click back in. Re-deriving automatically is the bug.Three things surfaced while building it
1. The 401 bounce had to move with the transport — and off the wrong question.
main.jsdecided withonWorkspace && localStorage['token']. Workspace calls no longer reach it, so the operator bounce is re-registered viasetPlatformSessionLostHandlerand fires only whenisPlatformSession. That's false in exactly the case the old predicate got wrong: a client at the OTP form on a browser holding an operator's JWT, where one mistyped digit would 401, bounce them to /login, and destroy the operator's session — objection 3 inworkspace-session-signout.md, now closed by construction. Without the move, an operator whose JWT expired on the workspace would have sat on "Failed to load your agents" forever.2.
sessionExpiredwas never rendered. The store has set it since ent#375 and no view read it, so an idle-out was indistinguishable from "you were never signed in" — the form just reappeared. It says which now.3.
resumePathwas never read either, so the notice's "pick up where you left off" was a promise the app didn't keep. The sign-in that consumes the expiry navigates there.Acceptance criteria
shows the expired sign-in state,and a refresh keeps it thereleaves the operator's platform session alone(+__logoutnever called)sends no credential while the UI says signed out,strips a platform JWT merged in from axios defaultsworkspaceSession.spec.jsA test-harness bug worth flagging
The spec's axios mock returned one shared instance for every
create(), soapi.js's PERF-269 dedupe wrapper (which replaces.geton its own instance) was also replacing the workspace store's — a stub on it was silently not the code path, and it surfaced only because this PR moved the store onto an instance.create()now returns a fresh instance, like real axios.Testing
Not covered by the unit suite (node-only, no DOM): the two new template branches render only in a browser. Their conditions are pure computeds over tested store state, and both carry
data-testids for an e2e follow-up.Docs
docs/memory/feature-flows/workspace-session-signout.md— the residual is struck through with the reason the flag became viable, plus a new "The expiry path (#2261)" section covering both halves, the escape, the bounce move, and the private-mode degradation.Related to #2261