Skip to content

Commit 93068bb

Browse files
committed
Move default system instructions resolution to WebSocket manager
- if chatbot supports system instructions, should send default system instructions as fallback ├── apps │ └── editor │ ├── package.json │ └── src │ └── services │ └── websocket-manager.ts └── packages └── shared └── src └── constants └── chatbots.ts
1 parent 7356765 commit 93068bb

5 files changed

Lines changed: 17 additions & 17 deletions

File tree

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { CHATBOTS } from '@shared/constants/chatbots'
55
import { show_response_ready_notification } from '../utils/show-response-ready-notification'
66
import { add_apply_response_button } from '../utils/add-apply-response-button'
77
import { report_initialization_error } from '../utils/report-initialization-error'
8-
import { default_system_instructions } from '@shared/constants/default-system-instructions'
98

109
export const ai_studio: Chatbot = {
1110
wait_until_ready: async () => {
@@ -33,8 +32,7 @@ export const ai_studio: Chatbot = {
3332
})
3433
},
3534
enter_system_instructions: async (chat) => {
36-
const system_instructions =
37-
chat.system_instructions || default_system_instructions
35+
if (!chat.system_instructions) return
3836
await open_panel()
3937
const system_instructions_button = document.querySelector(
4038
'button[data-test-system-instructions-card]'
@@ -81,7 +79,7 @@ export const ai_studio: Chatbot = {
8179
return
8280
}
8381

84-
textarea.value = system_instructions
82+
textarea.value = chat.system_instructions
8583
textarea.dispatchEvent(new Event('input', { bubbles: true }))
8684

8785
close_button.click()

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { default_system_instructions } from '@shared/constants/default-system-instructions'
21
import { Chatbot } from '../types/chatbot'
32
import {
43
add_apply_response_button,
@@ -24,9 +23,7 @@ export const open_webui: Chatbot = {
2423
await new Promise((resolve) => setTimeout(resolve, 500))
2524
},
2625
enter_system_instructions: async (chat) => {
27-
const system_instructions =
28-
chat.system_instructions || default_system_instructions
29-
if (!system_instructions) return
26+
if (!chat.system_instructions) return
3027
const controls_button = document.querySelector(
3128
'button[aria-label="Controls"]'
3229
) as HTMLButtonElement
@@ -60,7 +57,7 @@ export const open_webui: Chatbot = {
6057
})
6158
return
6259
}
63-
system_instructions_textarea.value = system_instructions
60+
system_instructions_textarea.value = chat.system_instructions
6461
system_instructions_textarea.dispatchEvent(
6562
new Event('input', { bubbles: true })
6663
)

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { default_system_instructions } from '@shared/constants/default-system-instructions'
21
import { Chatbot } from '../types/chatbot'
32
import {
43
add_apply_response_button,
@@ -72,9 +71,7 @@ export const openrouter: Chatbot = {
7271
await new Promise((resolve) => setTimeout(resolve, 500))
7372
},
7473
enter_system_instructions: async (chat) => {
75-
const system_instructions =
76-
chat.system_instructions || default_system_instructions
77-
if (!system_instructions) return
74+
if (!chat.system_instructions) return
7875
if (!(await show_options_modal('enter_system_instructions'))) return
7976
const textarea = document.querySelector(
8077
'div[role="dialog"] textarea'
@@ -120,7 +117,7 @@ export const openrouter: Chatbot = {
120117
window.HTMLTextAreaElement.prototype,
121118
'value'
122119
)?.set
123-
nativeTextAreaValueSetter?.call(active_textarea, system_instructions)
120+
nativeTextAreaValueSetter?.call(active_textarea, chat.system_instructions)
124121
active_textarea.dispatchEvent(new Event('input', { bubbles: true }))
125122
active_textarea.blur()
126123
await close_options_modal('enter_system_instructions')

‎apps/editor/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "gemini-coder",
33
"displayName": "Code Web Chat",
44
"description": "AI coding with static context (CWC)",
5-
"version": "2026.916.144",
5+
"version": "2026.916.145",
66
"scripts": {
77
"build": "npx vsce package --no-dependencies",
88
"vscode:prepublish": "rimraf out && npm run compile",

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,11 @@ export class WebSocketManager {
459459
model: web_configuration.model,
460460
target_browser_id,
461461
reasoning_effort: web_configuration.reasoningEffort,
462-
system_instructions: web_configuration.systemInstructions,
462+
system_instructions:
463+
web_configuration.systemInstructions ||
464+
(chatbot.supports_system_instructions
465+
? chatbot.default_system_instructions
466+
: undefined),
463467
options: web_configuration.options,
464468
client_id: this.client_id!,
465469
raw_instructions: params.raw_instructions,
@@ -561,7 +565,11 @@ export class WebSocketManager {
561565
model: params.web_configuration.model,
562566
target_browser_id,
563567
reasoning_effort: params.web_configuration.reasoning_effort,
564-
system_instructions: params.web_configuration.system_instructions,
568+
system_instructions:
569+
params.web_configuration.system_instructions ||
570+
(chatbot.supports_system_instructions
571+
? chatbot.default_system_instructions
572+
: undefined),
565573
options: params.web_configuration.options,
566574
client_id: this.client_id!,
567575
raw_instructions: params.raw_instructions,

0 commit comments

Comments
 (0)