-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat(mode): auto select imported mode #8506
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2220,12 +2220,20 @@ export const webviewMessageHandler = async ( | |
| // Update state after importing | ||
| const customModes = await provider.customModesManager.getCustomModes() | ||
| await updateGlobalState("customModes", customModes) | ||
|
|
||
| // Switch to the first imported mode if available | ||
| if (result.importedSlugs && result.importedSlugs.length > 0) { | ||
| const firstImportedSlug = result.importedSlugs[0] | ||
| await updateGlobalState("mode", firstImportedSlug) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P3] Consistency: The mode is set both via updateGlobalState("mode", firstImportedSlug) and by emitting importedSlug for the UI to set visualMode. This dual-path selection works but splits responsibility between backend state and frontend UI. Consider driving selection from one path (e.g., only emit a mode change message and rely on postStateToWebview), so side-effects and telemetry remain centralized. |
||
| } | ||
|
|
||
| await provider.postStateToWebview() | ||
|
|
||
| // Send success message to webview | ||
| // Send success message to webview with the imported slug | ||
| provider.postMessageToWebview({ | ||
| type: "importModeResult", | ||
| success: true, | ||
| importedSlug: result.importedSlugs?.[0], | ||
| }) | ||
|
|
||
| // Show success message | ||
|
|
||
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.
[P2] Performance: importModeWithRules performs updateCustomMode inside the loop (each call reads/merges/writes and triggers state refresh). With multiple modes this causes redundant work plus an extra refresh after the loop. Consider batching: write all mode updates in-memory and perform a single write/refresh at the end of the loop to reduce IO and recompute overhead.