Skip to content

Commit e5e41b3

Browse files
committed
Refactor chatbot button injection to use parameter objects and update README styling
1 parent 9023d38 commit e5e41b3

38 files changed

Lines changed: 162 additions & 212 deletions

File tree

‎README.md‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<picture>
44
<source srcset="https://github.com/robertpiosik/CodeWebChat/raw/HEAD/packages/shared/src/media/readme-heading-dark.svg" media="(prefers-color-scheme: dark)">
55
<source srcset="https://github.com/robertpiosik/CodeWebChat/raw/HEAD/packages/shared/src/media/readme-heading-light.svg" media="(prefers-color-scheme: light)">
6-
<img src="https://github.com/robertpiosik/CodeWebChat/raw/HEAD/packages/shared/src/media/logo-light.png" alt="Logo" width="680">
6+
<img alt="Logo" width="680" src="https://github.com/robertpiosik/CodeWebChat/raw/HEAD/packages/shared/src/media/readme-heading-light.svg">
77
</picture>
88
</a>
99
</p>
@@ -36,15 +36,17 @@ Code Web Chat is an open-source and privacy-first **AI coding toolkit for VS Cod
3636
3737
## 🌱 Sustainable AI coding
3838

39-
With its smart context files ordering, CWC is designed from the ground-up for [prompt caching](https://developers.openai.com/api/docs/guides/prompt-caching), across tasks!
39+
With its smart context files ordering, CWC is **designed from the ground-up for [prompt caching](https://developers.openai.com/api/docs/guides/prompt-caching)**, across tasks.
4040

41-
- When using chatbots, make the most of your usage allowances.
42-
- When calling APIs, reduce input token costs by up to 90%.
43-
- When using self-hosted models, reduce latency by up to 80%.
41+
**Why it matters?**
42+
43+
- When using chatbots, make the most of your usage allowances
44+
- When calling APIs, reduce input token costs by up to 90%
45+
- When using self-hosted models, reduce latency by up to 80%
4446

4547
## Enabling autofill
4648

47-
Got tired with copy and paste? Enable prompt autofill with a browser extension ([source code](https://github.com/robertpiosik/CodeWebChat/tree/dev/apps/browser)).
49+
Got tired with copy and paste? Enable prompt autofill with a browser extension! It's [open-source](https://github.com/robertpiosik/CodeWebChat/tree/dev/apps/browser).
4850

4951
- [Chrome Web Store](https://chromewebstore.google.com/detail/autofill-for-code-web-chat/ljookipcanaglfaocjbgdicfbdhhjffp)
5052
- [Firefox Add-ons](https://addons.mozilla.org/en-US/firefox/addon/autofill-for-code-web-chat/)

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -373,16 +373,12 @@ export const ai_studio: Chatbot = {
373373

374374
await close_panel()
375375
},
376-
inject_apply_response_button: (
377-
client_id: number,
378-
raw_instructions?: string,
379-
edit_format?: string
380-
) => {
376+
inject_apply_response_button: (params) => {
381377
const add_buttons = (footer: Element) => {
382378
add_apply_response_button({
383-
client_id,
384-
raw_instructions,
385-
edit_format,
379+
client_id: params.client_id,
380+
raw_instructions: params.raw_instructions,
381+
edit_format: params.edit_format,
386382
footer,
387383
get_chat_turn: (f) => f.closest('ms-chat-turn'),
388384
perform_copy: (f) => {

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,20 @@ export const arena: Chatbot = {
3232
input_element.value = params.message
3333
input_element.dispatchEvent(new Event('input', { bubbles: true }))
3434
},
35-
inject_apply_response_button: (
36-
client_id: number,
37-
raw_instructions?: string,
38-
edit_format?: string
39-
) => {
35+
inject_apply_response_button: (params) => {
4036
const add_buttons = (footer: Element) => {
4137
add_apply_response_button({
42-
client_id,
43-
raw_instructions,
44-
edit_format,
38+
client_id: params.client_id,
39+
raw_instructions: params.raw_instructions,
40+
edit_format: params.edit_format,
4541
footer,
4642
get_chat_turn: (f) =>
4743
f
4844
.closest('div[role="group"]')
4945
?.querySelector('div.prose') as HTMLElement,
5046
perform_copy: (f) => {
5147
const copy_button = f.querySelector(
52-
'button:nth-child(3)'
48+
'button:nth-child(2)'
5349
) as HTMLElement
5450
if (!copy_button) {
5551
report_initialization_error({
@@ -69,7 +65,7 @@ export const arena: Chatbot = {
6965
is_generating: () =>
7066
!!document.querySelector('canvas[data-sentry-component="Loading"]'),
7167
footer_selector:
72-
'div[aria-roledescription="slide"] > div > div > div.gap-2:last-child',
68+
'div[aria-roledescription="slide"] > div > div > div[role="presentation"]',
7369
add_buttons
7470
})
7571
}

‎apps/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
@@ -130,16 +130,12 @@ export const chatgpt: Chatbot = {
130130
input_element.innerText = params.message
131131
input_element.dispatchEvent(new Event('input', { bubbles: true }))
132132
},
133-
inject_apply_response_button: (
134-
client_id: number,
135-
raw_instructions?: string,
136-
edit_format?: string
137-
) => {
133+
inject_apply_response_button: (params) => {
138134
const add_buttons = (footer: Element) => {
139135
add_apply_response_button({
140-
client_id,
141-
raw_instructions,
142-
edit_format,
136+
client_id: params.client_id,
137+
raw_instructions: params.raw_instructions,
138+
edit_format: params.edit_format,
143139
footer,
144140
get_chat_turn: (f) => f.closest('.agent-turn'),
145141
perform_copy: (f) => {

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,12 @@ export const claude: Chatbot = {
127127
input_element.dispatchEvent(new Event('input', { bubbles: true }))
128128
input_element.focus()
129129
},
130-
inject_apply_response_button: (
131-
client_id: number,
132-
raw_instructions?: string,
133-
edit_format?: string
134-
) => {
130+
inject_apply_response_button: (params) => {
135131
const add_buttons = (footer: Element) => {
136132
add_apply_response_button({
137-
client_id,
138-
raw_instructions,
139-
edit_format,
133+
client_id: params.client_id,
134+
raw_instructions: params.raw_instructions,
135+
edit_format: params.edit_format,
140136
footer,
141137
get_chat_turn: (f) => f.closest('.group'),
142138
perform_copy: (f) => {

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,12 @@ export const copilot: Chatbot = {
3232
input_element.value = params.message
3333
input_element.dispatchEvent(new Event('input', { bubbles: true }))
3434
},
35-
inject_apply_response_button: (
36-
client_id: number,
37-
raw_instructions?: string,
38-
edit_format?: string
39-
) => {
35+
inject_apply_response_button: (params) => {
4036
const add_buttons = (footer: Element) => {
4137
add_apply_response_button({
42-
client_id,
43-
raw_instructions,
44-
edit_format,
38+
client_id: params.client_id,
39+
raw_instructions: params.raw_instructions,
40+
edit_format: params.edit_format,
4541
footer,
4642
get_chat_turn: (f) => f.closest('div[data-content="ai-message"]'),
4743
perform_copy: (f) => {

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,12 @@ export const deepseek: Chatbot = {
8080
input_element.value = params.message
8181
input_element.dispatchEvent(new Event('input', { bubbles: true }))
8282
},
83-
inject_apply_response_button: (
84-
client_id: number,
85-
raw_instructions?: string,
86-
edit_format?: string
87-
) => {
83+
inject_apply_response_button: (params) => {
8884
const add_buttons = (footer: Element) => {
8985
add_apply_response_button({
90-
client_id,
91-
raw_instructions,
92-
edit_format,
86+
client_id: params.client_id,
87+
raw_instructions: params.raw_instructions,
88+
edit_format: params.edit_format,
9389
footer,
9490
get_chat_turn: (f) =>
9591
f.parentElement?.parentElement?.querySelector(

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,12 @@ export const doubao: Chatbot = {
114114
input_element.value = params.message
115115
input_element.dispatchEvent(new Event('input', { bubbles: true }))
116116
},
117-
inject_apply_response_button: (
118-
client_id: number,
119-
raw_instructions?: string,
120-
edit_format?: string
121-
) => {
117+
inject_apply_response_button: (params) => {
122118
const add_buttons = (footer: Element) => {
123119
add_apply_response_button({
124-
client_id,
125-
raw_instructions,
126-
edit_format,
120+
client_id: params.client_id,
121+
raw_instructions: params.raw_instructions,
122+
edit_format: params.edit_format,
127123
footer,
128124
get_chat_turn: (f) => f.closest('div[data-testid="receive_message"]'),
129125
perform_copy: (f) => {

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,12 @@ export const gemini: Chatbot = {
151151
input_element.dispatchEvent(new Event('input', { bubbles: true }))
152152
input_element.focus()
153153
},
154-
inject_apply_response_button: (
155-
client_id: number,
156-
raw_instructions?: string,
157-
edit_format?: string
158-
) => {
154+
inject_apply_response_button: (params) => {
159155
const add_buttons = (footer: Element) => {
160156
add_apply_response_button({
161-
client_id,
162-
raw_instructions,
163-
edit_format,
157+
client_id: params.client_id,
158+
raw_instructions: params.raw_instructions,
159+
edit_format: params.edit_format,
164160
footer,
165161
get_chat_turn: (f) => f.closest('response-container'),
166162
perform_copy: (f) => {

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,12 @@ export const github_copilot: Chatbot = {
9696
input_element.dispatchEvent(new Event('input', { bubbles: true }))
9797
input_element.focus()
9898
},
99-
inject_apply_response_button: (
100-
client_id: number,
101-
raw_instructions?: string,
102-
edit_format?: string
103-
) => {
99+
inject_apply_response_button: (params) => {
104100
const add_buttons = (footer: Element) => {
105101
add_apply_response_button({
106-
client_id,
107-
raw_instructions,
108-
edit_format,
102+
client_id: params.client_id,
103+
raw_instructions: params.raw_instructions,
104+
edit_format: params.edit_format,
109105
footer,
110106
get_chat_turn: (f) => f.closest('div.message-container') as HTMLElement,
111107
perform_copy: (f) => {

0 commit comments

Comments
 (0)