#10800: fix(ui): apply token from URL param to settings
app: web-ui
stale
Cluster:
UI Enhancements and Security Fixes
## Summary
This PR fixes a bug where the `token` URL parameter was being read and removed from the URL but never actually applied to the application settings. This prevented the dashboard from automatically authenticating when opened with a constructed URL (e.g., `?gatewayUrl=...&token=...`).
## Changes
- Modified `applySettingsFromUrl` in `ui/src/ui/app-settings.ts` to correctly assign the `token` to the settings object and persist it before cleaning the URL.
- Added a new test file `ui/src/ui/app-settings-url.test.ts` to verify that both `token` and `gatewayUrl` parameters are correctly processed, applied to settings, and removed from the browser history.
## Testing
- Verified with new unit tests in `ui/src/ui/app-settings-url.test.ts`.
- `token` is now correctly saved to localStorage, allowing immediate connection on load without manual entry.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
- Fixes `applySettingsFromUrl` so a `token` query param is actually persisted into UI settings before the URL is cleaned.
- Adds a new Vitest file to assert that `token` and `gatewayUrl` URL params are applied and removed via `history.replaceState`.
- Change is localized to the UI settings URL parsing path (`ui/src/ui/app-settings.ts`).
<h3>Confidence Score: 3/5</h3>
- This PR is close, but the new test file likely fails and URL cleanup is inconsistent for the session param.
- The `token` fix in `applySettingsFromUrl` is straightforward, but the added test uses a likely-nonexistent/incorrect module import for mocking and constructs a potentially invalid URL for `pushState`. Additionally, `session` is applied without being removed from the URL, which conflicts with the function’s cleanup behavior for other params.
- ui/src/ui/app-settings-url.test.ts, ui/src/ui/app-settings.ts
<!-- 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
#10093: fix: import gateway token from URL param into localStorage
by devjiro76 · 2026-02-06
85.1%
#18273: fix: extract token from URL query string for Control UI websocket auth
by MisterGuy420 · 2026-02-16
77.9%
#4154: fix(control-ui): preserve URL session parameter over localStorage d...
by joeyfrasier · 2026-01-29
77.8%
#6352: fix(ux): update gateway token error message UI location
by Glucksberg · 2026-02-01
76.5%
#13960: fix(ui): preserve structured config validation error details
by constansino · 2026-02-11
76.1%
#11109: fix(tui): prefer config contextTokens over persisted session value
by marezgui · 2026-02-07
75.6%
#17765: fix: add link to settings when chat shows auth error
by MisterGuy420 · 2026-02-16
75.2%
#19885: test(gateway,browser): isolate tests from ambient OPENCLAW_GATEWAY_...
by NewdlDewdl · 2026-02-18
74.7%
#9218: Fix Control UI chat resync on gaps and terminal events
by figitaki · 2026-02-05
73.2%
#22808: test(ui): split baseline browser-test fixes from webchat feature
by opnsec · 2026-02-21
73.2%