Skip to content

Commit 1417a56

Browse files
committed
Refactor voice input validation and improve recording button styling
1 parent 386b361 commit 1417a56

3 files changed

Lines changed: 38 additions & 12 deletions

File tree

‎apps/editor/src/views/panel/backend/message-handlers/handle-voice-input.ts‎

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,7 @@ const stop_recording = async (panel_provider: PanelProvider) => {
4646
const configs =
4747
await model_providers_manager.get_voice_input_tool_configs()
4848

49-
if (configs.length == 0) {
50-
vscode.window.showWarningMessage(
51-
'No Voice Input configuration found. Please configure it in settings.',
52-
{ modal: true }
53-
)
54-
return
55-
}
49+
if (configs.length == 0) return
5650

5751
let config: ToolConfig | undefined =
5852
await model_providers_manager.get_default_voice_input_config()
@@ -177,6 +171,26 @@ export const handle_voice_input = async (
177171
return
178172
}
179173

174+
if (message.is_recording) {
175+
const model_providers_manager = new ModelProvidersManager(
176+
panel_provider.context
177+
)
178+
const configs = await model_providers_manager.get_voice_input_tool_configs()
179+
180+
if (configs.length == 0) {
181+
vscode.window.showWarningMessage('No configuration found', {
182+
modal: true,
183+
detail:
184+
'Add a "Voice Input" configuration in settings to use this feature.'
185+
})
186+
panel_provider.send_message({
187+
command: 'RECORDING_STATE',
188+
is_recording: false
189+
})
190+
return
191+
}
192+
}
193+
180194
panel_provider.is_recording = message.is_recording
181195
panel_provider.send_message({
182196
command: 'RECORDING_STATE',

‎packages/ui/src/components/editor/panel/PromptField/PromptField.module.scss‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,6 @@
461461
height: 20px;
462462
border-radius: 5px;
463463

464-
> svg {
465-
width: 10px;
466-
fill: var(--vscode-icon-foreground);
467-
}
468-
469464
&.codicon::before {
470465
font-size: 16px;
471466
}
@@ -487,6 +482,18 @@
487482
padding: 0 2px;
488483
}
489484

485+
&--recording {
486+
background-color: var(--cwc-bg-red);
487+
488+
&:hover {
489+
background-color: var(--cwc-bg-red-dark) !important;
490+
}
491+
492+
&::before {
493+
color: var(--cwc-text-color-red);
494+
}
495+
}
496+
490497
&--chevron {
491498
> span.codicon::before {
492499
font-size: 11px;

‎packages/ui/src/styles/foundation/_colors.scss‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
transparent
5050
);
5151
--cwc-bg-red: color-mix(in srgb, var(--cwc-text-color-red) 12%, transparent);
52+
--cwc-bg-red-dark: color-mix(
53+
in srgb,
54+
var(--cwc-text-color-red) 24%,
55+
transparent
56+
);
5257
--cwc-bg-orange: color-mix(
5358
in srgb,
5459
var(--cwc-text-color-orange) 12%,

0 commit comments

Comments
 (0)