fix: backup automation mock + Claude probes dashboard alias#2293
Conversation
FN-7537 manual backup parity needs store.getGlobalSettingsDir after resolveGlobalBackupRoot product drift. Alias dashboard Vitest Claude runtime to probes-entry so API-quality tests do not load ACP index.
📝 WalkthroughWalkthroughDashboard automation backup test stores now mock the global settings directory, and Vitest resolves the Claude runtime alias to its probe entry point while retaining the dedicated probe alias. ChangesBackup test fixtures
Claude runtime alias
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Greptile SummaryThis PR repairs dashboard backup tests and narrows Claude runtime resolution during Vitest runs. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (1): Last reviewed commit: "fix: backup automation mock getGlobalSet..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/dashboard/vitest.config.ts`:
- Around line 592-598: Reorder the aliases in the Vitest configuration so
"`@fusion-plugin-examples/claude-runtime/probe`" is declared before the broader
"`@fusion-plugin-examples/claude-runtime`" alias, ensuring probe imports resolve
to src/probe.ts rather than through probes-entry.ts.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: a2c8f00d-c6d9-4243-8b0c-694cc8673efe
📒 Files selected for processing (2)
packages/dashboard/src/__tests__/routes-automation.test.tspackages/dashboard/vitest.config.ts
| "@fusion-plugin-examples/claude-runtime": resolve( | ||
| __dirname, | ||
| "../../plugins/fusion-plugin-claude-runtime/src/index.ts", | ||
| "../../plugins/fusion-plugin-claude-runtime/src/probes-entry.ts", | ||
| ), | ||
| "@fusion-plugin-examples/claude-runtime/probe": resolve( | ||
| __dirname, | ||
| "../../plugins/fusion-plugin-claude-runtime/src/probe.ts", |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
python - <<'PY'
from pathlib import Path
text = Path("packages/dashboard/vitest.config.ts").read_text()
specific = text.index('"`@fusion-plugin-examples/claude-runtime/probe`"')
base = text.index('"`@fusion-plugin-examples/claude-runtime`"')
assert specific < base, "The specific /probe alias must precede the base alias"
PYRepository: Runfusion/Fusion
Length of output: 297
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
# Show the relevant section with line numbers.
sed -n '570,620p' packages/dashboard/vitest.config.ts | cat -n
# Search for similar alias ordering patterns in the repo.
rg -n '"`@fusion-plugin-examples/`.*/probe"|resolve\(' packages/dashboard -g 'vitest.config.ts' -g 'vite.config.ts' -g '*.ts' | sed -n '1,120p'Repository: Runfusion/Fusion
Length of output: 16186
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
sed -n '570,620p' packages/dashboard/vitest.config.ts | cat -n
rg -n '"`@fusion-plugin-examples/`.*/probe"|resolve\(' packages/dashboard -g 'vitest.config.ts' -g 'vite.config.ts' -g '*.ts' | sed -n '1,120p'Repository: Runfusion/Fusion
Length of output: 14944
🌐 Web query:
Vite resolve.alias array order first match prefix exact string alias subpath documentation
💡 Result:
In Vite, the resolve.alias configuration supports either an object or an array of objects [1][2]. When using the array format (Array<{ find: string | RegExp, replacement: string }>), the order of the entries is significant because Vite processes them sequentially and applies the first matching rule it encounters [1][3]. Key points regarding order, prefix matching, and string aliases: 1. Order Matters: Vite evaluates aliases in the order they are defined in the array [1][4]. The first rule that matches the import path will be applied, and subsequent rules for that path will be ignored [3]. 2. Prefix Collisions: If you have aliases that share a common prefix (e.g., @app and @app/components), the more specific alias (the longer path) must be defined before the more general alias [3]. If the general alias is listed first, it will intercept and handle the import, preventing the more specific rule from ever being evaluated [3]. 3. Array vs. Object: While the object format (Record<string, string>) is convenient for simple, exact-prefix mapping, it does not guarantee evaluation order in the same explicit way as an array [2][3]. The array format is required when you need to use Regular Expressions for complex patterns or when you must strictly control the precedence of competing aliases [1][3]. To ensure correct resolution, always order your alias array from the most specific paths to the most general ones [3]. Example of correct ordering: resolve: { alias: [ { find: '@app/components', replacement: '/absolute/path/to/components' }, // More specific first { find: '@app', replacement: '/absolute/path/to/app' } // Less specific second ] }
Citations:
- 1: https://vite.dev/config/shared-options
- 2: https://github.com/vitejs/vite/blob/v8.0.8/docs/config/shared-options.md
- 3: https://www.code-splitting.com/javascript-build-pipeline-module-resolution-fundamentals/understanding-es-modules-vs-commonjs-in-bundlers/how-to-configure-module-resolution-aliases-in-vite/
- 4: https://github.com/vitejs/vite/blob/main/docs/config/shared-options.md
🌐 Web query:
Vite object alias string prefix matching order specific alias before base object syntax
💡 Result:
In Vite, the resolve.alias configuration—whether defined as an object or an array—is processed in the order specified, with the first matching rule taking precedence [1][2][3]. Because Vite evaluates these entries sequentially and stops at the first successful match, the order of your aliases is critical, especially when dealing with overlapping or nested path prefixes [3]. When multiple aliases share a common prefix (e.g., @core and @core/auth), defining the more specific alias before the less specific one ensures that the correct path is resolved [3]. If the less specific alias (e.g., @core) is defined first, it will intercept imports intended for the more specific one (e.g., @core/auth) [3]. Key points regarding configuration: - Array Format: The array format (Array<{ find, replacement }>) is recommended for most configurations because it explicitly preserves the order of entries and allows for more complex patterns like Regular Expressions [1][2][3]. - Object Format: While the object format (Record<string, string>) is convenient for simple aliases, it relies on the iteration order of object keys, which is generally reliable in modern JavaScript but can be less transparent than an explicit array [1][2]. - Implementation Details: Internally, Vite processes these aliases in a top-down manner [4]. If you use the array format, your configuration should explicitly list your most specific aliases (e.g., those with longer or more distinct path segments) at the top of the array [3]. If you find that an alias is being incorrectly overridden, reordering your resolve.alias configuration to prioritize the most specific path match will resolve the issue [5][3].
Citations:
- 1: https://github.com/vitejs/vite/blob/v8.0.8/docs/config/shared-options.md
- 2: https://vite.dev/config/shared-options
- 3: https://www.code-splitting.com/javascript-build-pipeline-module-resolution-fundamentals/understanding-es-modules-vs-commonjs-in-bundlers/how-to-configure-module-resolution-aliases-in-vite/
- 4: https://github.com/vitejs/vite/blob/main/packages/vite/src/node/utils.ts
- 5: https://stackoverflow.com/questions/75403735/ambiguous-aliases-in-vite-monorepo
Place the /probe alias before the base alias.
The broader @fusion-plugin-examples/claude-runtime alias will also match @fusion-plugin-examples/claude-runtime/probe, so that import can resolve to probes-entry.ts/probe instead of src/probe.ts.
Suggested fix
- "`@fusion-plugin-examples/claude-runtime`": resolve(
- __dirname,
- "../../plugins/fusion-plugin-claude-runtime/src/probes-entry.ts",
- ),
"`@fusion-plugin-examples/claude-runtime/probe`": resolve(
__dirname,
"../../plugins/fusion-plugin-claude-runtime/src/probe.ts",
),
+ "`@fusion-plugin-examples/claude-runtime`": resolve(
+ __dirname,
+ "../../plugins/fusion-plugin-claude-runtime/src/probes-entry.ts",
+ ),📝 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.
| "@fusion-plugin-examples/claude-runtime": resolve( | |
| __dirname, | |
| "../../plugins/fusion-plugin-claude-runtime/src/index.ts", | |
| "../../plugins/fusion-plugin-claude-runtime/src/probes-entry.ts", | |
| ), | |
| "@fusion-plugin-examples/claude-runtime/probe": resolve( | |
| __dirname, | |
| "../../plugins/fusion-plugin-claude-runtime/src/probe.ts", | |
| "`@fusion-plugin-examples/claude-runtime/probe`": resolve( | |
| __dirname, | |
| "../../plugins/fusion-plugin-claude-runtime/src/probe.ts", | |
| ), | |
| "`@fusion-plugin-examples/claude-runtime`": resolve( | |
| __dirname, | |
| "../../plugins/fusion-plugin-claude-runtime/src/probes-entry.ts", | |
| ), |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/dashboard/vitest.config.ts` around lines 592 - 598, Reorder the
aliases in the Vitest configuration so
"`@fusion-plugin-examples/claude-runtime/probe`" is declared before the broader
"`@fusion-plugin-examples/claude-runtime`" alias, ensuring probe imports resolve
to src/probe.ts rather than through probes-entry.ts.
Summary
Full Suite after #2292: shards 1–3 green; shard 4 failed FN-7537 backup automation tests with
store.getGlobalSettingsDir is not a function.getGlobalSettingsDirto routes-automation mock store@fusion-plugin-examples/claude-runtime→probes-entry(same class as CLI fix: resolve claude-runtime probe source for CLI full-suite #2292)Test plan
Summary by CodeRabbit