Skip to content

Commit fc9fb97

Browse files
committed
Standardize chatbot initialization error messages by using the enum
1 parent 2b4a38e commit fc9fb97

18 files changed

Lines changed: 212 additions & 145 deletions

File tree

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

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import { Chatbot } from '../types/chatbot'
22
import { CHATBOTS } from '@shared/constants/chatbots'
33
import { show_response_ready_notification } from '../utils/show-response-ready-notification'
44
import { add_apply_response_button } from '../utils/add-apply-response-button'
5-
import { Logger } from '@shared/utils/logger'
6-
import { report_initialization_error } from '../utils/report-initialization-error'
5+
import {
6+
InitializationError,
7+
report_initialization_error
8+
} from '../utils/report-initialization-error'
79

810
export const ai_studio: Chatbot = {
911
wait_until_ready: async () => {
@@ -36,7 +38,7 @@ export const ai_studio: Chatbot = {
3638
report_initialization_error({
3739
function_name: 'set_model',
3840
log_message: 'Model selector button not found',
39-
alert_message: 'Unable to set model'
41+
alert_message: InitializationError.UNABLE_TO_SET_MODEL
4042
})
4143
return
4244
}
@@ -47,7 +49,7 @@ export const ai_studio: Chatbot = {
4749
report_initialization_error({
4850
function_name: 'set_model',
4951
log_message: 'Model name element not found',
50-
alert_message: 'Unable to set model'
52+
alert_message: InitializationError.UNABLE_TO_SET_MODEL
5153
})
5254
return
5355
}
@@ -92,7 +94,7 @@ export const ai_studio: Chatbot = {
9294
report_initialization_error({
9395
function_name: 'enter_system_instructions',
9496
log_message: 'System instructions button not found',
95-
alert_message: 'Unable to set system instructions'
97+
alert_message: InitializationError.UNABLE_TO_SET_SYSTEM_INSTRUCTIONS
9698
})
9799
return
98100
}
@@ -107,7 +109,7 @@ export const ai_studio: Chatbot = {
107109
report_initialization_error({
108110
function_name: 'enter_system_instructions',
109111
log_message: 'Close button for system instructions dialog not found',
110-
alert_message: 'Unable to set system instructions'
112+
alert_message: InitializationError.UNABLE_TO_SET_SYSTEM_INSTRUCTIONS
111113
})
112114
return
113115
}
@@ -119,7 +121,7 @@ export const ai_studio: Chatbot = {
119121
report_initialization_error({
120122
function_name: 'enter_system_instructions',
121123
log_message: 'System instructions panel not found',
122-
alert_message: 'Unable to set system instructions'
124+
alert_message: InitializationError.UNABLE_TO_SET_SYSTEM_INSTRUCTIONS
123125
})
124126
return
125127
}
@@ -129,7 +131,7 @@ export const ai_studio: Chatbot = {
129131
report_initialization_error({
130132
function_name: 'enter_system_instructions',
131133
log_message: 'System instructions textarea not found',
132-
alert_message: 'Unable to set system instructions'
134+
alert_message: InitializationError.UNABLE_TO_SET_SYSTEM_INSTRUCTIONS
133135
})
134136
return
135137
}
@@ -163,7 +165,7 @@ export const ai_studio: Chatbot = {
163165
report_initialization_error({
164166
function_name: 'set_options',
165167
log_message: 'Thinking toggle not found',
166-
alert_message: 'Unable to set options'
168+
alert_message: InitializationError.UNABLE_TO_SET_OPTIONS
167169
})
168170
return
169171
}
@@ -196,7 +198,7 @@ export const ai_studio: Chatbot = {
196198
report_initialization_error({
197199
function_name: 'set_options',
198200
log_message: 'Temporary chat toggle not found',
199-
alert_message: 'Unable to set options'
201+
alert_message: InitializationError.UNABLE_TO_SET_OPTIONS
200202
})
201203
return
202204
}
@@ -211,7 +213,7 @@ export const ai_studio: Chatbot = {
211213
report_initialization_error({
212214
function_name: 'set_options',
213215
log_message: 'Grounding with Google Search button not found',
214-
alert_message: 'Unable to set options'
216+
alert_message: InitializationError.UNABLE_TO_SET_OPTIONS
215217
})
216218
return
217219
}
@@ -230,7 +232,7 @@ export const ai_studio: Chatbot = {
230232
report_initialization_error({
231233
function_name: 'set_options',
232234
log_message: 'URL context button not found',
233-
alert_message: 'Unable to set options'
235+
alert_message: InitializationError.UNABLE_TO_SET_OPTIONS
234236
})
235237
return
236238
}
@@ -247,7 +249,7 @@ export const ai_studio: Chatbot = {
247249
report_initialization_error({
248250
function_name: 'set_temperature',
249251
log_message: 'Temperature input not found',
250-
alert_message: 'Unable to set temperature'
252+
alert_message: InitializationError.UNABLE_TO_SET_TEMPERATURE
251253
})
252254
return
253255
}
@@ -264,7 +266,7 @@ export const ai_studio: Chatbot = {
264266
report_initialization_error({
265267
function_name: 'set_thinking_budget',
266268
log_message: 'Manual budget toggle not found',
267-
alert_message: 'Unable to set thinking budget'
269+
alert_message: InitializationError.UNABLE_TO_SET_THINKING_BUDGET
268270
})
269271
return
270272
}
@@ -280,7 +282,7 @@ export const ai_studio: Chatbot = {
280282
report_initialization_error({
281283
function_name: 'set_thinking_budget',
282284
log_message: 'Thinking toggle not found',
283-
alert_message: 'Unable to set thinking budget'
285+
alert_message: InitializationError.UNABLE_TO_SET_THINKING_BUDGET
284286
})
285287
return
286288
}
@@ -295,7 +297,7 @@ export const ai_studio: Chatbot = {
295297
report_initialization_error({
296298
function_name: 'set_thinking_budget',
297299
log_message: 'Manual budget toggle not found',
298-
alert_message: 'Unable to set thinking budget'
300+
alert_message: InitializationError.UNABLE_TO_SET_THINKING_BUDGET
299301
})
300302
return
301303
}
@@ -310,7 +312,7 @@ export const ai_studio: Chatbot = {
310312
report_initialization_error({
311313
function_name: 'set_thinking_budget',
312314
log_message: 'Budget input not found',
313-
alert_message: 'Unable to set thinking budget'
315+
alert_message: InitializationError.UNABLE_TO_SET_THINKING_BUDGET
314316
})
315317
return
316318
}
@@ -345,7 +347,7 @@ export const ai_studio: Chatbot = {
345347
report_initialization_error({
346348
function_name: 'set_top_p',
347349
log_message: 'Top-p input not found',
348-
alert_message: 'Unable to set top-p'
350+
alert_message: InitializationError.UNABLE_TO_SET_TOP_P
349351
})
350352
return
351353
}
@@ -360,7 +362,7 @@ export const ai_studio: Chatbot = {
360362
report_initialization_error({
361363
function_name: 'enter_message_and_send',
362364
log_message: 'Message input textarea not found',
363-
alert_message: 'Unable to send message'
365+
alert_message: InitializationError.UNABLE_TO_SEND_MESSAGE
364366
})
365367
return
366368
}
@@ -390,7 +392,7 @@ export const ai_studio: Chatbot = {
390392
report_initialization_error({
391393
function_name: 'enter_message_and_send',
392394
log_message: 'Send button not found',
393-
alert_message: 'Unable to send message'
395+
alert_message: InitializationError.UNABLE_TO_SEND_MESSAGE
394396
})
395397
return
396398
}
@@ -409,7 +411,7 @@ export const ai_studio: Chatbot = {
409411
report_initialization_error({
410412
function_name: 'ai_studio.perform_copy',
411413
log_message: 'Chat turn container not found',
412-
alert_message: 'Unable to copy response'
414+
alert_message: InitializationError.UNABLE_TO_COPY_RESPONSE
413415
})
414416
return
415417
}
@@ -420,7 +422,7 @@ export const ai_studio: Chatbot = {
420422
report_initialization_error({
421423
function_name: 'ai_studio.perform_copy',
422424
log_message: 'Options button not found',
423-
alert_message: 'Unable to copy response'
425+
alert_message: InitializationError.UNABLE_TO_COPY_RESPONSE
424426
})
425427
return
426428
}
@@ -434,7 +436,7 @@ export const ai_studio: Chatbot = {
434436
report_initialization_error({
435437
function_name: 'ai_studio.perform_copy',
436438
log_message: 'Markdown copy button not found',
437-
alert_message: 'Unable to copy response'
439+
alert_message: InitializationError.UNABLE_TO_COPY_RESPONSE
438440
})
439441
return
440442
}
@@ -480,7 +482,7 @@ const open_panel = async () => {
480482
report_initialization_error({
481483
function_name: 'open_panel',
482484
log_message: 'Tune button not found',
483-
alert_message: 'Unable to open settings panel'
485+
alert_message: InitializationError.UNABLE_TO_OPEN_SETTINGS_PANEL
484486
})
485487
return
486488
}
@@ -498,7 +500,7 @@ const close_panel = async () => {
498500
report_initialization_error({
499501
function_name: 'close_panel',
500502
log_message: 'Close button for settings panel not found',
501-
alert_message: 'Unable to close settings panel'
503+
alert_message: InitializationError.UNABLE_TO_CLOSE_SETTINGS_PANEL
502504
})
503505
return
504506
}
@@ -512,7 +514,7 @@ const close_panel = async () => {
512514
report_initialization_error({
513515
function_name: 'close_panel',
514516
log_message: 'Close button for settings panel not found',
515-
alert_message: 'Unable to close settings panel'
517+
alert_message: InitializationError.UNABLE_TO_CLOSE_SETTINGS_PANEL
516518
})
517519
return
518520
}

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import {
44
add_apply_response_button,
55
observe_for_responses
66
} from '../utils/add-apply-response-button'
7-
import { report_initialization_error } from '../utils/report-initialization-error'
7+
import {
8+
InitializationError,
9+
report_initialization_error
10+
} from '../utils/report-initialization-error'
811

912
export const chatgpt: Chatbot = {
1013
wait_until_ready: async () => {
@@ -55,7 +58,7 @@ export const chatgpt: Chatbot = {
5558
report_initialization_error({
5659
function_name: 'set_options',
5760
log_message: 'Temporary chat button not found',
58-
alert_message: 'Unable to set options'
61+
alert_message: InitializationError.UNABLE_TO_SET_OPTIONS
5962
})
6063
}
6164
} else if (
@@ -92,14 +95,14 @@ export const chatgpt: Chatbot = {
9295
report_initialization_error({
9396
function_name: 'set_options',
9497
log_message: 'Think longer button not found',
95-
alert_message: 'Unable to set options'
98+
alert_message: InitializationError.UNABLE_TO_SET_OPTIONS
9699
})
97100
}
98101
} else {
99102
report_initialization_error({
100103
function_name: 'set_options',
101104
log_message: 'Plus button for "Think longer" not found',
102-
alert_message: 'Unable to set options'
105+
alert_message: InitializationError.UNABLE_TO_SET_OPTIONS
103106
})
104107
}
105108
}
@@ -120,7 +123,7 @@ export const chatgpt: Chatbot = {
120123
report_initialization_error({
121124
function_name: 'chatgpt.perform_copy',
122125
log_message: 'Copy button not found',
123-
alert_message: 'Unable to copy response'
126+
alert_message: InitializationError.UNABLE_TO_COPY_RESPONSE
124127
})
125128
return
126129
}

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import {
44
add_apply_response_button,
55
observe_for_responses
66
} from '../utils/add-apply-response-button'
7-
import { report_initialization_error } from '../utils/report-initialization-error'
7+
import {
8+
InitializationError,
9+
report_initialization_error
10+
} from '../utils/report-initialization-error'
811

912
export const claude: Chatbot = {
1013
wait_until_ready: async () => {
@@ -28,7 +31,7 @@ export const claude: Chatbot = {
2831
report_initialization_error({
2932
function_name: 'set_model',
3033
log_message: 'Model selector button not found',
31-
alert_message: 'Unable to set model'
34+
alert_message: InitializationError.UNABLE_TO_SET_MODEL
3235
})
3336
return
3437
}
@@ -38,7 +41,7 @@ export const claude: Chatbot = {
3841
report_initialization_error({
3942
function_name: 'set_model',
4043
log_message: `Model "${model}" not found`,
41-
alert_message: 'Unable to set model'
44+
alert_message: InitializationError.UNABLE_TO_SET_MODEL
4245
})
4346
return
4447
}
@@ -60,7 +63,7 @@ export const claude: Chatbot = {
6063
report_initialization_error({
6164
function_name: 'set_model',
6265
log_message: 'Model selector menu items not found',
63-
alert_message: 'Unable to set model'
66+
alert_message: InitializationError.UNABLE_TO_SET_MODEL
6467
})
6568
return
6669
}
@@ -94,15 +97,15 @@ export const claude: Chatbot = {
9497
report_initialization_error({
9598
function_name: 'set_options',
9699
log_message: 'Incognito chat button not found for Claude',
97-
alert_message: 'Unable to set options'
100+
alert_message: InitializationError.UNABLE_TO_SET_OPTIONS
98101
})
99102
return
100103
}
101104
} else {
102105
report_initialization_error({
103106
function_name: 'set_options',
104107
log_message: 'Incognito chat button path not found for Claude',
105-
alert_message: 'Unable to set options'
108+
alert_message: InitializationError.UNABLE_TO_SET_OPTIONS
106109
})
107110
return
108111
}
@@ -117,7 +120,7 @@ export const claude: Chatbot = {
117120
report_initialization_error({
118121
function_name: 'enter_message_and_send',
119122
log_message: 'Message input not found',
120-
alert_message: 'Unable to send message'
123+
alert_message: InitializationError.UNABLE_TO_SEND_MESSAGE
121124
})
122125
return
123126
}
@@ -137,7 +140,7 @@ export const claude: Chatbot = {
137140
report_initialization_error({
138141
function_name: 'enter_message_and_send',
139142
log_message: 'Submit button not found',
140-
alert_message: 'Unable to send message'
143+
alert_message: InitializationError.UNABLE_TO_SEND_MESSAGE
141144
})
142145
return
143146
}
@@ -158,7 +161,7 @@ export const claude: Chatbot = {
158161
report_initialization_error({
159162
function_name: 'claude.perform_copy',
160163
log_message: 'Copy button not found',
161-
alert_message: 'Unable to copy response'
164+
alert_message: InitializationError.UNABLE_TO_COPY_RESPONSE
162165
})
163166
return
164167
}

0 commit comments

Comments
 (0)