From f012bc96fee0ac15823d7e4eeb17c9685f02df8a Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Mon, 14 Sep 2026 12:27:34 -0700 Subject: [PATCH 1/2] fix(copilot): import the block registry statically in context resolution processBlockMetadata loaded @/blocks/registry with a dynamic import even though the module already reaches it statically through permission-groups/block-access. Concurrent dynamic imports of the mocked registry intermittently resolved the real registry under vitest, costing seconds and timing out the block-context test on CI. A static import is equivalent at runtime and removes the race. --- apps/sim/lib/copilot/chat/process-contents.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/sim/lib/copilot/chat/process-contents.ts b/apps/sim/lib/copilot/chat/process-contents.ts index 028b499bdf9..a098a28db70 100644 --- a/apps/sim/lib/copilot/chat/process-contents.ts +++ b/apps/sim/lib/copilot/chat/process-contents.ts @@ -58,6 +58,7 @@ import type { ColumnDefinition } from '@/lib/table/types' import { workflowDelegationPolicy } from '@/lib/workflows/application/authorization' import { readWorkflowMetadata } from '@/lib/workflows/application/read-workflow' import { readWorkspaceFileMetadata } from '@/lib/workspace-files/application/read-workspace-file-metadata' +import { getBlockRegistry } from '@/blocks/registry' import { escapeRegExp } from '@/executor/constants' import type { ResolvedSecretTraceRegistry } from '@/executor/utils/resolved-secret-trace-registry' import type { BrowserTextSelection, ChatContext, TerminalTextSelection } from '@/stores/panel' @@ -582,7 +583,6 @@ async function processBlockMetadata( return null } - const { getBlockRegistry } = await import('@/blocks/registry') const blockRegistry = getBlockRegistry() if (!blockRegistry[blockId]) { return null From 67d0c330230b05eea94e7ceef0ec81b659e1fe06 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Mon, 14 Sep 2026 12:35:58 -0700 Subject: [PATCH 2/2] test(scripts): anchor the deferred-edge graph fixture on a module that still defers the registry --- scripts/check-application-graph.test.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/scripts/check-application-graph.test.ts b/scripts/check-application-graph.test.ts index a477dd07bc6..b1b0f8a411b 100644 --- a/scripts/check-application-graph.test.ts +++ b/scripts/check-application-graph.test.ts @@ -122,22 +122,21 @@ describe('a deferred edge into a forbidden tree', () => { it('is reported when a root defers the load of a forbidden module', () => { /** * Walked from a module that defers the block registry — `const - * { getBlockRegistry } = await import('@/blocks/registry')` — and nothing - * else about it matters here. Before the deferred pass this root was green - * on `blocks/`, which is the whole evasion in one line. + * { getBlockRegistry } = await import('@/blocks/registry')`. A root's own + * deferred edges are checked before its static imports, so the reported chain + * is that single deferred hop, whatever else the root reaches. */ + const root = + 'app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/hooks/use-mention-data.ts' const violations = findViolations({ - root: 'lib/copilot/chat/process-contents.ts', + root, forbidden: { 'blocks/': FORBIDDEN_PREFIXES['blocks/'] }, }) expect(violations).toHaveLength(1) expect(violations[0].forbidden).toBe('blocks/registry.ts') expect(violations[0].reason).toContain('deferred') - expect(violations[0].path).toEqual([ - 'lib/copilot/chat/process-contents.ts', - 'blocks/registry.ts', - ]) + expect(violations[0].path).toEqual([root, 'blocks/registry.ts']) }) /**