Skip to content

Commit 7391906

Browse files
committed
Refactor generate commit message arguments and update provider detection to use base URLs
- [Fragment] should accept params variable, don't destructure in body - to determine provider in `apps/editor/src/utils/apply-reasoning-effort.ts`, use base url, not name. Compare precisely
1 parent 04bbccb commit 7391906

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

‎apps/editor/src/commands/generate-commit-message-command/generate-commit-message-command.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@ export const generate_commit_message_command = (
3838
return { repository, was_empty_stage, message_prompt, is_single_change }
3939
}
4040

41-
const run_generate_action = async (
42-
source_control: vscode.SourceControl | undefined,
41+
const run_generate_action = async (params: {
4342
should_commit: boolean
44-
) => {
43+
source_control?: vscode.SourceControl
44+
}) => {
4545
let files_staged_by_action = false
4646
let is_single_change_flow = false
4747
const api_providers_manager = new ModelProvidersManager(context)
4848
let force_quick_pick = false
4949
const selection_state: { files?: string[] } = {}
5050

5151
while (true) {
52-
const data = await get_prompt_data(source_control, selection_state)
52+
const data = await get_prompt_data(params.source_control, selection_state)
5353
if (!data) return
5454
const { repository, message_prompt, is_single_change } = data
5555
let { was_empty_stage } = data
@@ -69,7 +69,7 @@ export const generate_commit_message_command = (
6969
const has_default_config = !!default_config
7070

7171
const show_back_button =
72-
was_empty_stage && !is_single_change_flow && !source_control
72+
was_empty_stage && !is_single_change_flow && !params.source_control
7373

7474
const api_config_data = await get_commit_message_config(
7575
context,
@@ -134,7 +134,7 @@ export const generate_commit_message_command = (
134134
p.files.some((file) => staged_files.includes(file))
135135
)
136136

137-
if (should_commit) {
137+
if (params.should_commit) {
138138
const edited_message = await new Promise<string | 'back' | undefined>(
139139
(resolve) => {
140140
const input_box = vscode.window.createInputBox()
@@ -276,14 +276,14 @@ export const generate_commit_message_command = (
276276
const generate_command = vscode.commands.registerCommand(
277277
'codeWebChat.generateCommitMessage',
278278
async (source_control?: vscode.SourceControl) => {
279-
await run_generate_action(source_control, false)
279+
await run_generate_action({ source_control, should_commit: false })
280280
}
281281
)
282282

283283
const generate_and_commit_command = vscode.commands.registerCommand(
284284
'codeWebChat.generateCommitMessageAndCommit',
285285
async (source_control?: vscode.SourceControl) => {
286-
await run_generate_action(source_control, true)
286+
await run_generate_action({ source_control, should_commit: true })
287287
}
288288
)
289289

‎apps/editor/src/utils/apply-reasoning-effort.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@ export const apply_reasoning_effort = (params: {
55
provider: any
66
reasoning_effort?: ToolConfig['reasoning_effort']
77
}) => {
8-
if (params.provider.name == 'OpenRouter') {
8+
if (params.provider.base_url == 'https://openrouter.ai/api/v1') {
99
if (params.reasoning_effort) {
1010
if (params.reasoning_effort == 'none') {
1111
params.body.reasoning = { enabled: false }
1212
} else {
1313
params.body.reasoning = { effort: params.reasoning_effort }
1414
}
1515
}
16-
} else if (params.provider.name == 'Google') {
16+
} else if (
17+
params.provider.base_url ==
18+
'https://generativelanguage.googleapis.com/v1beta/openai'
19+
) {
1720
params.body.extra_body = {
1821
google: {
1922
thinking_config: {

0 commit comments

Comments
 (0)