Skip to content

feat: adding max-depth and file thresholds#2446

Merged
davydkov merged 2 commits into
mainfrom
kieron/shared-files
Dec 8, 2025
Merged

feat: adding max-depth and file thresholds#2446
davydkov merged 2 commits into
mainfrom
kieron/shared-files

Conversation

@kieronlanning

@kieronlanning kieronlanning commented Dec 8, 2025

Copy link
Copy Markdown
Collaborator

Checklist

  • I've thoroughly read the latest contribution guidelines.
  • I've rebased my branch onto main before creating this PR.
  • My commit messages follow conventional spec
  • I've added tests to cover my changes (if applicable).
  • I've verified that all new and existing tests have passed locally for mobile, tablet, and desktop screen sizes.
  • My change requires documentation updates.
  • I've updated the documentation accordingly.

Summary by CodeRabbit

  • New Features

    • Include config now uses an object with paths, maxDepth (1–20, default 3) and fileThreshold (default 30)
    • Directory traversal depth control and per-include file threshold with cross-path warning when limits exceeded
    • Multiple include directories supported and surfaced in project views
  • Documentation

    • Updated multi-project docs with new include syntax, examples, and performance tips

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

Copilot AI review requested due to automatic review settings December 8, 2025 08:21
@coderabbitai

coderabbitai Bot commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

The include configuration is refactored from a string array to an object { paths, maxDepth, fileThreshold } across config schema, docs, project registration, workspace loading, filesystem traversal, tests, and JSON schema.

Changes

Cohort / File(s) Summary
Include Schema & Configuration
packages/config/src/schema.include.ts, packages/config/src/index.ts
Replaced array-based include with object-based IncludeConfigSchema (paths: string[], maxDepth: number, fileThreshold: number). Added IncludeConfig type, normalizeIncludeConfig() and updated validateIncludePaths() to operate on include.paths. Exported new symbols.
Configuration Tests
packages/config/src/schema.spec.ts
Updated tests to use { paths: [...] } shape, adjusted assertions and error expectations for empty or invalid path arrays.
Project & Workspace Management
packages/language-server/src/workspace/ProjectsManager.ts, packages/language-server/src/workspace/ProjectsManager.spec.ts, packages/language-server/src/workspace/WorkspaceManager.ts
Added includeConfig to project data (initialized via normalizeIncludeConfig), propagated it through registration and getAllIncludePaths(). Workspace loading now respects per-path maxDepth, tracks per-path and total files loaded, and compares totals against a cross-path threshold (min fileThreshold) to log warnings. Tests updated to the new include object shape.
File System Abstraction
packages/language-server/src/filesystem/index.ts, packages/language-server/src/filesystem/LikeC4FileSystem.ts
Extended readDirectory(uri, options?) to accept maxDepth?: number alongside recursive?, defaulting traversal depth to Infinity when unspecified and enforcing depth limits when provided.
Documentation & JSON Schema
apps/docs/src/content/docs/dsl/Config/multi-projects.mdx, schemas/likec4-config.schema.json
Docs updated to show object-form include with examples and tips (performance/path resolution). JSON schema now references a new $defs/include-config object with paths, maxDepth, and fileThreshold.
Diagram & UI minor fixes
packages/diagram/src/base/BaseXYFlow.tsx, packages/diagram/src/likec4diagram/state/machine.state.navigating.ts, packages/diagram/src/likec4diagram/state/utils.ts
Removed zIndexMode="basic" prop; navigation focus now uses eventWithXYData.xynodes when available; removed an exported type import not otherwise used.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Client
participant ProjectsManager
participant WorkspaceManager
participant FileSystem
note over Client,ProjectsManager: Project registration / config change
Client->>ProjectsManager: registerProject(config with include object)
ProjectsManager->>ProjectsManager: normalizeIncludeConfig(config.include)
ProjectsManager->>WorkspaceManager: trigger load for project.includeConfig
WorkspaceManager->>ProjectsManager: getAllIncludePaths()
ProjectsManager-->>WorkspaceManager: [{projectId, includePath, includeConfig}, ...]
loop per includePath
WorkspaceManager->>FileSystem: readDirectory(includePath, { recursive:true, maxDepth: includeConfig.maxDepth })
FileSystem-->>WorkspaceManager: list of files (filesLoadedFromPath)
WorkspaceManager->>WorkspaceManager: accumulate totalFilesLoaded
end
WorkspaceManager->>WorkspaceManager: if totalFilesLoaded > min(includeConfig.fileThreshold) -> log warning

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

  • Areas requiring focused review:
    • packages/config/src/schema.include.ts — zod schema defaults, optional/required shapes, and validation messaging.
    • packages/language-server/src/workspace/WorkspaceManager.ts — traversal loop, error handling per-path, accumulation and threshold logic.
    • packages/language-server/src/filesystem/LikeC4FileSystem.ts & index.ts — traversal depth implementation and callers to ensure correct behavior.
    • Tests in ProjectsManager.spec.ts and schema.spec.ts — ensure coverage for edge cases (empty paths, absolute/URL paths, min/max bounds).

