Skip to content

Commit eeb9974

Browse files
committed
Refine Hugging Chat model selection logic by skipping selection if the model is already active, adding support for small screen navigation, and adjusting activation delays
1 parent 3ef6324 commit eeb9974

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

packages/browser/src/content-scripts/send-prompt-content-script/chatbots/hugging-chat.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ export const hugging_chat: Chatbot = {
2424
return
2525
}
2626

27+
if (model_picker_button.textContent.trim() == `Model: ${model}`) {
28+
return
29+
}
30+
2731
model_picker_button.click()
2832
await new Promise((r) => requestAnimationFrame(r))
2933

@@ -47,6 +51,21 @@ export const hugging_chat: Chatbot = {
4751
return
4852
}
4953

54+
if (window.innerWidth < 768) {
55+
const back_button = document
56+
.querySelector('path[d="M10 16L20 6l1.4 1.4l-8.6 8.6l8.6 8.6L20 26z"]')
57+
?.closest('button')
58+
if (back_button) {
59+
;(back_button as HTMLElement).click()
60+
await new Promise((resolve) => setTimeout(resolve, 100))
61+
} else {
62+
report_initialization_error({
63+
function_name: 'hugging_chat.set_model',
64+
log_message: 'Back button not found on small screen'
65+
})
66+
}
67+
}
68+
5069
const model_button = dialog.querySelector(
5170
`button[data-model-id="${model}"]`
5271
) as HTMLButtonElement
@@ -65,7 +84,7 @@ export const hugging_chat: Chatbot = {
6584
}
6685

6786
model_button.click()
68-
await new Promise((r) => requestAnimationFrame(r))
87+
await new Promise((resolve) => setTimeout(resolve, 250))
6988

7089
const activate_button = dialog.querySelector(
7190
'button[name="Activate model"]'
@@ -80,7 +99,7 @@ export const hugging_chat: Chatbot = {
8099
}
81100

82101
activate_button.click()
83-
await new Promise((resolve) => setTimeout(resolve, 500))
102+
await new Promise((resolve) => setTimeout(resolve, 250))
84103
},
85104
inject_apply_response_button: (
86105
client_id: number,

packages/browser/src/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"name": "Code Web Chat Connector",
55
"short_name": "CWC",
66
"description": "Connect your editor with free chatbots. Parse websites for context.",
7-
"version": "1.68.0",
7+
"version": "1.69.0",
88
"homepage_url": "https://github.com/robertpiosik/CodeWebChat",
99
"icons": {
1010
"16": "icons/icon-16.png",

0 commit comments

Comments
 (0)