-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: add optional mode parameter for slash commands #6820
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
Conversation
- Add mode field to Command interface in backend and frontend - Update command loading logic to parse mode from frontmatter - Modify ChatTextArea to auto-switch modes when command is selected - Update webview message handler to include mode in command data - Add comprehensive tests for mode parameter functionality - Ensure backward compatibility for commands without mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed my own code and found it surprisingly coherent. Must be a bug in the review system.
| name: command.name, | ||
| source: command.source, | ||
| filePath: command.filePath, | ||
| description: command.description, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intentional? The argumentHint field was added here but it seems unrelated to the mode feature. Was this fixing a missing field that you noticed while implementing the mode parameter?
| : undefined | ||
| mode = | ||
| typeof parsed.data.mode === "string" && parsed.data.mode.trim() | ||
| ? parsed.data.mode.trim() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding validation to ensure the mode value matches an existing mode. This would help catch typos in command configurations early:
| ? parsed.data.mode.trim() | |
| mode = | |
| typeof parsed.data.mode === "string" && parsed.data.mode.trim() | |
| ? parsed.data.mode.trim() | |
| : undefined | |
| // TODO: Consider validating against available modes list |
| @@ -0,0 +1,112 @@ | |||
| # Implementation Plan: Add Optional Mode Parameter for Slash Commands | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that the implementation is complete, should this planning document be removed or moved to documentation? It provides good context but might not need to be in the main codebase.
| slashCommand: `/${command.name}`, | ||
| description: command.description, | ||
| argumentHint: command.argumentHint, | ||
| mode: command.mode, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor type consistency: Consider explicitly typing the mode field here for better type safety:
| mode: command.mode, | |
| mode: command.mode as string | undefined, |
|
After testing, the implementation doesn't work as intended - the mode switching functionality isn't being triggered when selecting a command with a mode parameter. Beyond the functional issues, the UX needs improvement:
Closing this PR to properly scope the issue to include:
|
This PR adds support for an optional
modeparameter in slash command markdown files, allowing commands to automatically switch to a specific mode when selected.Changes Made
Backend Changes:
mode?: stringfield to theCommandinterface insrc/services/command/commands.tsmodefield from markdown frontmatterwebviewMessageHandler.tsto include mode information when sending commands to the frontendFrontend Changes:
mode?: stringfield to theCommandinterface insrc/shared/ExtensionMessage.tsChatTextArea.tsxto automatically switch modes when a command with a mode parameter is selectedcontext-mentions.tsto pass mode information through menu optionsTests:
src/services/command/__tests__/command-mode.spec.tsHow It Works
Commands can now specify a mode in their frontmatter:
When this command is selected via slash command, the UI will automatically switch to "architect" mode.
Backward Compatibility
modeparameter continue to work as beforeTesting
Important
Add optional
modeparameter for slash commands to enable automatic mode switching, with backend and frontend updates for support.modeparameter toCommandinterface incommands.tsandExtensionMessage.ts.scanCommandDirectoryandtryLoadCommandincommands.tsto parsemodefrom markdown frontmatter.webviewMessageHandler.tsto includemodewhen sending commands to frontend.ChatTextArea.tsxto switch modes when a command with amodeis selected.context-mentions.tspassesmodethrough menu options.command-mode.spec.tsfor parsing, validation, trimming, and override behavior ofmode.modecontinue to function as before.modevalues are ignored safely.This description was created by
for dda0d69. You can customize this summary. It will automatically update as commits are pushed.