Possibly related PRs

Suggested reviewers

  • davydkov

Poem

🐰 I hopped through paths both near and far,
I counted files beneath each star.
From arrays to configs, depth set with care,
Thresholds whisper—"load with flair!"
A rabbit's cheer for includes laid bare. 🎋

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: adding max-depth and file thresholds' directly and clearly describes the main feature addition - introducing max-depth and file threshold configuration options to the codebase.
Description check ✅ Passed The PR description is complete with all checklist items marked as done, confirming adherence to contribution guidelines, proper rebasing, conventional commits, test coverage, cross-platform verification, and documentation updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch kieron/shared-files

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d675925 and 1ec7b96.

📒 Files selected for processing (3)
  • packages/diagram/src/base/BaseXYFlow.tsx (0 hunks)
  • packages/diagram/src/likec4diagram/state/machine.state.navigating.ts (1 hunks)
  • packages/diagram/src/likec4diagram/state/utils.ts (0 hunks)
💤 Files with no reviewable changes (2)
  • packages/diagram/src/likec4diagram/state/utils.ts
  • packages/diagram/src/base/BaseXYFlow.tsx
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

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

Use pnpm ci:typecheck for TypeScript type checking across all packages except documentation

Files:

  • packages/diagram/src/likec4diagram/state/machine.state.navigating.ts
**/*.{ts,tsx,js,jsx}

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

Use oxlint with type-aware rules for linting instead of eslint, and run pnpm ci:lint to validate all packages except documentation

Files:

  • packages/diagram/src/likec4diagram/state/machine.state.navigating.ts
**/*.{ts,tsx,js,jsx,json,md}

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

Use pnpm fmt to format code with dprint instead of Prettier or eslint for formatting

Files:

  • packages/diagram/src/likec4diagram/state/machine.state.navigating.ts
🧬 Code graph analysis (1)
packages/diagram/src/likec4diagram/state/machine.state.navigating.ts (1)
packages/diagram/src/likec4diagram/state/utils.ts (1)
  • findNodeByModelFqn (23-29)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: checks / ⊞ windows build
  • GitHub Check: checks / 🛠️ build
🔇 Additional comments (1)
packages/diagram/src/likec4diagram/state/machine.state.navigating.ts (1)

200-204: Good alignment of focus logic with enriched XY data

Using eventWithXYData.xynodes for findNodeByModelFqn keeps the focus-on-element behavior in sync with findCorrespondingNode and mergeXYNodesEdges, and ensures focusing still works when XY data is injected via convertToXYFlow rather than being present on the original event. No issues spotted here.


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

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/docs/src/content/docs/dsl/Config/multi-projects.mdx (1)

73-78: Inconsistent include syntax in documentation.

This example shows the array syntax "include": ["../shared"], while examples at lines 100-103 and 110-112 show the new object syntax "include": { "paths": [...] }.

If both formats are supported (backward compatibility), please add a note clarifying this. Otherwise, update this example to match the object syntax:

-  "include": ["../shared"]
+  "include": {
+    "paths": ["../shared"]
+  }
🧹 Nitpick comments (3)
packages/language-server/src/filesystem/LikeC4FileSystem.ts (1)

43-60: Verify behavior when maxDepth is 0.

The implementation correctly defaults to Infinity and applies depth limiting conditionally. However, if a user passes maxDepth: 0, it will be applied via withMaxDepth(0).

Depending on fdir's behavior, this could either return no results or behave unexpectedly. If maxDepth should be at least 1 (as suggested by the documentation range "1-20"), consider adding validation or clamping:

