Skip to content

fix: corrected resolution of included documents#2495

Merged
davydkov merged 5 commits intomainfrom
2466-freezed-vscode-extension
Dec 19, 2025
Merged

fix: corrected resolution of included documents#2495
davydkov merged 5 commits intomainfrom
2466-freezed-vscode-extension

Conversation

@davydkov
Copy link
Copy Markdown
Member

@davydkov davydkov commented Dec 19, 2025

This pull request introduces several improvements and bug fixes to the LikeC4 language server and related tooling, focusing on project document resolution, workspace management, and plugin behavior. The changes enhance reliability when handling included documents, improve error handling, and address race conditions in extension activation.

Fixes #2466
Fixes #2472

Summary by CodeRabbit

  • Bug Fixes
    • Corrected resolution of project's included documents.
    • Fallbacks now pick the first project when a specified project ID is missing.
    • Removed workspace locking that caused startup race conditions.
  • Reliability & UX
    • Improved cancellation support for long-running operations for better responsiveness.
    • Enhanced error handling and logging to avoid whole-operation failures on per-project errors.
  • Examples
    • Added an examples project config to help test nested projects.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Dec 19, 2025

🦋 Changeset detected

Latest commit: 617ea4e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@likec4/language-server Patch
likec4 Patch
@likec4/playground Patch
@likec4/mcp Patch
likec4-vscode Patch
@likec4/config Patch
@likec4/core Patch
@likec4/diagram Patch
@likec4/generators Patch
@likec4/layouts Patch
@likec4/style-preset Patch
@likec4/styles Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@davydkov davydkov merged commit cbc2d79 into main Dec 19, 2025
6 checks passed
@davydkov davydkov deleted the 2466-freezed-vscode-extension branch December 19, 2025 04:58
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 19, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR threads cancellation tokens through RPC and project workflows, converts parallel view aggregation to a sequential, cancellable loop with per-project error handling, removes workspace locks during activation/rebuild flows, tightens include-path/project membership logic, and adds a Vite-plugin fallback to the first project when a projectId resolver is missing.

Changes

