mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-06-11 18:05:58 +00:00
fix(frontend): unify local settings runtime state and remove sidebar layout from LocalSettings (#1879)
* fix(frontend): resolve layout flickering by migrating workspace sidebar state to cookie * fix(frontend): unify local settings runtime state to fix state drift * fix(frontend): only persist thread model on explicit context model updates
This commit is contained in:
@@ -9,13 +9,10 @@ export const DEFAULT_LOCAL_SETTINGS: LocalSettings = {
|
||||
mode: undefined,
|
||||
reasoning_effort: undefined,
|
||||
},
|
||||
layout: {
|
||||
sidebar_collapsed: false,
|
||||
},
|
||||
};
|
||||
|
||||
const LOCAL_SETTINGS_KEY = "deerflow.local-settings";
|
||||
const THREAD_MODEL_KEY_PREFIX = "deerflow.thread-model.";
|
||||
export const LOCAL_SETTINGS_KEY = "deerflow.local-settings";
|
||||
export const THREAD_MODEL_KEY_PREFIX = "deerflow.thread-model.";
|
||||
|
||||
function isBrowser(): boolean {
|
||||
return typeof window !== "undefined";
|
||||
@@ -38,9 +35,6 @@ export interface LocalSettings {
|
||||
mode: "flash" | "thinking" | "pro" | "ultra" | undefined;
|
||||
reasoning_effort?: "minimal" | "low" | "medium" | "high";
|
||||
};
|
||||
layout: {
|
||||
sidebar_collapsed: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
function mergeLocalSettings(settings?: Partial<LocalSettings>): LocalSettings {
|
||||
@@ -50,10 +44,6 @@ function mergeLocalSettings(settings?: Partial<LocalSettings>): LocalSettings {
|
||||
...DEFAULT_LOCAL_SETTINGS.context,
|
||||
...settings?.context,
|
||||
},
|
||||
layout: {
|
||||
...DEFAULT_LOCAL_SETTINGS.layout,
|
||||
...settings?.layout,
|
||||
},
|
||||
notification: {
|
||||
...DEFAULT_LOCAL_SETTINGS.notification,
|
||||
...settings?.notification,
|
||||
@@ -87,11 +77,10 @@ export function saveThreadModelName(
|
||||
localStorage.setItem(key, modelName);
|
||||
}
|
||||
|
||||
function applyThreadModelOverride(
|
||||
export function applyThreadModelOverride(
|
||||
settings: LocalSettings,
|
||||
threadId?: string,
|
||||
threadModelName: string | undefined,
|
||||
): LocalSettings {
|
||||
const threadModelName = threadId ? getThreadModelName(threadId) : undefined;
|
||||
if (!threadModelName) {
|
||||
return settings;
|
||||
}
|
||||
@@ -118,21 +107,9 @@ export function getLocalSettings(): LocalSettings {
|
||||
return DEFAULT_LOCAL_SETTINGS;
|
||||
}
|
||||
|
||||
export function getThreadLocalSettings(threadId: string): LocalSettings {
|
||||
return applyThreadModelOverride(getLocalSettings(), threadId);
|
||||
}
|
||||
|
||||
export function saveLocalSettings(settings: LocalSettings) {
|
||||
if (!isBrowser()) {
|
||||
return;
|
||||
}
|
||||
localStorage.setItem(LOCAL_SETTINGS_KEY, JSON.stringify(settings));
|
||||
}
|
||||
|
||||
export function saveThreadLocalSettings(
|
||||
threadId: string,
|
||||
settings: LocalSettings,
|
||||
) {
|
||||
saveLocalSettings(settings);
|
||||
saveThreadModelName(threadId, settings.context.model_name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user