Repository navigation
fix(vscode): respect configured cwd across extension operations - #1743
Conversation
No changeset foundThis PR does not add a changeset, so it will not appear in the changelog or trigger a release. If the change is user-facing, add one: pnpm changesetPick a bump (patch / minor / major) and write the changelog entry in our usual voice ("Added X... Thanks to @you. Closes #123."), then commit the generated If this PR is docs-only or a chore that needs no release note, you can ignore this — or run |
addyCooks
left a comment
There was a problem hiding this comment.
Thanks @Srinidhi444, this covers the call sites from the issue and the helper is a good shape.
I checked the precedence (setting, then workspace folder, then home) and it behaves as intended. A few things before it can merge:
- acp-client.ts:476 (resumeSession) still sends workspaceFolders[0] as the cwd. Now that the agent honours the session cwd, a resumed session would run in a different directory from where it started. Please use resolveExtensionCwd() there too.
- extension.ts:120 has its own copy of the same logic. Please switch it to the helper so there's one source of truth. (startCli() at :376 is optional.)
- Please add a small spec for resolveExtensionCwd. The
vscodestub in test-stubs supports it: setting wins over folder, an empty setting counts as unset, and no folder falls back to home.
No changeset is needed, since nanocoder-vscode is in the ignore list. I'd also like to see the nanocoder.cwd-outside-workspace case checked by hand if you can, since findFiles may behave differently there.
nc-review: comments — 2 important, 2 nits@Srinidhi444 — a few things worth a look, none blocking. PR #1743 introduces a shared 🟠 important · The new 🟠 important · In ⚪ nit · Related to the previous finding: the diff changes ⚪ nit ·
🔴 blocking · 🟠 a reviewer would ask for a change · ⚪ optional Automated code review — correctness, security, design, tests, plus duplicates and scope. A human still decides; this is not a substitute for review and is not exhaustive. The required status checks separately cover lint, formatting, types, unused dependencies, the test suite and the build. This bot never merges. Maintainers can rerun with |
|
Hey @addyCooks , I've addressed the requested changes and added the regression tests for The The changes have been pushed to the PR. Let me know if anything else needs adjustment! |
With no folder open and no nanocoder.cwd set, the new cwd fallback is the home directory, so @ mention search started crawling it where it used to find nothing. Search only the configured cwd or the first workspace folder; sessions still fall back to home. Add resolveProjectCwd for that distinction, test the search root, and update the nanocoder.cwd description in package.json, the README and the extension docs, which still said it only set the CLI's working directory.
addyCooks
left a comment
There was a problem hiding this comment.
Thanks @Srinidhi444, this covers everything from my review. I checked it: resumeSession now sends the configured nanocoder.cwd (main sends the first workspace folder), openConfig uses the helper, and the new spec covers the three cases.
I pushed one small commit on top (9fd1b40) for the follow-ups I'd noted:
@mention search no longer falls back to your home directory: with no folder open and nonanocoder.cwdset it finds nothing, as before. Sessions still fall back to home. AddedresolveProjectCwd()for that distinction, plus tests for the search root.- Updated the
nanocoder.cwddescription in package.json, the README and docs/features/vscode-extension.md.
CI is green on it.
Approving 🎉
Fixes #1720
Ensures the VS Code extension consistently respects the configured
nanocoder.cwdinstead of defaulting to the first workspace folder.Introduces a shared
resolveExtensionCwd()helper and uses it across ACP process startup, session initialization, settings operations, and@mention file searches.Type of Change
Changeset
pnpm changeset) describing this change for the changelogNo changeset added, as
nanocoder-vscodeis excluded from Changesets in.changeset/config.json.Testing
Automated Tests
.spec.ts/tsxfiles (N/A — bug fix)pnpm test:allcompletes successfully)Additional checks performed:
pnpm run test:types:vscode— Passedgit diff --check— Passedpnpm --filter ./plugins/vscode build:extManual Testing
Checklist
Additional Notes
The
@mention search now uses the configured CWD as its search root. One edge case that may need further handling is whennanocoder.cwdpoints outside the currently opened VS Code workspace, sincevscode.workspace.findFiles()may not search external directories as expected. This scenario has not yet been verified.