Skip to content

Commit 70ba926

Browse files
committed
Standardize QuickPick separator labels to lowercase and add OS-specific error handling for missing SoX dependency in voice input
- when sox is not installed, provide clearer error message,e.g. including command: 'brew install sox' - make the sox error message targeted per platform - it's been reported that the missing microphone permission dialog (system wide one) is shown AFTER recordiing is supposedly done
1 parent d34806f commit 70ba926

3 files changed

Lines changed: 43 additions & 4 deletions

File tree

‎apps/editor/src/utils/show-api-configuration-quick-pick.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ export const show_api_configuration_quick_pick = async (
5353
const items: Item[] = []
5454
const pinned = api_configurations.filter((c) => c.is_pinned)
5555
if (pinned.length > 0) {
56-
items.push({ label: 'Pinned', kind: vscode.QuickPickItemKind.Separator })
56+
items.push({ label: 'pinned', kind: vscode.QuickPickItemKind.Separator })
5757
items.push(...pinned.map(map_api_configuration_to_item))
58-
items.push({ label: 'All', kind: vscode.QuickPickItemKind.Separator })
58+
items.push({ label: 'all', kind: vscode.QuickPickItemKind.Separator })
5959
}
6060
items.push(...api_configurations.map(map_api_configuration_to_item))
6161

‎apps/editor/src/views/panel/backend/message-handlers/handle-send-to-browser.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,9 @@ const show_web_configuration_quick_pick = async (params: {
284284

285285
const pinned = valid_web_configurations.filter((c: any) => c.isPinned)
286286
if (pinned.length > 0) {
287-
items.push({ label: 'Pinned', kind: vscode.QuickPickItemKind.Separator })
287+
items.push({ label: 'pinned', kind: vscode.QuickPickItemKind.Separator })
288288
items.push(...pinned.map(map_web_configuration_to_item))
289-
items.push({ label: 'All', kind: vscode.QuickPickItemKind.Separator })
289+
items.push({ label: 'all', kind: vscode.QuickPickItemKind.Separator })
290290
}
291291

292292
items.push(...valid_web_configurations.map(map_web_configuration_to_item))

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,48 @@ const start_recording = (panel_provider: PanelProvider) => {
2121
panel_provider.recording_start_time = Date.now()
2222
try {
2323
panel_provider.recording_process = spawn('rec', ['-q', '-t', 'wav', '-'])
24+
2425
panel_provider.recording_process.stdout.on('data', (chunk: Buffer) => {
2526
panel_provider.audio_chunks.push(chunk)
2627
})
28+
29+
panel_provider.recording_process.on('error', (error: any) => {
30+
if (error.code == 'ENOENT') {
31+
let error_message =
32+
'The "rec" command was not found. Please install SoX to use voice input.'
33+
34+
if (process.platform == 'darwin') {
35+
error_message =
36+
'The "rec" command was not found. Please install SoX to use voice input (e.g., run "brew install sox" in your terminal).'
37+
} else if (process.platform == 'linux') {
38+
error_message =
39+
'The "rec" command was not found. Please install SoX to use voice input (e.g., run "sudo apt install sox" in your terminal).'
40+
} else if (process.platform == 'win32') {
41+
error_message =
42+
'The "rec" command was not found. Please install SoX to use voice input (e.g., run "winget install sox.sox" and add it to your PATH).'
43+
}
44+
45+
vscode.window.showErrorMessage(error_message)
46+
} else {
47+
vscode.window.showErrorMessage(
48+
'Failed to start recording: ' + error.message
49+
)
50+
}
51+
52+
Logger.error({
53+
function_name: 'start_recording',
54+
message: 'Failed to start recording process',
55+
data: { error }
56+
})
57+
58+
// Ensure the UI state resets if recording failed to start
59+
panel_provider.is_recording = false
60+
panel_provider.send_message({
61+
command: 'RECORDING_STATE',
62+
is_recording: false
63+
})
64+
panel_provider.recording_process = null
65+
})
2766
} catch (error: any) {
2867
Logger.error({
2968
function_name: 'start_recording',

0 commit comments

Comments
 (0)