Skip to content

Commit 06c8066

Browse files
committed
fix(chat): apply same setState bail-out to clearContexts for consistency
Matches the invariant we already established for the message effect: calling setSelectedContexts([]) against an already-empty array emits a fresh [] reference (Object.is bails out are not reference-level), which cascades through consumers that key on selectedContexts identity. clearContexts is part of the hook's public API so callers can't know whether the list is empty — make it safe for them. Made-with: Cursor
1 parent 07adcc5 commit 06c8066

File tree

1 file changed

+1
-1
lines changed
  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/hooks

1 file changed

+1
-1
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/hooks/use-context-management.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function useContextManagement({ message, initialContexts }: UseContextMan
4949
* Clears all selected contexts
5050
*/
5151
const clearContexts = useCallback(() => {
52-
setSelectedContexts([])
52+
setSelectedContexts((prev) => (prev.length === 0 ? prev : []))
5353
}, [])
5454

5555
/**

0 commit comments

Comments
 (0)