fix(control-ui): preserve URL session parameter over localStorage defaults
When opening the dashboard with a ?session= URL parameter, the session was being overwritten by applySessionDefaults() after the gateway connected. This broke direct links to specific sessions (e.g., from external tools like Kanban boards with per-project sessions). The fix adds a sessionFromUrl flag that's set when a session is explicitly provided via URL. applySessionDefaults() now checks for this flag and skips overriding URL-provided sessions. Fixes #4150
This commit is contained in:
parent
4583f88626
commit
a75d939cb0
@ -84,6 +84,16 @@ function normalizeSessionKeyForDefaults(
|
|||||||
|
|
||||||
function applySessionDefaults(host: GatewayHost, defaults?: SessionDefaultsSnapshot) {
|
function applySessionDefaults(host: GatewayHost, defaults?: SessionDefaultsSnapshot) {
|
||||||
if (!defaults?.mainSessionKey) return;
|
if (!defaults?.mainSessionKey) return;
|
||||||
|
|
||||||
|
// If session was explicitly set from URL, don't override with defaults
|
||||||
|
// This ensures direct links to specific sessions work correctly
|
||||||
|
const hostWithFlag = host as GatewayHost & { sessionFromUrl?: boolean };
|
||||||
|
if (hostWithFlag.sessionFromUrl) {
|
||||||
|
// Clear the flag after first connection so future reconnects can apply defaults if needed
|
||||||
|
hostWithFlag.sessionFromUrl = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const resolvedSessionKey = normalizeSessionKeyForDefaults(host.sessionKey, defaults);
|
const resolvedSessionKey = normalizeSessionKeyForDefaults(host.sessionKey, defaults);
|
||||||
const resolvedSettingsSessionKey = normalizeSessionKeyForDefaults(
|
const resolvedSettingsSessionKey = normalizeSessionKeyForDefaults(
|
||||||
host.settings.sessionKey,
|
host.settings.sessionKey,
|
||||||
|
|||||||
@ -88,6 +88,8 @@ export function applySettingsFromUrl(host: SettingsHost) {
|
|||||||
const session = sessionRaw.trim();
|
const session = sessionRaw.trim();
|
||||||
if (session) {
|
if (session) {
|
||||||
host.sessionKey = session;
|
host.sessionKey = session;
|
||||||
|
// Mark that this session was explicitly set from URL to prevent override by defaults
|
||||||
|
(host as { sessionFromUrl?: boolean }).sessionFromUrl = true;
|
||||||
applySettings(host, {
|
applySettings(host, {
|
||||||
...host.settings,
|
...host.settings,
|
||||||
sessionKey: session,
|
sessionKey: session,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user