← Back to PRs

#10093: fix: import gateway token from URL param into localStorage

by devjiro76 open 2026-02-06 03:39 View on GitHub →
app: web-ui stale
## Summary - When opening the Control UI with `?token=<value>` in the URL, the token was stripped from the URL but never persisted to localStorage, causing an authentication error on every visit. - Now the token is saved to localStorage on first visit (when no token is already stored), so the gateway connection succeeds immediately. - Existing stored tokens are not overwritten, preserving the original security intent. ## Test plan - [ ] Open `http://localhost:18789/?token=<gateway-token>` with empty localStorage — token should be saved and gateway should connect. - [ ] Open the same URL when a token is already stored — existing token should not be overwritten. - [ ] Updated browser test: "imports token from URL when no token is stored". 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR updates the Control UI settings bootstrap so that when the page is opened with a token URL parameter, the token is persisted into UI settings (and therefore localStorage) on first visit, while still stripping it from the URL. Concretely, `applySettingsFromUrl` now trims and imports the token only when `host.settings.token` is empty, preserving the existing intent of not overwriting already-stored tokens. Browser tests were updated to assert the new behavior and to keep coverage for the “do not override stored token” case. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk. - The change is small and localized (URL settings import), preserves the existing non-overwrite behavior for stored tokens, and is covered by an updated browser test plus an explicit regression test for the non-overwrite case. No other code paths are affected beyond initial URL parsing and settings persistence. - No files require special attention <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs