Skip to content

Commit 0317820

Browse files
committed
Remove mandatory API key checks before making requests and remove unused scroll key logic in the frontend
1 parent 6cbe055 commit 0317820

6 files changed

Lines changed: 16 additions & 55 deletions

File tree

‎packages/vscode/src/commands/code-completion-commands.ts‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,6 @@ const perform_code_completion = async (params: {
307307
endpoint_url = provider.base_url
308308
}
309309

310-
if (!provider.api_key) {
311-
vscode.window.showErrorMessage(dictionary.error_message.API_KEY_MISSING)
312-
return
313-
}
314-
315310
const editor = vscode.window.activeTextEditor
316311
if (editor) {
317312
if (!editor.selection.isEmpty) {
@@ -484,14 +479,12 @@ const perform_code_completion = async (params: {
484479
}
485480
}
486481

487-
export const code_completion_commands = (
488-
params: {
489-
file_tree_provider: any
490-
open_editors_provider: any
491-
context: vscode.ExtensionContext
492-
panel_provider: PanelProvider
493-
}
494-
) => {
482+
export const code_completion_commands = (params: {
483+
file_tree_provider: any
484+
open_editors_provider: any
485+
context: vscode.ExtensionContext
486+
panel_provider: PanelProvider
487+
}) => {
495488
return [
496489
vscode.commands.registerCommand('codeWebChat.codeCompletion', async () =>
497490
perform_code_completion({

‎packages/vscode/src/utils/make-api-request.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const process_stream_chunk = async (
6161

6262
export const make_api_request = async (params: {
6363
endpoint_url: string
64-
api_key: string
64+
api_key?: string
6565
body: any
6666
cancellation_token: any
6767
on_chunk?: StreamCallback
@@ -241,7 +241,9 @@ export const make_api_request = async (params: {
241241
request_body,
242242
{
243243
headers: {
244-
['Authorization']: `Bearer ${params.api_key}`,
244+
...(params.api_key
245+
? { ['Authorization']: `Bearer ${params.api_key}` }
246+
: {}),
245247
['Content-Type']: 'application/json',
246248
...(params.endpoint_url == 'https://openrouter.ai/api/v1'
247249
? {

‎packages/vscode/src/views/panel/backend/message-handlers/handle-code-completion.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,6 @@ const perform_code_completion = async (params: {
289289
endpoint_url = provider.base_url
290290
}
291291

292-
if (!provider.api_key) {
293-
vscode.window.showErrorMessage(dictionary.error_message.API_KEY_MISSING)
294-
return
295-
}
296-
297292
const editor = vscode.window.activeTextEditor
298293
if (editor) {
299294
if (!editor.selection.isEmpty) {

‎packages/vscode/src/views/panel/backend/message-handlers/handle-commit-changes/utils/get-commit-message-config.ts‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,6 @@ export const get_commit_message_config = async (
179179
return null
180180
}
181181

182-
if (!provider.api_key) {
183-
vscode.window.showErrorMessage(
184-
dictionary.error_message.API_KEY_MISSING_FOR_PROVIDER
185-
)
186-
return null
187-
}
188-
189182
let endpoint_url = ''
190183
if (provider.type == 'built-in') {
191184
const provider_info = PROVIDERS[provider.name]

‎packages/vscode/src/views/panel/backend/message-handlers/handle-edit-context.ts‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,6 @@ const perform_context_editing = async (params: {
310310

311311
const { provider, config: edit_context_config } = config_result
312312

313-
if (!provider.api_key) {
314-
vscode.window.showErrorMessage(dictionary.error_message.API_KEY_MISSING)
315-
should_show_quick_pick = true
316-
current_config_id = undefined
317-
continue
318-
}
319-
320313
let endpoint_url = ''
321314
if (provider.type == 'built-in') {
322315
const provider_info = PROVIDERS[provider.name as keyof typeof PROVIDERS]

‎packages/vscode/src/views/panel/frontend/Main/MainView/MainView.tsx‎

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ import { Preset } from '@shared/types/preset'
77
import { Responses as UiResponses } from '@ui/components/editor/panel/Responses'
88
import { ResponseHistoryItem } from '@shared/types/response-history-item'
99
import { EditFormat } from '@shared/types/edit-format'
10-
import {
11-
MODE,
12-
Mode
13-
} from '@/views/panel/types/home-view-type'
10+
import { MODE, Mode } from '@/views/panel/types/home-view-type'
1411
import { ApiPromptType, WebPromptType } from '@shared/types/prompt-types'
1512
import { Scrollable } from '@ui/components/editor/panel/Scrollable'
1613
import { BrowserExtensionMessage as UiBrowserExtensionMessage } from '@ui/components/editor/panel/BrowserExtensionMessage'
@@ -100,16 +97,12 @@ type Props = {
10097

10198
export const MainView: React.FC<Props> = (props) => {
10299
const is_in_code_completions_prompt_type =
103-
(props.mode == MODE.WEB &&
104-
props.web_prompt_type == 'code-completions') ||
105-
(props.mode == MODE.API &&
106-
props.api_prompt_type == 'code-completions')
100+
(props.mode == MODE.WEB && props.web_prompt_type == 'code-completions') ||
101+
(props.mode == MODE.API && props.api_prompt_type == 'code-completions')
107102

108103
const show_edit_format_selector =
109-
(props.mode == MODE.WEB &&
110-
props.web_prompt_type == 'edit-context') ||
111-
(props.mode == MODE.API &&
112-
props.api_prompt_type == 'edit-context')
104+
(props.mode == MODE.WEB && props.web_prompt_type == 'edit-context') ||
105+
(props.mode == MODE.API && props.api_prompt_type == 'edit-context')
113106

114107
const handle_input_change = (value: string) => {
115108
props.set_instructions(value)
@@ -147,14 +140,6 @@ export const MainView: React.FC<Props> = (props) => {
147140
configurations: props.configurations
148141
})
149142

150-
const scroll_to_top_key = `${props.scroll_reset_key}-${
151-
props.mode
152-
}-${
153-
props.mode == MODE.WEB
154-
? props.web_prompt_type
155-
: props.api_prompt_type
156-
}`
157-
158143
return (
159144
<>
160145
<Header
@@ -167,7 +152,7 @@ export const MainView: React.FC<Props> = (props) => {
167152
on_api_mode_change={props.on_api_mode_change}
168153
on_quick_action_click={props.on_quick_action_click}
169154
/>
170-
<Scrollable scroll_to_top_key={scroll_to_top_key}>
155+
<Scrollable>
171156
<UiSeparator height={4} />
172157

173158
{!props.is_connected && props.mode == MODE.WEB && (

0 commit comments

Comments
 (0)