Skip to content

Commit afd9a7b

Browse files
authored
Only store tasks for active thread and message (#257)
1 parent 83db6af commit afd9a7b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

web/src/state/chat/reducer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ export const chatSlice = createSlice({
380380
}
381381
},
382382
startNewThread: (state) => {
383+
// Clear existing tasks
384+
state.threads[state.activeThread].tasks = []
383385
if (state.threads.length >= MAX_THREADS) {
384386
const excessThreads = state.threads.length - MAX_THREADS + 1;
385387
state.threads.splice(0, excessThreads);

web/src/state/store.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,11 +472,22 @@ const migrations = {
472472
newState.settings.metadataProcessingCache = {}
473473
return newState
474474
},
475+
46: (state: RootState) => {
476+
let newState = {...state}
477+
// Clear tasks objects in all threads except latest
478+
const activeThreadIndex = newState.chat.activeThread
479+
newState.chat.threads.forEach((thread, index: number) => {
480+
if (index !== activeThreadIndex) {
481+
thread.tasks = []
482+
}
483+
})
484+
return newState
485+
},
475486
}
476487

477488
const persistConfig = {
478489
key: 'root',
479-
version: 45,
490+
version: 46,
480491
storage,
481492
blacklist: ['billing', 'cache', userStateApi.reducerPath],
482493
// @ts-ignore

0 commit comments

Comments
 (0)