Skip to content

Commit dc8f890

Browse files
only21milclaude
andcommitted
refactor(web): fall back to default client settings in the shared read
Both callers of the saved settings read now get the defaults when nothing is stored, so neither can keep an outdated snapshot. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3f9bb80 commit dc8f890

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎apps/web/src/hooks/useSettings.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,11 @@ export function subscribeClientSettingsHydration(listener: () => void): () => vo
133133
};
134134
}
135135

136-
async function readPersistedClientSettings(): Promise<ClientSettings | null> {
136+
async function readPersistedClientSettings(): Promise<ClientSettings> {
137137
const persistedSettings = await ensureLocalApi().persistence.getClientSettings();
138-
return persistedSettings ? { ...DEFAULT_CLIENT_SETTINGS, ...persistedSettings } : null;
138+
return persistedSettings
139+
? { ...DEFAULT_CLIENT_SETTINGS, ...persistedSettings }
140+
: DEFAULT_CLIENT_SETTINGS;
139141
}
140142

141143
async function hydrateClientSettings(): Promise<void> {
@@ -158,9 +160,7 @@ async function hydrateClientSettings(): Promise<void> {
158160
if (hydrationGeneration !== clientSettingsHydrationGeneration) {
159161
return;
160162
}
161-
if (persistedSettings) {
162-
replaceClientSettingsSnapshot(persistedSettings);
163-
}
163+
replaceClientSettingsSnapshot(persistedSettings);
164164
setClientSettingsHydrationStatus("ready");
165165
stopReloadingClientSettings ??= subscribeBrowserClientSettings(reloadClientSettings);
166166
} catch (error) {
@@ -202,7 +202,7 @@ async function ensureFreshClientSettings(): Promise<void> {
202202
return hydrateClientSettings();
203203
}
204204
if (clientSettingsStale) {
205-
replaceClientSettingsSnapshot((await readPersistedClientSettings()) ?? DEFAULT_CLIENT_SETTINGS);
205+
replaceClientSettingsSnapshot(await readPersistedClientSettings());
206206
clientSettingsStale = false;
207207
}
208208
}

0 commit comments

Comments
 (0)