fix: clear stale diff panel targets in DELETE_PROJECT and SYNC_PROJECTS reducers
When threads are removed by DELETE_PROJECT or SYNC_PROJECTS, the diff panel state (diffOpen, diffThreadId, diffTurnId, diffFilePath) was not being cleared if the removed threads included the one referenced by diffThreadId. This mirrors the cleanup already done in DELETE_THREAD.
This commit is contained in:
1 parent
108513f246
commit
04e6a947fc
1 file changed
+20
@@ -602,12 +602,22 @@ export function reducer(state: AppState, action: Action): AppState {
|
||||
const activeThreadId = nextThreads.some((thread) => thread.id === state.activeThreadId)
|
||||
? state.activeThreadId
|
||||
: (nextThreads[0]?.id ?? null);
|
||||
const shouldClearDiffTarget =
|
||||
state.diffThreadId !== null && !nextThreads.some((t) => t.id === state.diffThreadId);
|
||||
|
||||
return {
|
||||
...state,
|
||||
projects: nextProjects,
|
||||
threads: nextThreads,
|
||||
activeThreadId,
|
||||
...(shouldClearDiffTarget
|
||||
? {
|
||||
diffOpen: false,
|
||||
diffThreadId: null,
|
||||
diffTurnId: null,
|
||||
diffFilePath: null,
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -629,12 +639,22 @@ export function reducer(state: AppState, action: Action): AppState {
|
||||
const activeThreadId = threads.some((thread) => thread.id === state.activeThreadId)
|
||||
? state.activeThreadId
|
||||
: (threads[0]?.id ?? null);
|
||||
const shouldClearDiffTarget =
|
||||
state.diffThreadId !== null && !threads.some((t) => t.id === state.diffThreadId);
|
||||
|
||||
return {
|
||||
...state,
|
||||
projects,
|
||||
threads,
|
||||
activeThreadId,
|
||||
...(shouldClearDiffTarget
|
||||
? {
|
||||
diffOpen: false,
|
||||
diffThreadId: null,
|
||||
diffTurnId: null,
|
||||
diffFilePath: null,
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user