Skip to content

Conversation

@tt-a1i
Copy link
Contributor

@tt-a1i tt-a1i commented Jan 1, 2026

Summary

This PR adds the ability to set approval mode directly via command argument, without needing to open the interactive dialog.

New Usage:

/approval-mode plan       # Set to plan mode directly
/approval-mode yolo       # Set to yolo mode directly  
/approval-mode auto-edit  # Set to auto-edit mode directly
/approval-mode default    # Set to default mode directly

Behavior:

  • If no argument is provided, opens the dialog as before (backward compatible)
  • If a valid mode is provided, sets the mode directly and shows confirmation
  • If an invalid mode is provided, shows error with list of valid modes
  • Tab completion is supported for mode arguments

Note: Direct argument mode always saves to User scope. The interactive dialog still allows choosing between User/Workspace scopes.

Changes

  • Modified approvalModeCommand.ts to parse and handle direct mode arguments
  • Added completion function for tab completion support
  • Updated tests to cover new functionality (including explicit setApprovalMode argument assertions)
  • Added i18n translations (en, zh, ru)

Fixes #1353

AI Assistance Disclosure

I used Codex to review the changes, sanity-check the implementation against existing patterns, and help spot potential edge cases.

@tt-a1i tt-a1i marked this pull request as ready for review January 1, 2026 12:29
@tanzhenxin tanzhenxin self-assigned this Jan 6, 2026
@tanzhenxin
Copy link
Collaborator

@tt-a1i Thanks for your contribution! I’m not sure it’s a good idea to set approval mode at the user scope, since it could easily be overridden by the project scope setting. You can try this out using the /approval-mode dialog.

From my perspective, this issue is more of a power-user requirement rather than a typical CLI use case. So I’m thinking we could keep things simple: no autocomplete, and when a user runs /approval-mode xxx, we apply it only at the session scope—without persisting it to either the project or user scope. This would be similar to how the Shift+Tab shortcut works.

What do you think about this approach?

tt-a1i added 3 commits January 6, 2026 21:54
Allow users to set approval mode directly via argument instead of
opening the dialog. For example:
- /approval-mode plan
- /approval-mode yolo
- /approval-mode auto-edit
- /approval-mode default

If no argument is provided, the dialog opens as before.
If an invalid argument is provided, an error message shows valid options.

Also adds tab completion for mode arguments.

Fixes QwenLM#1353
Verify the exact mode value passed to config.setApprovalMode to catch
potential regressions in settings merge/update mechanism.
- Remove persistence to user settings (no setValue call)
- Only use config.setApprovalMode() for session scope
- Remove autocomplete feature for simplicity
- Align with Shift+Tab behavior
@tt-a1i tt-a1i force-pushed the feat/approval-mode-direct-arg branch from 77e9ff3 to bfe7298 Compare January 6, 2026 13:57
Add try/catch to gracefully handle errors when setting privileged
modes (yolo/auto-edit) in untrusted folders, returning an error
message instead of throwing.
@tt-a1i
Copy link
Contributor Author

tt-a1i commented Jan 6, 2026

@tt-a1i Thanks for your contribution! I’m not sure it’s a good idea to set approval mode at the user scope, since it could easily be overridden by the project scope setting. You can try this out using the /approval-mode dialog.

From my perspective, this issue is more of a power-user requirement rather than a typical CLI use case. So I’m thinking we could keep things simple: no autocomplete, and when a user runs /approval-mode xxx, we apply it only at the session scope—without persisting it to either the project or user scope. This would be similar to how the Shift+Tab shortcut works.

What do you think about this approach?

thanks for the feedback! updated:

  • removed persistence, now session-only (just config.setApprovalMode())
  • dropped autocomplete

also added try/catch for the untrusted folder case since setApprovalMode can throw there.

Copy link
Collaborator

@tanzhenxin tanzhenxin left a comment

Choose a reason for hiding this comment

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

LGTM!

@tanzhenxin tanzhenxin merged commit 3f51252 into QwenLM:main Jan 7, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/approval-mode 建议后面可以加参数 直接设定模式,不用进一步选择,

2 participants