Files
ThothII/frontend/src/workspaces/preferences.ts
T

36 lines
984 B
TypeScript

export interface WorkspacePreference {
workspaceId?: string;
provider?: string;
model?: string;
thinking?: string;
}
let current: WorkspacePreference | undefined;
function snapshot(value: WorkspacePreference | undefined): WorkspacePreference {
return value === undefined ? {} : { ...value };
}
/** Ephemeral workspace choices for the current application process. */
export const workspacePreferences = {
load(): WorkspacePreference {
return snapshot(current);
},
save(value: WorkspacePreference): WorkspacePreference {
current = { ...value };
return snapshot(current);
},
/** Seed current memory from backend installation settings only before the first local choice. */
migrate(settings: WorkspacePreference): WorkspacePreference {
if (current === undefined) current = { ...settings };
return snapshot(current);
},
/** Clear ephemeral state on application/test lifecycle reset. */
reset(): void {
current = undefined;
},
};