Skip to content

Commit f1c5ac1

Browse files
committed
Add keyboard shortcut settings button and handler for opening VS Code keybindings
1 parent 9fb05c3 commit f1c5ac1

8 files changed

Lines changed: 49 additions & 4 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as vscode from 'vscode'
2+
import { OpenKeybindingsMessage } from '@/views/settings/types/messages'
3+
4+
export const handle_open_keybindings = async (
5+
message: OpenKeybindingsMessage
6+
): Promise<void> => {
7+
await vscode.commands.executeCommand(
8+
'workbench.action.openGlobalKeybindings',
9+
message.search
10+
)
11+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ export * from './handle-delete-configuration'
3636
export * from './handle-get-configurations'
3737
export * from './handle-get-fix-all-automatically'
3838
export * from './handle-update-fix-all-automatically'
39+
export * from './handle-open-keybindings'

‎apps/editor/src/views/settings/backend/settings-provider.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ import {
4141
handle_open_ignore_patterns_settings,
4242
handle_open_allow_patterns_settings,
4343
handle_get_fix_all_automatically,
44-
handle_update_fix_all_automatically
44+
handle_update_fix_all_automatically,
45+
handle_open_keybindings
4546
} from './message-handlers'
4647

4748
export class SettingsProvider {
@@ -293,6 +294,8 @@ export class SettingsProvider {
293294
await handle_get_fix_all_automatically(this)
294295
} else if (message.command == 'UPDATE_FIX_ALL_AUTOMATICALLY') {
295296
await handle_update_fix_all_automatically(message)
297+
} else if (message.command == 'OPEN_KEYBINDINGS') {
298+
await handle_open_keybindings(message)
296299
}
297300
},
298301
null,

‎apps/editor/src/views/settings/frontend/Home/Home.tsx‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { Input } from '@ui/components/editor/common/Input'
1111
import { Textarea } from '@ui/components/editor/common/Textarea'
1212
import { Toggler } from '@ui/components/editor/common/Toggler'
1313
import { Button } from '@ui/components/editor/common/Button'
14+
import { TextButton } from '@ui/components/editor/settings/TextButton'
1415
import {
1516
ConfigurationForClient,
1617
ProviderForClient,
@@ -115,6 +116,7 @@ type Props = {
115116
value: 'ignore-open-editors' | 'uncheck-all'
116117
) => void
117118
on_fix_all_automatically_change: (enabled: boolean) => void
119+
on_open_keybindings: (search?: string) => void
118120
on_open_editor_settings: () => void
119121
on_open_ignore_patterns_settings: () => void
120122
on_open_allow_patterns_settings: () => void
@@ -532,6 +534,19 @@ export const Home: React.FC<Props> = (props) => {
532534
props.on_unset_default_config('CODE_AT_CURSOR')
533535
}
534536
/>
537+
<Item
538+
title="Keyboard Shortcut"
539+
description="Setup tool triggering key combinations."
540+
slot_right={
541+
<TextButton
542+
on_click={() =>
543+
props.on_open_keybindings('codeWebChat.codeAtCursor')
544+
}
545+
>
546+
Open Keyboard Shortcuts
547+
</TextButton>
548+
}
549+
/>
535550
</Group>
536551
</Section>
537552
<Section

‎apps/editor/src/views/settings/frontend/Home/sections/GeneralSection.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
175175
description="Glob patterns that you don't want to place in .gitignore files."
176176
slot_right={
177177
<TextButton on_click={props.on_open_ignore_patterns_settings}>
178-
Open settings file
178+
Open Settings File
179179
</TextButton>
180180
}
181181
/>
@@ -184,7 +184,7 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
184184
description="Glob patterns that you want to include despite being ignored by .gitignore."
185185
slot_right={
186186
<TextButton on_click={props.on_open_allow_patterns_settings}>
187-
Open settings file
187+
Open Settings File
188188
</TextButton>
189189
}
190190
/>

‎apps/editor/src/views/settings/frontend/Settings.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ export const Settings = () => {
132132
on_fix_all_automatically_change={
133133
settings_hook.handle_fix_all_automatically_change
134134
}
135+
on_open_keybindings={settings_hook.handle_open_keybindings}
135136
on_open_editor_settings={settings_hook.handle_open_editor_settings}
136137
on_open_ignore_patterns_settings={
137138
settings_hook.handle_open_ignore_patterns_settings

‎apps/editor/src/views/settings/frontend/hooks/use-settings.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,13 @@ export const use_settings = (vscode: any) => {
423423
})
424424
}
425425

426+
const handle_open_keybindings = (search?: string) => {
427+
post_message(vscode, {
428+
command: 'OPEN_KEYBINDINGS',
429+
search
430+
})
431+
}
432+
426433
return {
427434
providers,
428435
set_providers,
@@ -475,6 +482,7 @@ export const use_settings = (vscode: any) => {
475482
handle_send_with_shift_enter_change,
476483
handle_check_new_files_change,
477484
handle_clear_checks_in_workspace_behavior_change,
478-
handle_fix_all_automatically_change
485+
handle_fix_all_automatically_change,
486+
handle_open_keybindings
479487
}
480488
}

‎apps/editor/src/views/settings/types/messages.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,11 @@ export interface UpdateFixAllAutomaticallyMessage {
285285
enabled: boolean
286286
}
287287

288+
export interface OpenKeybindingsMessage {
289+
command: 'OPEN_KEYBINDINGS'
290+
search?: string
291+
}
292+
288293
export type FrontendMessage =
289294
| GetModelProvidersMessage
290295
| ReorderModelProvidersMessage
@@ -341,6 +346,7 @@ export type FrontendMessage =
341346
| OpenAllowPatternsSettingsMessage
342347
| GetFixAllAutomaticallyMessage
343348
| UpdateFixAllAutomaticallyMessage
349+
| OpenKeybindingsMessage
344350

345351
// === FROM BACKEND TO FRONTEND ===
346352
export interface ModelProvidersMessage {

0 commit comments

Comments
 (0)