{
- const reset = await this.invoke('gui.chat.settings.reset');
- if (reset) {
- this.settings.set(reset);
- if (reset.default_model) {
- this.selectedModel.set(reset.default_model);
- }
+ const defaults = await this.invoke('gui.chat.settings.defaults');
+ if (!defaults) {
+ return;
+ }
+ const saved = await this.invoke('gui.chat.settings.save', defaults);
+ if (saved) {
+ this.settings.set(saved);
+ this.selectedModel.set(saved.default_model || '');
}
}
@@ -479,6 +481,17 @@ export class ChatStateService {
if (route === 'gui.chat.settings.load') {
return this.settings() as T;
}
+ if (route === 'gui.chat.settings.defaults') {
+ return {
+ temperature: 1,
+ top_p: 0.95,
+ top_k: 64,
+ max_tokens: 2048,
+ context_window: 8192,
+ system_prompt: 'You are a helpful assistant.',
+ default_model: '',
+ } as T;
+ }
if (route === 'gui.chat.settings.save') {
const settings = payload as ChatSettings;
this.settings.set(settings);
@@ -488,15 +501,7 @@ export class ChatStateService {
return settings as T;
}
if (route === 'gui.chat.settings.reset') {
- const defaults: ChatSettings = {
- temperature: 1,
- top_p: 0.95,
- top_k: 64,
- max_tokens: 2048,
- context_window: 8192,
- system_prompt: 'You are a helpful assistant.',
- default_model: '',
- };
+ const defaults = (await this.mockInvoke('gui.chat.settings.defaults')) as ChatSettings;
this.settings.set(defaults);
return defaults as T;
}
diff --git a/ui/src/chat/settings-panel.component.ts b/ui/src/chat/settings-panel.component.ts
index 2cafda3c..d1a05fbe 100644
--- a/ui/src/chat/settings-panel.component.ts
+++ b/ui/src/chat/settings-panel.component.ts
@@ -12,7 +12,7 @@ import { ChatSettings, ModelEntry } from './chat.types';
diff --git a/ui/src/generated/core-gui-chat.bindings.ts b/ui/src/generated/core-gui-chat.bindings.ts
index fa163c77..71a3b08f 100644
--- a/ui/src/generated/core-gui-chat.bindings.ts
+++ b/ui/src/generated/core-gui-chat.bindings.ts
@@ -14,6 +14,7 @@ declare global {
export interface ChatRouteMap {
'gui.chat.models': { request: void; response: ModelEntry[] };
+ 'gui.chat.settings.defaults': { request: void; response: ChatSettings };
'gui.chat.settings.load': { request: void; response: ChatSettings };
'gui.chat.settings.save': { request: ChatSettings; response: ChatSettings };
'gui.chat.settings.reset': { request: void; response: ChatSettings };