Skip to content

Commit 33ed0fd

Browse files
committed
Replace task forwarding with text copying functionality in the Tasks component
- remove forwarding tasks, instead allow copying to clipboard (briefly replace with 'check' once copied) ├── apps │ └── editor │ └── src │ └── views │ └── prompt │ └── frontend │ ├── Home │ │ ├── Home.tsx │ │ └── hooks │ │ └── use-tasks.ts │ └── Prompt.tsx └── packages └── ui └── src └── components └── editor └── prompt └── Tasks ├── Tasks.module.scss ├── Tasks.stories.tsx ├── Tasks.tsx ├── components │ └── TaskGroup.tsx ├── hooks │ └── use-auto-focus-new-task.ts └── index.ts
1 parent 438d611 commit 33ed0fd

4 files changed

Lines changed: 14 additions & 25 deletions

File tree

‎apps/editor/src/views/prompt/frontend/Home/Home.tsx‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ type Props = {
2828
is_setup_complete: boolean
2929
is_connected: boolean
3030
on_donate_click: () => void
31-
on_forward_task: (text: string) => void
3231
bottom_spacer_height?: number
3332
web_prompt_type: WebPromptType
3433
api_prompt_type: ApiPromptType
@@ -299,7 +298,6 @@ export const Home: React.FC<Props> = (props) => {
299298
on_delete={(timestamp) => {
300299
handle_delete(active_root, timestamp)
301300
}}
302-
on_forward={props.on_forward_task}
303301
translations={{
304302
placeholder: t('home.tasks.placeholder'),
305303
add_new: t('home.tasks.add-new')

‎apps/editor/src/views/prompt/frontend/Prompt.tsx‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -399,19 +399,6 @@ export const Prompt = () => {
399399
version={version}
400400
is_setup_complete={is_setup_complete}
401401
on_donate_click={() => set_viewing_donations(true)}
402-
on_forward_task={(text) => {
403-
set_active_view('main')
404-
set_main_view_scroll_reset_key((k) => k + 1)
405-
406-
if (target == TARGET.WEB) {
407-
handle_web_prompt_type_change('edit-files')
408-
} else if (target == TARGET.API) {
409-
handle_api_prompt_type_change('edit-files')
410-
}
411-
412-
handle_instructions_change(text, 'edit-files')
413-
set_chat_input_focus_key((k) => k + 1)
414-
}}
415402
/>
416403
</div>
417404
</Layout>

‎packages/ui/src/components/editor/prompt/Tasks/Tasks.stories.tsx‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,6 @@ export const Default = () => {
133133
set_tasks((prev) => delete_from_tree(prev, created_at))
134134
}
135135

136-
const handle_copy = (text: string) => {
137-
console.log('Copied task:', text)
138-
}
139-
140136
return (
141137
<div
142138
style={{
@@ -151,7 +147,6 @@ export const Default = () => {
151147
on_add={handle_add}
152148
on_add_subtask={handle_add_subtask}
153149
on_delete={handle_delete}
154-
on_forward={(text) => console.log('Forward task:', text)}
155150
translations={{
156151
placeholder: 'Click to add text...',
157152
add_new: 'Add new...'
@@ -182,7 +177,6 @@ export const NoReorder = () => {
182177
on_add={() => {}}
183178
on_add_subtask={() => {}}
184179
on_delete={() => {}}
185-
on_forward={() => {}}
186180
translations={{
187181
placeholder: 'Click to add text...',
188182
add_new: 'Add new...'

‎packages/ui/src/components/editor/prompt/Tasks/Tasks.tsx‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export namespace Tasks {
2222
on_add: () => void
2323
on_add_subtask?: (parent_task: Task) => void
2424
on_delete: (created_at: number) => void
25-
on_forward: (text: string) => void
2625
translations: {
2726
placeholder: string
2827
add_new: string
@@ -64,6 +63,7 @@ export const Tasks: React.FC<Tasks.Props> = (props) => {
6463
null
6564
)
6665
const [editing_initial_text, set_editing_initial_text] = useState<string>('')
66+
const [copied_timestamp, set_copied_timestamp] = useState<number | null>(null)
6767
const prevent_edit_ref = useRef(false)
6868
const is_canceling_ref = useRef(false)
6969

@@ -208,15 +208,25 @@ export const Tasks: React.FC<Tasks.Props> = (props) => {
208208
>
209209
{params.task.text && (
210210
<IconButton
211-
codicon_icon="forward"
211+
codicon_icon={
212+
copied_timestamp === params.task.created_at
213+
? 'check'
214+
: 'copy'
215+
}
212216
on_mouse_down={
213217
is_editing ? (e) => e.preventDefault() : undefined
214218
}
215219
on_click={(e) => {
216220
e.stopPropagation()
217-
props.on_forward(params.task.text)
221+
navigator.clipboard.writeText(params.task.text)
222+
set_copied_timestamp(params.task.created_at)
223+
setTimeout(() => {
224+
set_copied_timestamp((current) =>
225+
current === params.task.created_at ? null : current
226+
)
227+
}, 2000)
218228
}}
219-
title="Forward to edit instructions"
229+
title="Copy text"
220230
/>
221231
)}
222232
<IconButton

0 commit comments

Comments
 (0)