Skip to content

Commit 5e8c8a6

Browse files
committed
Add a push-to-talk voice input setting to allow users to toggle the spacebar recording feature
1 parent 5e4aebf commit 5e8c8a6

18 files changed

Lines changed: 172 additions & 3 deletions

File tree

apps/editor/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,10 @@
809809
"type": "string",
810810
"scope": "resource"
811811
},
812+
"codeWebChat.voiceInputPushToTalk": {
813+
"type": "boolean",
814+
"scope": "resource"
815+
},
812816
"codeWebChat.extendedCacheDurationForAnthropic": {
813817
"type": "boolean",
814818
"scope": "resource"

apps/editor/src/views/panel/backend/panel-provider.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,15 @@ export class PanelProvider implements vscode.WebviewViewProvider {
328328
})
329329
}
330330

331+
private _send_voice_input_push_to_talk() {
332+
const config = vscode.workspace.getConfiguration('codeWebChat')
333+
const enabled = config.get<boolean>('voiceInputPushToTalk', false)
334+
this.send_message({
335+
command: 'VOICE_INPUT_PUSH_TO_TALK',
336+
enabled
337+
})
338+
}
339+
331340
public async send_setup_progress() {
332341
const providers_manager = new ModelProvidersManager(this.context)
333342
const [providers, configs] = await Promise.all([
@@ -492,6 +501,10 @@ export class PanelProvider implements vscode.WebviewViewProvider {
492501
if (event.affectsConfiguration('codeWebChat.sendWithShiftEnter')) {
493502
this._send_send_with_shift_enter()
494503
}
504+
505+
if (event.affectsConfiguration('codeWebChat.voiceInputPushToTalk')) {
506+
this._send_voice_input_push_to_talk()
507+
}
495508
}
496509
)
497510

@@ -1002,6 +1015,8 @@ export class PanelProvider implements vscode.WebviewViewProvider {
10021015
this,
10031016
message.shrink_source_code
10041017
)
1018+
} else if (message.command == 'GET_VOICE_INPUT_PUSH_TO_TALK') {
1019+
this._send_voice_input_push_to_talk()
10051020
}
10061021
} catch (error: any) {
10071022
Logger.error({

apps/editor/src/views/panel/frontend/Main/Main.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ type Props = {
8080
on_new_tab: () => void
8181
on_tab_delete: (index: number) => void
8282
missing_preset?: boolean
83+
voice_input_push_to_talk: boolean
8384
}
8485

8586
export const Main: React.FC<Props> = (props) => {
@@ -855,6 +856,7 @@ export const Main: React.FC<Props> = (props) => {
855856
on_tab_change={props.on_tab_change}
856857
on_new_tab={props.on_new_tab}
857858
on_tab_delete={props.on_tab_delete}
859+
voice_input_push_to_talk={props.voice_input_push_to_talk}
858860
/>
859861
)
860862
}

apps/editor/src/views/panel/frontend/Main/MainView/MainView.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ type Props = {
125125
on_tab_change: (index: number) => void
126126
on_new_tab: () => void
127127
on_tab_delete: (index: number) => void
128+
voice_input_push_to_talk: boolean
128129
}
129130

130131
export const MainView: React.FC<Props> = (props) => {
@@ -319,6 +320,7 @@ export const MainView: React.FC<Props> = (props) => {
319320
props.mode == MODE.API && props.configurations.length == 0
320321
}
321322
missing_preset={props.mode == MODE.WEB && props.presets.length == 0}
323+
voice_input_push_to_talk={props.voice_input_push_to_talk}
322324
/>
323325
<UiContextUtilisation
324326
current_context_size={props.token_count}

apps/editor/src/views/panel/frontend/Panel.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ export const Panel = () => {
8282
is_setup_complete,
8383
handle_tab_change,
8484
handle_new_tab,
85-
handle_tab_delete
85+
handle_tab_delete,
86+
voice_input_push_to_talk
8687
} = use_panel(vscode)
8788

8889
const {
@@ -432,6 +433,7 @@ export const Panel = () => {
432433
on_tab_change={handle_tab_change}
433434
on_new_tab={handle_new_tab}
434435
on_tab_delete={handle_tab_delete}
436+
voice_input_push_to_talk={voice_input_push_to_talk}
435437
/>
436438
</div>
437439
<div

apps/editor/src/views/panel/frontend/hooks/panel/use-panel.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ export const use_panel = (vscode: any) => {
5454
find_relevant_files_shrink_source_code,
5555
set_find_relevant_files_shrink_source_code
5656
] = useState<boolean>(false)
57+
const [voice_input_push_to_talk, set_voice_input_push_to_talk] =
58+
useState(false)
5759

5860
const handle_task_forward = (text: string) => {
5961
handle_instructions_change(text, 'edit-context')
@@ -152,6 +154,8 @@ export const use_panel = (vscode: any) => {
152154
set_find_relevant_files_shrink_source_code(message.shrink_source_code)
153155
} else if (message.command == 'RETURN_HOME') {
154156
set_active_view('home')
157+
} else if (message.command == 'VOICE_INPUT_PUSH_TO_TALK') {
158+
set_voice_input_push_to_talk(message.enabled)
155159
}
156160
}
157161
window.addEventListener('message', handle_message)
@@ -168,7 +172,8 @@ export const use_panel = (vscode: any) => {
168172
{ command: 'GET_CHECKPOINTS' },
169173
{ command: 'REQUEST_CAN_UNDO' },
170174
{ command: 'GET_SETUP_PROGRESS' },
171-
{ command: 'GET_FIND_RELEVANT_FILES_SHRINK_SOURCE_CODE' }
175+
{ command: 'GET_FIND_RELEVANT_FILES_SHRINK_SOURCE_CODE' },
176+
{ command: 'GET_VOICE_INPUT_PUSH_TO_TALK' }
172177
]
173178
initial_messages.forEach((message) => post_message(vscode, message))
174179

@@ -296,6 +301,7 @@ export const use_panel = (vscode: any) => {
296301
handle_find_relevant_files_shrink_source_code_change,
297302
handle_tab_change,
298303
handle_new_tab,
299-
handle_tab_delete
304+
handle_tab_delete,
305+
voice_input_push_to_talk
300306
}
301307
}

apps/editor/src/views/panel/types/messages.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,10 @@ export interface InsertSymbolAtCursorMessage extends BaseMessage {
561561
target: 'preset-prefix' | 'preset-suffix'
562562
}
563563

564+
export interface GetVoiceInputPushToTalkMessage extends BaseMessage {
565+
command: 'GET_VOICE_INPUT_PUSH_TO_TALK'
566+
}
567+
564568
export type FrontendMessage =
565569
| GetInstructionsMessage
566570
| SaveInstructionsMessage
@@ -654,6 +658,7 @@ export type FrontendMessage =
654658
| SaveFindRelevantFilesShrinkSourceCodeMessage
655659
| GetSetupProgressMessage
656660
| RequestReturnHomeMessage
661+
| GetVoiceInputPushToTalkMessage
657662

658663
// === FROM BACKEND TO FRONTEND ===
659664
export interface InstructionsMessage extends BaseMessage {
@@ -917,6 +922,11 @@ export interface ReturnHomeMessage extends BaseMessage {
917922
command: 'RETURN_HOME'
918923
}
919924

925+
export interface VoiceInputPushToTalkMessage extends BaseMessage {
926+
command: 'VOICE_INPUT_PUSH_TO_TALK'
927+
enabled: boolean
928+
}
929+
920930
export type BackendMessage =
921931
| InstructionsMessage
922932
| FocusPromptFieldMessage
@@ -967,3 +977,4 @@ export type BackendMessage =
967977
| SetupProgressMessage
968978
| InsertSymbolAtCursorMessage
969979
| ReturnHomeMessage
980+
| VoiceInputPushToTalkMessage
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as vscode from 'vscode'
2+
import { SettingsProvider } from '@/views/settings/backend/settings-provider'
3+
4+
export const handle_get_voice_input_push_to_talk = async (
5+
provider: SettingsProvider
6+
): Promise<void> => {
7+
const config = vscode.workspace.getConfiguration('codeWebChat')
8+
const enabled = config.get<boolean>('voiceInputPushToTalk', false)
9+
provider.postMessage({
10+
command: 'VOICE_INPUT_PUSH_TO_TALK',
11+
enabled
12+
})
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import * as vscode from 'vscode'
2+
import { UpdateVoiceInputPushToTalkMessage } from '@/views/settings/types/messages'
3+
4+
export const handle_update_voice_input_push_to_talk = async (
5+
message: UpdateVoiceInputPushToTalkMessage
6+
): Promise<void> => {
7+
await vscode.workspace
8+
.getConfiguration('codeWebChat')
9+
.update(
10+
'voiceInputPushToTalk',
11+
message.enabled || undefined,
12+
vscode.ConfigurationTarget.Global
13+
)
14+
}

apps/editor/src/views/settings/backend/message-handlers/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export * from './handle-update-commit-message-instructions'
1414
export * from './handle-get-include-prompts-in-commit-messages'
1515
export * from './handle-update-include-prompts-in-commit-messages'
1616
export * from './handle-get-voice-input-instructions'
17+
export * from './handle-get-voice-input-push-to-talk'
18+
export * from './handle-update-voice-input-push-to-talk'
1719
export * from './handle-update-voice-input-instructions'
1820
export * from './handle-get-clear-checks-in-workspace-behavior'
1921
export * from './handle-update-clear-checks-in-workspace-behavior'

0 commit comments

Comments
 (0)