From dce8e40dcace06e6dece7e3cbe68aea3d25566d8 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Mon, 24 Aug 2026 10:44:27 -0700 Subject: [PATCH] fix(workspace-cleanup): unify chip clears on the merged updater form #15298 landed the functional-update `patchFilters`, so `replaceFilters` uses the same idiom rather than reading the store directly. Same guarantee, one pattern. --- .../use-workspace-cleanup-browse-state.test.tsx | 1 - .../use-workspace-cleanup-browse-state.ts | 7 +++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-browse-state.test.tsx b/src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-browse-state.test.tsx index 70f8f903afe..061fdf3ea9e 100644 --- a/src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-browse-state.test.tsx +++ b/src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-browse-state.test.tsx @@ -105,7 +105,6 @@ describe('useWorkspaceCleanupBrowseState', () => { field: 'size', direction: 'desc' }) - }) }) it('keeps a cleared chip cleared when a facet patch lands in the same tick', () => { diff --git a/src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-browse-state.ts b/src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-browse-state.ts index 87e15404527..3651f4e01a0 100644 --- a/src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-browse-state.ts +++ b/src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-browse-state.ts @@ -60,12 +60,11 @@ export function useWorkspaceCleanupBrowseState(): WorkspaceCleanupBrowseControll [updateBrowse] ) - // Why read the store rather than the rendered `browse`: a chip click and any other - // filter write can land in the same tick, and the rendered snapshot would drop one. + // Same updater form as patchFilters: a chip clear and a facet patch can land in one + // tick, and whichever read the render snapshot would undo the other. const replaceFilters = useCallback( (transform) => { - const current = useAppStore.getState().workspaceCleanupBrowse - updateBrowse({ ...current, filters: transform(current.filters) }) + updateBrowse((current) => ({ ...current, filters: transform(current.filters) })) }, [updateBrowse] )