Skip to content

Commit 7bd5a8b

Browse files
committed
Replace prompt type and commit message indicators with an explicit inject apply response button flag
- rename 'is for commit message' to 'inject apply response button', also set it to true when prompt type is 'edit files', 'find relevant files' or 'code at cursor' - don't send 'prompt type' to the browser, 'inject apply response button' is enough ├── apps │ ├── browser │ │ └── src │ │ ├── background │ │ │ └── message-handler.ts │ │ └── content-scripts │ │ └── send-prompt-content-script │ │ └── send-prompt-content-script.ts │ └── editor │ └── src │ ├── commands │ │ ├── code-at-cursor-command │ │ │ └── utils │ │ │ └── get-code-at-cursor-config.ts │ │ └── generate-commit-message-commands │ │ └── actions │ │ └── run-generate-action.ts │ ├── constants │ │ └── state-keys.ts │ ├── services │ │ └── websocket-manager.ts │ ├── utils │ │ └── changes-integration │ │ └── diff-processor │ │ └── test-cases │ │ └── generic-6 │ │ ├── diff.txt │ │ ├── expected.txt │ │ └── original.txt │ └── views │ └── prompt │ ├── backend │ │ ├── message-handlers │ │ │ ├── handle-autofill.ts │ │ │ ├── handle-copy-prompt.ts │ │ │ ├── handle-get-api-prompt-type.ts │ │ │ ├── handle-get-web-prompt-type.ts │ │ │ ├── handle-hash-sign-quick-pick │ │ │ │ └── handle-hash-sign-quick-pick.ts │ │ │ ├── handle-make-api-call.ts │ │ │ ├── handle-preview-web-configuration.ts │ │ │ ├── handle-prompt-template-quick-pick.ts │ │ │ ├── handle-save-api-prompt-type.ts │ │ │ ├── handle-save-history.ts │ │ │ ├── handle-save-instructions.ts │ │ │ ├── handle-save-web-prompt-type.ts │ │ │ ├── handle-update-api-configuration.ts │ │ │ ├── handle-update-last-used-web-configuration.ts │ │ │ └── handle-update-web-configuration.ts │ │ └── prompt-view-provider.ts │ ├── frontend │ │ ├── Main │ │ │ ├── Main.tsx │ │ │ └── MainView │ │ │ ├── MainView.tsx │ │ │ ├── components │ │ │ │ └── Header │ │ │ │ ├── Header.tsx │ │ │ │ └── hooks │ │ │ │ ├── use-alternate-prompt-type.ts │ │ │ │ └── use-keyboard-shortcuts.ts │ │ │ ├── hooks │ │ │ │ └── use-invocation-counts.ts │ │ │ └── prompt-type-labels.ts │ │ ├── Prompt.tsx │ │ └── hooks │ │ └── use-prompt │ │ ├── hooks │ │ │ └── use-instructions.ts │ │ └── use-prompt.ts │ └── types │ └── messages.ts └── packages ├── shared │ └── src │ └── types │ └── websocket-message.ts └── ui └── src └── components └── editor └── prompt └── prompts └── PromptField ├── PromptField.stories.tsx └── PromptField.tsx
1 parent 2b693b8 commit 7bd5a8b

7 files changed

Lines changed: 23 additions & 30 deletions

File tree

‎apps/browser/src/background/message-handler.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ const process_next_chat = async () => {
7878
},
7979
client_id: current_chat_message.client_id,
8080
raw_instructions: current_chat_message.raw_instructions,
81-
prompt_type: current_chat_message.prompt_type,
82-
is_for_commit_message: current_chat_message.is_for_commit_message
81+
inject_apply_response_button:
82+
current_chat_message.inject_apply_response_button
8383
}
8484
})
8585

‎apps/browser/src/content-scripts/send-prompt-content-script/send-prompt-content-script.ts‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,7 @@ const main = async () => {
188188
current_chat: Chat
189189
client_id: number
190190
raw_instructions?: string
191-
prompt_type?:
192-
| 'ask-about-files'
193-
| 'edit-files'
194-
| 'code-at-cursor'
195-
| 'find-relevant-files'
196-
| 'without-files'
197-
is_for_commit_message?: boolean
191+
inject_apply_response_button?: boolean
198192
}
199193

