-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Modes selector improvements #4902
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
f4fb0bf
1837400
5ac5a4e
b4bdeb2
aea3481
489d4a2
52c5e95
5835621
1da0fd8
7ef7202
e45d2da
fdb92d9
c903eb8
dcb2cab
df5574f
b0d714f
3dc4df6
3afab13
df7a9c3
5dc5c31
a5018d5
9f126dc
19ef6f2
f489b0b
61d1799
7302a3e
0185d09
75dc3db
1b308ca
03e4fe9
07f5f3f
57977aa
35e2db2
4452bdc
0a0c0da
0bbdd32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -942,8 +942,27 @@ export const webviewMessageHandler = async ( | |
const updatedPrompts = { ...existingPrompts, [message.promptMode]: message.customPrompt } | ||
await updateGlobalState("customModePrompts", updatedPrompts) | ||
const currentState = await provider.getStateToPostToWebview() | ||
const stateWithPrompts = { ...currentState, customModePrompts: updatedPrompts } | ||
const stateWithPrompts = { | ||
...currentState, | ||
customModePrompts: updatedPrompts, | ||
hasOpenedModeSelector: currentState.hasOpenedModeSelector ?? false, | ||
} | ||
provider.postMessageToWebview({ type: "state", state: stateWithPrompts }) | ||
|
||
if (TelemetryService.hasInstance()) { | ||
// Determine which setting was changed by comparing objects | ||
const oldPrompt = existingPrompts[message.promptMode] || {} | ||
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. I don't love the complexity of this logic and the fact it's repeated elsewhere, but this was Roo's insistent suggestion on how to determine the changed setting and I couldn't figure out a different one which didn't lead to much more complex changes (eg one global event per setting change) |
||
const newPrompt = message.customPrompt | ||
const changedSettings = Object.keys(newPrompt).filter( | ||
(key) => | ||
JSON.stringify((oldPrompt as Record<string, unknown>)[key]) !== | ||
JSON.stringify((newPrompt as Record<string, unknown>)[key]), | ||
) | ||
|
||
if (changedSettings.length > 0) { | ||
TelemetryService.instance.captureModeSettingChanged(changedSettings[0]) | ||
} | ||
} | ||
} | ||
break | ||
case "deleteMessage": { | ||
|
@@ -1079,6 +1098,10 @@ export const webviewMessageHandler = async ( | |
await updateGlobalState("showRooIgnoredFiles", message.bool ?? true) | ||
await provider.postStateToWebview() | ||
break | ||
case "hasOpenedModeSelector": | ||
await updateGlobalState("hasOpenedModeSelector", message.bool ?? true) | ||
await provider.postStateToWebview() | ||
break | ||
case "maxReadFileLine": | ||
await updateGlobalState("maxReadFileLine", message.value) | ||
await provider.postStateToWebview() | ||
|
@@ -1408,12 +1431,41 @@ export const webviewMessageHandler = async ( | |
break | ||
case "updateCustomMode": | ||
if (message.modeConfig) { | ||
// Check if this is a new mode or an update to an existing mode | ||
const existingModes = await provider.customModesManager.getCustomModes() | ||
const isNewMode = !existingModes.some((mode) => mode.slug === message.modeConfig?.slug) | ||
|
||
await provider.customModesManager.updateCustomMode(message.modeConfig.slug, message.modeConfig) | ||
// Update state after saving the mode | ||
const customModes = await provider.customModesManager.getCustomModes() | ||
await updateGlobalState("customModes", customModes) | ||
await updateGlobalState("mode", message.modeConfig.slug) | ||
await provider.postStateToWebview() | ||
|
||
// Track telemetry for custom mode creation or update | ||
if (TelemetryService.hasInstance()) { | ||
if (isNewMode) { | ||
// This is a new custom mode | ||
TelemetryService.instance.captureCustomModeCreated( | ||
message.modeConfig.slug, | ||
message.modeConfig.name, | ||
) | ||
} else { | ||
// Determine which setting was changed by comparing objects | ||
const existingMode = existingModes.find((mode) => mode.slug === message.modeConfig?.slug) | ||
const changedSettings = existingMode | ||
? Object.keys(message.modeConfig).filter( | ||
(key) => | ||
JSON.stringify((existingMode as Record<string, unknown>)[key]) !== | ||
JSON.stringify((message.modeConfig as Record<string, unknown>)[key]), | ||
) | ||
: [] | ||
|
||
if (changedSettings.length > 0) { | ||
TelemetryService.instance.captureModeSettingChanged(changedSettings[0]) | ||
} | ||
} | ||
} | ||
} | ||
break | ||
case "deleteCustomMode": | ||
|
@@ -1598,6 +1650,7 @@ export const webviewMessageHandler = async ( | |
) | ||
await provider.postStateToWebview() | ||
console.log(`Marketplace item installed and config file opened: ${configFilePath}`) | ||
|
||
// Send success message to webview | ||
provider.postMessageToWebview({ | ||
type: "marketplaceInstallResult", | ||
|
@@ -1650,7 +1703,11 @@ export const webviewMessageHandler = async ( | |
|
||
case "switchTab": { | ||
if (message.tab) { | ||
// Send a message to the webview to switch to the specified tab | ||
// Capture tab shown event for all switchTab messages (which are user-initiated) | ||
if (TelemetryService.hasInstance()) { | ||
TelemetryService.instance.captureTabShown(message.tab) | ||
} | ||
|
||
await provider.postMessageToWebview({ type: "action", action: "switchTab", tab: message.tab }) | ||
} | ||
break | ||
|
Uh oh!
There was an error while loading. Please reload this page.