Skip to content

Commit e7b0b00

Browse files
centdixclaude
andauthored
fix: mark base_url as unsaved when using browser fallback (#7964)
* fix: mark base_url as unsaved when using browser fallback in instance settings When base_url is not set in the database, the frontend silently fills in window.location.origin but also snapshots it as the initial value. This makes the dirty-check see no change, so the Save button stays disabled and the user cannot persist the auto-detected value. Fix by snapshotting initialValues before applying the fallback, and show a yellow warning indicating the value is auto-detected and unsaved. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: render base_url fallback warning inside the setting card Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4587cd5 commit e7b0b00

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

frontend/src/lib/components/InstanceSetting.svelte

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@
3535
loading?: boolean
3636
openSmtpSettings?: () => void
3737
oauths?: Record<string, any>
38+
warning?: string
3839
}
3940
40-
let { setting, version, values, loading = true, openSmtpSettings, oauths }: Props = $props()
41+
let { setting, version, values, loading = true, openSmtpSettings, oauths, warning }: Props = $props()
4142
const dispatch = createEventDispatcher()
4243
4344
let latestKeyRenewalAttempt: {
@@ -282,6 +283,11 @@
282283
bind:value={$values[setting.key]}
283284
class="max-w-lg"
284285
/>
286+
{#if warning}
287+
<span class="text-yellow-600 dark:text-yellow-500 text-2xs">
288+
{warning}
289+
</span>
290+
{/if}
285291
{#if setting.advancedToggle}
286292
<div class="mt-1">
287293
<Toggle

frontend/src/lib/components/InstanceSettings.svelte

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
let requirePreexistingUserForOauth: boolean = $state(false)
5353
5454
let initialValues: Record<string, any> = $state({})
55+
let baseUrlIsFallback = $state(false)
5556
let snowflakeAccountIdentifier = $state('')
5657
let version: string = $state('')
5758
let loading = $state(true)
@@ -96,16 +97,20 @@
9697
9798
let nvalues: Record<string, any> = { ...gs }
9899
99-
if (!nvalues['base_url']) {
100-
nvalues['base_url'] = window.location.origin
101-
}
100+
baseUrlIsFallback = !nvalues['base_url']
102101
if (nvalues['retention_period_secs'] == undefined) {
103102
nvalues['retention_period_secs'] = 60 * 60 * 24 * 30
104103
}
105104
applyFormDefaults(nvalues)
106105
106+
// Snapshot initialValues before applying the base_url fallback so that
107+
// the dirty-check detects the unsaved default and enables the Save button.
108+
initialValues = JSON.parse(JSON.stringify(nvalues))
109+
110+
if (baseUrlIsFallback) {
111+
nvalues['base_url'] = window.location.origin
112+
}
107113
$values = nvalues
108-
initialValues = JSON.parse(JSON.stringify($values))
109114
loading = false
110115
111116
// populate snowflake account identifier from db
@@ -186,6 +191,7 @@
186191
initialValues = JSON.parse(JSON.stringify($values))
187192
initialOauths = JSON.parse(JSON.stringify(oauths))
188193
initialRequirePreexistingUserForOauth = requirePreexistingUserForOauth
194+
baseUrlIsFallback = false
189195
190196
if (licenseKeySet) {
191197
setLicense()
@@ -502,6 +508,9 @@
502508
const v = $values[s.key]
503509
initialValues[s.key] = v !== undefined ? JSON.parse(JSON.stringify(v)) : undefined
504510
}
511+
if (categorySettings.some((s) => s.key === 'base_url')) {
512+
baseUrlIsFallback = false
513+
}
505514
506515
// Handle Auth/OAuth/SAML-specific saves
507516
if (category === 'Auth/OAuth/SAML') {
@@ -998,6 +1007,7 @@
9981007
{values}
9991008
{version}
10001009
{oauths}
1010+
warning={setting.key === 'base_url' && baseUrlIsFallback ? 'Auto-detected from browser — not yet saved' : undefined}
10011011
/>
10021012
{/if}
10031013
{/each}

0 commit comments

Comments
 (0)