200194
if (!stored_data) {
@@ -225,11 +219,7 @@ const main = async () => {
225219
await browser.storage.local.remove(storage_key)
226220

227221
if (chatbot?.setup_observer) {
228-
const inject_button =
229-
stored_data.prompt_type == 'edit-files' ||
230-
stored_data.prompt_type == 'code-at-cursor' ||
231-
stored_data.prompt_type == 'find-relevant-files' ||
232-
!!stored_data.is_for_commit_message
222+
const inject_button = stored_data.inject_apply_response_button ?? false
233223

234224
sessionStorage.setItem(
235225
session_data_key,

‎apps/editor/src/commands/generate-commit-message-commands/actions/run-generate-action.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ export const run_generate_action = async (params: {
295295
text: chatbot_prompt,
296296
web_configuration_name: selected_web_configuration_name,
297297
invocation_count: 1,
298-
is_for_commit_message: true
298+
inject_apply_response_button: true
299299
})
300300
if (sent) {
301301
vscode.window.showInformationMessage(

‎apps/editor/src/services/websocket-manager.ts‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { WebConfiguration } from '@shared/types/web-configuration'
1818
import { ConfigWebConfigurationFormat } from '@/utils/web-configuration-format-converters'
1919
import { LAST_SELECTED_BROWSER_ID_STATE_KEY } from '@/constants/state-keys'
2020
import { ApplyResponseCommandArgs } from '@/commands/apply-response-command/response-processor'
21-
import { WebPromptType } from '@shared/types/prompt-types'
2221

2322
/**
2423
* Bridges the current workspace window and a WebSockets server
@@ -366,9 +365,8 @@ export class WebSocketManager {
366365
text: string
367366
web_configuration_name: string
368367
raw_instructions?: string
369-
prompt_type?: WebPromptType
370368
invocation_count: number
371-
is_for_commit_message?: boolean
369+
inject_apply_response_button?: boolean
372370
}): Promise<boolean> {
373371
if (!this.has_connected_browsers) {
374372
throw new Error('Does not have connected browsers.')
@@ -457,10 +455,9 @@ export class WebSocketManager {
457455
options: web_configuration.options,
458456
client_id: this.client_id || 0, // 0 is a temporary fallback and should be removed few weeks from 28.03.25
459457
raw_instructions: params.raw_instructions,
460-
prompt_type: params.prompt_type,
461458
reuse_last_tab,
462459
invocation_count: params.invocation_count,
463-
is_for_commit_message: params.is_for_commit_message
460+
inject_apply_response_button: params.inject_apply_response_button
464461
}
465462

466463
Logger.info({
@@ -478,7 +475,7 @@ export class WebSocketManager {
478475
instruction: string
479476
web_configuration: WebConfiguration
480477
raw_instructions: string
481-
prompt_type?: WebPromptType
478+
inject_apply_response_button?: boolean
482479
}): Promise<boolean> {
483480
if (!this.has_connected_browsers) {
484481
throw new Error('Does not have connected browsers.')
@@ -563,8 +560,8 @@ export class WebSocketManager {
563560
options: params.web_configuration.options,
564561
client_id: this.client_id || 0, // 0 is a temporary fallback and should be removed few weeks from 28.03.25
565562
raw_instructions: params.raw_instructions,
566-
prompt_type: params.prompt_type,
567-
reuse_last_tab
563+
reuse_last_tab,
564+
inject_apply_response_button: params.inject_apply_response_button
568565
}
569566

570567
Logger.info({

‎apps/editor/src/views/prompt/backend/message-handlers/handle-autofill.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ export const handle_autofill = async (params: {
132132
text,
133133
web_configuration_name: resolved_web_configuration_name,
134134
raw_instructions: processed_completion_instructions,
135-
prompt_type: params.prompt_view_provider.web_prompt_type,
136-
invocation_count: params.invocation_count
135+
invocation_count: params.invocation_count,
136+
inject_apply_response_button: true
137137
}
138138
)
139139
} else {
@@ -203,14 +203,18 @@ export const handle_autofill = async (params: {
203203
user_instructions
204204
})
205205

206+
const prompt_type = params.prompt_view_provider.web_prompt_type
207+
const inject_apply_response_button =
208+
prompt_type == 'edit-files' || prompt_type == 'find-relevant-files'
209+
206210
sent =
207211
await params.prompt_view_provider.websocket_server_instance.initialize_chat(
208212
{
209213
text,
210214
web_configuration_name: resolved_web_configuration_name,
211215
raw_instructions: current_instructions,
212-
prompt_type: params.prompt_view_provider.web_prompt_type,
213-
invocation_count: params.invocation_count
216+
invocation_count: params.invocation_count,
217+
inject_apply_response_button
214218
}
215219
)
216220
}

‎apps/editor/src/views/prompt/backend/message-handlers/handle-preview-web-configuration.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ export const handle_preview_web_configuration = async (
173173
{
174174
instruction: text_to_send,
175175
web_configuration: web_configuration_for_preview,
176-
prompt_type: prompt_view_provider.web_prompt_type,
176+
inject_apply_response_button:
177+
prompt_view_provider.web_prompt_type == 'edit-files' ||
178+
prompt_view_provider.web_prompt_type == 'code-at-cursor' ||
179+
prompt_view_provider.web_prompt_type == 'find-relevant-files',
177180
raw_instructions: current_instructions
178181
}
179182
)

‎packages/shared/src/types/websocket-message.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ export type InitializeChatMessage = {
2525
system_instructions?: string
2626
options?: string[]
2727
raw_instructions?: string
28-
prompt_type?: WebPromptType
2928
reuse_last_tab?: boolean
3029
invocation_count?: number
31-
is_for_commit_message?: boolean
30+
inject_apply_response_button?: boolean
3231
}
3332

3433
export type BrowserConnectionStatusMessage = {

0 commit comments

Comments
 (0)