Skip to content

Conversation

@Ashwinhegde19
Copy link

@Ashwinhegde19 Ashwinhegde19 commented Oct 26, 2025

Fix: CLI Local Config Path Resolution

Summary

Fixes a bug where switching to/from local configuration files would fail in the Continue CLI. The issue occurred because relative paths and tilde expansion were not being resolved to absolute paths before creating file:// URIs, resulting in invalid URIs like file://./config.yaml.

Problem

Users reported that config switching would fail when involving local config files:

  • ❌ Remote → Local switching failed
  • ❌ Local → Remote switching failed
  • ❌ Local → Local switching failed
  • ✅ Remote → Remote switching worked fine

The root cause was in the URI creation logic which didn't properly handle:

  • Relative paths: ./config.yaml, ../config.yaml
  • Tilde expansion: ~/.continue/config.yaml
  • Mixed paths in switching scenarios

Solution

Added a resolveFilePath() helper function that:

  1. Expands tilde (~) to the user's home directory
  2. Resolves relative paths to absolute paths using path.resolve()
  3. Preserves already-absolute paths unchanged

Updated two key functions:

  • getUriFromSource() in configLoader.ts
  • pathToUri() in auth/uriUtils.ts

Both now ensure all file paths are absolute before creating file:// URIs.

Changes

  • ✨ Added resolveFilePath() helper in configLoader.ts
  • ✨ Added resolveFilePath() helper in auth/uriUtils.ts
  • 🔧 Updated getUriFromSource() to use path resolution
  • 🔧 Updated pathToUri() to use path resolution
  • ✅ Added comprehensive unit tests in uriUtils.test.ts
  • 📝 Updated local-config-switching.test.tsx documentation

Test Coverage

Added tests for:

  • ✅ Absolute path conversion
  • ✅ Relative path resolution (./ , ../)
  • ✅ Tilde expansion (~/)
  • ✅ Windows paths (C:\, UNC paths)
  • ✅ Round-trip URI conversions
  • ✅ Edge cases and invalid inputs

Example Before/After

Before (Broken)

pathToUri("./config.yaml")
// Returns: "file://./config.yaml" ❌ (invalid URI)

pathToUri("~/.continue/config.yaml")
// Returns: "file://~/.continue/config.yaml" ❌ (invalid URI)

After (Fixed)

pathToUri("./config.yaml")
// Returns: "file:///home/user/project/config.yaml" ✅

pathToUri("~/.continue/config.yaml")
// Returns: "file:///home/user/.continue/config.yaml" ✅

Impact

  • ✅ Users can now seamlessly switch between remote and local configs
  • ✅ Supports all path types (relative, absolute, tilde)
  • ✅ No breaking changes to existing functionality
  • ✅ Fully backward compatible

Testing Instructions

  1. Create a local config file: ./my-config.yaml
  2. Run: cn chat --config ./my-config.yaml "test"
  3. Switch to remote: cn chat --config continuedev/default-agent "test"
  4. Switch back to local: cn chat --config ~/my-config.yaml "test"

All switches should work without errors.

Related Issues

This fix addresses the documented issue in /extensions/cli/src/e2e/local-config-switching.test.tsx where local config switching was identified as broken.

Checklist

  • Code follows the project's style guidelines
  • Self-review performed
  • Comments added for complex logic
  • Tests added and passing
  • No breaking changes
  • Documentation updated

Summary by cubic

Fixes CLI config switching by resolving relative paths and tilde to absolute paths before creating file:// URIs. Remote↔Local and Local↔Local switches now work reliably across OSes.

  • Bug Fixes
    • Resolve ~ and relative paths to absolute before URI creation.
    • Update pathToUri and getUriFromSource to enforce absolute paths.
    • Handle Windows and POSIX paths correctly; produce valid file:// URIs.
    • Add unit tests for resolution and round-trip conversions; update e2e test to reflect fix.

@Ashwinhegde19 Ashwinhegde19 requested a review from a team as a code owner October 26, 2025 20:03
@Ashwinhegde19 Ashwinhegde19 requested review from RomneyDa and removed request for a team October 26, 2025 20:03
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 26, 2025
@github-actions
Copy link


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="extensions/cli/src/configLoader.ts">

<violation number="1" location="extensions/cli/src/configLoader.ts:578">
Home-directory expansion only handles &quot;~/&quot;, so a Windows path like &quot;~\config.yaml&quot; is still left unresolved and the CLI looks in a literal &quot;~&quot; folder. Please handle both path separators to finish closing this bug.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

*/
function resolveFilePath(filePath: string): string {
// Handle tilde (~) expansion for home directory
if (filePath.startsWith("~/")) {
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 26, 2025

Choose a reason for hiding this comment

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

Home-directory expansion only handles "/", so a Windows path like "\config.yaml" is still left unresolved and the CLI looks in a literal "~" folder. Please handle both path separators to finish closing this bug.

Prompt for AI agents
Address the following comment on extensions/cli/src/configLoader.ts at line 578:

<comment>Home-directory expansion only handles &quot;~/&quot;, so a Windows path like &quot;~\config.yaml&quot; is still left unresolved and the CLI looks in a literal &quot;~&quot; folder. Please handle both path separators to finish closing this bug.</comment>

<file context>
@@ -569,15 +570,32 @@ function isFilePath(configPath: string): boolean {
+ */
+function resolveFilePath(filePath: string): string {
+  // Handle tilde (~) expansion for home directory
+  if (filePath.startsWith(&quot;~/&quot;)) {
+    return path.join(os.homedir(), filePath.slice(2));
+  }
</file context>
Suggested change
if (filePath.startsWith("~/")) {
if (filePath.startsWith("~/") || filePath.startsWith("~\\")) {
Fix with Cubic

@github-project-automation github-project-automation bot moved this from Todo to Done in Issues and PRs Oct 28, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Oct 28, 2025
@Ashwinhegde19 Ashwinhegde19 deleted the fix/cli-local-config-path-resolution branch October 28, 2025 16:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant