Upload 27 files
Browse files
client/src/hooks/useChatSession.js
CHANGED
|
@@ -228,6 +228,20 @@ export function useChatSession() {
|
|
| 228 |
}
|
| 229 |
}, [activeSession?.mode]);
|
| 230 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
// Save sessions globally whenever they change
|
| 232 |
useEffect(() => {
|
| 233 |
if (sessions.length > 0) {
|
|
|
|
| 228 |
}
|
| 229 |
}, [activeSession?.mode]);
|
| 230 |
|
| 231 |
+
// Sync selectedModelId onto the active session while it's still empty
|
| 232 |
+
// This ensures that if the user changes the model dropdown before typing,
|
| 233 |
+
// the session remembers this correct new model when it gets locked.
|
| 234 |
+
useEffect(() => {
|
| 235 |
+
if (activeSession && selectedModelId && !isSessionLocked) {
|
| 236 |
+
if (activeSession.modelId !== selectedModelId) {
|
| 237 |
+
updateSession(activeSession.id, (session) => ({
|
| 238 |
+
...session,
|
| 239 |
+
modelId: selectedModelId
|
| 240 |
+
}));
|
| 241 |
+
}
|
| 242 |
+
}
|
| 243 |
+
}, [activeSession, selectedModelId, isSessionLocked]);
|
| 244 |
+
|
| 245 |
// Save sessions globally whenever they change
|
| 246 |
useEffect(() => {
|
| 247 |
if (sessions.length > 0) {
|