Cohort / File(s) Summary
Changesets
.changeset/moody-fans-win.md, .changeset/new-flies-greet.md, .changeset/wicked-pots-pump.md
Adds three patch-level changeset entries documenting included-document resolution fix, Vite plugin fallback to first project (closes #2472), and removal of workspace locks to avoid race conditions (references #2466).
Example Configuration
examples/likec4.config.json
New example config file declaring a nested-project test project.
RPC Handler Layer
packages/language-server/src/Rpc.ts
Adds cancelToken parameter to multiple RPC handlers (ReloadProjects, RegisterProject, ChangeView, FetchTelemetryMetrics), threads cancellation into downstream service calls, replaces Promise.allSettled aggregation of views with a sequential, cancellable for-of loop, and adds per-project try/catch logging and deferred metrics init.
Model Change Workflow
packages/language-server/src/model-change/ModelChanges.ts
Removes WorkspaceLock pattern; does early project/textDocument lookup and validation; restructures save-view-snapshot and reset-manual-layout flows; returns explicit structured success/error objects and applies edits only when present.
Document Indexing
packages/language-server/src/workspace/IndexManager.ts
Replaces include-path string construction with a single isIncluded(projectId, uri) predicate to decide document retention, simplifying the include check pipeline.
Langium Document Management
packages/language-server/src/workspace/LangiumDocuments.ts
Removes protected compare field; enforces strict project ID assignment on documents; changes allExcludingBuiltin to combined exclusion predicate; simplifies projectDocuments to use direct or ProjectsManager inclusion; adds resetProjectIds() to clear project ownership.
Project Management Core
packages/language-server/src/workspace/ProjectsManager.ts
Adds isIncluded and includedInProjects public methods; changes includePaths types to NonEmptyArray/NonEmptyReadonlyArray; accepts optional CancellationToken on registerConfigFile, registerProject, reloadProjects, and rebuidProject; introduces isParentFolderFor predicate and updated findProjectForDocument logic; improves overlap detection, logging, and rebuild cascades.
Project Management Tests
packages/language-server/src/workspace/ProjectsManager.spec.ts
Updates tests to capture registerProject return values, assert by project IDs, and adjust expected document ownership and membership assertions.
Workspace Initialization
packages/language-server/src/workspace/WorkspaceManager.ts
Imports CancellationToken, calls registerConfigFile with CancellationToken.None, and removes auto-acquiring WorkspaceLock in rebuildAll flow.
Vite Plugin Fallback
packages/likec4/src/vite-plugin/virtuals/_shared.ts
Changes resolver reference to mutable, adds logic to enumerate projects when a resolver is missing, logs error and either throws (no projects) or falls back to the first project with a warning, then re-resolves the function.
Repo Config
.changeset/config.json
Moves "likec4-vscode" from the first inner array to the second inner array in the fixed configuration.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Client as Client (Editor / Extension)
participant Rpc as Language Server RPC
participant PM as ProjectsManager
participant Docs as LangiumDocuments
participant Vite as Vite-plugin resolver

Client->>Rpc: Request (ReloadProjects / RegisterProject / ChangeView / FetchTelemetryMetrics) + cancelToken
Rpc->>PM: reload/register/rebuild(..., cancelToken)
alt sequential view aggregation
    Rpc->>PM: iterate projects
    PM->>Docs: get project documents / computeModel
    Docs-->>Rpc: per-project result or error
    Rpc-->>Client: aggregated views/metrics (errors logged per-project)
end
Note over Rpc,PM: Cancellation checked at loop start and before per-project calls
Client->>Vite: request for virtual resolver (projectId possibly missing)
Vite-->>Vite: if resolver missing -> list projects
alt projects exist
    Vite-->>Vite: pick first project (warn), re-resolve and call
else no projects
    Vite-->>Client: throw error listing none available
end

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Areas requiring extra attention:

  • packages/language-server/src/Rpc.ts — cancellation threading, conversion from parallel to sequential aggregation, and per-project error handling.
  • packages/language-server/src/workspace/ProjectsManager.ts — new public API, includePaths type changes, document-to-project resolution, and cancellation handling across flows.
  • packages/language-server/src/workspace/LangiumDocuments.ts — document ownership assignment, allExcludingBuiltin change, and resetProjectIds behavior.
  • packages/language-server/src/model-change/ModelChanges.ts — removal of WorkspaceLock and new early-return structured result semantics.
  • Integration points — ensure cancelToken propagation from Rpc through ProjectsManager to rebuild/register flows and that tests reflect new behaviors.

Possibly related PRs

Poem

🐰 Threads of tokens whisked through every call,
No locks to tumble, no races to brawl,
One-by-one views gathered, gentle and slow,
If a project goes missing, the first one will go —
Hops of a rabbit, patching the flow! 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive The PR description adequately summarizes the changes and links to the relevant issues, but does not follow the provided checklist template from the repository. Consider using the repository's standard PR description template including the contribution checklist to ensure consistency with repository conventions.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: correcting resolution of included documents, which is the central focus of these modifications.
Linked Issues check ✅ Passed The PR addresses all requirements from linked issues: document resolution improvements for nested projects (#2466) and fallback logic for export/project selection (#2472).
Out of Scope Changes check ✅ Passed All changes align with the stated objectives: document resolution fixes, cancellation token threading, race condition prevention, and project fallback logic for export.

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1ac4371 and 617ea4e.

📒 Files selected for processing (1)
  • .changeset/config.json (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
packages/language-server/src/Rpc.ts (1)

273-311: Consider moving the cancellation check inside the loop.

The interruptAndCheck(cancelToken) on line 307 executes after all projects have been processed. For effective cancellation during the loop, consider adding a check at the start of each iteration, similar to FetchViewsFromAllProjects.

🔎 Proposed improvement
       let metrics: FetchTelemetryMetrics.Res['metrics'] = null
       for (const projectId of projects.all) {
+        await interruptAndCheck(cancelToken)
         try {
           const model = await likec4Services.ModelBuilder.computeModel(projectId, cancelToken)
packages/language-server/src/model-change/ModelChanges.ts (1)

40-57: Consider consistent error handling for manual layout removal.

The removeManualLayoutV1 failures are caught and logged as warnings, but the operation continues. While this is reasonable for cleanup of legacy data, consider whether a failed cleanup should:

  1. Be surfaced to the user in some way (not just logged)
  2. Affect the success status of the overall operation

Current approach is pragmatic - the new layout is saved regardless of v1 cleanup success.

Also applies to: 59-72

packages/language-server/src/workspace/ProjectsManager.ts (1)

517-571: Verify cancellation check placement in reload loop.

The interruptAndCheck is called inside the config file registration loop, which is good. However, consider whether cancellation should also be checked after scanProjectFiles completes for each folder, especially if there are many folders.

 for (const folder of folders) {
   try {
+    if (cancelToken) {
+      await interruptAndCheck(cancelToken)
+    }
     logger.debug`scan projects in folder ${folder.uri}`
     const files = await this.services.workspace.FileSystemProvider.scanProjectFiles(URI.parse(folder.uri))
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d24d02 and 1ac4371.

📒 Files selected for processing (12)
  • .changeset/moody-fans-win.md (1 hunks)
  • .changeset/new-flies-greet.md (1 hunks)
  • .changeset/wicked-pots-pump.md (1 hunks)
  • examples/likec4.config.json (1 hunks)
  • packages/language-server/src/Rpc.ts (3 hunks)
  • packages/language-server/src/model-change/ModelChanges.ts (2 hunks)
  • packages/language-server/src/workspace/IndexManager.ts (1 hunks)
  • packages/language-server/src/workspace/LangiumDocuments.ts (3 hunks)
  • packages/language-server/src/workspace/ProjectsManager.spec.ts (2 hunks)
  • packages/language-server/src/workspace/ProjectsManager.ts (20 hunks)
  • packages/language-server/src/workspace/WorkspaceManager.ts (2 hunks)
  • packages/likec4/src/vite-plugin/virtuals/_shared.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,js,jsx,json,yaml,yml}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use pnpm fmt with dprint for code formatting; do not use Prettier or eslint for formatting

Files:

  • packages/language-server/src/workspace/ProjectsManager.spec.ts
  • packages/language-server/src/model-change/ModelChanges.ts
  • packages/language-server/src/workspace/IndexManager.ts
  • packages/language-server/src/workspace/LangiumDocuments.ts
  • packages/likec4/src/vite-plugin/virtuals/_shared.ts
  • examples/likec4.config.json
  • packages/language-server/src/workspace/WorkspaceManager.ts
  • packages/language-server/src/workspace/ProjectsManager.ts
  • packages/language-server/src/Rpc.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use oxlint with type-aware rules for linting; run pnpm lint for checking and pnpm lint:fix for auto-fixing

Files:

  • packages/language-server/src/workspace/ProjectsManager.spec.ts
  • packages/language-server/src/model-change/ModelChanges.ts
  • packages/language-server/src/workspace/IndexManager.ts
  • packages/language-server/src/workspace/LangiumDocuments.ts
  • packages/likec4/src/vite-plugin/virtuals/_shared.ts
  • packages/language-server/src/workspace/WorkspaceManager.ts
  • packages/language-server/src/workspace/ProjectsManager.ts
  • packages/language-server/src/Rpc.ts
packages/**/src/**/*.spec.ts

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Run unit tests with pnpm test before submitting changes; unit tests are located in packages/*/src/**/*.spec.ts and packages/*/src/**/__test__/*.spec.ts

Files:

  • packages/language-server/src/workspace/ProjectsManager.spec.ts
🧠 Learnings (1)
📚 Learning: 2025-12-18T20:09:20.430Z
Learnt from: CR
Repo: likec4/likec4 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-18T20:09:20.430Z
Learning: Applies to **/tsconfig.json : Use TypeScript project references for incremental builds; ensure `tsconfig.json` at root properly references all package tsconfigs

Applied to files:

  • packages/language-server/src/workspace/ProjectsManager.ts
🧬 Code graph analysis (2)
packages/language-server/src/workspace/ProjectsManager.spec.ts (4)
packages/language-server/src/model/model-parser.ts (1)
  • documents (97-101)
packages/language-server/src/model/fqn-index.ts (1)
  • documents (59-64)
packages/language-server/src/model/model-builder.ts (1)
  • documents (300-302)
packages/language-server/src/model/model-locator.ts (1)
  • documents (47-49)
packages/language-server/src/workspace/LangiumDocuments.ts (5)
packages/language-server/src/ast.ts (1)
  • LikeC4LangiumDocument (247-249)
packages/language-server/src/LikeC4LanguageServices.ts (1)
  • projects (105-152)
packages/language-server/src/index.ts (1)
  • isLikeC4Builtin (19-19)
packages/core/src/model/LikeC4Model.ts (1)
  • projectId (346-348)
packages/core/src/types/_common.ts (1)
  • NonEmptyArray (9-9)
🔇 Additional comments (24)
.changeset/wicked-pots-pump.md (1)

1-5: Changeset format is correct.

The YAML frontmatter and description follow the standard changeset format. However, note that the PR objectives declare fixes for both #2466 and #2472. You may want to verify whether #2472 should also be referenced in this changeset, or if it's documented in a separate changeset entry for clarity on the scope of changes.

examples/likec4.config.json (1)

1-4: LGTM! Clear test configuration for nested projects.

The configuration is syntactically correct and its purpose is clearly stated. This aligns well with the PR objectives of fixing nested multi-project workspace issues.

packages/language-server/src/Rpc.ts (2)

164-173: LGTM!

The cancellation token is now properly threaded through ReloadProjects and RegisterProject handlers, enabling cancellable operations during project reload and registration.


175-203: LGTM!

Good refactoring to sequential iteration with per-project error handling. This ensures a failure in one project doesn't prevent fetching views from other projects.

.changeset/moody-fans-win.md (1)

1-5: LGTM!

Changeset is properly formatted with correct package reference and clear description of the fix.

packages/language-server/src/workspace/IndexManager.ts (1)

18-29: LGTM!

The refactored logic correctly includes documents that either belong to the project or are explicitly included via include paths. Centralizing the inclusion check in ProjectsManager.isIncluded() improves maintainability and ensures consistent behavior across the codebase.

packages/language-server/src/workspace/WorkspaceManager.ts (3)

12-12: LGTM!

The import correctly brings in CancellationToken as a value (namespace) alongside the WorkspaceFolder type, enabling access to CancellationToken.None for non-cancellable operations.


54-54: LGTM!

Passing CancellationToken.None explicitly for startup config loading is appropriate since the initial workspace startup should not be interruptible. This aligns with the cancellation-aware flow introduced throughout the project.


144-149: LGTM - Simplified rebuild logic.

The removal of auto-acquired workspace locks in rebuildAll simplifies the control flow and eliminates potential deadlock scenarios when rebuilds are triggered from contexts that already hold locks.

packages/language-server/src/workspace/ProjectsManager.spec.ts (2)

506-520: LGTM!

Capturing the return values from registerProject allows the test to use stable project.id references rather than relying on string literals, making the test more robust to project ID generation changes.


528-544: Good clarification of shared document ownership semantics.

The test now explicitly verifies that:

  1. Shared documents are owned by the first project that includes them (a-project1)
  2. Both projects can still access shared documents via projectDocuments() using the new isIncluded logic

The explicit URI path expectations make the test more precise and easier to debug if something breaks.

packages/language-server/src/workspace/LangiumDocuments.ts (4)

42-42: LGTM - Simplified project ID assignment.

The likec4ProjectId assignment is now unconditional within the guard blocks, which is correct since:

  • In getDocument: the !exclude(doc) check ensures only LikeC4 documents (non-builtin) reach this line
  • In all: the !isLikeC4Builtin(doc.uri) check provides the same guarantee

This aligns with the LikeC4LangiumDocument interface which declares likec4ProjectId: c4.ProjectId as required.

Also applies to: 55-55


64-70: LGTM!

The combined filter correctly excludes both built-in documents and documents excluded by ProjectsManager, providing a clean set of user documents for processing.


73-81: Correct implementation of project document resolution.

The logic properly returns documents that either:

  1. Are owned by the project (doc.likec4ProjectId === projectId)
  2. Are included by the project via include paths (projects.isIncluded(projectId, doc.uri))

This enables multiple projects to share documents from common include paths while maintaining proper ownership semantics.


86-97: LGTM - Clean project ID reset implementation.

The resetProjectIds method correctly:

  • Uses super.all to avoid triggering re-assignment during iteration
  • Skips excluded (non-LikeC4) documents
  • Uses delete to properly clear the optional property for subsequent re-assignment
packages/language-server/src/model-change/ModelChanges.ts (3)

21-37: Improved early validation pattern.

The restructured flow performs project and view validation upfront before any modifications, making the error paths clearer and avoiding partial state changes when validation fails.


74-108: LGTM - Clean structured return pattern.

The refactored code:

  • Uses an invariant to ensure lspConnection exists for IDE-only text edit operations
  • Returns structured {success, location/error} objects consistently
  • Properly handles the applyEdit failure case with user feedback via showErrorMessage

117-120: LGTM!

Error handling now returns a structured error object instead of throwing, consistent with the new return-based API contract.

packages/language-server/src/workspace/ProjectsManager.ts (6)

46-54: Clean predicate factory for folder containment.

isParentFolderFor encapsulates the path prefix check logic and returns a reusable predicate, making the include path matching code more readable and consistent across the codebase.


76-79: Good type refinement for include paths.

Changing includePaths to NonEmptyArray<{uri, folder}> (internal) and NonEmptyReadonlyArray<URI> (public) ensures:

  1. Include paths are never empty arrays (validated at registration)
  2. The internal representation caches both URI and folder string for efficiency
  3. The public API exposes only URIs, hiding the internal folder string optimization

Also applies to: 93-93


285-309: Well-designed inclusion check APIs.

The new isIncluded and includedInProjects methods provide clean interfaces for:

  • Checking if a specific project includes a document via its include paths
  • Finding all projects that include a given document

These support the updated projectDocuments logic in LangiumDocuments that needs to aggregate both owned and included documents.


331-331: Consistent cancellation token propagation.

Adding optional cancelToken parameters to registerConfigFile and registerProject enables proper cancellation support throughout the project registration workflow, integrating with the broader cancellation-aware changes in this PR.

Also applies to: 362-362


583-591: Critical fix: Reset project IDs before rebuild.

The call to LangiumDocuments.resetProjectIds() in reset() is essential for the fix. It ensures that when projects are re-registered or config changes occur, documents don't retain stale project ID assignments that could cause them to be associated with the wrong project.


639-651: Improved document-to-project resolution.

The updated findProjectForDocument correctly:

  1. First checks if the document is directly within a project's folder
  2. Falls back to checking if any project includes the document via include paths
  3. Returns the default project if no match is found

This ensures proper resolution for both owned and included documents.

"likec4": patch
---

Fallback to the first project in vite plugin, if `projectId` is not found, instead of erroring out. Closes [#2472](https://github.com/like-c4/likec4/issues/2472)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Incorrect repository URL in issue link.

The issue link references like-c4/likec4 but the PR URL indicates the repository is likec4/likec4. This will result in a broken link.

🔎 Proposed fix
-Fallback to the first project in vite plugin, if `projectId` is not found, instead of erroring out. Closes [#2472](https://github.com/like-c4/likec4/issues/2472)
+Fallback to the first project in vite plugin, if `projectId` is not found, instead of erroring out. Closes [#2472](https://github.com/likec4/likec4/issues/2472)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Fallback to the first project in vite plugin, if `projectId` is not found, instead of erroring out. Closes [#2472](https://github.com/like-c4/likec4/issues/2472)
Fallback to the first project in vite plugin, if `projectId` is not found, instead of erroring out. Closes [#2472](https://github.com/likec4/likec4/issues/2472)
🤖 Prompt for AI Agents
In .changeset/new-flies-greet.md around line 5, the issue URL uses the wrong
repository path `like-c4/likec4`; update the link to the correct repository
`likec4/likec4` (e.g. https://github.com/likec4/likec4/issues/2472) so the issue
link resolves; keep the rest of the sentence unchanged and verify the markdown
link renders and closes the issue as intended.

Comment on lines +104 to 114
let fn = ${fnName}Fn[projectId]
if (!fn) {
throw new Error('Unknown projectId: ' + projectId)
const projects = Object.keys(${fnName}Fn)
console.error('Unknown projectId: ' + projectId + ' (available: ' + projectIds + ')')
if (projects.length === 0) {
throw new Error('No projects found, invalid state')
}
projectId = projects[0]
console.warn('Falling back to project: ' + projectId)
fn = ${fnName}Fn[projectId]
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical bug: projectIds is undefined, should be projects.

Line 107 references projectIds but the variable declared on line 106 is named projects. This will cause a ReferenceError at runtime when the fallback path is triggered.

🔎 Proposed fix
   let fn = ${fnName}Fn[projectId]
   if (!fn) {
     const projects = Object.keys(${fnName}Fn)
-    console.error('Unknown projectId: ' + projectId + ' (available: ' + projectIds + ')')
+    console.error('Unknown projectId: ' + projectId + ' (available: ' + projects + ')')
     if (projects.length === 0) {
       throw new Error('No projects found, invalid state')
     }
     projectId = projects[0]
     console.warn('Falling back to project: ' + projectId)
     fn = ${fnName}Fn[projectId]
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let fn = ${fnName}Fn[projectId]
if (!fn) {
throw new Error('Unknown projectId: ' + projectId)
const projects = Object.keys(${fnName}Fn)
console.error('Unknown projectId: ' + projectId + ' (available: ' + projectIds + ')')
if (projects.length === 0) {
throw new Error('No projects found, invalid state')
}
projectId = projects[0]
console.warn('Falling back to project: ' + projectId)
fn = ${fnName}Fn[projectId]
}
let fn = ${fnName}Fn[projectId]
if (!fn) {
const projects = Object.keys(${fnName}Fn)
console.error('Unknown projectId: ' + projectId + ' (available: ' + projects + ')')
if (projects.length === 0) {
throw new Error('No projects found, invalid state')
}
projectId = projects[0]
console.warn('Falling back to project: ' + projectId)
fn = ${fnName}Fn[projectId]
}
🤖 Prompt for AI Agents
In packages/likec4/src/vite-plugin/virtuals/_shared.ts around lines 104 to 114,
the error path logs a variable named projectIds that doesn't exist (causing a
ReferenceError); change the console.error call to reference the existing
projects array (or otherwise stringify the available project keys) so it uses
projects instead of projectIds, keeping the rest of the fallback logic intact.

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.

View previews not working in VSCode extension on nested multi-projects since v1.45.0

1 participant