fix(web): the console switcher carries no token and sits beside the chip (#815 review) - #816
Merged
Merged
Conversation
…hip (#815 review) #815 put every running console's `http://.../?token=` into /api/config and into <option value>: the paper console's page held the live console's session token, and its own, which security.py says must never be written into the page. It also rendered an empty select (`el()` has no children form), named a different console as this one when this console had no record, showed a start-up mode that goes stale, and made the session chip a dropdown, which #704 forbids. - The page gets {label, href} per OTHER console; href is a token-free /switch/<port> on this console. server._switch reads the peer's record when followed and 303s into the peer's own ?token= hand-off, so only the browser's navigation carries the token (as `keel open` does). Local only: security.local_deployment, shared with gated_action_permitted, plus a loopback peer. - sw.js declines /switch/ navigations to the network; answered from the cached shell they would silently do nothing. - The switcher is its own control, #console-switcher, beside the chip. sessionChip is back to its pre-#815 code and still passes #704's no-interactive-node rule; the new control has a matching rule. - This console is never read from a record; no mode in labels; the record no longer stores one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
eaitbrahim
added a commit
that referenced
this pull request
Sep 25, 2026
…e switcher with no tokens (#818) MINOR: #810 and #814/#816 add console features. No schema change since 0.16.0, so a deployment needs no `keel migrate` step beyond the usual idempotent run. What lands: #807 -- a quote-increment cache record predating quote_increment is a MISS, not an "unknown". #810 -- the refused view says how to get the address it asks you to paste; #817 fixes its duplicate `const note`, which blanked the console. #813 (#812) -- the cycle line ends `vetoed=N (rail, ...)`, so a rail veto no longer reads as a silent drop. #815 + #816 (#814) -- a console switcher beside the session chip. /api/config carries no session token; /switch/<port> redirects into the chosen console's own hand-off, local deployments only. Eight workspace versions and the inter-package `==` pins move together, plus the refreshed uv.lock the release workflow checks first. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Follow-up to #815 (merged, not yet released), from its review. Refs #814.
What was wrong in #815
live_peersreturnedurl_for(record), which ishttp://host:port/?token=…, for every running console, and/api/configcarried the list into<option value>. So the paper console's page held the live console's session token, and its own. That breakssecurity.py("HttpOnlyand must never be written into the page"). On a tunnelled deployment it would also have shipped every local token to the remote viewer.el(tag, className, text)has no children form, soel("select", …, ...options)set the select's text to"[object HTMLOptionElement]"and dropped every option._auto_trade_mode's rule of re-reading the config on every request.test_neither_the_chip_nor_the_banner_builds_anything_clickablebecauseselectisn't on that test's token list.The fix
payload.profile_switchersends{switchable, choices: [{label, href}], display}. Eachhrefis a token-free/switch/<port>on the current console.GET /switch/<port>. This goes through normal admission, then a locality check, then reads the peer's record at click time. It answers303to the peer's own?token=hand-off, which is the routekeel openalready uses. No page script can read a redirect'sLocationheader./.security.local_deploymentis split out ofgated_action_permitted, so the switcher offer and the switch route can't disagree about what "local" means.sw.jsnow sends/switch/navigations to the network. Otherwise the cached shell would answer them and switching would silently do nothing.#console-switchersits beside the chip. It's a select with a disabled "switch console…" placeholder, listing the other consoles.sessionChipis byte-identical to its pre-feat(web): in-app profile switcher dropdown for multi-daemon navigation (#814) #815 code and passes [web] Session identity: profile · mode · equity-state switcher chip and a no-CTA paper banner #704's rule unchanged.servenow callsapi._profile_nameinstead of an inline copy of it.Verification
tests/web/test_profile_switcher.pyis rewritten (23 tests). The old version asserted the token was present in the URL.el, dropping the locality check, removing the service-worker guard, listing this console as a choice, offering switching on a remote deployment, and an extra payload field.ruff check,ruff format --checkandmypyare clean.KEEL_HOME(keel-live and keel-paper) with the service worker controlling the page./api/config200) with no token left in the URL./api/configcontains notoken=.Note:
maincurrently has a JS syntax error from #810 (a duplicateconst noteinrender.js), so every console built frommainis blank. It's fixed separately. For the manual check above I applied that rename locally; it is not in this PR.🤖 Generated with Claude Code