Compare commits

...
Author SHA1 Message Date
Cursor Agent 04e6a947fc 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.
2026-02-18 18:47:11 +00:00
+20
View File
@@ -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,
}
: {}),
};
}