Skip to content

fix(vscode): start new sessions in the configured defaultMode - #2468

Open
Dhirenderchoudhary wants to merge 1 commit into
Nano-Collective:mainfrom
Dhirenderchoudhary:fix/1722-default-mode-source
Open

Dhirenderchoudhary wants to merge 1 commit into
Nano-Collective:mainfrom
Dhirenderchoudhary:fix/1722-default-mode-source

Conversation

@Dhirenderchoudhary

Copy link
Copy Markdown
Contributor

Description

Fixes #1722.

Changing Default mode in the VS Code Settings tab did nothing for new sidebar sessions:

  • _createSession() used config.get('mode') || 'auto-accept'. The manifest declares a default for nanocoder.mode, so get() always returned a value and the client forced every new session into it.
  • The ACP agent never read nanocoder.defaultMode. Sessions started in --mode (or the profile mode), else auto-accept.
  • The settings change listener used get() too, so clearing nanocoder.mode switched the open session to the manifest default.

What changed:

  • acp-agent.ts: registerSession uses initialMode ?? loadDefaultMode(). It runs inside the session's context, so it reads the session folder's config (profile, project, then global). loadDefaultMode already validates against the known modes.
  • acp-client.ts: a small explicitModeSetting() reads config.inspect('mode') (folder, workspace, then user value) and ignores the manifest default. A new session is only switched when the user set nanocoder.mode. The change listener uses the same helper.
  • No protocol change. The agent already returns the session's mode in newSession.

Precedence for a new sidebar session is now: explicit nanocoder.mode (if it's one of the agent's modes) > --mode > defaultMode > auto-accept.

The mode selector still saves the picked mode to nanocoder.mode, as before, so after a pick that value outranks defaultMode until it's cleared. The docs and the setting description now say this. I didn't change the selector, to keep this PR to the precedence fix.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Changeset

  • Added a changeset (pnpm changeset) describing this change for the changelog

Docs-only or internal chores need no changeset (or run pnpm changeset --empty to note that intentionally).

Testing

Automated Tests

  • New features include passing tests in .spec.ts/tsx files

  • All existing tests pass (pnpm test:all completes successfully)

  • Tests cover both success and error scenarios

  • acp-client.spec.ts: an unset nanocoder.mode keeps the agent's mode, an explicit one overrides it, a workspace value beats a user value, an unknown value is ignored, and clearing the setting doesn't switch the open session.

  • acp-agent.spec.ts: new, load and resume start in the project's defaultMode, --mode beats it, and an unknown defaultMode falls back to auto-accept.

The "unset keeps the agent's mode", "clearing doesn't switch" and "starts in defaultMode" tests fail on main. The vscode test stub gained inspect(). Ran tsc --noEmit for both projects, pnpm test:format, pnpm test:lint, pnpm test:knip, and ava on plugins/vscode and source/acp (814 tests).

Manual Testing

  • Tested with Ollama
  • Tested with OpenRouter
  • Tested with OpenAI-compatible API
  • Tested MCP integration (if applicable)

Checklist

  • If this was for an open issue, I was assigned to it
  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated (if needed)
  • No breaking changes (or clearly documented)
  • Appropriate logging added using structured logging (see CONTRIBUTING.md)

Docs: docs/features/vscode-extension.md, docs/features/acp.md and docs/configuration/index.md now describe the order. No new logging.

@github-actions github-actions Bot added area:docs Documentation area:vscode VS Code extension and host integration labels Nov 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

nc-review could not produce a verdict this run (agent exit 1). This is a problem with the review agent, not with your pull request. A maintainer can retry with /re-review.

@will-lamerton will-lamerton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @Dhirenderchoudhary, this is correct and well documented:

  • Precedence is explicit nanocoder.mode > --mode > defaultMode > auto-accept, and the code, docs/features/acp.md and vscode-extension.md agree. Using config.inspect() instead of get() stops the manifest default from forcing a mode, including when the setting is cleared.
  • No mode from the client: the ACP agent reads defaultMode from the session folder's config via loadDefaultMode() and validates it against VALID_MODES.
  • No new exposure: a project agents.config.json setting defaultMode behaves as it already does in the CLI, and ACP sessions require the folder to pass the directory-trust check. Specs pass (181/181).

Nit: the changeset could mention that a trusted project's defaultMode now sets the sidebar's starting mode, since that's new for extension users.

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

Labels

area:docs Documentation area:vscode VS Code extension and host integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Multiple conflicting default mode settings between agents.config.json, package.json manifest, and ACP backend

2 participants