Skip to content

Commit 137f2c2

Browse files
committed
Add missing configuration and preset warnings to PromptField and refactor mode naming and internal function signatures
1 parent 0c35efd commit 137f2c2

11 files changed

Lines changed: 481 additions & 390 deletions

File tree

‎apps/editor/src/views/i18n/panel.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ export const panel = {
415415
},
416416
'panel.action.add-new': {
417417
en: 'Add New',
418-
pl: 'Dodaj nowy',
418+
pl: 'Dodaj...',
419419
'zh-cn': '添加新项',
420420
ja: '新規追加',
421421
'zh-tw': '新增',

‎apps/editor/src/views/i18n/settings.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export const settings = {
181181
},
182182
'settings.action.add-new': {
183183
en: 'Add New',
184-
pl: 'Dodaj nowy',
184+
pl: 'Dodaj...',
185185
'zh-cn': '添加新的',
186186
ja: '新規追加',
187187
'zh-tw': '新增',

‎apps/editor/src/views/panel/frontend/Main/Main.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ type Props = {
7979
on_tab_change: (index: number) => void
8080
on_new_tab: () => void
8181
on_tab_delete: (index: number) => void
82+
missing_preset?: boolean
8283
}
8384

8485
export const Main: React.FC<Props> = (props) => {

‎apps/editor/src/views/panel/frontend/Main/MainView/MainView.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export const MainView: React.FC<Props> = (props) => {
245245
on_at_sign_click={props.on_at_sign_click}
246246
on_hash_sign_click={props.on_hash_sign_click}
247247
on_curly_braces_click={props.on_curly_braces_click}
248-
is_chatbots_mode={props.mode == MODE.WEB}
248+
is_web_mode={props.mode == MODE.WEB}
249249
is_connected={props.is_connected}
250250
prompt_type={
251251
props.mode == MODE.WEB
@@ -299,6 +299,10 @@ export const MainView: React.FC<Props> = (props) => {
299299
on_tab_change={props.on_tab_change}
300300
on_new_tab={props.on_new_tab}
301301
on_tab_delete={props.on_tab_delete}
302+
missing_configuration={
303+
props.mode == MODE.API && props.configurations.length == 0
304+
}
305+
missing_preset={props.mode == MODE.WEB && props.presets.length == 0}
302306
/>
303307
<UiContextUtilisation
304308
current_context_size={props.token_count}

‎packages/ui/src/components/editor/panel/PromptField/PromptField.module.scss‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121

2222
&--disabled {
2323
pointer-events: none;
24-
> * {
25-
opacity: 0.3;
24+
opacity: var(--disabled-opacity);
25+
26+
* {
27+
pointer-events: none !important;
2628
}
2729
}
2830

@@ -38,7 +40,7 @@
3840
position: relative;
3941
}
4042

41-
.error {
43+
.warning {
4244
position: absolute;
4345
z-index: 2;
4446
width: 100%;
@@ -48,21 +50,24 @@
4850
display: flex;
4951
align-items: center;
5052
justify-content: center;
53+
pointer-events: none;
5154

5255
&__inner {
5356
display: flex;
57+
pointer-events: auto;
5458
text-align: center;
5559
align-items: center;
56-
padding: 3px 10px 3px 8px;
57-
font-weight: 500;
58-
color: var(--vscode-activityWarningBadge-foreground);
59-
background-color: var(--vscode-activityWarningBadge-background);
60+
padding: 3px 12px 3px 8px;
61+
color: var(--cwc-text-color-orange);
62+
background-color: var(--cwc-bg-orange);
6063
border-radius: 999px;
6164
margin: 0 8px;
6265

6366
&::before {
64-
content: '⚠';
65-
padding-right: 4px;
67+
font-family: 'codicon';
68+
content: '\ea6c';
69+
font-size: 16px;
70+
padding-right: 5px;
6671
}
6772
}
6873
}

‎packages/ui/src/components/editor/panel/PromptField/PromptField.stories.tsx‎

Lines changed: 79 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const Empty = () => (
1717
current_selection={null}
1818
currently_open_file_path="/path/to/file"
1919
on_caret_position_change={(pos) => console.log('Caret position:', pos)}
20-
is_chatbots_mode={false}
20+
is_web_mode={false}
2121
on_at_sign_click={() => console.log('@ clicked')}
2222
on_hash_sign_click={() => console.log('# clicked')}
2323
on_submit_with_control={() => console.log('Submitted with control')}
@@ -52,6 +52,8 @@ export const Empty = () => (
5252
on_tab_change={() => {}}
5353
on_new_tab={() => {}}
5454
on_tab_delete={() => {}}
55+
missing_configuration={false}
56+
missing_preset={false}
5557
/>
5658
)
5759

@@ -67,7 +69,7 @@ export const WithText = () => (
6769
current_selection={null}
6870
currently_open_file_path="/path/to/file"
6971
on_caret_position_change={(pos) => console.log('Caret position:', pos)}
70-
is_chatbots_mode={false}
72+
is_web_mode={false}
7173
on_at_sign_click={() => console.log('@ clicked')}
7274
on_hash_sign_click={() => console.log('# clicked')}
7375
on_submit_with_control={() => console.log('Submitted with control')}
@@ -102,6 +104,8 @@ export const WithText = () => (
102104
on_tab_change={() => {}}
103105
on_new_tab={() => {}}
104106
on_tab_delete={() => {}}
107+
missing_configuration={false}
108+
missing_preset={false}
105109
/>
106110
)
107111

@@ -117,7 +121,7 @@ export const LongText = () => (
117121
current_selection={null}
118122
currently_open_file_path="/path/to/file"
119123
on_caret_position_change={(pos) => console.log('Caret position:', pos)}
120-
is_chatbots_mode={false}
124+
is_web_mode={false}
121125
on_at_sign_click={() => console.log('@ clicked')}
122126
on_hash_sign_click={() => console.log('# clicked')}
123127
on_submit_with_control={() => console.log('Submitted with control')}
@@ -152,6 +156,8 @@ export const LongText = () => (
152156
on_tab_change={() => {}}
153157
on_new_tab={() => {}}
154158
on_tab_delete={() => {}}
159+
missing_configuration={false}
160+
missing_preset={false}
155161
/>
156162
)
157163

@@ -169,7 +175,7 @@ export const WithPlaceholderSavedContext = () => (
169175
on_caret_position_change={(pos) => console.log('Caret position:', pos)}
170176
on_at_sign_click={() => console.log('@ clicked')}
171177
on_hash_sign_click={() => console.log('# clicked')}
172-
is_chatbots_mode={false}
178+
is_web_mode={false}
173179
on_submit_with_control={() => console.log('Submitted with control')}
174180
context_file_paths={[]}
175181
invocation_count={1}
@@ -202,6 +208,8 @@ export const WithPlaceholderSavedContext = () => (
202208
on_tab_change={() => {}}
203209
on_new_tab={() => {}}
204210
on_tab_delete={() => {}}
211+
missing_configuration={false}
212+
missing_preset={false}
205213
/>
206214
)
207215

@@ -225,7 +233,7 @@ export const WithPlaceholderSelection = () => (
225233
on_caret_position_change={(pos) => console.log('Caret position:', pos)}
226234
on_at_sign_click={() => console.log('@ clicked')}
227235
on_hash_sign_click={() => console.log('# clicked')}
228-
is_chatbots_mode={false}
236+
is_web_mode={false}
229237
on_submit_with_control={() => console.log('Submitted with control')}
230238
context_file_paths={[]}
231239
invocation_count={1}
@@ -258,6 +266,8 @@ export const WithPlaceholderSelection = () => (
258266
on_tab_change={() => {}}
259267
on_new_tab={() => {}}
260268
on_tab_delete={() => {}}
269+
missing_configuration={false}
270+
missing_preset={false}
261271
/>
262272
)
263273

@@ -275,7 +285,7 @@ export const WithCommit = () => (
275285
on_caret_position_change={(pos) => console.log('Caret position:', pos)}
276286
on_at_sign_click={() => console.log('@ clicked')}
277287
on_hash_sign_click={() => console.log('# clicked')}
278-
is_chatbots_mode={false}
288+
is_web_mode={false}
279289
on_submit_with_control={() => console.log('Submitted with control')}
280290
context_file_paths={[]}
281291
invocation_count={1}
@@ -308,6 +318,8 @@ export const WithCommit = () => (
308318
on_tab_change={() => {}}
309319
on_new_tab={() => {}}
310320
on_tab_delete={() => {}}
321+
missing_configuration={false}
322+
missing_preset={false}
311323
/>
312324
)
313325

@@ -325,7 +337,7 @@ export const WithCommitWithQuotes = () => (
325337
on_caret_position_change={(pos) => console.log('Caret position:', pos)}
326338
on_at_sign_click={() => console.log('@ clicked')}
327339
on_hash_sign_click={() => console.log('# clicked')}
328-
is_chatbots_mode={false}
340+
is_web_mode={false}
329341
on_submit_with_control={() => console.log('Submitted with control')}
330342
context_file_paths={[]}
331343
invocation_count={1}
@@ -358,6 +370,8 @@ export const WithCommitWithQuotes = () => (
358370
on_tab_change={() => {}}
359371
on_new_tab={() => {}}
360372
on_tab_delete={() => {}}
373+
missing_configuration={false}
374+
missing_preset={false}
361375
/>
362376
)
363377
export const WithContextAtCommit = () => (
@@ -374,7 +388,7 @@ export const WithContextAtCommit = () => (
374388
on_caret_position_change={(pos) => console.log('Caret position:', pos)}
375389
on_at_sign_click={() => console.log('@ clicked')}
376390
on_hash_sign_click={() => console.log('# clicked')}
377-
is_chatbots_mode={false}
391+
is_web_mode={false}
378392
on_submit_with_control={() => console.log('Submitted with control')}
379393
context_file_paths={[]}
380394
invocation_count={1}
@@ -407,6 +421,8 @@ export const WithContextAtCommit = () => (
407421
on_tab_change={() => {}}
408422
on_new_tab={() => {}}
409423
on_tab_delete={() => {}}
424+
missing_configuration={false}
425+
missing_preset={false}
410426
/>
411427
)
412428

@@ -425,7 +441,7 @@ export const WithEditFormatSelector = () => {
425441
current_selection={null}
426442
currently_open_file_path="/path/to/file"
427443
on_caret_position_change={(pos) => console.log('Caret position:', pos)}
428-
is_chatbots_mode={false}
444+
is_web_mode={false}
429445
on_at_sign_click={() => console.log('@ clicked')}
430446
on_hash_sign_click={() => console.log('# clicked')}
431447
on_submit_with_control={() => console.log('Submitted with control')}
@@ -461,6 +477,8 @@ export const WithEditFormatSelector = () => {
461477
on_tab_change={() => {}}
462478
on_new_tab={() => {}}
463479
on_tab_delete={() => {}}
480+
missing_configuration={false}
481+
missing_preset={false}
464482
/>
465483
)
466484
}
@@ -477,7 +495,7 @@ export const WithFilePaths = () => (
477495
current_selection={null}
478496
currently_open_file_path="/path/to/file"
479497
on_caret_position_change={(pos) => console.log('Caret position:', pos)}
480-
is_chatbots_mode={false}
498+
is_web_mode={false}
481499
on_at_sign_click={() => console.log('@ clicked')}
482500
on_hash_sign_click={() => console.log('# clicked')}
483501
on_submit_with_control={() => console.log('Submitted with control')}
@@ -512,6 +530,8 @@ export const WithFilePaths = () => (
512530
on_tab_change={() => {}}
513531
on_new_tab={() => {}}
514532
on_tab_delete={() => {}}
533+
missing_configuration={false}
534+
missing_preset={false}
515535
/>
516536
)
517537

@@ -555,7 +575,7 @@ export const WithTabs = () => {
555575
current_selection={null}
556576
currently_open_file_path="/path/to/file"
557577
on_caret_position_change={(pos) => console.log('Caret position:', pos)}
558-
is_chatbots_mode={false}
578+
is_web_mode={false}
559579
on_at_sign_click={() => console.log('@ clicked')}
560580
on_hash_sign_click={() => console.log('# clicked')}
561581
on_submit_with_control={() => console.log('Submitted with control')}
@@ -590,6 +610,54 @@ export const WithTabs = () => {
590610
on_tab_change={set_active_index}
591611
on_new_tab={handle_new_tab}
592612
on_tab_delete={handle_tab_delete}
613+
missing_configuration={false}
614+
missing_preset={false}
593615
/>
594616
)
595617
}
618+
619+
export const MissingPreset = () => (
620+
<PromptField
621+
value="I want to copy this even if there are no presets"
622+
chat_history={[]}
623+
on_change={(value) => console.log('Changed:', value)}
624+
on_submit={() => console.log('Submitted')}
625+
on_copy={() => console.log('Copied')}
626+
is_connected={true}
627+
prompt_type="ask-about-context"
628+
current_selection={null}
629+
currently_open_file_path="/path/to/file"
630+
on_caret_position_change={(pos) => console.log('Caret position:', pos)}
631+
is_web_mode={true}
632+
on_at_sign_click={() => console.log('@ clicked')}
633+
on_hash_sign_click={() => console.log('# clicked')}
634+
on_submit_with_control={() => console.log('Submitted with control')}
635+
context_file_paths={[]}
636+
on_curly_braces_click={() => {}}
637+
invocation_count={1}
638+
on_invocation_count_change={(count) =>
639+
console.log('Invocation count changed:', count)
640+
}
641+
on_go_to_file={(path) => console.log('Go to file:', path)}
642+
prune_context_instructions_prefix=""
643+
on_prune_context_instructions_prefix_change={() => {}}
644+
on_pasted_lines_click={() => {}}
645+
on_open_url={() => {}}
646+
on_open_website={() => {}}
647+
on_paste_image={() => {}}
648+
on_paste_pasted_text={() => {}}
649+
on_open_image={() => {}}
650+
on_open_pasted_text={() => {}}
651+
on_paste_url={() => {}}
652+
is_recording={false}
653+
on_recording_started={() => {}}
654+
on_recording_finished={() => {}}
655+
tabs_count={1}
656+
active_tab_index={0}
657+
on_tab_change={() => {}}
658+
on_new_tab={() => {}}
659+
on_tab_delete={() => {}}
660+
missing_configuration={false}
661+
missing_preset={true}
662+
/>
663+
)

0 commit comments

Comments
 (0)