Skip to content

Commit 017fd59

Browse files
committed
Add support for specifying a non-default Gemini user ID via the new setting and update Gemini URL matching
1 parent 7a7c102 commit 017fd59

4 files changed

Lines changed: 24 additions & 3 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const batch_id = hash.substring(hash_prefix_new.length + 1)
3434
const ai_studio_url = 'https://aistudio.google.com/prompts/new_chat'
3535
const is_ai_studio = current_url.startsWith(ai_studio_url)
3636

37-
const gemini_url = 'https://gemini.google.com/app'
37+
const gemini_url = 'https://gemini.google.com/'
3838
const is_gemini = current_url.startsWith(gemini_url)
3939

4040
const openrouter_url = 'https://openrouter.ai/chat'

‎packages/browser/src/manifest.json‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"author": "Robert Piosik",
44
"name": "Code Web Chat Connector",
55
"short_name": "CWC",
6-
"description": "Connect your editor with free chatbots. Include websites in context.",
7-
"version": "1.48.0",
6+
"description": "Connect your editor with free chatbots. Parse websites for context.",
7+
"version": "1.49.0",
88
"homepage_url": "https://github.com/robertpiosik/CodeWebChat",
99
"icons": {
1010
"16": "icons/icon-16.png",
@@ -26,6 +26,7 @@
2626
"matches": [
2727
"https://aistudio.google.com/prompts/new_chat",
2828
"https://gemini.google.com/app",
29+
"https://gemini.google.com/u/*/app",
2930
"https://openrouter.ai/chat*",
3031
"https://chatgpt.com/",
3132
"https://claude.ai/new",

‎packages/vscode/package.json‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,14 @@
494494
"type": "object",
495495
"title": "Code Web Chat Settings",
496496
"properties": {
497+
"codeWebChat.geminiUserId": {
498+
"type": [
499+
"integer",
500+
"null"
501+
],
502+
"default": null,
503+
"description": "Run Gemini chatbot as non-default user. Check URL for ID, e.g. gemini.google.com/u/2/app -> 2."
504+
},
497505
"codeWebChat.commitMessageInstructions": {
498506
"type": "string",
499507
"scope": "resource",

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ export class WebSocketManager {
275275

276276
const config = vscode.workspace.getConfiguration('codeWebChat')
277277
const web_chat_presets = config.get<any[]>(params.presets_config_key) ?? []
278+
const gemini_user_id = config.get<number | null>('geminiUserId')
278279

279280
for (const chat of params.chats) {
280281
const preset = web_chat_presets.find((p) => p.name == chat.preset_name)
@@ -290,6 +291,8 @@ export class WebSocketManager {
290291
} else {
291292
url = 'http://openwebui/'
292293
}
294+
} else if (preset.chatbot == 'Gemini' && gemini_user_id) {
295+
url = `https://gemini.google.com/u/${gemini_user_id}/app`
293296
} else {
294297
url = chatbot.url
295298
}
@@ -329,6 +332,9 @@ export class WebSocketManager {
329332
throw new Error('Does not have connected browsers.')
330333
}
331334

335+
const config = vscode.workspace.getConfiguration('codeWebChat')
336+
const geminiUserNumber = config.get<number | null>('geminiUserNumber')
337+
332338
const chatbot = CHATBOTS[preset.chatbot as keyof typeof CHATBOTS]
333339
let url: string
334340
if (preset.chatbot == 'Open WebUI') {
@@ -337,6 +343,12 @@ export class WebSocketManager {
337343
} else {
338344
url = 'http://openwebui/'
339345
}
346+
} else if (
347+
preset.chatbot == 'Gemini' &&
348+
geminiUserNumber !== undefined &&
349+
geminiUserNumber !== null
350+
) {
351+
url = `https://gemini.google.com/u/${geminiUserNumber}/app`
340352
} else {
341353
url = chatbot.url
342354
}

0 commit comments

Comments
 (0)