feat: check the server on launch and remember the selected model
The chat showed 'Server offline' until the user opened Settings, and the selected model was forgotten on every restart. useAutoConnect fetches the models once after the persisted settings are restored; activeModelId is now persisted.
This commit is contained in:
1 parent
1a3ce9ccec
commit
541aefd7e4
5 files changed
+72
-2
No files matched your search
@@ -162,13 +162,14 @@ describe('chat sessions', () => {
|
||||
});
|
||||
|
||||
describe('persistence', () => {
|
||||
it('persists settings and chats but not transient connection or streaming state', async () => {
|
||||
it('persists settings, the selected model and chats but not transient connection or streaming state', async () => {
|
||||
useAppStore.setState({
|
||||
theme: 'dark',
|
||||
serverConfig: { host: 'lan.local', port: 4321, apiKey: 'k' },
|
||||
isConnected: true,
|
||||
isStreaming: true,
|
||||
activeModelId: 'model',
|
||||
availableModels: [{ id: 'model', object: 'model', owned_by: 'x' }],
|
||||
editingMessageId: 'e',
|
||||
});
|
||||
state().addMessage({ role: 'user', content: 'persist me' });
|
||||
@@ -178,9 +179,10 @@ describe('persistence', () => {
|
||||
const persisted = JSON.parse(raw as string).state;
|
||||
|
||||
expect(Object.keys(persisted).sort()).toEqual(
|
||||
['chatSessions', 'currentChatId', 'messages', 'serverConfig', 'theme'],
|
||||
['activeModelId', 'chatSessions', 'currentChatId', 'messages', 'serverConfig', 'theme'],
|
||||
);
|
||||
expect(persisted.serverConfig).toEqual({ host: 'lan.local', port: 4321, apiKey: 'k' });
|
||||
expect(persisted.activeModelId).toBe('model');
|
||||
expect(persisted.messages[0].content).toBe('persist me');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user