From 48f7be9d8d73711684cde1385ad0182227bc9ae9 Mon Sep 17 00:00:00 2001 From: Siddharth Ganesan Date: Fri, 23 Jan 2026 19:19:24 -0800 Subject: [PATCH 1/3] 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 acbb30ff20..bdcee75900 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 5068cd1673..c9464b4c19 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) { From 58ef2def008a51cea4ffb0e63e2fe8e98201ac1c Mon Sep 17 00:00:00 2001 From: Siddharth Ganesan Date: Fri, 23 Jan 2026 19:26:05 -0800 Subject: [PATCH 2/3] Colean up --- .../copilot/components/copilot-message/copilot-message.tsx | 1 - apps/sim/stores/panel/copilot/store.ts | 2 -- 2 files changed, 3 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 bdcee75900..1e745f3f28 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 @@ -80,7 +80,6 @@ const CopilotMessage: FC = memo( isAborting, } = useCopilotStore() - // Use stable selector to avoid re-renders when unrelated state changes const maskCredentialValue = useCopilotStore((s) => s.maskCredentialValue) const messageCheckpoints = isUser ? allMessageCheckpoints[message.id] || [] : [] diff --git a/apps/sim/stores/panel/copilot/store.ts b/apps/sim/stores/panel/copilot/store.ts index c9464b4c19..ca8acc6446 100644 --- a/apps/sim/stores/panel/copilot/store.ts +++ b/apps/sim/stores/panel/copilot/store.ts @@ -2737,8 +2737,6 @@ export const useCopilotStore = create()( })) } - // 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) }) From 1944da14bcc9ef9bd760357e9aa008f32cd59260 Mon Sep 17 00:00:00 2001 From: Siddharth Ganesan Date: Fri, 23 Jan 2026 19:31:31 -0800 Subject: [PATCH 3/3] Lint --- apps/sim/stores/panel/copilot/store.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/sim/stores/panel/copilot/store.ts b/apps/sim/stores/panel/copilot/store.ts index ca8acc6446..10d66b3984 100644 --- a/apps/sim/stores/panel/copilot/store.ts +++ b/apps/sim/stores/panel/copilot/store.ts @@ -2737,12 +2737,16 @@ export const useCopilotStore = create()( })) } - 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) - }) + 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) {