-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: auto-switch to imported mode after successful import #8240
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 importedModes field to ImportResult interface to track imported mode slugs - Modify importModeWithRules method to collect and return imported mode slugs - Update webview message handler to automatically switch to first imported mode - Update ModesView.tsx to handle successful import with mode switching Fixes #6491
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.
Reviewed my own code. Found it suspiciously working on the first try. Very suspicious indeed.
| if (result.importedModes && result.importedModes.length > 0) { | ||
| // Switch to the first imported mode | ||
| const modeToSwitchTo = result.importedModes[0] | ||
| await updateGlobalState("mode", modeToSwitchTo) |
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.
Important: This should use await provider.handleModeSwitch(result.importedModes[0]) instead of directly calling updateGlobalState("mode", modeToSwitchTo).
The current approach bypasses important logic including:
- Telemetry tracking for mode switches
- Task history updates
- API configuration switching for the new mode
Suggested change:
if (result.importedModes && result.importedModes.length > 0) {
// Switch to the first imported mode
const modeToSwitchTo = result.importedModes[0]
await provider.handleModeSwitch(modeToSwitchTo)
}| const customModes = await provider.customModesManager.getCustomModes() | ||
| await updateGlobalState("customModes", customModes) | ||
|
|
||
| // Automatically switch to imported mode if modes were imported |
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 error handling around the mode switching logic. If the mode switch fails, the user won't receive any feedback about the failure.
Suggested improvement:
if (result.importedModes && result.importedModes.length > 0) {
try {
const modeToSwitchTo = result.importedModes[0]
await provider.handleModeSwitch(modeToSwitchTo)
} catch (error) {
provider.log(`Failed to switch to imported mode: ${error}`)
// Optionally show user notification
}
}
Summary
This PR addresses Issue #8239 by automatically switching to the imported mode after a successful import from the modes configuration page.
Changes
CustomModesManager.tsto track and return imported modes in theImportResultwebviewMessageHandler.tsto automatically switch to the first imported mode after successful importMotivation
Previously, after importing a mode, users had to manually switch to it, requiring extra clicks. This enhancement improves the user experience by automatically switching to the imported mode, reducing friction in the workflow.
Implementation Details
ImportResultinterface to include an optionalimportedModesfieldimportModeWithRuleshandleModeSwitchwith the first imported mode's slugTesting
Review Confidence
The implementation was reviewed with a 95% confidence score:
Fixes #8239
Important
Automatically switch to the first imported mode after a successful import, enhancing user experience by reducing manual steps.
webviewMessageHandler.ts.ImportResultinCustomModesManager.tsto includeimportedModes.ModesView.tsxto handle visual state updates post-import.This description was created by
for a76b089. You can customize this summary. It will automatically update as commits are pushed.