Skip to content

Commit 7ff7e4e

Browse files
committed
Refactor preset URL handling by replacing url_path with new_url across the codebase and update ChatGPT's "Think longer" option to "Thinking" for consistency
1 parent 8339dbd commit 7ff7e4e

11 files changed

Lines changed: 87 additions & 68 deletions

File tree

‎packages/browser/src/content-scripts/send-prompt-content-script/chatbots/chatgpt.ts‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,19 @@ export const chatgpt: Chatbot = {
7272
} else {
7373
report_initialization_error({
7474
function_name: 'set_options',
75-
log_message: 'Temporary chat button not found',
76-
alert_message: InitializationError.UNABLE_TO_SET_OPTIONS
75+
log_message: 'Temporary chat button not found'
76+
// Don't show alert because temporary mode doesn't work in projects (url override)
7777
})
7878
}
79-
} else if (
80-
option == 'think-longer' &&
81-
supported_options['think-longer']
82-
) {
79+
} else if (option == 'thinking' && supported_options['thinking']) {
8380
const plus_button = document.querySelector(
8481
'button[data-testid="composer-plus-btn"]'
8582
) as HTMLButtonElement
8683
if (plus_button) {
8784
plus_button.dispatchEvent(
8885
new PointerEvent('pointerdown', { bubbles: true })
8986
)
90-
await new Promise((r) => requestAnimationFrame(r))
91-
87+
await new Promise((resolve) => setTimeout(resolve, 500))
9288
const menu_items = document.querySelectorAll(
9389
'div[role="menuitemradio"]'
9490
)

‎packages/browser/src/content-scripts/send-prompt-content-script/utils/report-initialization-error.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ export enum InitializationError {
2020
export const report_initialization_error = (params: {
2121
function_name: string
2222
log_message: string
23-
alert_message: InitializationError
23+
alert_message?: InitializationError
2424
}) => {
2525
Logger.error({
2626
function_name: params.function_name,
2727
message: params.log_message
2828
})
29-
alert(`${params.alert_message}. Please open an issue.`)
29+
if (params.alert_message) {
30+
alert(`${params.alert_message}. Please open an issue.`)
31+
}
3032
}

‎packages/shared/src/constants/chatbots.ts‎

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type Chatbots = {
88
supports_user_provided_port: boolean
99
supports_reasoning_effort: boolean
1010
supports_thinking_budget: boolean
11-
supports_custom_url_path: boolean
11+
supports_url_override: boolean
1212
default_system_instructions: string
1313
default_top_p: number
1414
supported_options: {
@@ -33,7 +33,7 @@ export const CHATBOTS = {
3333
supports_user_provided_port: false,
3434
supports_reasoning_effort: false,
3535
supports_thinking_budget: true,
36-
supports_custom_url_path: false,
36+
supports_url_override: false,
3737
default_system_instructions: "You're a helpful coding assistant.",
3838
default_top_p: 0.95,
3939
supported_options: {
@@ -71,11 +71,11 @@ export const CHATBOTS = {
7171
supports_user_provided_port: false,
7272
supports_reasoning_effort: false,
7373
supports_thinking_budget: false,
74-
supports_custom_url_path: true,
74+
supports_url_override: true,
7575
default_system_instructions: '',
7676
supported_options: {
7777
temporary: 'Temporary',
78-
'think-longer': 'Think longer (free plans)'
78+
thinking: 'Thinking (free plans)'
7979
},
8080
default_top_p: 0,
8181
models: {}
@@ -89,7 +89,7 @@ export const CHATBOTS = {
8989
supports_user_provided_port: false,
9090
supports_reasoning_effort: false,
9191
supports_thinking_budget: false,
92-
supports_custom_url_path: false,
92+
supports_url_override: false,
9393
default_system_instructions: '',
9494
supported_options: {
9595
'incognito-chat': 'Incognito chat'
@@ -110,7 +110,7 @@ export const CHATBOTS = {
110110
supports_user_provided_port: false,
111111
supports_reasoning_effort: false,
112112
supports_thinking_budget: false,
113-
supports_custom_url_path: false,
113+
supports_url_override: false,
114114
default_system_instructions: '',
115115
supported_options: {},
116116
default_top_p: 0,
@@ -131,7 +131,7 @@ export const CHATBOTS = {
131131
supports_user_provided_port: false,
132132
supports_reasoning_effort: false,
133133
supports_thinking_budget: false,
134-
supports_custom_url_path: false,
134+
supports_url_override: false,
135135
default_system_instructions: '',
136136
supported_options: { 'deep-think': 'DeepThink', search: 'Search' },
137137
default_top_p: 0,
@@ -146,7 +146,7 @@ export const CHATBOTS = {
146146
supports_user_provided_port: false,
147147
supports_reasoning_effort: false,
148148
supports_thinking_budget: false,
149-
supports_custom_url_path: false,
149+
supports_url_override: false,
150150
default_system_instructions: '',
151151
supported_options: { 'deep-thinking': 'Deep Thinking' },
152152
default_top_p: 0,
@@ -161,7 +161,7 @@ export const CHATBOTS = {
161161
supports_user_provided_port: false,
162162
supports_reasoning_effort: false,
163163
supports_thinking_budget: false,
164-
supports_custom_url_path: false,
164+
supports_url_override: false,
165165
supported_options: { 'temporary-chat': 'Temporary chat' },
166166
default_system_instructions: '',
167167
default_top_p: 0,
@@ -179,7 +179,7 @@ export const CHATBOTS = {
179179
supports_user_provided_port: false,
180180
supports_reasoning_effort: false,
181181
supports_thinking_budget: false,
182-
supports_custom_url_path: false,
182+
supports_url_override: false,
183183
default_system_instructions: '',
184184
supported_options: {},
185185
default_top_p: 0,
@@ -209,7 +209,7 @@ export const CHATBOTS = {
209209
supports_user_provided_port: false,
210210
supports_reasoning_effort: false,
211211
supports_thinking_budget: false,
212-
supports_custom_url_path: false,
212+
supports_url_override: false,
213213
default_system_instructions: '',
214214
supported_options: {},
215215
default_top_p: 0,
@@ -224,7 +224,7 @@ export const CHATBOTS = {
224224
supports_user_provided_port: false,
225225
supports_reasoning_effort: false,
226226
supports_thinking_budget: false,
227-
supports_custom_url_path: false,
227+
supports_url_override: false,
228228
default_system_instructions: '',
229229
supported_options: { private: 'Private' },
230230
default_top_p: 0,
@@ -245,7 +245,7 @@ export const CHATBOTS = {
245245
supports_user_provided_port: false,
246246
supports_reasoning_effort: false,
247247
supports_thinking_budget: false,
248-
supports_custom_url_path: false,
248+
supports_url_override: false,
249249
default_system_instructions: '',
250250
supported_options: {},
251251
default_top_p: 0,
@@ -260,7 +260,7 @@ export const CHATBOTS = {
260260
supports_user_provided_port: false,
261261
supports_reasoning_effort: false,
262262
supports_thinking_budget: false,
263-
supports_custom_url_path: false,
263+
supports_url_override: false,
264264
default_system_instructions: '',
265265
supported_options: {},
266266
default_top_p: 0,
@@ -275,7 +275,7 @@ export const CHATBOTS = {
275275
supports_user_provided_port: false,
276276
supports_reasoning_effort: false,
277277
supports_thinking_budget: false,
278-
supports_custom_url_path: false,
278+
supports_url_override: false,
279279
default_system_instructions: '',
280280
supported_options: {
281281
incognito: 'Incognito mode',
@@ -307,7 +307,7 @@ export const CHATBOTS = {
307307
supports_user_provided_port: true,
308308
supports_reasoning_effort: false,
309309
supports_thinking_budget: false,
310-
supports_custom_url_path: false,
310+
supports_url_override: false,
311311
default_system_instructions: "You're a helpful coding assistant.",
312312
supported_options: {},
313313
default_top_p: 0.9,
@@ -322,7 +322,7 @@ export const CHATBOTS = {
322322
supports_user_provided_port: false,
323323
supports_reasoning_effort: true,
324324
supports_thinking_budget: false,
325-
supports_custom_url_path: false,
325+
supports_url_override: false,
326326
default_system_instructions: "You're a helpful coding assistant.",
327327
supported_options: {
328328
'disable-reasoning': 'Disable reasoning (for hybrid models)'
@@ -339,7 +339,7 @@ export const CHATBOTS = {
339339
supports_user_provided_port: false,
340340
supports_reasoning_effort: false,
341341
supports_thinking_budget: false,
342-
supports_custom_url_path: true,
342+
supports_url_override: true,
343343
default_system_instructions: '',
344344
supported_options: {
345345
search: 'Search'
@@ -356,7 +356,7 @@ export const CHATBOTS = {
356356
supports_user_provided_port: false,
357357
supports_reasoning_effort: false,
358358
supports_thinking_budget: false,
359-
supports_custom_url_path: false,
359+
supports_url_override: false,
360360
default_system_instructions: '',
361361
supported_options: {
362362
thinking: 'Thinking',
@@ -384,7 +384,7 @@ export const CHATBOTS = {
384384
supports_user_provided_port: false,
385385
supports_reasoning_effort: false,
386386
supports_thinking_budget: false,
387-
supports_custom_url_path: false,
387+
supports_url_override: false,
388388
default_system_instructions: '',
389389
supported_options: {},
390390
default_top_p: 0,
@@ -408,7 +408,7 @@ export const CHATBOTS = {
408408
supports_user_provided_port: false,
409409
supports_reasoning_effort: false,
410410
supports_thinking_budget: false,
411-
supports_custom_url_path: false,
411+
supports_url_override: false,
412412
default_system_instructions: '',
413413
supported_options: { 'deep-think': 'DeepThink', search: 'Search' },
414414
default_top_p: 0,
@@ -426,7 +426,7 @@ export const CHATBOTS = {
426426
supports_user_provided_port: false,
427427
supports_reasoning_effort: false,
428428
supports_thinking_budget: false,
429-
supports_custom_url_path: false,
429+
supports_url_override: false,
430430
default_system_instructions: '',
431431
supported_options: {
432432
'deep-think': 'Deep Think'

‎packages/shared/src/constants/dictionary.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ export const dictionary = {
8181
TYPE_SOMETHING_TO_USE_GROUP: 'Type something to use this group.',
8282
GROUP_HAS_NO_SELECTED_PRESETS:
8383
'The chosen group has no selected presets to run.',
84+
URL_OVERRIDE_DIFFERENT_DOMAIN: (preset_name: string) =>
85+
`URL override for preset "${preset_name}" was discarded because it uses a different domain.`,
8486
CONTEXT_SIZE_WARNING: (threshold: string, percentage: number) =>
8587
`Context exceeds threshold of ${threshold} tokens by ${percentage}%. Unreasonably large context may degrade response quality, hurt plan's usage allowance or incur significant costs.`,
8688
FAILED_TO_CREATE_FILE: (file_path: string) =>

‎packages/shared/src/types/preset.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export type Preset = {
1313
system_instructions?: string
1414
options?: string[]
1515
port?: number
16-
url_path?: string
16+
new_url?: string
1717
is_selected?: boolean
1818
is_collapsed?: boolean
1919
}

‎packages/ui/src/components/editor/panel/ContextUtilisation/ContextUtilisation.tsx‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ export const ContextUtilisation: React.FC<Props> = (props) => {
3232
: formatted_current_size
3333

3434
let title_text = ''
35-
const context_text = is_above_threshold
36-
? `${display_current_size} tokens in context`
37-
: `${display_current_size}/${formatted_threshold} tokens in context`
3835

3936
if (!is_above_threshold) {
4037
const remaining_tokens =
@@ -43,9 +40,9 @@ export const ContextUtilisation: React.FC<Props> = (props) => {
4340
? props.current_context_size
4441
: Math.floor(props.current_context_size / 1000) * 1000)
4542
const formatted_remaining_tokens = format_tokens(remaining_tokens)
46-
title_text = `${formatted_remaining_tokens} tokens remaining until threshold warning`
43+
title_text = `${formatted_remaining_tokens} tokens remaining until threshold warning (change in settings)`
4744
} else {
48-
title_text = `Context size (${formatted_current_size}) exceeds threshold (${formatted_threshold})`
45+
title_text = `Context of size ${formatted_current_size} exceeds threshold ${formatted_threshold} by `
4946
}
5047

5148
return (
@@ -59,7 +56,7 @@ export const ContextUtilisation: React.FC<Props> = (props) => {
5956
/>
6057
</div>
6158
<span className={styles.label} title={title_text}>
62-
{context_text}
59+
{display_current_size} tokens in context
6360
</span>
6461
</div>
6562
)

‎packages/vscode/src/services/websocket-manager.ts‎

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,23 @@ export class WebSocketManager {
297297
}
298298
} else if (preset.chatbot == 'Gemini' && gemini_user_id) {
299299
url = `https://gemini.google.com/u/${gemini_user_id}/app`
300-
} else if (chatbot.supports_custom_url_path && preset.urlPath) {
301-
const base_url = new URL(chatbot.url)
302-
url = `${base_url.origin}${
303-
preset.urlPath.startsWith('/') ? preset.urlPath : `/${preset.urlPath}`
304-
}`
300+
} else if (chatbot.supports_url_override && preset.newUrl) {
301+
try {
302+
const original_domain = new URL(chatbot.url).hostname
303+
const new_domain = new URL(preset.newUrl).hostname
304+
if (original_domain == new_domain) {
305+
url = preset.newUrl
306+
} else {
307+
url = chatbot.url
308+
vscode.window.showWarningMessage(
309+
dictionary.warning_message.URL_OVERRIDE_DIFFERENT_DOMAIN(
310+
preset.name
311+
)
312+
)
313+
}
314+
} catch (error) {
315+
url = chatbot.url
316+
}
305317
} else {
306318
url = chatbot.url
307319
}
@@ -361,13 +373,23 @@ export class WebSocketManager {
361373
gemini_user_number !== null
362374
) {
363375
url = `https://gemini.google.com/u/${gemini_user_number}/app`
364-
} else if (chatbot.supports_custom_url_path && params.preset.url_path) {
365-
const base_url = new URL(chatbot.url)
366-
url = `${base_url.origin}${
367-
params.preset.url_path.startsWith('/')
368-
? params.preset.url_path
369-
: `/${params.preset.url_path}`
370-
}`
376+
} else if (chatbot.supports_url_override && params.preset.new_url) {
377+
try {
378+
const original_domain = new URL(chatbot.url).hostname
379+
const new_domain = new URL(params.preset.new_url).hostname
380+
if (original_domain == new_domain) {
381+
url = params.preset.new_url
382+
} else {
383+
url = chatbot.url
384+
vscode.window.showWarningMessage(
385+
dictionary.warning_message.URL_OVERRIDE_DIFFERENT_DOMAIN(
386+
params.preset.name
387+
)
388+
)
389+
}
390+
} catch (error) {
391+
url = chatbot.url
392+
}
371393
} else {
372394
url = chatbot.url
373395
}

‎packages/vscode/src/views/panel/backend/message-handlers/handle-preview-preset.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export const handle_preview_preset = async (
155155
system_instructions: message.preset.system_instructions,
156156
options: message.preset.options,
157157
port: message.preset.port,
158-
url_path: message.preset.url_path
158+
new_url: message.preset.new_url
159159
}
160160

161161
provider.websocket_server_instance.preview_preset({

‎packages/vscode/src/views/panel/backend/message-handlers/handle-update-preset.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const handle_update_preset = async (
5151
a.system_instructions == b.system_instructions &&
5252
JSON.stringify(a.options) == JSON.stringify(b.options) &&
5353
a.port == b.port &&
54-
a.url_path == b.url_path &&
54+
a.new_url == b.new_url &&
5555
a.is_selected == b.is_selected
5656
)
5757
}

‎packages/vscode/src/views/panel/backend/utils/preset-format-converters.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export type ConfigPresetFormat = {
1414
systemInstructions?: string
1515
options?: string[]
1616
port?: number
17-
urlPath?: string
17+
newUrl?: string
1818
isSelected?: boolean
1919
isCollapsed?: boolean
2020
}
@@ -35,7 +35,7 @@ export function config_preset_to_ui_format(
3535
system_instructions: config_preset.systemInstructions,
3636
options: config_preset.options,
3737
port: config_preset.port,
38-
url_path: config_preset.urlPath,
38+
new_url: config_preset.newUrl,
3939
is_selected: config_preset.isSelected,
4040
is_collapsed: config_preset.isCollapsed
4141
}
@@ -55,7 +55,7 @@ export function ui_preset_to_config_format(preset: Preset): ConfigPresetFormat {
5555
systemInstructions: preset.system_instructions,
5656
options: preset.options,
5757
port: preset.port,
58-
urlPath: preset.url_path,
58+
newUrl: preset.new_url,
5959
isSelected: preset.is_selected,
6060
isCollapsed: preset.is_collapsed
6161
}

0 commit comments

Comments
 (0)