-
-
Notifications
You must be signed in to change notification settings - Fork 1
bug(frontend): duplicate auto-save on mount — controller and ChatInterface both register independent save intervals #3750
Description
Summary
`ChatInterface.vue` registers two independent auto-save intervals on every mount, causing every session to be saved twice per cycle.
Root Cause
`onMounted` in `ChatInterface.vue:822-829` calls both:
```ts
// Call 1 — ChatController interval (30s default, leaked — see related issue)
if (store.settings.autoSave) {
controller.enableAutoSave()
}
// Call 2 — local Vue interval (120s, properly managed)
enableAutoSave()
```
Both check `store.settings.autoSave && store.currentSessionId` and both call `controller.saveChatSession()`. When they fire at the same time, two identical `POST /api/chats/{id}/save` requests hit the backend simultaneously.
Evidence
Backend log for session `82feb428-c4fa-4e4d-ab89-f94c7ca056b2` shows two simultaneous saves at every interval tick:
```
2026-04-07 13:24:59 POST /api/chats/.../save 200 OK
2026-04-07 13:24:59 POST /api/chats/.../save 200 OK ← duplicate same second
2026-04-07 13:25:59 POST /api/chats/.../save 200 OK
2026-04-07 13:25:59 POST /api/chats/.../save 200 OK ← duplicate same second
```
Fix
Remove the `controller.enableAutoSave()` call from `onMounted`. The local `enableAutoSave()` (120s, properly managed with `clearInterval` guard) is sufficient. The controller method is redundant and also leaks its interval (see related issue).