Skip to content

Commit 8442d70

Browse files
committed
Lift completed tasks expansion state to PromptField and collapse it on input
- typing anything should collapse 'completed tasks' └── packages └── ui └── src └── components └── editor └── common └── prompts ├── PromptField │ ├── PromptField.module.scss │ ├── PromptField.stories.tsx │ ├── PromptField.tsx │ ├── components │ │ ├── CompletedTasks │ │ │ ├── CompletedTasks.module.scss │ │ │ ├── CompletedTasks.tsx │ │ │ └── index.ts │ │ ├── Footer │ │ │ ├── Footer.module.scss │ │ │ ├── Footer.tsx │ │ │ └── index.ts │ │ └── Tabs │ │ ├── Tabs.module.scss │ │ ├── Tabs.tsx │ │ └── index.ts │ ├── 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 edeb31b commit 8442d70

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ export const PromptField: React.FC<PromptField.Props> = (props) => {
136136
const [is_text_selecting, set_is_text_selecting] = useState(false)
137137
const [is_focused, set_is_focused] = useState(false)
138138
const [is_checkbox_hovered, set_is_checkbox_hovered] = useState(false)
139+
const [is_completed_tasks_expanded, set_is_completed_tasks_expanded] =
140+
useState(false)
139141

140142
const container_inner_ref = useRef<HTMLDivElement>(null)
141143
const tabs_ref = useRef<TabsRef>(null)
@@ -405,6 +407,7 @@ export const PromptField: React.FC<PromptField.Props> = (props) => {
405407
onInput={(e) => {
406408
set_should_show_ghost_text(true)
407409
handle_input_change(e)
410+
set_is_completed_tasks_expanded(false)
408411
}}
409412
onKeyDown={(e) => {
410413
if (
@@ -463,6 +466,8 @@ export const PromptField: React.FC<PromptField.Props> = (props) => {
463466
completed_task: props.translations.completed_task,
464467
clear_session: props.translations.clear_session
465468
}}
469+
is_expanded={is_completed_tasks_expanded}
470+
set_is_expanded={set_is_completed_tasks_expanded}
466471
/>
467472
</div>
468473

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const CompletedTask: React.FC<TaskProps> = ({
3838
)
3939
}
4040

41-
type CompletedTasksProps = {
41+
type Props = {
4242
tasks: string[]
4343
selected_files?: string[]
4444
is_web_target?: boolean
@@ -48,17 +48,19 @@ type CompletedTasksProps = {
4848
completed_task: string
4949
clear_session: string
5050
}
51+
is_expanded: boolean
52+
set_is_expanded: (is_expanded: boolean) => void
5153
}
5254

53-
export const CompletedTasks: React.FC<CompletedTasksProps> = ({
55+
export const CompletedTasks: React.FC<Props> = ({
5456
tasks,
5557
selected_files,
5658
is_web_target,
5759
on_clear_completed_tasks,
58-
translations
60+
translations,
61+
is_expanded,
62+
set_is_expanded
5963
}) => {
60-
const [is_expanded, set_is_expanded] = useState(false)
61-
6264
if (tasks.length === 0) {
6365
return null
6466
}

0 commit comments

Comments
 (0)