Skip to content

[Bug] VS Code extension inconsistently applies nanocoder.cwd to new sessions, settings, and mention search #1720

Closed

Description

@akramcodez

Description

The extension provides a nanocoder.cwd configuration setting. AcpProcessManager and the top-level nanocoder.openConfig command respect this setting. However, multiple other components in the extension host hardcode vscode.workspace.workspaceFolders?.[0]?.uri.fsPath || process.cwd().

Consequently, new session creation (newSession), settings-panel inspection, and @ mention file searches default to the first workspace folder rather than the configured nanocoder.cwd.

Environment

  • OS: Linux (reviewed); macOS / Windows potentially affected
  • Node version: >= 22.0.0
  • Nanocoder version: 1.31.0
  • Configuration: "nanocoder.cwd": "/custom/project/path"

Steps to Reproduce

  1. Set "nanocoder.cwd" in VS Code settings to a specific subdirectory or secondary project path.
  2. Open a workspace where the first workspace folder differs from nanocoder.cwd.
  3. Start the extension and trigger session initialization (getOrCreateSession) or @ mention file search.

Expected Behavior

The extension should consistently respect nanocoder.cwd for new session creation, settings inspection, and mention searches rather than falling back to workspaceFolders?.[0]. Once a session starts, its working directory should remain stable rather than changing when editor focus moves.

Actual Behavior

AcpProcessManager.ts:113 and extension.ts:120 respect nanocoder.cwd, but chat-webview-provider.ts:512, 557, 570, 605, 679, 747, 884 bypass it and default to workspaceFolders?.[0].

Additional Context

Implementation Notes (optional)

  • Create a shared helper resolveExtensionCwd(): string in src/workspace-utils.ts that checks config.get('cwd') before falling back to workspaceFolders?.[0].
  • Replace ad-hoc workspaceFolders?.[0]?.uri.fsPath || process.cwd() expressions in chat-webview-provider.ts for new sessions, settings reading, and mention search.

Activity

  1. added
    bug
    on Oct 12, 2026
  2. added
    needs-triage
    area:vscode
    good first issue
    and removed
    needs-triage
    on Oct 12, 2026
  3. Srinidhi444 commented on Oct 12, 2026

    @Srinidhi444
    Contributor

    Hey @akramcodez, I'd like to work on this issue. I'll follow the suggested approach by introducing a shared helper to resolve the working directory and updating the affected code paths to use it consistently.

  4. akramcodez commented on Oct 13, 2026

    @akramcodez
    MemberAuthor

    Sure @Srinidhi444 👍

  5. Srinidhi444 commented on Oct 13, 2026

    @Srinidhi444
    Contributor

    Hey @akramcodez, @addyCooks the PR is ready for review Just one quick question: should I add an empty changeset or a patch changeset for this fix, since nanocoder-vscode is listed in the ignore section of .changeset/config.json?

  6. Srinidhi444 commented on Oct 13, 2026

    @Srinidhi444
    Contributor

    Also @akramcodez, I've made the suggested changes, but I noticed a potential UX edge case. Please correct me if I'm wrong.

    With the current approach, an explicitly configured nanocoder.cwd takes priority over the opened VS Code workspace.

    For example, suppose I'm working on Project A, which has frontend and backend folders, and I explicitly set nanocoder.cwd to the backend directory. A few weeks later, I open a completely different Project B in VS Code but forget to update that setting.

    In this case, Nanocoder would still use Project A's backend directory, including for @ mention searches, even though I'm now working in Project B.

    This is technically correct since we're respecting the explicit configuration, but it could be confusing from a user's perspective.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:vscodebuggood first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions