Skip to content

Commit b9970a5

Browse files
committed
Implement a hierarchical task management feature in the Home view with support for persistent storage and nested subtasks
1 parent 8129fca commit b9970a5

30 files changed

Lines changed: 1173 additions & 130 deletions

‎packages/shared/src/constants/dictionary.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export const dictionary = {
77

88
information_message: {
99
ALL_CHECKPOINTS_CLEARED: 'All checkpoints have been cleared.',
10+
TASK_DELETED: 'Task deleted.',
11+
TASK_COPIED_TO_CLIPBOARD: 'Task copied to clipboard.',
1012
ALL_CHECKED_FILES_UNCAHNGED_SINCE_COMMIT: (
1113
folder_name: string,
1214
commit_hash: string

‎packages/shared/src/types/task.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export type Task = {
2+
text: string
3+
is_checked: boolean
4+
created_at: number
5+
is_collapsed?: boolean
6+
children?: Task[]
7+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.checkbox {
2+
appearance: none;
3+
height: 15px;
4+
width: 15px;
5+
color: var(--vscode-checkbox-foreground);
6+
position: relative;
7+
cursor: pointer;
8+
flex-shrink: 0;
9+
margin: 0;
10+
11+
&:focus {
12+
outline: none;
13+
}
14+
15+
&::before {
16+
font-family: 'codicon';
17+
content: '\eab2';
18+
font-size: 13px;
19+
position: absolute;
20+
top: 50%;
21+
left: 50%;
22+
transform: translate(-50%, -50%);
23+
opacity: 0.3;
24+
}
25+
26+
&:checked::before {
27+
opacity: 1;
28+
}
29+
30+
&:hover::before {
31+
opacity: 0.5;
32+
}
33+
34+
&:checked:hover::before {
35+
opacity: 1;
36+
}
37+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { useState } from 'react'
2+
import { SimpleCheckbox } from './SimpleCheckbox'
3+
4+
export default {
5+
component: SimpleCheckbox
6+
}
7+
8+
export const Default = () => {
9+
const [checked, set_checked] = useState(false)
10+
11+
return (
12+
<div style={{ padding: '20px', background: 'var(--vscode-sideBar-background)' }}>
13+
<SimpleCheckbox
14+
checked={checked}
15+
on_change={set_checked}
16+
title="Toggle simple checkbox"
17+
/>
18+
</div>
19+
)
20+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { FC, ChangeEvent } from 'react'
2+
import styles from './SimpleCheckbox.module.scss'
3+
4+
type Props = {
5+
checked: boolean
6+
on_change: (checked: boolean) => void
7+
title?: string
8+
}
9+
10+
export const SimpleCheckbox: FC<Props> = (props) => {
11+
const handle_change = (e: ChangeEvent<HTMLInputElement>) => {
12+
props.on_change(e.target.checked)
13+
}
14+
15+
return (
16+
<input
17+
type="checkbox"
18+
className={styles.checkbox}
19+
checked={props.checked}
20+
onChange={handle_change}
21+
onClick={(e) => e.stopPropagation()}
22+
title={props.title}
23+
/>
24+
)
25+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './SimpleCheckbox'

‎packages/ui/src/components/editor/common/Textarea/Textarea.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const Textarea = React.forwardRef<HTMLTextAreaElement, Props>(
2222
const set_ref = React.useCallback(
2323
(node: HTMLTextAreaElement | null) => {
2424
internal_ref.current = node
25-
if (typeof ref === 'function') {
25+
if (typeof ref == 'function') {
2626
ref(node)
2727
} else if (ref) {
2828
ref.current = node
@@ -42,7 +42,7 @@ export const Textarea = React.forwardRef<HTMLTextAreaElement, Props>(
4242
}, [])
4343

4444
const handle_key_down = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
45-
if (e.key == 'Enter' && !e.shiftKey) {
45+
if ((e.key == 'Enter' || e.key == 'Escape') && !e.shiftKey) {
4646
e.preventDefault()
4747
e.currentTarget.blur()
4848
}

‎packages/ui/src/components/editor/panel/IconButton/IconButton.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import cn from 'classnames'
44
type Props = {
55
codicon_icon: string
66
on_click?: (e: any) => void
7+
on_mouse_down?: (e: any) => void
78
href?: string
89
title?: string
910
label?: string
@@ -25,6 +26,7 @@ export const IconButton: React.FC<Props> = (props) => {
2526
className={cn(styles['icon-button'], {
2627
[styles['with-label']]: !!props.label
2728
})}
29+
onMouseDown={props.on_mouse_down}
2830
title={props.title}
2931
target="_blank"
3032
rel="noopener noreferrer"
@@ -39,6 +41,7 @@ export const IconButton: React.FC<Props> = (props) => {
3941
className={cn(styles['icon-button'], {
4042
[styles['with-label']]: !!props.label
4143
})}
44+
onMouseDown={props.on_mouse_down}
4245
onClick={props.on_click}
4346
title={props.title}
4447
>

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

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -145,33 +145,3 @@
145145
flex: 1;
146146
}
147147
}
148-
149-
.checkbox {
150-
appearance: none;
151-
height: 15px;
152-
width: 15px;
153-
color: var(--vscode-checkbox-foreground);
154-
position: relative;
155-
cursor: pointer;
156-
flex-shrink: 0;
157-
margin: 0;
158-
159-
&:focus {
160-
outline: none;
161-
}
162-
163-
&::before {
164-
font-family: 'codicon';
165-
content: '\eab2';
166-
font-size: 12px;
167-
position: absolute;
168-
top: 50%;
169-
left: 50%;
170-
transform: translate(-50%, -50%);
171-
opacity: 0.3;
172-
}
173-
174-
&:checked::before {
175-
opacity: 1;
176-
}
177-
}

‎packages/ui/src/components/editor/panel/Presets/Presets.tsx‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Icon } from '../../common/Icon'
66
import { Button } from '../../common/Button'
77
import { CHATBOTS } from '@shared/constants/chatbots'
88
import { ListHeader } from '../ListHeader'
9+
import { SimpleCheckbox } from '../../common/SimpleCheckbox'
910

1011
export const chatbot_to_icon: Record<keyof typeof CHATBOTS, Icon.Variant> = {
1112
'AI Studio': 'AI_STUDIO',
@@ -255,9 +256,7 @@ export const Presets: React.FC<Presets.Props> = (props) => {
255256
(item, index) => item.id != sortable_list[index].id
256257
)
257258

258-
if (!has_order_changed) {
259-
return
260-
}
259+
if (!has_order_changed) return
261260

262261
// Handle normal preset/group reordering
263262
const new_visible_presets = new_state.map(
@@ -460,14 +459,11 @@ export const Presets: React.FC<Presets.Props> = (props) => {
460459
)}
461460
{preset.chatbot &&
462461
preset_indices_in_group.has(preset.original_index) && (
463-
<input
464-
type="checkbox"
465-
className={styles.checkbox}
462+
<SimpleCheckbox
466463
checked={!!preset.is_selected}
467-
onChange={() =>
464+
on_change={() =>
468465
props.on_toggle_selected_preset(preset.name!)
469466
}
470-
onClick={(e) => e.stopPropagation()}
471467
title="Select for multi-initialization"
472468
/>
473469
)}

0 commit comments

Comments
 (0)