@steerable/agent-shell-web 0.14.3 → 0.14.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/components/AgentSidebar.tsx +189 -46
- package/src/components/ChatHeader.tsx +12 -1
- package/src/components/SidebarAccount.tsx +33 -41
- package/src/components/chat/AssistantMessage.tsx +36 -10
- package/src/components/chat/ChatInput.tsx +308 -131
- package/src/components/chat/ChatProjectBadge.tsx +311 -100
- package/src/components/chat/ContextUsagePill.tsx +20 -5
- package/src/components/chat/ExecPolicyPicker.tsx +72 -67
- package/src/components/chat/LocalChatPanel.tsx +33 -35
- package/src/components/chat/Markdown.tsx +109 -11
- package/src/components/chat/MessageList.tsx +109 -19
- package/src/components/chat/ModelPicker.tsx +2 -2
- package/src/components/chat/PlanTodoList.tsx +184 -78
- package/src/components/chat/SessionTodoList.tsx +63 -72
- package/src/components/chat/TurnFilesCard.tsx +270 -112
- package/src/components/chat/TurnProcessGroup.tsx +3 -0
- package/src/components/chat/TurnProcessTimeline.tsx +13 -0
- package/src/components/chat/UserMessage.tsx +8 -1
- package/src/components/chat/next-steps-tags.ts +13 -0
- package/src/components/chat/process-status.ts +112 -2
- package/src/components/chat/todo-list-model.ts +52 -4
- package/src/layouts/AgentLayout.tsx +173 -10
- package/src/layouts/PanelToggleButton.tsx +27 -9
- package/src/layouts/conversation-preview.ts +3 -0
- package/src/layouts/request-chat-slot.ts +20 -0
- package/src/layouts/right-panel-tabs.ts +32 -0
- package/src/lib/chat-mode-store.ts +241 -0
- package/src/lib/file-preview-registry.ts +57 -0
- package/src/pages/AgentPage.tsx +188 -78
|
@@ -1,81 +1,107 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useState, type ReactNode } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
LuArrowRight,
|
|
4
|
+
LuCheck,
|
|
5
|
+
LuCircle,
|
|
6
|
+
LuCircleCheck,
|
|
7
|
+
LuCopy,
|
|
8
|
+
LuListChecks,
|
|
9
|
+
LuSquarePlus,
|
|
10
|
+
} from 'react-icons/lu';
|
|
11
|
+
import {
|
|
12
|
+
parseProposedPlanBody,
|
|
13
|
+
type ParsedProposedPlan,
|
|
14
|
+
} from '@steerable/agent-protocol';
|
|
2
15
|
import { t } from '@/i18n';
|
|
16
|
+
import {
|
|
17
|
+
useCurrentMessageId,
|
|
18
|
+
usePlanActionContext,
|
|
19
|
+
} from '@/lib/chat-mode-store';
|
|
3
20
|
|
|
4
21
|
/**
|
|
5
|
-
* PlanTodoList — renders
|
|
6
|
-
*
|
|
7
|
-
* code block.
|
|
22
|
+
* PlanTodoList — renders `<proposed_plan>` blocks and legacy ```` ```plan ````
|
|
23
|
+
* fenced blocks as an actionable plan artifact card.
|
|
8
24
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* - [ ] 第一步……
|
|
13
|
-
* - [x] 已完成的步骤(执行回顾时可能出现)
|
|
14
|
-
*
|
|
15
|
-
* The parser is intentionally forgiving: numbered lists (`1. …`), plain
|
|
16
|
-
* dashes (`- …`) and bare `[ ] …` lines all count as steps, so a slightly
|
|
17
|
-
* off-spec local model still gets a proper todolist instead of a wall of
|
|
18
|
-
* monospace text. Unclosed fences during streaming parse the same way, so
|
|
19
|
-
* steps appear progressively as tokens arrive.
|
|
25
|
+
* Supports both simple checklist plans and rich Markdown specifications
|
|
26
|
+
* (summaries, subheadings, nested code blocks, tables), plus an inline
|
|
27
|
+
* Codex-style 3-way implementation footer on the latest actionable plan.
|
|
20
28
|
*/
|
|
21
29
|
|
|
22
|
-
interface PlanItem {
|
|
30
|
+
export interface PlanItem {
|
|
23
31
|
text: string;
|
|
24
32
|
done: boolean;
|
|
25
33
|
}
|
|
26
34
|
|
|
27
|
-
interface ParsedPlan {
|
|
35
|
+
export interface ParsedPlan {
|
|
28
36
|
title: string | null;
|
|
29
37
|
items: PlanItem[];
|
|
30
38
|
notes: string[];
|
|
31
39
|
}
|
|
32
40
|
|
|
33
|
-
const CHECKBOX_RE = /^(?:[-*]\s*)?\[([ xX])\]\s*(.*)$/;
|
|
34
|
-
const BULLET_RE = /^[-*]\s+(.*)$/;
|
|
35
|
-
const NUMBERED_RE = /^\d+[.、)]\s*(.*)$/;
|
|
36
|
-
|
|
37
41
|
export function parsePlanContent(raw: string): ParsedPlan {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
const parsed = parseProposedPlanBody(raw);
|
|
43
|
+
return {
|
|
44
|
+
title: parsed.title,
|
|
45
|
+
items: parsed.steps,
|
|
46
|
+
notes: parsed.notes,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
42
49
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
export interface PlanTodoListProps {
|
|
51
|
+
/** Raw inner text when rendered from a standalone ```` ```plan ```` code block. */
|
|
52
|
+
content?: string;
|
|
53
|
+
/** Pre-parsed plan model when split at the message level. */
|
|
54
|
+
plan?: ParsedProposedPlan;
|
|
55
|
+
/** Optional rich Markdown renderer injected by `Markdown.tsx` to avoid circular imports. */
|
|
56
|
+
renderRichMarkdown?: (markdown: string) => ReactNode;
|
|
57
|
+
/** True when this card is the last plan block in its parent message (default: true). */
|
|
58
|
+
isLastPlanInMessage?: boolean;
|
|
59
|
+
}
|
|
48
60
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
61
|
+
export function PlanTodoList({
|
|
62
|
+
content = '',
|
|
63
|
+
plan: providedPlan,
|
|
64
|
+
renderRichMarkdown,
|
|
65
|
+
isLastPlanInMessage = true,
|
|
66
|
+
}: PlanTodoListProps) {
|
|
67
|
+
const plan: ParsedProposedPlan = providedPlan ?? {
|
|
68
|
+
syntax: 'fence',
|
|
69
|
+
complete: true,
|
|
70
|
+
...parseProposedPlanBody(content),
|
|
71
|
+
};
|
|
72
|
+
const { title, steps: items, notes, hasRichMarkdown, bodyMarkdown, markdown } = plan;
|
|
55
73
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (text) plan.items.push({ text, done: false });
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
74
|
+
const [copied, setCopied] = useState(false);
|
|
75
|
+
const currentMessageId = useCurrentMessageId();
|
|
76
|
+
const planActionCtx = usePlanActionContext();
|
|
62
77
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
78
|
+
const showActionFooter = Boolean(
|
|
79
|
+
isLastPlanInMessage &&
|
|
80
|
+
planActionCtx?.actionable &&
|
|
81
|
+
currentMessageId &&
|
|
82
|
+
planActionCtx.actionable.messageId === currentMessageId,
|
|
83
|
+
);
|
|
84
|
+
const contextUsedPercent = planActionCtx?.actionable?.contextUsedPercent ?? null;
|
|
67
85
|
|
|
68
|
-
|
|
69
|
-
|
|
86
|
+
const handleCopy = () => {
|
|
87
|
+
const copyText = markdown || content;
|
|
88
|
+
if (!copyText || typeof navigator === 'undefined' || !navigator.clipboard?.writeText) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
void navigator.clipboard.writeText(copyText).then(() => {
|
|
92
|
+
setCopied(true);
|
|
93
|
+
setTimeout(() => setCopied(false), 1800);
|
|
94
|
+
});
|
|
95
|
+
};
|
|
70
96
|
|
|
71
97
|
return (
|
|
72
98
|
<div
|
|
73
|
-
className="my-2 overflow-hidden rounded-agent-lg border border-amber-400/50 bg-amber-400/5 not-italic dark:border-amber-500/30"
|
|
99
|
+
className="my-2.5 overflow-hidden rounded-agent-lg border border-amber-400/50 bg-amber-400/5 not-italic dark:border-amber-500/30"
|
|
74
100
|
data-testid="plan-todo-list"
|
|
75
101
|
>
|
|
76
102
|
<div className="flex items-center gap-2 border-b border-amber-400/30 bg-amber-400/10 px-3 py-2 dark:border-amber-500/20">
|
|
77
103
|
<LuListChecks className="h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400" />
|
|
78
|
-
<span className="flex-1 truncate text-[13px] font-semibold text-amber-
|
|
104
|
+
<span className="flex-1 truncate text-[13px] font-semibold text-amber-900 dark:text-amber-100">
|
|
79
105
|
{title || t('Execution plan')}
|
|
80
106
|
</span>
|
|
81
107
|
{items.length > 0 && (
|
|
@@ -83,36 +109,116 @@ export function PlanTodoList({ content }: { content: string }) {
|
|
|
83
109
|
{items.filter((i) => i.done).length}/{items.length}
|
|
84
110
|
</span>
|
|
85
111
|
)}
|
|
112
|
+
{markdown && (
|
|
113
|
+
<button
|
|
114
|
+
type="button"
|
|
115
|
+
onClick={handleCopy}
|
|
116
|
+
title={copied ? t('Copied') : t('Copy plan')}
|
|
117
|
+
aria-label={copied ? t('Copied') : t('Copy plan')}
|
|
118
|
+
data-testid="plan-copy"
|
|
119
|
+
className="inline-flex h-5 items-center gap-1 rounded px-1.5 text-[11px] text-amber-800/80 transition-colors hover:bg-amber-400/20 hover:text-amber-900 dark:text-amber-200/80 dark:hover:text-amber-100"
|
|
120
|
+
>
|
|
121
|
+
{copied ? (
|
|
122
|
+
<>
|
|
123
|
+
<LuCheck className="h-3 w-3 shrink-0" />
|
|
124
|
+
<span>{t('Copied')}</span>
|
|
125
|
+
</>
|
|
126
|
+
) : (
|
|
127
|
+
<>
|
|
128
|
+
<LuCopy className="h-3 w-3 shrink-0" />
|
|
129
|
+
<span className="hidden sm:inline">{t('Copy plan')}</span>
|
|
130
|
+
</>
|
|
131
|
+
)}
|
|
132
|
+
</button>
|
|
133
|
+
)}
|
|
86
134
|
</div>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
className=
|
|
98
|
-
item.done
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
135
|
+
|
|
136
|
+
{hasRichMarkdown && renderRichMarkdown && bodyMarkdown ? (
|
|
137
|
+
<div className="px-3 py-2.5 text-[12.5px] leading-relaxed text-agent-foreground [&_pre]:bg-agent-canvas/90">
|
|
138
|
+
{renderRichMarkdown(bodyMarkdown)}
|
|
139
|
+
</div>
|
|
140
|
+
) : (
|
|
141
|
+
<>
|
|
142
|
+
{items.length > 0 && (
|
|
143
|
+
<ol className="m-0 list-none space-y-1 px-3 py-2">
|
|
144
|
+
{items.map((item, idx) => (
|
|
145
|
+
<li key={idx} className="flex items-start gap-2 text-[13px] leading-relaxed">
|
|
146
|
+
{item.done ? (
|
|
147
|
+
<LuCircleCheck className="mt-[3px] h-3.5 w-3.5 shrink-0 text-amber-600 dark:text-amber-400" />
|
|
148
|
+
) : (
|
|
149
|
+
<LuCircle className="mt-[3px] h-3.5 w-3.5 shrink-0 text-amber-500/60" />
|
|
150
|
+
)}
|
|
151
|
+
<span
|
|
152
|
+
className={
|
|
153
|
+
item.done
|
|
154
|
+
? 'text-agent-muted-foreground line-through'
|
|
155
|
+
: 'text-agent-foreground'
|
|
156
|
+
}
|
|
157
|
+
>
|
|
158
|
+
{item.text}
|
|
159
|
+
</span>
|
|
160
|
+
</li>
|
|
161
|
+
))}
|
|
162
|
+
</ol>
|
|
163
|
+
)}
|
|
164
|
+
{notes.length > 0 && (
|
|
165
|
+
<div className="border-t border-amber-400/20 px-3 py-1.5 text-[12px] text-agent-muted-foreground">
|
|
166
|
+
{notes.map((note, idx) => (
|
|
167
|
+
<p key={idx} className="my-0.5">
|
|
168
|
+
{note}
|
|
169
|
+
</p>
|
|
170
|
+
))}
|
|
171
|
+
</div>
|
|
172
|
+
)}
|
|
173
|
+
</>
|
|
108
174
|
)}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
175
|
+
|
|
176
|
+
{showActionFooter && planActionCtx && currentMessageId && (
|
|
177
|
+
<div
|
|
178
|
+
className="flex flex-wrap items-center justify-between gap-2 border-t border-amber-400/30 bg-amber-400/10 px-3 py-2 text-xs dark:border-amber-500/20"
|
|
179
|
+
data-testid="plan-action-bar"
|
|
180
|
+
>
|
|
181
|
+
<div className="flex min-w-0 items-center gap-2 text-amber-800 dark:text-amber-200">
|
|
182
|
+
<span className="font-medium">
|
|
183
|
+
{t('Plan ready. How would you like to proceed?')}
|
|
184
|
+
</span>
|
|
185
|
+
{contextUsedPercent !== null && contextUsedPercent >= 25 && (
|
|
186
|
+
<span className="rounded-full bg-amber-400/20 px-1.5 py-0.5 text-[10px] text-amber-700 dark:text-amber-300">
|
|
187
|
+
{t('{percent}% context used', { percent: contextUsedPercent })}
|
|
188
|
+
</span>
|
|
189
|
+
)}
|
|
190
|
+
</div>
|
|
191
|
+
<div className="flex flex-wrap items-center gap-1.5">
|
|
192
|
+
<button
|
|
193
|
+
type="button"
|
|
194
|
+
onClick={() => planActionCtx.onDismiss(currentMessageId)}
|
|
195
|
+
className="rounded-full px-2.5 py-1 text-agent-muted-foreground transition-colors hover:bg-agent-foreground/5 hover:text-agent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50"
|
|
196
|
+
data-testid="plan-dismiss"
|
|
197
|
+
>
|
|
198
|
+
{t('Keep refining')}
|
|
199
|
+
</button>
|
|
200
|
+
{planActionCtx.onExecuteInFreshChat && markdown && (
|
|
201
|
+
<button
|
|
202
|
+
type="button"
|
|
203
|
+
onClick={() => planActionCtx.onExecuteInFreshChat?.(markdown)}
|
|
204
|
+
title={t('Start a fresh chat in Agent mode with only this approved plan')}
|
|
205
|
+
className="inline-flex items-center gap-1 rounded-full border border-amber-500/40 bg-agent-canvas/80 px-2.5 py-1 font-medium text-amber-800 transition-colors hover:bg-amber-400/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50 dark:border-amber-400/35 dark:text-amber-200"
|
|
206
|
+
data-testid="plan-execute-fresh"
|
|
207
|
+
>
|
|
208
|
+
<LuSquarePlus className="h-3.5 w-3.5 shrink-0" />
|
|
209
|
+
<span>{t('Execute in new chat')}</span>
|
|
210
|
+
</button>
|
|
211
|
+
)}
|
|
212
|
+
<button
|
|
213
|
+
type="button"
|
|
214
|
+
onClick={planActionCtx.onExecuteInPlace}
|
|
215
|
+
className="inline-flex items-center gap-1 rounded-full bg-agent-foreground px-3 py-1 font-medium text-agent-canvas transition hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50"
|
|
216
|
+
data-testid="plan-execute"
|
|
217
|
+
>
|
|
218
|
+
<span>{t('Execute plan')}</span>
|
|
219
|
+
<LuArrowRight className="h-3.5 w-3.5 shrink-0" />
|
|
220
|
+
</button>
|
|
221
|
+
</div>
|
|
116
222
|
</div>
|
|
117
223
|
)}
|
|
118
224
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
1
|
+
import { useEffect, useId, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
LuCircle,
|
|
4
4
|
LuCircleCheck,
|
|
@@ -6,9 +6,7 @@ import {
|
|
|
6
6
|
LuChevronDown,
|
|
7
7
|
LuListChecks,
|
|
8
8
|
LuLoaderCircle,
|
|
9
|
-
LuX,
|
|
10
9
|
} from 'react-icons/lu';
|
|
11
|
-
import { useExclusiveExpand } from './composer-status-stack';
|
|
12
10
|
import { t } from '@/i18n';
|
|
13
11
|
import {
|
|
14
12
|
summarizeTodos,
|
|
@@ -63,7 +61,7 @@ export function TodoItems({
|
|
|
63
61
|
}) {
|
|
64
62
|
return (
|
|
65
63
|
<ol
|
|
66
|
-
className={`m-0 list-none ${compact ? 'max-h-
|
|
64
|
+
className={`m-0 list-none ${compact ? 'max-h-52 space-y-1.5 overflow-y-auto px-3 py-2' : 'space-y-1 px-2.5 py-1.5'}`}
|
|
67
65
|
>
|
|
68
66
|
{todos.map((todo) => {
|
|
69
67
|
const done = todo.status === 'completed';
|
|
@@ -94,11 +92,28 @@ export function TodoItems({
|
|
|
94
92
|
);
|
|
95
93
|
}
|
|
96
94
|
|
|
97
|
-
export
|
|
95
|
+
export interface TurnTodoStripProps {
|
|
96
|
+
todos: SessionTodo[];
|
|
97
|
+
/** When false, renders standalone rounded corners (e.g. isolated tests). Defaults to true. */
|
|
98
|
+
attachedTop?: boolean;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Compact 28px single-line progress strip attached directly beneath the turn's
|
|
103
|
+
* sticky user prompt card. Always defaults to collapsed so streaming output is
|
|
104
|
+
* never occluded; clicking opens a downward step list dismissed via Escape or
|
|
105
|
+
* outside pointerdown in any status.
|
|
106
|
+
*/
|
|
107
|
+
export function TurnTodoStrip({
|
|
108
|
+
todos,
|
|
109
|
+
attachedTop = true,
|
|
110
|
+
}: TurnTodoStripProps) {
|
|
98
111
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
112
|
+
const panelId = useId();
|
|
113
|
+
const [expanded, setExpanded] = useState(false);
|
|
114
|
+
|
|
99
115
|
const current = useMemo(() => currentTodoStep(todos), [todos]);
|
|
100
116
|
const progressLabel = useMemo(() => todoProgressCopy(todos), [todos]);
|
|
101
|
-
|
|
102
117
|
const hasActive = useMemo(
|
|
103
118
|
() => todos.some((todo) => todo.status === 'in_progress'),
|
|
104
119
|
[todos],
|
|
@@ -108,83 +123,72 @@ export function SessionTodoList({ todos }: { todos: SessionTodo[] }) {
|
|
|
108
123
|
return summary.total > 0 && summary.completed === summary.total;
|
|
109
124
|
}, [todos]);
|
|
110
125
|
|
|
111
|
-
// 执行中默认展开,全部完成默认折叠;允许用户手动点击收起或展开。
|
|
112
|
-
// 与编排胶囊同列时,展开浮层互斥。
|
|
113
|
-
const [userToggled, setUserToggled] = useState<boolean | null>(null);
|
|
114
|
-
const desired = userToggled ?? hasActive;
|
|
115
|
-
const { expanded, requestOpen } = useExclusiveExpand('todos', desired);
|
|
116
|
-
|
|
117
|
-
// 当任务全部执行完毕时,自动收起为紧凑胶囊
|
|
118
|
-
useEffect(() => {
|
|
119
|
-
if (isAllCompleted) {
|
|
120
|
-
setUserToggled(false);
|
|
121
|
-
}
|
|
122
|
-
}, [isAllCompleted]);
|
|
123
|
-
|
|
124
|
-
// 当新出现执行中的任务时,恢复默认展开
|
|
125
126
|
useEffect(() => {
|
|
126
|
-
if (
|
|
127
|
-
setUserToggled(null);
|
|
128
|
-
}
|
|
129
|
-
}, [hasActive]);
|
|
130
|
-
|
|
131
|
-
// 任务全部完成后,如果展开了浮层,点击外部区域时自动收起
|
|
132
|
-
useEffect(() => {
|
|
133
|
-
if (!expanded || !isAllCompleted) return;
|
|
127
|
+
if (!expanded) return;
|
|
134
128
|
const handlePointerDown = (event: PointerEvent) => {
|
|
135
129
|
if (
|
|
136
130
|
containerRef.current &&
|
|
137
131
|
!containerRef.current.contains(event.target as Node)
|
|
138
132
|
) {
|
|
139
|
-
|
|
133
|
+
setExpanded(false);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
137
|
+
if (event.key === 'Escape') {
|
|
138
|
+
event.preventDefault();
|
|
139
|
+
event.stopPropagation();
|
|
140
|
+
setExpanded(false);
|
|
140
141
|
}
|
|
141
142
|
};
|
|
142
143
|
document.addEventListener('pointerdown', handlePointerDown);
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
145
|
+
return () => {
|
|
146
|
+
document.removeEventListener('pointerdown', handlePointerDown);
|
|
147
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
148
|
+
};
|
|
149
|
+
}, [expanded]);
|
|
150
|
+
|
|
151
|
+
const shapeClass = attachedTop
|
|
152
|
+
? 'rounded-b-agent-lg border border-t-0 border-agent-border/80'
|
|
153
|
+
: 'rounded-agent-lg border border-agent-border/80';
|
|
154
|
+
|
|
155
|
+
const toneClass = isAllCompleted
|
|
156
|
+
? 'bg-emerald-500/[0.06] text-emerald-700 dark:text-emerald-300 hover:bg-emerald-500/[0.10]'
|
|
157
|
+
: hasActive
|
|
158
|
+
? 'bg-blue-500/[0.06] text-blue-700 dark:text-blue-300 hover:bg-blue-500/[0.11]'
|
|
159
|
+
: 'bg-agent-canvas/90 text-agent-muted-foreground hover:bg-agent-muted/60 hover:text-agent-foreground';
|
|
145
160
|
|
|
146
161
|
return (
|
|
147
162
|
<div
|
|
148
163
|
ref={containerRef}
|
|
149
|
-
className="relative
|
|
164
|
+
className="relative w-full"
|
|
150
165
|
data-testid="session-todo-list"
|
|
151
166
|
>
|
|
152
167
|
<button
|
|
153
168
|
type="button"
|
|
154
|
-
onClick={() =>
|
|
155
|
-
if (expanded) setUserToggled(false);
|
|
156
|
-
else {
|
|
157
|
-
setUserToggled(true);
|
|
158
|
-
requestOpen();
|
|
159
|
-
}
|
|
160
|
-
}}
|
|
161
|
-
className={[
|
|
162
|
-
'flex h-6 max-w-[240px] sm:max-w-[320px] items-center gap-1.5 rounded-full px-2 text-left text-[11px] transition-all duration-200 select-none shadow-2xs',
|
|
163
|
-
isAllCompleted
|
|
164
|
-
? 'border border-emerald-500/25 bg-emerald-500/[0.04] text-emerald-700 dark:text-emerald-300 hover:bg-emerald-500/[0.08]'
|
|
165
|
-
: hasActive
|
|
166
|
-
? 'border border-blue-500/30 bg-blue-500/[0.06] text-blue-700 dark:text-blue-300 hover:bg-blue-500/10'
|
|
167
|
-
: 'border border-agent-border/80 bg-agent-canvas text-agent-muted-foreground hover:bg-agent-foreground/5 hover:text-agent-foreground',
|
|
168
|
-
].join(' ')}
|
|
169
|
+
onClick={() => setExpanded((prev) => !prev)}
|
|
169
170
|
aria-expanded={expanded}
|
|
171
|
+
aria-controls={expanded ? panelId : undefined}
|
|
172
|
+
title={expanded ? t('Hide task steps') : t('Show task steps')}
|
|
173
|
+
className={`flex h-7 w-full cursor-pointer items-center gap-2 px-3 text-left text-[11px] select-none transition-colors ${shapeClass} ${toneClass}`}
|
|
170
174
|
>
|
|
171
175
|
{isAllCompleted ? (
|
|
172
176
|
<LuCircleCheck className="h-3.5 w-3.5 shrink-0 text-emerald-600 dark:text-emerald-400" />
|
|
173
177
|
) : hasActive ? (
|
|
174
178
|
<LuLoaderCircle className="h-3.5 w-3.5 shrink-0 animate-spin text-blue-600 dark:text-blue-400" />
|
|
175
|
-
) : current ? (
|
|
176
|
-
<StatusIcon status={current.status} />
|
|
177
179
|
) : (
|
|
178
|
-
<LuListChecks className="h-3.5 w-3.5 shrink-0 text-agent-foreground" />
|
|
180
|
+
<LuListChecks className="h-3.5 w-3.5 shrink-0 text-agent-muted-foreground" />
|
|
179
181
|
)}
|
|
180
182
|
<span className="min-w-0 flex-1 truncate font-medium">
|
|
181
|
-
{isAllCompleted
|
|
183
|
+
{isAllCompleted
|
|
184
|
+
? t('All tasks completed')
|
|
185
|
+
: (current?.content ?? t('Task list'))}
|
|
182
186
|
</span>
|
|
183
187
|
{progressLabel ? (
|
|
184
188
|
<span
|
|
185
|
-
className={`shrink-0 rounded-full px-1.5 py-0.
|
|
189
|
+
className={`shrink-0 rounded-full px-1.5 py-0.5 font-mono text-[10px] font-medium tabular-nums leading-none ${
|
|
186
190
|
isAllCompleted
|
|
187
|
-
? 'bg-emerald-500/
|
|
191
|
+
? 'bg-emerald-500/12 text-emerald-700 dark:text-emerald-300'
|
|
188
192
|
: hasActive
|
|
189
193
|
? 'bg-blue-500/15 text-blue-700 dark:text-blue-300'
|
|
190
194
|
: 'bg-agent-muted text-agent-muted-foreground'
|
|
@@ -203,25 +207,11 @@ export function SessionTodoList({ todos }: { todos: SessionTodo[] }) {
|
|
|
203
207
|
|
|
204
208
|
{expanded && (
|
|
205
209
|
<div
|
|
206
|
-
|
|
210
|
+
id={panelId}
|
|
211
|
+
role="region"
|
|
212
|
+
aria-label={t('Task list')}
|
|
213
|
+
className="absolute left-0 right-0 top-full z-30 mt-1 overflow-hidden rounded-agent-lg border border-agent-border bg-agent-canvas/98 shadow-lg backdrop-blur-md animate-in fade-in slide-in-from-top-1 duration-150"
|
|
207
214
|
>
|
|
208
|
-
<div className="flex items-center justify-between border-b border-agent-border/60 bg-agent-muted/30 px-2.5 py-1.5">
|
|
209
|
-
<div className="flex items-center gap-1.5 text-[11px] font-medium text-agent-foreground">
|
|
210
|
-
<LuListChecks className="h-3.5 w-3.5 text-agent-foreground" />
|
|
211
|
-
<span>{t('Task list')}</span>
|
|
212
|
-
</div>
|
|
213
|
-
<div className="flex items-center gap-1.5">
|
|
214
|
-
<button
|
|
215
|
-
type="button"
|
|
216
|
-
onClick={() => setUserToggled(false)}
|
|
217
|
-
className="flex h-5 w-5 items-center justify-center rounded text-agent-muted-foreground transition-colors hover:bg-agent-foreground/10 hover:text-agent-foreground"
|
|
218
|
-
title={t('Collapse list')}
|
|
219
|
-
aria-label={t('Collapse list')}
|
|
220
|
-
>
|
|
221
|
-
<LuX className="h-3 w-3" />
|
|
222
|
-
</button>
|
|
223
|
-
</div>
|
|
224
|
-
</div>
|
|
225
215
|
<TodoItems todos={todos} compact />
|
|
226
216
|
</div>
|
|
227
217
|
)}
|
|
@@ -229,5 +219,6 @@ export function SessionTodoList({ todos }: { todos: SessionTodo[] }) {
|
|
|
229
219
|
);
|
|
230
220
|
}
|
|
231
221
|
|
|
232
|
-
export
|
|
222
|
+
export const SessionTodoList = TurnTodoStrip;
|
|
233
223
|
|
|
224
|
+
export default TurnTodoStrip;
|