Skip to content

Commit 685f72f

Browse files
committed
Transition API tool and provider settings to a native VS Code Quick Pick interface
1 parent 9a06649 commit 685f72f

21 files changed

Lines changed: 116 additions & 323 deletions

File tree

packages/ui/src/components/editor/Dropdown/Dropdown.module.scss

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
.button {
66
display: flex;
77
align-items: center;
8-
justify-content: space-between;
9-
padding: 0 var(--padding-4px) 0 var(--padding-5px);
10-
height: 22px;
8+
gap: var(--padding-2px);
9+
padding: 0 var(--padding-5px) 0 var(--padding-8px);
10+
height: 24px;
1111
border: 1px solid var(--vscode-dropdown-border);
1212
border-radius: var(--border-radius-2px);
1313
cursor: pointer;
@@ -24,7 +24,7 @@
2424
white-space: nowrap;
2525
flex-grow: 1;
2626
text-align: left;
27-
font-size: var(--font-size-12px);
27+
font-size: var(--font-size-13px);
2828
}
2929

3030
&__icon {
@@ -47,10 +47,10 @@
4747
&__item {
4848
display: flex;
4949
align-items: center;
50-
height: 22px;
51-
padding: 0 var(--padding-5px);
50+
height: 24px;
51+
padding: 0 var(--padding-8px);
5252
color: var(--vscode-menu-foreground);
53-
font-size: var(--font-size-12px);
53+
font-size: var(--font-size-13px);
5454
cursor: pointer;
5555
margin: 1px;
5656
white-space: nowrap;

packages/ui/src/components/editor/Switch/Switch.module.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
align-items: center;
1414
position: relative;
1515
padding: 0 var(--padding-8px);
16-
height: 22px;
16+
height: 24px;
1717
cursor: pointer;
18-
font-size: var(--font-size-12px);
18+
font-size: var(--font-size-13px);
1919
border-radius: var(--border-radius-999px);
2020
white-space: nowrap;
2121
color: var(--vscode-foreground);

packages/vscode/package.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,10 @@
310310
"category": "Code Web Chat"
311311
},
312312
{
313-
"command": "codeWebChat.openSettings",
314-
"title": "Open Settings",
313+
"command": "codeWebChat.settings",
314+
"title": "Settings",
315315
"category": "Code Web Chat",
316-
"icon": "$(settings)"
316+
"icon": "$(settings-gear)"
317317
},
318318
{
319319
"command": "codeWebChat.openRepository",
@@ -426,10 +426,6 @@
426426
"command": "codeWebChat.referenceInChat",
427427
"when": "false"
428428
},
429-
{
430-
"command": "codeWebChat.openSettings",
431-
"when": "false"
432-
},
433429
{
434430
"command": "codeWebChat.openRepository",
435431
"when": "false"
@@ -520,7 +516,7 @@
520516
"group": "navigation@4"
521517
},
522518
{
523-
"command": "codeWebChat.openSettings",
519+
"command": "codeWebChat.settings",
524520
"when": "view == codeWebChatView",
525521
"group": "navigation@7"
526522
}

packages/vscode/src/commands/open-settings-command.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/vscode/src/view/backend/message-handlers/handle-open-settings/configure-api-providers.ts renamed to packages/vscode/src/commands/open-settings-command/configure-api-providers.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as vscode from 'vscode'
2-
import { ViewProvider } from '@/view/backend/view-provider'
32
import {
43
ApiProvidersManager,
54
BuiltInProvider,
@@ -13,9 +12,9 @@ const normalize_base_url = (url: string): string => {
1312
}
1413

1514
export const configure_api_providers = async (
16-
provider: ViewProvider
15+
context: vscode.ExtensionContext
1716
): Promise<void> => {
18-
const providers_manager = new ApiProvidersManager(provider.context)
17+
const providers_manager = new ApiProvidersManager(context)
1918

2019
const back_label = '$(arrow-left) Back'
2120

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './open-settings-command'
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import * as vscode from 'vscode'
2+
import { configure_api_providers } from './configure-api-providers'
3+
import { setup_api_tool_multi_config } from './setup-api-tool-multi-config'
4+
import { setup_api_tool } from './setup-api-tool'
5+
6+
const LABEL_API_PROVIDERS = 'My API Providers'
7+
const LABEL_CODE_COMPLETIONS = 'API tool: Code Completions'
8+
const LABEL_EDIT_CONTEXT = 'API tool: Edit Context'
9+
const LABEL_INTELLIGENT_UPDATE = 'API tool: Intelligent Update'
10+
const LABEL_COMMIT_MESSAGES = 'API tool: Commit Messages'
11+
12+
export const open_settings_command = (context: vscode.ExtensionContext) => {
13+
return vscode.commands.registerCommand(
14+
'codeWebChat.settings',
15+
async () => {
16+
let show_menu = true
17+
while (show_menu) {
18+
const selected = await vscode.window.showQuickPick(
19+
[
20+
{
21+
label: LABEL_API_PROVIDERS,
22+
description:
23+
'API keys are stored encrypted and never leave your device'
24+
},
25+
{
26+
label: LABEL_CODE_COMPLETIONS,
27+
description:
28+
'Get code at cursor from state-of-the-art reasoning models'
29+
},
30+
{
31+
label: LABEL_EDIT_CONTEXT,
32+
description:
33+
'Create and modify files based on natural language instructions'
34+
},
35+
{
36+
label: LABEL_INTELLIGENT_UPDATE,
37+
description:
38+
'Handle "truncated" edit format and fix malformed diffs'
39+
},
40+
{
41+
label: LABEL_COMMIT_MESSAGES,
42+
description:
43+
'Generate meaningful commit messages adhering to your style'
44+
}
45+
],
46+
{
47+
title: 'Settings',
48+
placeHolder: 'Select option'
49+
}
50+
)
51+
52+
if (!selected) {
53+
show_menu = false
54+
continue
55+
}
56+
57+
switch (selected.label) {
58+
case LABEL_API_PROVIDERS:
59+
await configure_api_providers(context)
60+
break
61+
case LABEL_CODE_COMPLETIONS:
62+
await setup_api_tool_multi_config({
63+
context,
64+
tool: 'code-completions'
65+
})
66+
break
67+
case LABEL_EDIT_CONTEXT:
68+
await setup_api_tool_multi_config({
69+
context,
70+
tool: 'edit-context'
71+
})
72+
break
73+
case LABEL_INTELLIGENT_UPDATE:
74+
await setup_api_tool_multi_config({
75+
context,
76+
tool: 'intelligent-update'
77+
})
78+
break
79+
case LABEL_COMMIT_MESSAGES:
80+
await setup_api_tool({
81+
context,
82+
tool: 'commit-messages'
83+
})
84+
break
85+
}
86+
}
87+
}
88+
)
89+
}

packages/vscode/src/view/backend/message-handlers/handle-open-settings/setup-api-tool-multi-config.ts renamed to packages/vscode/src/commands/open-settings-command/setup-api-tool-multi-config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { ViewProvider } from '@/view/backend/view-provider'
21
import * as vscode from 'vscode'
32
import {
43
ApiProvidersManager,
@@ -29,10 +28,10 @@ interface ToolMethods {
2928
}
3029

3130
export const setup_api_tool_multi_config = async (params: {
32-
provider: ViewProvider
31+
context: vscode.ExtensionContext
3332
tool: SupportedTool
3433
}): Promise<void> => {
35-
const providers_manager = new ApiProvidersManager(params.provider.context)
34+
const providers_manager = new ApiProvidersManager(params.context)
3635
const model_fetcher = new ModelFetcher()
3736

3837
const back_label = '$(arrow-left) Back'

packages/vscode/src/view/backend/message-handlers/handle-open-settings/setup-api-tool.ts renamed to packages/vscode/src/commands/open-settings-command/setup-api-tool.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { ViewProvider } from '@/view/backend/view-provider'
21
import * as vscode from 'vscode'
32
import {
43
ApiProvidersManager,
@@ -21,10 +20,10 @@ const DEFAULT_CONFIRMATION_THRESHOLD = 20000
2120
const BACK_LABEL = '$(arrow-left) Back'
2221

2322
export const setup_api_tool = async (params: {
24-
provider: ViewProvider
23+
context: vscode.ExtensionContext
2524
tool: SupportedTool
2625
}): Promise<void> => {
27-
const providers_manager = new ApiProvidersManager(params.provider.context)
26+
const providers_manager = new ApiProvidersManager(params.context)
2827
const model_fetcher = new ModelFetcher()
2928

3029
const current_config =
@@ -53,7 +52,7 @@ export const setup_api_tool = async (params: {
5352
await providers_manager.save_commit_messages_tool_config(config)
5453

5554
if (params.tool == 'commit-messages') {
56-
await params.provider.context.globalState.update(
55+
await params.context.globalState.update(
5756
COMMIT_MESSAGES_CONFIRMATION_THRESHOLD_STATE_KEY,
5857
DEFAULT_CONFIRMATION_THRESHOLD
5958
)
@@ -73,7 +72,7 @@ export const setup_api_tool = async (params: {
7372

7473
let showMenu = true
7574
while (showMenu) {
76-
const current_threshold = params.provider.context.globalState.get<number>(
75+
const current_threshold = params.context.globalState.get<number>(
7776
COMMIT_MESSAGES_CONFIRMATION_THRESHOLD_STATE_KEY,
7877
DEFAULT_CONFIRMATION_THRESHOLD
7978
)
@@ -176,7 +175,7 @@ export const setup_api_tool = async (params: {
176175
current_threshold
177176
)
178177
if (new_threshold !== undefined) {
179-
await params.provider.context.globalState.update(
178+
await params.context.globalState.update(
180179
COMMIT_MESSAGES_CONFIRMATION_THRESHOLD_STATE_KEY,
181180
new_threshold
182181
)

packages/vscode/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export async function activate(context: vscode.ExtensionContext) {
170170
command: 'codeWebChat.rateExtension',
171171
url: 'https://marketplace.visualstudio.com/items?itemName=robertpiosik.gemini-coder&ssr=false#review-details'
172172
}),
173-
open_settings_command(),
173+
open_settings_command(context),
174174
apply_context_from_clipboard_command(workspace_provider)
175175
)
176176
}

0 commit comments

Comments
 (0)