Fix copilot masking

This commit is contained in:
Siddharth Ganesan
2026-01-23 19:19:24 -08:00
parent b913cff46e
commit 48f7be9d8d
2 changed files with 12 additions and 7 deletions

View File

@@ -78,9 +78,11 @@ const CopilotMessage: FC<CopilotMessageProps> = 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<CopilotMessageProps> = memo(
}
return null
})
}, [message.contentBlocks, isActivelyStreaming, parsedTags, isLastMessage, maskCredentialValue])
}, [message.contentBlocks, isActivelyStreaming, parsedTags, isLastMessage])
if (isUser) {
return (

View File

@@ -2737,11 +2737,14 @@ export const useCopilotStore = create<CopilotStore>()(
}))
}
// 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) {