Skip to content

fix(copilot): import the block registry statically in context resolution - #7816

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/process-contents-test-flake
Sep 14, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/process-contents-test-flake

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • processBlockMetadata loaded @/blocks/registry with a dynamic import(), but process-contents.ts already reaches the registry statically through lib/permission-groups/block-access.ts, so the lazy load bought nothing at runtime
  • Under vitest, concurrent dynamic imports of the mocked registry intermittently resolved the real 356-block registry (~2.5s locally), timing out resolves integration mentions through the same metadata and access policy as blocks on slower CI runners
  • Import getBlockRegistry statically; runtime behavior is unchanged and every test call now gets the mock

Type of Change

  • Bug fix

Testing

  • process-contents.test.ts: slow test 2489ms → 1ms, file tests 2.5s → ~22ms across repeated runs; all registry reads confirmed to hit the mock
  • lib/copilot + app/api/mothership suites (2434 tests), type-check, bun run lint, check:audits, block registry, docs manifest

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

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.
@vercel

vercel Bot commented Sep 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Sep 14, 2026 7:38pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no new correctness, security, or repository-rule violations remain.

Summary

  • Removes redundant asynchronous registry loading from processBlockMetadata.
  • Preserves coverage for detecting deferred imports into forbidden dependency trees.

Reviews (2) · Last reviewed commit: "test(scripts): anchor the deferred-edge ..."

Comment thread apps/sim/lib/copilot/chat/process-contents.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@waleedlatif1
waleedlatif1 merged commit e15cca1 into staging Sep 14, 2026
33 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/process-contents-test-flake branch September 14, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant