Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add command to switch mode #1120

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

aheizi
Copy link

@aheizi aheizi commented Feb 22, 2025

Description

Feature: add command to switch mode

When I'm developing with roo-code, I often need to switch between different modes. Clicking the select box is somewhat inconvenient for me, and I hope there could be a better way to help me switch modes. When I learned that the new version of Cursor added a Cmd + . shortcut to switch modes, I was excited and wanted to add this functionality to roo-code as well.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Manual testing

Checklist:

  • My code follows the patterns of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Additional context

roo-code-add-cmd-switch-mode.mov

Related Issues

Reviewers


Important

Add cycleModes command and keyboard shortcut to switch modes in Roo Code, integrating it with the ChatView component.

  • Feature:
    • Add cycleModes command in package.json to switch modes.
    • Register cycleModes command in src/commands/mode-switching.ts.
    • Add keybinding for cycleModes in package.json.
  • Integration:
    • Register mode switching command in src/extension.ts.
    • Handle mode messages in webview-ui/src/App.tsx to switch to chat tab and call switchMode.
  • Components:
    • Add switchMode method to ChatView in webview-ui/src/components/chat/ChatView.tsx to update mode and send message to VSCode.

This description was created by Ellipsis for 867d5e0. It will automatically update as commits are pushed.

Copy link

changeset-bot bot commented Feb 22, 2025

⚠️ No Changeset found

Latest commit: 2f00058

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. enhancement New feature or request labels Feb 22, 2025
"win": "ctrl+.",
"linux": "ctrl+.",
"mac": "cmd+.",
"when": "true"
Copy link

Choose a reason for hiding this comment

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

The new keybinding for 'roo-cline.cycleModes' is registered with a universal condition ('when': 'true'). Consider refining the condition (e.g. checking for an active editor or focused window) to avoid accidental triggering in contexts where switching modes isn’t applicable.

Suggested change
"when": "true"
"when": "editorTextFocus"

@aheizi aheizi force-pushed the feature/add-command-to-switch-mode branch from c8985fe to 71bdc7e Compare February 23, 2025 03:03
@aheizi
Copy link
Author

aheizi commented Feb 27, 2025

windsurf support switch mode
image
cursor support switch mode
image

@mrubens
Copy link
Collaborator

mrubens commented Feb 27, 2025

Thanks @aheizi! I fixed the conflicts and pushed a change to find the current mode in the list before cycling. Hope you don't mind!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 27, 2025
Copy link
Collaborator

@mrubens mrubens left a comment

Choose a reason for hiding this comment

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

Er, I just realized that this gets in the way of the previous cmd + . behavior when you have selected text in the editor. Do you know if there's a way to only apply this when the extension is in focus?

@dosubot dosubot bot removed the lgtm This PR has been approved by a maintainer label Feb 27, 2025
@aheizi
Copy link
Author

aheizi commented Feb 28, 2025

okey, I'll try it right now

@aheizi
Copy link
Author

aheizi commented Feb 28, 2025

Er, I just realized that this gets in the way of the previous cmd + . behavior when you have selected text in the editor. Do you know if there's a way to only apply this when the extension is in focus?

emmm, I tried some methods, but they didn't work, I'll try again later.

@aheizi
Copy link
Author

aheizi commented Feb 28, 2025

Er, I just realized that this gets in the way of the previous cmd + . behavior when you have selected text in the editor. Do you know if there's a way to only apply this when the extension is in focus?

vscode.commands.registerCommand is used to register VSCode commands, but in this scenario, we need to handle the shortcut key events of the plugin's internal webview. so i will change the way to realize this function.

@mrubens
Copy link
Collaborator

mrubens commented Feb 28, 2025

Great! Thanks for digging in.

@aheizi
Copy link
Author

aheizi commented Feb 28, 2025

Great! Thanks for digging in.

Please take a look at this PR: #1270

@aheizi aheizi requested a review from mrubens March 1, 2025 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants