Skip to content

Commit 48f7be9

Browse files
committed
Fix copilot masking
1 parent b913cff commit 48f7be9

File tree

2 files changed

+12
-7
lines changed
  • apps/sim
    • app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-message
    • stores/panel/copilot

2 files changed

+12
-7
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-message/copilot-message.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ const CopilotMessage: FC<CopilotMessageProps> = memo(
7878
mode,
7979
setMode,
8080
isAborting,
81-
maskCredentialValue,
8281
} = useCopilotStore()
8382

83+
// Use stable selector to avoid re-renders when unrelated state changes
84+
const maskCredentialValue = useCopilotStore((s) => s.maskCredentialValue)
85+
8486
const messageCheckpoints = isUser ? allMessageCheckpoints[message.id] || [] : []
8587
const hasCheckpoints = messageCheckpoints.length > 0 && messageCheckpoints.some((cp) => cp?.id)
8688

@@ -265,7 +267,7 @@ const CopilotMessage: FC<CopilotMessageProps> = memo(
265267
}
266268
return null
267269
})
268-
}, [message.contentBlocks, isActivelyStreaming, parsedTags, isLastMessage, maskCredentialValue])
270+
}, [message.contentBlocks, isActivelyStreaming, parsedTags, isLastMessage])
269271

270272
if (isUser) {
271273
return (

apps/sim/stores/panel/copilot/store.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2737,11 +2737,14 @@ export const useCopilotStore = create<CopilotStore>()(
27372737
}))
27382738
}
27392739

2740-
// Load sensitive credential IDs for masking before streaming starts
2741-
await get().loadSensitiveCredentialIds()
2742-
2743-
// Ensure auto-allowed tools are loaded before tool calls arrive
2744-
await get().loadAutoAllowedTools()
2740+
// Load sensitive credential IDs and auto-allowed tools in background (non-blocking)
2741+
// These will be ready before any tool calls arrive since SSE setup takes time
2742+
get().loadSensitiveCredentialIds().catch((err) => {
2743+
logger.warn('[Copilot] Failed to load sensitive credential IDs', err)
2744+
})
2745+
get().loadAutoAllowedTools().catch((err) => {
2746+
logger.warn('[Copilot] Failed to load auto-allowed tools', err)
2747+
})
27452748

27462749
let newMessages: CopilotMessage[]
27472750
if (revertState) {

0 commit comments

Comments
 (0)