- const maxDepth = opts?.maxDepth ?? Infinity
+ const maxDepth = opts?.maxDepth ?? Infinity
+ const effectiveMaxDepth = typeof maxDepth === 'number' && maxDepth < 1 ? 1 : maxDepth

Alternatively, validation at the schema level may already prevent this.

schemas/likec4-config.schema.json (1)

55-57: Consider using $id instead of id for JSON Schema 2020-12 compliance.

In JSON Schema draft 2020-12 (as referenced in line 2), the identifier keyword is $id, not id. The id keyword was used in older drafts (draft-04 and earlier).

     "include-config": {
-      "id": "include-config",
+      "$id": "include-config",
       "description": "Configuration for including additional LikeC4 source files",
packages/config/src/schema.include.ts (1)

38-48: Consider adding a maximum constraint to fileThreshold.

The JSON schema defines maximum: 9007199254740991 for fileThreshold, but the Zod schema has no upper bound. While this is unlikely to cause issues in practice, adding .max(Number.MAX_SAFE_INTEGER) would maintain consistency between the schemas.

   fileThreshold: z.number()
     .int()
     .min(1)
+    .max(Number.MAX_SAFE_INTEGER)
     .default(30)
     .meta({
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a00872 and d675925.

📒 Files selected for processing (10)
  • apps/docs/src/content/docs/dsl/Config/multi-projects.mdx (1 hunks)
  • packages/config/src/index.ts (1 hunks)
  • packages/config/src/schema.include.ts (1 hunks)
  • packages/config/src/schema.spec.ts (8 hunks)
  • packages/language-server/src/filesystem/LikeC4FileSystem.ts (2 hunks)
  • packages/language-server/src/filesystem/index.ts (1 hunks)
  • packages/language-server/src/workspace/ProjectsManager.spec.ts (9 hunks)
  • packages/language-server/src/workspace/ProjectsManager.ts (9 hunks)
  • packages/language-server/src/workspace/WorkspaceManager.ts (1 hunks)
  • schemas/likec4-config.schema.json (2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

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

Use pnpm ci:typecheck for TypeScript type checking across all packages except documentation

Files:

  • packages/language-server/src/filesystem/LikeC4FileSystem.ts
  • packages/language-server/src/workspace/WorkspaceManager.ts
  • packages/language-server/src/filesystem/index.ts
  • packages/config/src/index.ts
  • packages/language-server/src/workspace/ProjectsManager.spec.ts
  • packages/config/src/schema.spec.ts
  • packages/config/src/schema.include.ts
  • packages/language-server/src/workspace/ProjectsManager.ts
**/*.{ts,tsx,js,jsx}

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

Use oxlint with type-aware rules for linting instead of eslint, and run pnpm ci:lint to validate all packages except documentation

Files:

  • packages/language-server/src/filesystem/LikeC4FileSystem.ts
  • packages/language-server/src/workspace/WorkspaceManager.ts
  • packages/language-server/src/filesystem/index.ts
  • packages/config/src/index.ts
  • packages/language-server/src/workspace/ProjectsManager.spec.ts
  • packages/config/src/schema.spec.ts
  • packages/config/src/schema.include.ts
  • packages/language-server/src/workspace/ProjectsManager.ts
**/*.{ts,tsx,js,jsx,json,md}

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

Use pnpm fmt to format code with dprint instead of Prettier or eslint for formatting

Files:

  • packages/language-server/src/filesystem/LikeC4FileSystem.ts
  • packages/language-server/src/workspace/WorkspaceManager.ts
  • packages/language-server/src/filesystem/index.ts
  • packages/config/src/index.ts
  • packages/language-server/src/workspace/ProjectsManager.spec.ts
  • schemas/likec4-config.schema.json
  • packages/config/src/schema.spec.ts
  • packages/config/src/schema.include.ts
  • packages/language-server/src/workspace/ProjectsManager.ts
packages/*/**/!(node_modules)/**/*.spec.ts

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

Unit tests must be located in packages/*/src/**/*.spec.ts or packages/*/src/**/__test__/*.spec.ts files

Files:

  • packages/language-server/src/workspace/ProjectsManager.spec.ts
  • packages/config/src/schema.spec.ts
🧠 Learnings (3)
📚 Learning: 2025-12-05T15:36:11.968Z
Learnt from: CR
Repo: likec4/likec4 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-05T15:36:11.968Z
Learning: Applies to packages/*/**/!(node_modules)/**/*.spec.ts : Unit tests must be located in `packages/*/src/**/*.spec.ts` or `packages/*/src/**/__test__/*.spec.ts` files

Applied to files:

  • packages/language-server/src/workspace/ProjectsManager.spec.ts
  • packages/config/src/schema.spec.ts
📚 Learning: 2025-12-05T15:36:11.968Z
Learnt from: CR
Repo: likec4/likec4 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-05T15:36:11.968Z
Learning: Applies to e2e/{tests,src}/**/*.spec.ts : E2E tests must be located in `e2e/tests/*.spec.ts` or `e2e/src/*.spec.ts` files

Applied to files:

  • packages/language-server/src/workspace/ProjectsManager.spec.ts
📚 Learning: 2025-12-05T15:36:11.968Z
Learnt from: CR
Repo: likec4/likec4 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-05T15:36:11.968Z
Learning: Applies to {packages/language-server/src/generated/**/*,packages/vscode/src/meta.ts,packages/likec4/app/src/routeTree.gen.ts,styled-system/preset/src/generated.ts} : Generated files in `packages/language-server/src/generated/`, `packages/vscode/src/meta.ts`, `packages/likec4/app/src/routeTree.gen.ts`, and `styled-system/preset/src/generated.ts` must be regenerated via `pnpm generate` and should not be manually edited

Applied to files:

  • packages/language-server/src/workspace/ProjectsManager.spec.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: CodeQL analysis (javascript-typescript)
  • GitHub Check: Agent
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: checks / 🛠️ build
  • GitHub Check: checks / ⊞ windows build
🔇 Additional comments (23)
packages/config/src/index.ts (1)

12-14: LGTM! Clean public API surface expansion.

The new exports follow the existing file organization pattern—types grouped separately from value exports. This properly exposes the IncludeConfig type and associated normalization/validation utilities for downstream consumers.

Also applies to: 23-23

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

77-95: LGTM! Good integration of includeConfig with depth-limited traversal.

The destructuring of includeConfig and passing maxDepth to readDirectory cleanly integrates the new configuration. Per-path file counting with debug logging provides good observability for troubleshooting.


101-115: Verify the minimum-threshold design choice is intentional.

Using Math.min() across all include paths means the most restrictive fileThreshold governs the warning. This is a safe/conservative approach, but may surprise users if one project has a low threshold while others are higher.

Consider whether per-project threshold checking would provide more accurate feedback, or document this cross-project behavior.

packages/language-server/src/filesystem/index.ts (1)

27-31: LGTM! Backwards-compatible interface extension.

The optional maxDepth parameter with clear JSDoc documentation extends the interface without breaking existing consumers. The default behavior (Infinity) preserves previous functionality.

apps/docs/src/content/docs/dsl/Config/multi-projects.mdx (1)

116-139: LGTM! Clear documentation for the new configuration options.

The new section provides clear documentation of the object-based include configuration with sensible defaults, valid ranges, and helpful performance optimization tips. The asides provide good context for users.

schemas/likec4-config.schema.json (2)

77-83: The fileThreshold maximum is set to Number.MAX_SAFE_INTEGER.

The maximum value of 9007199254740991 effectively means no practical upper limit. This is reasonable for avoiding artificial constraints while still providing schema validation.


33-36: Well-structured include-config schema definition.

The new object-based include configuration is well-documented with clear descriptions, sensible defaults, and appropriate constraints. The required paths array with minItems: 1 ensures users must provide at least one path when using this configuration.

Also applies to: 55-88

packages/config/src/schema.spec.ts (4)

184-209: Tests properly validate the new object-based include configuration.

The test cases comprehensively cover valid include paths using the new { paths: [...] } structure and correctly use toMatchObject for partial matching of the result.


212-215: Good validation of empty paths rejection at schema level.

This test ensures that { paths: [] } is rejected with the appropriate error message during schema parsing, enforcing the minItems: 1 constraint.


537-598: IncludeSchema tests correctly updated for object-based configuration.

The tests properly exercise the new schema shape including valid paths, empty array rejection, undefined handling, and path validation (absolute paths, URLs, relative paths).


601-657: Comprehensive validateIncludePaths tests with new object shape.

The tests cover all validation scenarios including undefined handling, empty paths (which passes validation since it's post-normalization), and invalid path detection with proper error messages.

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

340-360: Include path resolution tests properly updated.

The tests correctly verify that include paths are resolved relative to the project folder using the new { paths: [...] } configuration format.


410-422: Empty include paths validation test correctly expects rejection.

This test ensures that attempting to register a project with include: { paths: [] } throws an error, which aligns with the schema's minItems: 1 constraint.


448-478: getAllIncludePaths tests properly verify includeConfig propagation.

The tests confirm that each include path entry now includes the full includeConfig object with paths, maxDepth, and fileThreshold values. This enables consumers to access configuration details for each include path.


502-531: Project reload test validates config change handling.

The test demonstrates that changing the project name during reload (project1project3) correctly re-registers the project and updates include paths. This is an important behavior verification for configuration hot-reloading scenarios.

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

71-75: Well-documented includeConfig field addition.

The new includeConfig field properly documents its purpose and stores the normalized include configuration with maxDepth and fileThreshold values that can be used by consumers.


87-95: DefaultProject includes sensible includeConfig defaults.

The default values (paths: [], maxDepth: 3, fileThreshold: 30) align with the schema defaults and ensure the default project has a consistent configuration structure.


345-352: Consistent normalization of include configuration during registration.

The normalizeIncludeConfig function is correctly called both when creating new projects and when updating existing ones, ensuring defaults are always applied.

Also applies to: 378-380


392-400: Include path resolution uses normalized configuration.

The path resolution logic correctly accesses project.includeConfig.paths and resolves each path relative to the project folder. The null check with hasAtLeast ensures safe iteration.


649-671: getAllIncludePaths correctly exposes includeConfig to consumers.

This enables the WorkspaceManager to access maxDepth and fileThreshold when scanning include directories, which is essential for implementing the depth limiting and file threshold warning features. WorkspaceManager actively uses maxDepth (line 82) and fileThreshold (line 104) from the returned includeConfig for these features.

packages/config/src/schema.include.ts (3)

16-54: Well-structured IncludeConfigSchema with clear metadata.

The schema correctly defines the object structure with appropriate constraints. The .meta() usage for descriptions aligns with Zod 4 patterns documented in the library context.


68-73: normalizeIncludeConfig correctly provides consistent defaults.

This function ensures that consumers always receive a complete IncludeConfig object with defaults, avoiding null checks throughout the codebase. The default values match those in DefaultProject.includeConfig.


75-97: validateIncludePaths correctly handles the new object structure.

The function safely handles undefined input and validates each path in the include.paths array. The error message is clear and actionable.

Copilot AI left a comment

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.

Pull request overview

This PR adds performance control features to the include configuration by introducing maxDepth and fileThreshold parameters. The change transitions the include field from a simple array of paths (string[]) to a configuration object ({ paths: string[], maxDepth?: number, fileThreshold?: number }), enabling users to limit directory traversal depth and receive warnings when too many files are loaded from include paths.

Key changes:

  • Schema updated to use object-based include configuration with paths, maxDepth (default: 3, range: 1-20), and fileThreshold (default: 30)
  • FileSystemProvider enhanced to accept maxDepth parameter for directory scanning
  • WorkspaceManager now enforces maxDepth limits and warns when file threshold is exceeded
  • Documentation updated with new configuration format and performance optimization guidance

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
schemas/likec4-config.schema.json JSON schema updated to define include as object with paths, maxDepth, and fileThreshold properties
packages/config/src/schema.include.ts Replaced simple array schema with IncludeConfigSchema object; added normalizeIncludeConfig helper
packages/config/src/index.ts Exported new IncludeConfig type and normalizeIncludeConfig function
packages/config/src/schema.spec.ts Updated all tests to use new object format; changed expectation for empty array handling
packages/language-server/src/filesystem/index.ts Added maxDepth parameter to readDirectory interface
packages/language-server/src/filesystem/LikeC4FileSystem.ts Implemented maxDepth support using fdir's withMaxDepth method
packages/language-server/src/workspace/ProjectsManager.ts Added includeConfig field to ProjectData; normalized include config using helper function
packages/language-server/src/workspace/ProjectsManager.spec.ts Updated test fixtures to use new include object format
packages/language-server/src/workspace/WorkspaceManager.ts Added file counting and threshold warning logic when loading from include paths
apps/docs/src/content/docs/dsl/Config/multi-projects.mdx Added documentation section explaining new include configuration options

Comment on lines +101 to +114
// Warn if total files loaded exceeds threshold across all include paths
if (includePaths.length > 0 && totalFilesLoaded > 0) {
// Get the minimum threshold from all projects
const minThreshold = Math.min(...includePaths.map(p => p.includeConfig.fileThreshold))

if (totalFilesLoaded > minThreshold) {
logger.warn(
`Loaded ${totalFilesLoaded} files from include paths (threshold: ${minThreshold}). ` +
'Large include directories may slow workspace initialization. ' +
'Consider adjusting "include.fileThreshold" or "include.maxDepth" in your project configuration.',
)
} else {
logger.info`loaded ${totalFilesLoaded} total files from ${includePaths.length} include paths`
}

Copilot AI Dec 8, 2025

Copy link

Choose a reason for hiding this comment

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

The warning logic is confusing because it compares total files loaded across all projects against the minimum threshold from any single project. This can produce misleading warnings.

For example:

  • Project A (threshold: 30) loads 20 files
  • Project B (threshold: 50) loads 25 files
  • Total: 45 files, but the warning will use minThreshold=30, making it seem like the limit was exceeded when both projects are actually under their individual thresholds.

Consider one of these approaches:

Option 1: Track and warn per-project:

for (const { projectId, includePath, includeConfig } of includePaths) {
  // ... load files ...
  if (filesLoadedFromPath > includeConfig.fileThreshold) {
    logger.warn(
      `Project "${projectId}" loaded ${filesLoadedFromPath} files from ${includePath.fsPath} ` +
      `(threshold: ${includeConfig.fileThreshold}). Consider adjusting "include.fileThreshold" or "include.maxDepth".`
    )
  }
}

Option 2: Group by project and check totals per project:

const filesPerProject = new Map<string, number>()
// After loading all files, check each project's total
for (const [projectId, count] of filesPerProject) {
  const threshold = projects.get(projectId).includeConfig.fileThreshold
  if (count > threshold) { /* warn */ }
}

Copilot uses AI. Check for mistakes.
Comment on lines 511 to +528
// Reload with different include paths
await projectsManager.registerProject({
config: {
name: 'project1',
include: ['../new-shared'],
name: 'project3',
include: { paths: ['../new-shared'] },
},
folderUri,
})

project = projectsManager.getProject('project1' as ProjectId)
project = projectsManager.getProject('project3' as ProjectId)

Copilot AI Dec 8, 2025

Copy link

Choose a reason for hiding this comment

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

The project name was changed from 'project1' to 'project3' during the reload, which changes the test's purpose. The test name says "should update include paths when project is reloaded with different config", suggesting it should test updating the same project's configuration, not registering a different project at the same location.

This should remain 'project1' to accurately test the reload scenario:

// Reload with different include paths
await projectsManager.registerProject({
  config: {
    name: 'project1',  // Keep the same name
    include: { paths: ['../new-shared'] },
  },
  folderUri,
})

project = projectsManager.getProject('project1' as ProjectId)

Copilot uses AI. Check for mistakes.
Comment on lines +616 to 618
it('should pass when include has empty paths array', ({ expect }) => {
expect(() => validateIncludePaths({ paths: [], maxDepth: 3, fileThreshold: 30 })).not.toThrow()
})

Copilot AI Dec 8, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] This test is misleading because it tests validateIncludePaths with { paths: [] }, which would never pass Zod schema validation in the first place. The IncludeConfigSchema has .min(1) for the paths array (line 18 in schema.include.ts), so Zod rejects empty arrays before validateIncludePaths is called.

The validateIncludePaths function is designed to be called after Zod validation (see schema.ts line 253), so this test validates behavior that shouldn't occur in practice.

Consider either:

  1. Removing this test since empty arrays are caught by Zod validation
  2. Or changing the test expectation to verify it properly handles pre-validated input:
it('should skip validation when include has empty paths array (already validated by Zod)', ({ expect }) => {
  // This scenario shouldn't happen in practice, but validateIncludePaths handles it gracefully
  expect(() => validateIncludePaths({ paths: [], maxDepth: 3, fileThreshold: 30 })).not.toThrow()
})

Copilot uses AI. Check for mistakes.
Comment thread packages/config/src/schema.include.ts
- Remove unused SyncLayoutActorRef import
- Fix event.xynodes to eventWithXYData.xynodes reference
- Remove deprecated zIndexMode prop from ReactFlow
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.

3 participants