Skip to content

Commit a1f6b89

Browse files
committed
Fix filter identity check in project.deleted and thread.deleted handlers
Array.filter() always returns a new array, so identity checks like 'projects === state.projects' always evaluate to false. Replace with length comparison to preserve referential identity when no element was actually removed.
1 parent 45e5724 commit a1f6b89

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

apps/web/src/store.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,9 @@ export function applyOrchestrationEvent(state: AppState, event: OrchestrationEve
568568

569569
case "project.deleted": {
570570
const projects = state.projects.filter((project) => project.id !== event.payload.projectId);
571-
return projects === state.projects ? state : { ...state, projects, threadsHydrated: true };
571+
return projects.length === state.projects.length
572+
? state
573+
: { ...state, projects, threadsHydrated: true };
572574
}
573575

574576
case "thread.created": {
@@ -604,7 +606,9 @@ export function applyOrchestrationEvent(state: AppState, event: OrchestrationEve
604606

605607
case "thread.deleted": {
606608
const threads = state.threads.filter((thread) => thread.id !== event.payload.threadId);
607-
return threads === state.threads ? state : { ...state, threads, threadsHydrated: true };
609+
return threads.length === state.threads.length
610+
? state
611+
: { ...state, threads, threadsHydrated: true };
608612
}
609613

610614
case "thread.archived": {

0 commit comments

Comments
 (0)