From 48f7be9d8d73711684cde1385ad0182227bc9ae9 Mon Sep 17 00:00:00 2001 From: Siddharth Ganesan Date: Fri, 23 Jan 2026 19:19:24 -0800 Subject: [PATCH] Fix copilot masking --- .../components/copilot-message/copilot-message.tsx | 6 ++++-- apps/sim/stores/panel/copilot/store.ts | 13 ++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-message/copilot-message.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-message/copilot-message.tsx index acbb30ff2..bdcee7590 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-message/copilot-message.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-message/copilot-message.tsx @@ -78,9 +78,11 @@ const CopilotMessage: FC = memo( mode, setMode, isAborting, - maskCredentialValue, } = useCopilotStore() + // Use stable selector to avoid re-renders when unrelated state changes + const maskCredentialValue = useCopilotStore((s) => s.maskCredentialValue) + const messageCheckpoints = isUser ? allMessageCheckpoints[message.id] || [] : [] const hasCheckpoints = messageCheckpoints.length > 0 && messageCheckpoints.some((cp) => cp?.id) @@ -265,7 +267,7 @@ const CopilotMessage: FC = memo( } return null }) - }, [message.contentBlocks, isActivelyStreaming, parsedTags, isLastMessage, maskCredentialValue]) + }, [message.contentBlocks, isActivelyStreaming, parsedTags, isLastMessage]) if (isUser) { return ( diff --git a/apps/sim/stores/panel/copilot/store.ts b/apps/sim/stores/panel/copilot/store.ts index 5068cd167..c9464b4c1 100644 --- a/apps/sim/stores/panel/copilot/store.ts +++ b/apps/sim/stores/panel/copilot/store.ts @@ -2737,11 +2737,14 @@ export const useCopilotStore = create()( })) } - // Load sensitive credential IDs for masking before streaming starts - await get().loadSensitiveCredentialIds() - - // Ensure auto-allowed tools are loaded before tool calls arrive - await get().loadAutoAllowedTools() + // Load sensitive credential IDs and auto-allowed tools in background (non-blocking) + // These will be ready before any tool calls arrive since SSE setup takes time + get().loadSensitiveCredentialIds().catch((err) => { + logger.warn('[Copilot] Failed to load sensitive credential IDs', err) + }) + get().loadAutoAllowedTools().catch((err) => { + logger.warn('[Copilot] Failed to load auto-allowed tools', err) + }) let newMessages: CopilotMessage[] if (revertState) {