Skip to content

fix(vscode): make defaultMode the source of truth for new session mode - #1928

Closed
Mahdi-Hasan wants to merge 1 commit into
Nano-Collective:mainfrom
Mahdi-Hasan:fix/1722-default-mode-source-of-truth
Closed

Mahdi-Hasan wants to merge 1 commit into
Nano-Collective:mainfrom
Mahdi-Hasan:fix/1722-default-mode-source-of-truth

Conversation

@Mahdi-Hasan

Copy link
Copy Markdown
Contributor

Description

Makes defaultMode in agents.config.json the source of truth for the starting mode of new sessions. Fixes #1722.

Starting mode, highest priority first:

  1. nanocoder.mode in VS Code settings, only when the user set it explicitly (user, workspace or folder level)
  2. --mode passed to the ACP agent
  3. nanocoder.defaultMode from agents.config.json
  4. auto-accept
  • Agent: registerSession uses initContext.initialMode ?? loadDefaultMode(). loadDefaultMode() already validates against VALID_MODES. It runs for each session, so changing the default in the Settings tab applies to the next new chat without restarting the agent.
  • Extension: _createSession() reads nanocoder.mode with config.inspect() instead of get(). get() always returned the manifest default, which hid defaultMode. A value the agent doesn't offer is logged and ignored. I removed the manifest default for nanocoder.mode, so the settings UI no longer shows a value that is never applied.
  • Docs: acp.md and vscode-extension.md describe the new order.
  • Note: the mode selector still writes nanocoder.mode. A mode picked there keeps overriding defaultMode until that setting is cleared.

Type of Change

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

Changeset

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

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

  • source/acp/acp-agent.spec.ts (5 new):

    • defaultMode is used.
    • --mode beats it.
    • Invalid or missing values fall back to auto-accept.
    • A config change between two sessions takes effect.
  • plugins/vscode/src/acp-client.spec.ts (6 new):

    • inspect scope order.
    • An unset setting keeps the agent's mode.
    • An explicit setting overrides it.
    • An unknown value is ignored.
  • Format, types (root and vscode), lint, knip and audit pass.

  • I developed this on Windows, where pnpm test:ava has many failures on main too. This branch adds no new failures.

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 (I commented on the issue with the proposed order before starting)
  • 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)

Possible follow-ups, not in this PR:

  • The Settings tab shows "normal" when defaultMode is unset, but sidebar chats fall back to auto-accept.
  • validModes in settings-manager.ts leaves out architect.

🤖 Generated with Claude Code

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

github-actions Bot commented Nov 2, 2026

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.

The default mode had three sources that disagreed. The Settings tab
writes nanocoder.defaultMode to agents.config.json, but the ACP agent
started every session in auto-accept unless --mode was passed, and the
extension then forced nanocoder.mode on top. That setting declared an
auto-accept default, so config.get('mode') always returned a value and
defaultMode never took effect.

The ACP agent now starts a session in --mode, then defaultMode from
agents.config.json via loadDefaultMode(), which already validates the
value against VALID_MODES, then auto-accept. It reads defaultMode when
each session is registered, so a change from the Settings tab applies
to the next new chat without restarting the agent.

The extension reads nanocoder.mode with inspect() and only overrides
the agent's mode when the user set it at user, workspace or folder
level. A value the agent does not offer is logged and ignored. The
manifest default for nanocoder.mode is gone, so the settings UI no
longer shows a value that is not applied.

The mode selector still writes nanocoder.mode, so a mode picked there
keeps winning over defaultMode until the setting is cleared. The ACP
and extension docs describe that order.

Tests cover the agent order (defaultMode, --mode over it, invalid and
missing values, a change between sessions) and the extension side
(inspect scopes, unset setting keeps the agent mode, explicit setting
overrides it, unknown value is ignored).

Fixes Nano-Collective#1722

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Mahdi-Hasan
Mahdi-Hasan force-pushed the fix/1722-default-mode-source-of-truth branch from 31293db to ba834bd Compare November 2, 2026 12:24
@Mahdi-Hasan

Copy link
Copy Markdown
Contributor Author

Closing this since #1722 is assigned to @Dhirenderchoudhary. Thanks for taking a look!

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

1 participant