66 getActiveWorkflowRecord ,
77} from '@sim/platform-authz/workflow'
88import { and , eq , isNull , ne } from 'drizzle-orm'
9+ import { getBlockVisibilityForCopilot } from '@/lib/copilot/block-visibility'
910import {
1011 MAX_TABLE_SELECTION_CONTENT_LENGTH ,
1112 safeBrowserSelectionUrl ,
@@ -25,7 +26,7 @@ import {
2526} from '@/lib/copilot/vfs/path-utils'
2627import { EnvCapabilityConfigurationError } from '@/lib/core/config/env-capabilities'
2728import { getAllowedIntegrationsFromEnv } from '@/lib/core/config/env-flags'
28- import { isIntegrationDeploymentAvailable } from '@/lib/integrations/availability.server'
29+ import { isIntegrationDeploymentAvailableForVisibility } from '@/lib/integrations/availability.server'
2930import { toOverview } from '@/lib/logs/log-views'
3031import type { TraceSpan } from '@/lib/logs/types'
3132import { mcpService } from '@/lib/mcp/service'
@@ -612,11 +613,13 @@ async function processBlockMetadata(
612613 workspaceId ?: string
613614) : Promise < AgentContext | null > {
614615 try {
615- const permissionConfig =
616- userId && workspaceId ? await getUserPermissionConfig ( userId , workspaceId ) : null
616+ const [ permissionConfig , visibility ] = await Promise . all ( [
617+ userId && workspaceId ? getUserPermissionConfig ( userId , workspaceId ) : null ,
618+ userId ? getBlockVisibilityForCopilot ( userId , workspaceId ) : null ,
619+ ] )
617620 const allowedIntegrations =
618621 permissionConfig ?. allowedIntegrations ?? getAllowedIntegrationsFromEnv ( )
619- if ( ! isIntegrationDeploymentAvailable ( blockId ) ) {
622+ if ( ! isIntegrationDeploymentAvailableForVisibility ( blockId , visibility ) ) {
620623 logger . debug ( 'Block unavailable for this deployment' , { blockId } )
621624 return null
622625 }
0 commit comments