Skip to content

Commit 081dce5

Browse files
committed
Simplify PromptField disabled state management and clean up tooltips
- unify props [Pasted text] in a single prop - 'is action disabled' should disable the primary submit button - from tooltips, remove shortcuts ├── apps │ └── editor │ └── src │ └── views │ └── prompt │ └── frontend │ └── Main │ └── MainView │ └── MainView.tsx └── packages └── ui └── src └── components └── editor └── common └── prompts ├── PromptField │ ├── PromptField.module.scss │ ├── PromptField.stories.tsx │ ├── PromptField.tsx │ ├── hooks │ │ ├── use-drag-drop.ts │ │ ├── use-dropdown.ts │ │ ├── use-ghost-text.ts │ │ ├── use-handlers │ │ │ ├── handle-copy.ts │ │ │ ├── handle-cut.ts │ │ │ ├── handle-input-change.ts │ │ │ ├── handle-input-click.ts │ │ │ ├── handle-key-down.ts │ │ │ ├── handle-paste.ts │ │ │ ├── handle-submit.ts │ │ │ ├── index.ts │ │ │ ├── types.ts │ │ │ ├── use-handlers.ts │ │ │ └── utils.ts │ │ └── use-keyboard-shortcuts.ts │ └── index.ts ├── Template │ ├── Template.module.scss │ ├── Template.tsx │ └── index.ts └── shared └── symbols ├── caret.ts ├── get-highlighted-text.tsx ├── index.ts ├── position-mapping.ts ├── prompt-symbols.module.scss ├── reconstruct-raw-value.ts └── use-symbol-deletion.ts
1 parent 309f069 commit 081dce5

2 files changed

Lines changed: 5 additions & 22 deletions

File tree

  • apps/editor/src/views/prompt/frontend/Main/MainView
  • packages/ui/src/components/editor/common/prompts/PromptField

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -342,18 +342,7 @@ export const MainView: React.FC<Props> = (props) => {
342342
props.target == TARGET.WEB &&
343343
(!props.is_connected || !props.web_configurations.length)
344344
}
345-
is_action_disabled={
346-
(props.target == TARGET.WEB
347-
? props.web_prompt_type
348-
: props.api_prompt_type) == 'edit-files' &&
349-
!props.selected_files.length
350-
}
351-
is_preview_disabled={
352-
(props.target == TARGET.WEB
353-
? props.web_prompt_type
354-
: props.api_prompt_type) == 'edit-files' &&
355-
!props.selected_files.length
356-
}
345+
is_action_disabled={context_is_empty_warning}
357346
value={props.instructions}
358347
chat_history={props.chat_history}
359348
on_change={handle_input_change}

‎packages/ui/src/components/editor/common/prompts/PromptField/PromptField.tsx‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export type PromptFieldProps = {
4040
on_copy: () => void
4141
is_connected: boolean
4242
is_action_disabled?: boolean
43-
is_preview_disabled?: boolean
4443
current_selection?: SelectionState | null
4544
on_caret_position_change: (caret_position: number) => void
4645
is_web_target: boolean
@@ -382,7 +381,7 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
382381
props.on_preview_prompt?.()
383382
close_dropdown()
384383
},
385-
is_disabled: props.is_preview_disabled ?? props.is_action_disabled
384+
is_disabled: props.is_action_disabled
386385
}
387386
].filter((item) => !(!has_content && item.is_disabled))
388387

@@ -418,7 +417,7 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
418417
props.on_preview_prompt?.()
419418
close_dropdown()
420419
},
421-
is_disabled: props.is_preview_disabled ?? props.is_action_disabled
420+
is_disabled: props.is_action_disabled
422421
}
423422
].filter((item) => !(!has_content && item.is_disabled))
424423

@@ -477,7 +476,6 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
477476
? props.translations.stop_recording
478477
: props.translations.voice_input
479478
}
480-
details={is_mac ? '⇧⌘Space' : 'Ctrl+Shift+Space'}
481479
offset={
482480
!props.is_copy_only &&
483481
(!props.is_web_target ||
@@ -541,7 +539,6 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
541539
{is_edit_format_hovered && (
542540
<Tooltip
543541
message={props.translations.edit_format}
544-
details={is_mac ? '⌥' : 'Alt'}
545542
align="center"
546543
/>
547544
)}
@@ -671,11 +668,7 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
671668
{props.target && props.on_target_change && (
672669
<div className={styles['footer__right__target-switch']}>
673670
{is_target_switch_hovered && (
674-
<Tooltip
675-
message={props.translations.target}
676-
details={is_mac ? '⌥' : 'Alt'}
677-
align="center"
678-
/>
671+
<Tooltip message={props.translations.target} align="center" />
679672
)}
680673
<KeycapWrapper char={is_alt_pressed ? 'Esc' : undefined}>
681674
<button
@@ -749,6 +742,7 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
749742
onClick={handle_submit}
750743
onMouseEnter={() => set_show_submit_tooltip(true)}
751744
onMouseLeave={() => set_show_submit_tooltip(false)}
745+
disabled={props.is_action_disabled}
752746
/>
753747
)}
754748
{primary_dropdown_items.length > 0 && (

0 commit comments

Comments
 (0)