kaizen-agent 1.87.4 → 1.88.1
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/cli/activity.ts +2 -1
- package/cli/state.ts +15 -0
- package/cli/task-service.ts +23 -6
- package/cli/tasks.ts +4 -3
- package/cli/whats-new.json +26 -0
- package/package.json +1 -1
- package/web/components/decision/decision-bar.tsx +77 -26
- package/web/components/decision/index.ts +1 -0
- package/web/components/decision/plan-text.tsx +17 -0
- package/web/components/phone/phone-home.tsx +19 -14
- package/web/components/rail/rail-list.tsx +27 -4
- package/web/components/shared/action-menu.tsx +19 -2
- package/web/components/shared/index.ts +1 -0
- package/web/components/shared/panel-frame.tsx +212 -0
- package/web/components/shell/rail.tsx +5 -3
- package/web/components/task/agent-chip.tsx +56 -0
- package/web/components/task/agent-mark.tsx +34 -0
- package/web/components/task/changes-view.tsx +26 -0
- package/web/components/task/chat-bubble.tsx +8 -3
- package/web/components/task/composer.tsx +78 -0
- package/web/components/task/conversation.tsx +65 -0
- package/web/components/task/index.ts +12 -0
- package/web/components/task/plan-view.tsx +50 -0
- package/web/components/task/reference-files.tsx +24 -0
- package/web/components/task/result-view.tsx +3 -1
- package/web/components/task/review-view.tsx +40 -0
- package/web/components/task/saved-results.tsx +38 -0
- package/web/components/task/task-panel.tsx +143 -0
- package/web/components/task/task-phone.tsx +211 -0
- package/web/components/task/task-row.tsx +2 -2
- package/web/components/task/task-tabs.tsx +77 -0
- package/web/dist/annotate.js +1 -1
- package/web/dist/board.css +7 -5
- package/web/dist/board.js +59 -58
- package/web/dist/boot.js +1 -1
- package/web/dist/notebook.css +2 -2
- package/web/dist/notebook.js +33 -32
- package/web/dist/popup.css +1 -1
- package/web/dist/popup.js +1 -1
- package/web/dist/term.js +1 -1
- package/web/dist/ui.css +2 -2
- package/web/dist/video.js +18 -18
- package/web/lib/core/index.ts +1 -0
- package/web/lib/core/use-phone.ts +15 -0
- package/web/lib/router/route-rules.ts +17 -4
- package/web/lib/server/types.ts +1 -0
- package/web/lib/task/conversation.ts +56 -0
- package/web/lib/task/index.ts +5 -0
- package/web/lib/task/task-progress.ts +21 -0
- package/web/lib/task/task-tabs.ts +29 -0
- package/web/lib/task/tasks.ts +40 -1
- package/web/lib/task/use-task-page.ts +123 -0
- package/web/lib/task/use-task-run.ts +50 -0
- package/web/pages/board/panel.tsx +99 -4
- package/web/pages/task-page.tsx +319 -350
- package/web/ui/legacy/board.css +5 -3
- package/web/ui/theme.css +4 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import type { ReactNode, Ref } from "react";
|
|
2
|
+
import { cn } from "@lib/core";
|
|
3
|
+
import { Icon } from "@web/ui";
|
|
4
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@web/ui";
|
|
5
|
+
|
|
6
|
+
// The frame of a side panel, the same for the task page's conversation and, later, the run workspace's panel: a header
|
|
7
|
+
// block, a body, a foot, and a strip of icon buttons down the right edge. Folded, only the strip is left.
|
|
8
|
+
export function PanelFrame({
|
|
9
|
+
header,
|
|
10
|
+
body,
|
|
11
|
+
foot,
|
|
12
|
+
strip,
|
|
13
|
+
folded,
|
|
14
|
+
label,
|
|
15
|
+
className,
|
|
16
|
+
id,
|
|
17
|
+
rootRef,
|
|
18
|
+
flush,
|
|
19
|
+
extra,
|
|
20
|
+
as: Root = "div",
|
|
21
|
+
hidden,
|
|
22
|
+
}: {
|
|
23
|
+
header: ReactNode;
|
|
24
|
+
body: ReactNode;
|
|
25
|
+
foot?: ReactNode;
|
|
26
|
+
strip: ReactNode;
|
|
27
|
+
folded?: boolean;
|
|
28
|
+
label: string;
|
|
29
|
+
className?: string;
|
|
30
|
+
id?: string;
|
|
31
|
+
rootRef?: Ref<HTMLDivElement>;
|
|
32
|
+
// The body and the foot bring their own padding and scrolling (the run workspace's own elements do); the frame only places them.
|
|
33
|
+
flush?: boolean;
|
|
34
|
+
// Drawn inside the frame, on top of it: the run workspace's resize grip.
|
|
35
|
+
extra?: ReactNode;
|
|
36
|
+
// The run workspace keeps an <aside>: the board's old rules for a panel's inside (its body, footer, tabs) hang off it.
|
|
37
|
+
as?: "div" | "aside";
|
|
38
|
+
// No panel to show (the run workspace with no run): not drawn. `!hidden` because the frame's own display utility would otherwise win.
|
|
39
|
+
hidden?: boolean;
|
|
40
|
+
}) {
|
|
41
|
+
return (
|
|
42
|
+
<Root
|
|
43
|
+
id={id}
|
|
44
|
+
ref={rootRef as never}
|
|
45
|
+
role="complementary"
|
|
46
|
+
aria-label={label}
|
|
47
|
+
// The run workspace panel's metrics, from the tokens in board.css (--panel-*): its width is the one the board
|
|
48
|
+
// remembers (--rpanel-w), the strip, the canvas colour and no border.
|
|
49
|
+
style={folded ? undefined : { width: "var(--rpanel-w, var(--panel-w))" }}
|
|
50
|
+
className={cn(
|
|
51
|
+
"relative grid min-h-0 flex-none grid-rows-[auto_minmax(0,1fr)_auto] bg-canvas transition-[width] duration-300 motion-reduce:transition-none",
|
|
52
|
+
folded
|
|
53
|
+
? "w-[var(--panel-strip)] grid-cols-[var(--panel-strip)]"
|
|
54
|
+
: "grid-cols-[minmax(0,1fr)_var(--panel-strip)] max-md:!w-full",
|
|
55
|
+
hidden && "!hidden",
|
|
56
|
+
className,
|
|
57
|
+
)}
|
|
58
|
+
>
|
|
59
|
+
{!folded && (
|
|
60
|
+
<div
|
|
61
|
+
className="col-start-1 row-start-1 min-w-0 px-[var(--panel-pad-x)] pb-[var(--panel-head-bot)] pt-[var(--panel-head-top)]"
|
|
62
|
+
// The desktop app's window controls overlay the top right of the run workspace: keep clear of them (--wco, --wch are set there).
|
|
63
|
+
style={flush ? { paddingRight: "calc(var(--panel-pad-x) + var(--wco, 0px))" } : undefined}
|
|
64
|
+
>
|
|
65
|
+
{header}
|
|
66
|
+
</div>
|
|
67
|
+
)}
|
|
68
|
+
<div
|
|
69
|
+
className={cn(
|
|
70
|
+
"row-span-3 row-start-1 flex flex-col items-center pt-2.5",
|
|
71
|
+
folded ? "col-start-1" : "col-start-2",
|
|
72
|
+
)}
|
|
73
|
+
// Window controls overlay the top right of the desktop app (--wch is their height there).
|
|
74
|
+
style={flush ? { paddingTop: "calc(10px + var(--wch, 0px))" } : undefined}
|
|
75
|
+
>
|
|
76
|
+
{strip}
|
|
77
|
+
</div>
|
|
78
|
+
{!folded && (
|
|
79
|
+
<div
|
|
80
|
+
className={cn(
|
|
81
|
+
"col-start-1 row-start-2 min-h-0 min-w-0",
|
|
82
|
+
flush
|
|
83
|
+
? "flex flex-col overflow-hidden"
|
|
84
|
+
: "overflow-auto px-[var(--panel-pad-x)] pb-[var(--panel-body-bot)] pt-[var(--panel-body-top)]",
|
|
85
|
+
)}
|
|
86
|
+
>
|
|
87
|
+
{body}
|
|
88
|
+
</div>
|
|
89
|
+
)}
|
|
90
|
+
{!folded && foot && (
|
|
91
|
+
<div
|
|
92
|
+
className={cn(
|
|
93
|
+
"col-start-1 row-start-3 min-w-0",
|
|
94
|
+
!flush && "px-[var(--panel-pad-x)] py-[var(--panel-foot-y)]",
|
|
95
|
+
)}
|
|
96
|
+
>
|
|
97
|
+
{foot}
|
|
98
|
+
</div>
|
|
99
|
+
)}
|
|
100
|
+
{extra}
|
|
101
|
+
</Root>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
export type PanelStripItem = { id: string; icon: string; label: string; sprite?: "i" | "t" | "r"; dot?: boolean };
|
|
105
|
+
// The icon strip: one button per view. Pressing the open view folds the panel; pressing another opens it on that view.
|
|
106
|
+
export function PanelStrip({
|
|
107
|
+
items,
|
|
108
|
+
active,
|
|
109
|
+
folded,
|
|
110
|
+
onPick,
|
|
111
|
+
}: {
|
|
112
|
+
items: PanelStripItem[];
|
|
113
|
+
active: string;
|
|
114
|
+
folded?: boolean;
|
|
115
|
+
onPick: (id: string) => void;
|
|
116
|
+
}) {
|
|
117
|
+
return (
|
|
118
|
+
<div className="flex flex-col items-center gap-0.5">
|
|
119
|
+
{items.map((it) => (
|
|
120
|
+
<button
|
|
121
|
+
key={it.id}
|
|
122
|
+
type="button"
|
|
123
|
+
title={folded || it.id !== active ? it.label : `Hide the panel`}
|
|
124
|
+
aria-label={it.label}
|
|
125
|
+
aria-pressed={!folded && it.id === active}
|
|
126
|
+
onClick={() => onPick(it.id)}
|
|
127
|
+
className={cn(
|
|
128
|
+
"relative grid size-8 place-items-center rounded-sm text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
129
|
+
!folded && it.id === active && "bg-muted text-foreground",
|
|
130
|
+
)}
|
|
131
|
+
>
|
|
132
|
+
<Icon sprite={it.sprite ?? "t"} name={it.icon} className="size-[17px]" />
|
|
133
|
+
{it.dot && (
|
|
134
|
+
<i className="absolute right-[5px] top-[5px] size-2 rounded-full bg-warning shadow-[0_0_0_2px_var(--bg)]" />
|
|
135
|
+
)}
|
|
136
|
+
</button>
|
|
137
|
+
))}
|
|
138
|
+
</div>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
// The thin bar under the title: how far along, with the stage word in the colour of what it means.
|
|
142
|
+
export function PanelProgress({
|
|
143
|
+
word,
|
|
144
|
+
pct,
|
|
145
|
+
tone,
|
|
146
|
+
}: {
|
|
147
|
+
word: string;
|
|
148
|
+
pct: number;
|
|
149
|
+
tone: "wait" | "run" | "ok" | "idle";
|
|
150
|
+
}) {
|
|
151
|
+
const c = tone === "wait" ? "text-warning" : tone === "ok" ? "text-success" : "text-muted-foreground",
|
|
152
|
+
bar = tone === "wait" ? "bg-warning" : tone === "ok" ? "bg-success" : "bg-muted-foreground";
|
|
153
|
+
return (
|
|
154
|
+
<div role="status" className={cn("flex min-w-0 flex-1 items-center gap-2 text-xs", c)}>
|
|
155
|
+
<span className="shrink-0 whitespace-nowrap">{word}</span>
|
|
156
|
+
<span
|
|
157
|
+
role="progressbar"
|
|
158
|
+
aria-label="Progress"
|
|
159
|
+
aria-valuenow={pct}
|
|
160
|
+
aria-valuemin={0}
|
|
161
|
+
aria-valuemax={100}
|
|
162
|
+
className="h-[3px] min-w-0 flex-1 overflow-hidden rounded-sm bg-border"
|
|
163
|
+
>
|
|
164
|
+
<i
|
|
165
|
+
className={cn("block h-full rounded-sm transition-[width] duration-500 motion-reduce:transition-none", bar)}
|
|
166
|
+
style={{ width: pct + "%" }}
|
|
167
|
+
/>
|
|
168
|
+
</span>
|
|
169
|
+
</div>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
export type PanelPickItem = { id: string; label: string; hint?: string; mark?: ReactNode };
|
|
173
|
+
// The title as a picker: a dropdown of the other items of the same kind (tasks of a project), a mark in front.
|
|
174
|
+
export function PanelPicker({
|
|
175
|
+
current,
|
|
176
|
+
mark,
|
|
177
|
+
items,
|
|
178
|
+
onPick,
|
|
179
|
+
}: {
|
|
180
|
+
current: string;
|
|
181
|
+
mark?: ReactNode;
|
|
182
|
+
items: PanelPickItem[];
|
|
183
|
+
onPick: (id: string) => void;
|
|
184
|
+
}) {
|
|
185
|
+
return (
|
|
186
|
+
<DropdownMenu>
|
|
187
|
+
<DropdownMenuTrigger asChild>
|
|
188
|
+
<button
|
|
189
|
+
type="button"
|
|
190
|
+
title="Choose another"
|
|
191
|
+
className="-ml-2 flex min-h-[30px] w-full items-center gap-2 rounded-sm px-2 text-foreground hover:bg-muted [&[aria-expanded=true]_svg:last-child]:rotate-180"
|
|
192
|
+
>
|
|
193
|
+
{mark}
|
|
194
|
+
<b className="min-w-0 flex-1 truncate text-left text-sm font-medium leading-[1.4]">{current}</b>
|
|
195
|
+
<Icon name="chev" className="size-3 shrink-0 text-muted-foreground transition-transform" />
|
|
196
|
+
</button>
|
|
197
|
+
</DropdownMenuTrigger>
|
|
198
|
+
<DropdownMenuContent
|
|
199
|
+
align="start"
|
|
200
|
+
className="max-h-[min(60vh,420px)] w-(--radix-dropdown-menu-trigger-width) min-w-[260px] overflow-y-auto"
|
|
201
|
+
>
|
|
202
|
+
{items.map((it) => (
|
|
203
|
+
<DropdownMenuItem key={it.id} onSelect={() => onPick(it.id)} className="min-h-[30px] gap-2 text-sm">
|
|
204
|
+
{it.mark}
|
|
205
|
+
<b className="min-w-0 flex-1 truncate font-medium text-foreground">{it.label}</b>
|
|
206
|
+
{it.hint && <small className="max-w-[40%] shrink truncate text-xs text-muted-foreground">{it.hint}</small>}
|
|
207
|
+
</DropdownMenuItem>
|
|
208
|
+
))}
|
|
209
|
+
</DropdownMenuContent>
|
|
210
|
+
</DropdownMenu>
|
|
211
|
+
);
|
|
212
|
+
}
|
|
@@ -113,9 +113,11 @@ export function Rail(p: { srcs?: ReactNode; before?: ReactNode }) {
|
|
|
113
113
|
className="it ponly"
|
|
114
114
|
href="/?view=device"
|
|
115
115
|
view="device"
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
n={need}
|
|
117
|
+
title={tasksTitle}
|
|
118
|
+
aria={known ? tasksTitle : undefined}
|
|
119
|
+
label="Tasks"
|
|
120
|
+
icon="r-bulb"
|
|
119
121
|
/>
|
|
120
122
|
<Item
|
|
121
123
|
className="it ponly"
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { agentName, type TaskAgent } from "@lib/task";
|
|
2
|
+
import { Popover, PopoverContent, PopoverTrigger } from "@web/ui";
|
|
3
|
+
import { AgentMark } from "./agent-mark.tsx";
|
|
4
|
+
|
|
5
|
+
const VERB: Record<string, string> = { explore: "exploring", plan: "planning", build: "building", review: "reviewing" };
|
|
6
|
+
const STATE = { working: "working", stopped: "stopped", done: "done" } as const;
|
|
7
|
+
|
|
8
|
+
// Who is on this task. The agent working now stands in front with a ring and says what it is doing; the others step
|
|
9
|
+
// back. Pressing it lists every agent on the task and what each is doing. Nothing when no run has an agent yet.
|
|
10
|
+
export function AgentChip({ agents, stage }: { agents: TaskAgent[]; stage?: string }) {
|
|
11
|
+
if (!agents.length) return null;
|
|
12
|
+
const cur = agents.find((a) => a.current) ?? agents[agents.length - 1],
|
|
13
|
+
shown = [cur, ...agents.filter((a) => a !== cur)].slice(0, 3),
|
|
14
|
+
word = cur.state === "working" ? (VERB[stage ?? ""] ?? "working") : cur.state === "stopped" ? "stopped" : "done";
|
|
15
|
+
const label = cur.current ? agentName(cur.agent) : agents.map((a) => a.name || agentName(a.agent)).join(" and ");
|
|
16
|
+
return (
|
|
17
|
+
<Popover>
|
|
18
|
+
<PopoverTrigger asChild>
|
|
19
|
+
<button
|
|
20
|
+
type="button"
|
|
21
|
+
aria-label={`Agents on this task: ${agents.map((a) => `${a.name} ${STATE[a.state]}`).join(", ")}`}
|
|
22
|
+
className="flex min-w-0 items-center gap-2 rounded-full py-1 pl-1.5 pr-2.5 text-sm hover:bg-muted"
|
|
23
|
+
>
|
|
24
|
+
<span className="flex shrink-0 gap-1">
|
|
25
|
+
{shown.map((a) => (
|
|
26
|
+
<AgentMark
|
|
27
|
+
key={a.agent}
|
|
28
|
+
agent={a.agent}
|
|
29
|
+
live={a.state === "working"}
|
|
30
|
+
dim={a !== cur && agents.length > 1 && cur.state === "working"}
|
|
31
|
+
/>
|
|
32
|
+
))}
|
|
33
|
+
</span>
|
|
34
|
+
<span className="truncate">
|
|
35
|
+
<span className="font-medium text-strong">{label}</span>
|
|
36
|
+
<span className="text-muted-foreground"> · {word}</span>
|
|
37
|
+
</span>
|
|
38
|
+
<span aria-hidden="true" className="text-[10px] text-muted-foreground">
|
|
39
|
+
▾
|
|
40
|
+
</span>
|
|
41
|
+
</button>
|
|
42
|
+
</PopoverTrigger>
|
|
43
|
+
<PopoverContent align="start" className="w-[280px]">
|
|
44
|
+
{agents.map((a) => (
|
|
45
|
+
<div key={a.agent} className="flex items-center gap-2.5 rounded-sm px-2 py-2">
|
|
46
|
+
<AgentMark agent={a.agent} live={a.state === "working"} />
|
|
47
|
+
<span className="min-w-0 flex-1 truncate font-medium text-strong">{a.name || agentName(a.agent)}</span>
|
|
48
|
+
<span className={a.state === "working" ? "text-sm text-success" : "text-sm text-muted-foreground"}>
|
|
49
|
+
{a.state === "working" ? (VERB[stage ?? ""] ?? "working") : STATE[a.state]}
|
|
50
|
+
</span>
|
|
51
|
+
</div>
|
|
52
|
+
))}
|
|
53
|
+
</PopoverContent>
|
|
54
|
+
</Popover>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { cn } from "@lib/core";
|
|
2
|
+
import { agentMark } from "@lib/phone";
|
|
3
|
+
import { Icon } from "@web/ui";
|
|
4
|
+
|
|
5
|
+
// An agent's own mark in a quiet circle. `live` turns a ring around it while that agent works; `dim` steps one that
|
|
6
|
+
// has handed over to the back.
|
|
7
|
+
export function AgentMark({
|
|
8
|
+
agent,
|
|
9
|
+
size = "md",
|
|
10
|
+
live,
|
|
11
|
+
dim,
|
|
12
|
+
className,
|
|
13
|
+
}: {
|
|
14
|
+
agent: string;
|
|
15
|
+
size?: "sm" | "md";
|
|
16
|
+
live?: boolean;
|
|
17
|
+
dim?: boolean;
|
|
18
|
+
className?: string;
|
|
19
|
+
}) {
|
|
20
|
+
return (
|
|
21
|
+
<span
|
|
22
|
+
className={cn(
|
|
23
|
+
"relative grid shrink-0 place-items-center rounded-full bg-muted transition-opacity",
|
|
24
|
+
size === "sm" ? "size-5" : "size-6",
|
|
25
|
+
dim && "opacity-45",
|
|
26
|
+
live &&
|
|
27
|
+
"before:absolute before:-inset-[3px] before:rounded-full before:border-[1.5px] before:border-success/25 after:absolute after:-inset-[3px] after:rounded-full after:border-[1.5px] after:border-transparent after:border-t-success motion-safe:after:animate-spin",
|
|
28
|
+
className,
|
|
29
|
+
)}
|
|
30
|
+
>
|
|
31
|
+
<Icon name={agentMark(agent)} className={size === "sm" ? "size-3" : "size-3.5"} />
|
|
32
|
+
</span>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { RunDoc } from "@lib/task";
|
|
2
|
+
|
|
3
|
+
// The files the task's run changed, with how much each changed. Read-only: committing and pushing live in the run workspace.
|
|
4
|
+
export function ChangesView({ run, workspace }: { run: RunDoc | null; workspace?: string }) {
|
|
5
|
+
if (!run?.files.length) return <p className="p-2 text-muted-foreground">No changed files yet.</p>;
|
|
6
|
+
return (
|
|
7
|
+
<div className="flex flex-col gap-3">
|
|
8
|
+
<ul aria-label="Changed files" className="overflow-hidden rounded-lg border border-border bg-card">
|
|
9
|
+
{run.files.map((f) => (
|
|
10
|
+
<li key={f.path} className="flex items-baseline gap-3 border-b border-border px-3 py-2 last:border-b-0">
|
|
11
|
+
<code className="min-w-0 flex-1 truncate font-mono text-sm" title={f.path}>
|
|
12
|
+
{f.path}
|
|
13
|
+
</code>
|
|
14
|
+
{f.add > 0 && <span className="text-sm text-success">+{f.add}</span>}
|
|
15
|
+
{f.del > 0 && <span className="text-sm text-danger">−{f.del}</span>}
|
|
16
|
+
</li>
|
|
17
|
+
))}
|
|
18
|
+
</ul>
|
|
19
|
+
{workspace && (
|
|
20
|
+
<a href={workspace} className="text-sm text-muted-foreground underline">
|
|
21
|
+
Open in the run workspace
|
|
22
|
+
</a>
|
|
23
|
+
)}
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
import { cn } from "@lib/core";
|
|
3
|
+
import { AgentMark } from "./agent-mark.tsx";
|
|
3
4
|
|
|
4
|
-
// One message: who and when above, the text in a bubble.
|
|
5
|
+
// One message: who and when above, the text in a bubble. An agent's message carries its agent's mark and name. A long
|
|
6
|
+
// message shows its first lines and "Show more".
|
|
5
7
|
export function ChatBubble({
|
|
6
8
|
from,
|
|
7
9
|
name,
|
|
8
10
|
at,
|
|
9
11
|
text,
|
|
12
|
+
agent,
|
|
10
13
|
}: {
|
|
11
14
|
from: "user" | "agent";
|
|
12
15
|
name: string;
|
|
13
16
|
at?: number | string;
|
|
14
17
|
text: string;
|
|
18
|
+
agent?: string;
|
|
15
19
|
}) {
|
|
16
20
|
const [open, setOpen] = useState(false);
|
|
17
21
|
const long = text.length > 320 && !open;
|
|
@@ -20,14 +24,15 @@ export function ChatBubble({
|
|
|
20
24
|
<article
|
|
21
25
|
className={cn("flex max-w-[88%] flex-col gap-[3px]", user ? "items-end self-end" : "items-start self-start")}
|
|
22
26
|
>
|
|
23
|
-
<div className={cn("flex items-
|
|
27
|
+
<div className={cn("flex items-center gap-1.5 px-1 text-xs text-muted-foreground", user && "flex-row-reverse")}>
|
|
28
|
+
{agent && <AgentMark agent={agent} size="sm" className="size-4 bg-transparent [&_svg]:size-3" />}
|
|
24
29
|
<strong className="font-medium">{name}</strong>
|
|
25
30
|
{at ? <time>{new Date(at).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}</time> : null}
|
|
26
31
|
</div>
|
|
27
32
|
<div
|
|
28
33
|
className={cn(
|
|
29
34
|
"whitespace-pre-wrap break-words rounded-[14px] px-3 py-2 text-base leading-[1.45]",
|
|
30
|
-
user ? "rounded-br-xs bg-
|
|
35
|
+
user ? "rounded-br-xs bg-muted" : "rounded-bl-xs border border-border bg-card",
|
|
31
36
|
)}
|
|
32
37
|
>
|
|
33
38
|
{long ? (
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
|
+
import { cn } from "@lib/core";
|
|
3
|
+
import { Icon, Textarea } from "@web/ui";
|
|
4
|
+
|
|
5
|
+
// The one message box: a rounded field and a round send button. Enter sends and Shift+Enter adds a line, except on a
|
|
6
|
+
// phone, where Enter stays a new line. `help` is read to a screen reader, `receipt` is the server's answer to the send.
|
|
7
|
+
export function Composer({
|
|
8
|
+
inputRef,
|
|
9
|
+
value,
|
|
10
|
+
onChange,
|
|
11
|
+
onSend,
|
|
12
|
+
pending,
|
|
13
|
+
answering,
|
|
14
|
+
help,
|
|
15
|
+
receipt,
|
|
16
|
+
className,
|
|
17
|
+
}: {
|
|
18
|
+
inputRef: RefObject<HTMLTextAreaElement | null>;
|
|
19
|
+
value: string;
|
|
20
|
+
onChange: (text: string) => void;
|
|
21
|
+
onSend: () => void;
|
|
22
|
+
pending?: boolean;
|
|
23
|
+
answering?: boolean;
|
|
24
|
+
help: string;
|
|
25
|
+
receipt?: string;
|
|
26
|
+
className?: string;
|
|
27
|
+
}) {
|
|
28
|
+
const label = pending ? "Sending…" : answering ? "Send answer" : "Send";
|
|
29
|
+
return (
|
|
30
|
+
<form
|
|
31
|
+
className={cn("flex-none", className)}
|
|
32
|
+
onSubmit={(e) => {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
onSend();
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
<div className="flex items-end gap-2 rounded-[22px] border border-border bg-card py-1.5 pl-4 pr-1.5 shadow-sm focus-within:border-muted-foreground">
|
|
38
|
+
<Textarea
|
|
39
|
+
ref={inputRef}
|
|
40
|
+
rows={1}
|
|
41
|
+
aria-label="Your message"
|
|
42
|
+
aria-describedby="task-composer-help"
|
|
43
|
+
placeholder="Message the agent"
|
|
44
|
+
title="Enter to send, Shift+Enter for a new line"
|
|
45
|
+
value={value}
|
|
46
|
+
onChange={(e) => onChange(e.target.value)}
|
|
47
|
+
onKeyDown={(e) => {
|
|
48
|
+
if (
|
|
49
|
+
e.key === "Enter" &&
|
|
50
|
+
!e.shiftKey &&
|
|
51
|
+
!e.nativeEvent.isComposing &&
|
|
52
|
+
!matchMedia("(pointer:coarse)").matches
|
|
53
|
+
) {
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
onSend();
|
|
56
|
+
}
|
|
57
|
+
}}
|
|
58
|
+
className="max-h-[140px] min-h-[28px] min-w-0 flex-1 py-1 [field-sizing:content]"
|
|
59
|
+
/>
|
|
60
|
+
<button
|
|
61
|
+
type="submit"
|
|
62
|
+
aria-label={label}
|
|
63
|
+
title={label}
|
|
64
|
+
disabled={pending}
|
|
65
|
+
className="grid size-8 shrink-0 place-items-center rounded-full bg-primary text-primary-foreground transition-opacity disabled:opacity-50"
|
|
66
|
+
>
|
|
67
|
+
<Icon name="send" className="size-4" />
|
|
68
|
+
</button>
|
|
69
|
+
</div>
|
|
70
|
+
<p id="task-composer-help" className="sr-only">
|
|
71
|
+
{help}
|
|
72
|
+
</p>
|
|
73
|
+
<p role="status" className={cn("mx-0.5 mt-1.5 text-sm text-muted-foreground", !receipt && "hidden")}>
|
|
74
|
+
{receipt}
|
|
75
|
+
</p>
|
|
76
|
+
</form>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { cn } from "@lib/core";
|
|
2
|
+
import { agentName, type ConversationItem } from "@lib/task";
|
|
3
|
+
import { AgentMark } from "./agent-mark.tsx";
|
|
4
|
+
import { ChatBubble } from "./chat-bubble.tsx";
|
|
5
|
+
import { TypingDots } from "./typing-dots.tsx";
|
|
6
|
+
|
|
7
|
+
// One quiet line between messages: the plan waiting, a stop, an approval, a warning.
|
|
8
|
+
function Line({ text, tone }: { text: string; tone?: "wait" | "warn" }) {
|
|
9
|
+
return (
|
|
10
|
+
<div
|
|
11
|
+
role="separator"
|
|
12
|
+
className={cn(
|
|
13
|
+
"flex items-center gap-2 text-xs text-muted-foreground before:h-px before:flex-1 before:bg-border after:h-px after:flex-1 after:bg-border",
|
|
14
|
+
tone === "wait" && "text-warning",
|
|
15
|
+
tone === "warn" && "text-warning",
|
|
16
|
+
)}
|
|
17
|
+
>
|
|
18
|
+
<span className="max-w-[80%] text-center">{text}</span>
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
// Where one agent hands over to another.
|
|
23
|
+
function Handoff({ item }: { item: Extract<ConversationItem, { kind: "handoff" }> }) {
|
|
24
|
+
return (
|
|
25
|
+
<div
|
|
26
|
+
role="separator"
|
|
27
|
+
className="flex items-center gap-2 text-xs text-muted-foreground before:h-px before:flex-1 before:bg-border after:h-px after:flex-1 after:bg-border"
|
|
28
|
+
>
|
|
29
|
+
<AgentMark agent={item.fromAgent} size="sm" />
|
|
30
|
+
<span aria-hidden="true">→</span>
|
|
31
|
+
<AgentMark agent={item.toAgent} size="sm" />
|
|
32
|
+
<span>Handed to {item.to}</span>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
// The messages, the quiet lines and the handoffs, in order. Shared by the desktop panel and the phone's page.
|
|
37
|
+
export function Thread({ items, working }: { items: ConversationItem[]; working?: boolean }) {
|
|
38
|
+
return (
|
|
39
|
+
<div
|
|
40
|
+
role="log"
|
|
41
|
+
aria-label="Task conversation"
|
|
42
|
+
aria-live="polite"
|
|
43
|
+
aria-relevant="additions"
|
|
44
|
+
className="flex flex-col gap-3 pb-2 pt-1"
|
|
45
|
+
>
|
|
46
|
+
{items.map((i) =>
|
|
47
|
+
i.kind === "message" ? (
|
|
48
|
+
<ChatBubble
|
|
49
|
+
key={i.m.id}
|
|
50
|
+
from={i.user ? "user" : "agent"}
|
|
51
|
+
name={i.user ? "You" : i.m.role === "system" ? "kaizen" : i.agent ? agentName(i.agent) : "Assistant"}
|
|
52
|
+
at={i.m.at}
|
|
53
|
+
text={i.m.text}
|
|
54
|
+
agent={i.user ? undefined : i.agent}
|
|
55
|
+
/>
|
|
56
|
+
) : i.kind === "line" ? (
|
|
57
|
+
<Line key={i.id} text={i.text} tone={i.tone} />
|
|
58
|
+
) : (
|
|
59
|
+
<Handoff key={i.id} item={i} />
|
|
60
|
+
),
|
|
61
|
+
)}
|
|
62
|
+
{working && <TypingDots />}
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
@@ -5,3 +5,15 @@ export * from "./result-view.tsx";
|
|
|
5
5
|
export * from "./status-badge.tsx";
|
|
6
6
|
export * from "./task-row.tsx";
|
|
7
7
|
export * from "./typing-dots.tsx";
|
|
8
|
+
export * from "./agent-chip.tsx";
|
|
9
|
+
export * from "./agent-mark.tsx";
|
|
10
|
+
export * from "./changes-view.tsx";
|
|
11
|
+
export * from "./composer.tsx";
|
|
12
|
+
export * from "./conversation.tsx";
|
|
13
|
+
export * from "./plan-view.tsx";
|
|
14
|
+
export * from "./review-view.tsx";
|
|
15
|
+
export * from "./task-tabs.tsx";
|
|
16
|
+
export * from "./task-phone.tsx";
|
|
17
|
+
export * from "./reference-files.tsx";
|
|
18
|
+
export * from "./saved-results.tsx";
|
|
19
|
+
export * from "./task-panel.tsx";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { PlanText } from "@components/decision";
|
|
3
|
+
import type { RunDoc } from "@lib/task";
|
|
4
|
+
|
|
5
|
+
// A kaizen plan starts with a short Work list; show that, with the whole plan one press away.
|
|
6
|
+
const workList = (plan: string) => plan.match(/^## Work list\s*\n([\s\S]*?)(?=^## |(?![\s\S]))/m)?.[1]?.trim();
|
|
7
|
+
|
|
8
|
+
// The Plan tab. While something waits on the person the page puts the decision first (`children`); after it the tab
|
|
9
|
+
// shows the plan that was approved, read-only, from the run.
|
|
10
|
+
export function PlanView({
|
|
11
|
+
run,
|
|
12
|
+
loaded,
|
|
13
|
+
waiting,
|
|
14
|
+
planning,
|
|
15
|
+
children,
|
|
16
|
+
}: {
|
|
17
|
+
run: RunDoc | null;
|
|
18
|
+
loaded: boolean;
|
|
19
|
+
waiting?: boolean; // something waits on the person (the decision is in `children`)
|
|
20
|
+
planning?: boolean; // the agent is writing the plan
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
}) {
|
|
23
|
+
const list = run?.plan ? workList(run.plan) : undefined;
|
|
24
|
+
return (
|
|
25
|
+
<div className="flex flex-col gap-4">
|
|
26
|
+
{children}
|
|
27
|
+
{run?.plan ? (
|
|
28
|
+
<section aria-label="Approved plan" className="rounded-lg border border-border bg-card p-4">
|
|
29
|
+
<h3 className="mb-2 text-base font-semibold">{waiting ? "Plan so far" : "Approved plan"}</h3>
|
|
30
|
+
<PlanText text={list ?? run.plan} />
|
|
31
|
+
{list && (
|
|
32
|
+
<details className="mt-3 text-muted-foreground">
|
|
33
|
+
<summary className="cursor-pointer text-sm">Full plan</summary>
|
|
34
|
+
<PlanText text={run.plan} className="mt-3 text-foreground" />
|
|
35
|
+
</details>
|
|
36
|
+
)}
|
|
37
|
+
</section>
|
|
38
|
+
) : (
|
|
39
|
+
!waiting &&
|
|
40
|
+
loaded && (
|
|
41
|
+
<p className="p-2 text-muted-foreground">
|
|
42
|
+
{planning
|
|
43
|
+
? "The agent is planning. The plan appears here when it is ready."
|
|
44
|
+
: "The plan appears here once the agent writes it."}
|
|
45
|
+
</p>
|
|
46
|
+
)
|
|
47
|
+
)}
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TaskView } from "@lib/task";
|
|
2
|
+
|
|
3
|
+
// The files the person attached to the task, as links the board can serve.
|
|
4
|
+
export function ReferenceFiles({ files }: { files?: TaskView["files"] }) {
|
|
5
|
+
if (!files?.length) return null;
|
|
6
|
+
return (
|
|
7
|
+
<details className="mb-3">
|
|
8
|
+
<summary className="cursor-pointer">Reference files · {files.length}</summary>
|
|
9
|
+
<ul className="list-disc pl-5">
|
|
10
|
+
{files.map((f, i) => (
|
|
11
|
+
<li key={i} className="my-1">
|
|
12
|
+
{f.url && /^\/file\?/.test(f.url) ? (
|
|
13
|
+
<a href={f.url} target="_blank" rel="noopener noreferrer" className="underline">
|
|
14
|
+
{f.name}
|
|
15
|
+
</a>
|
|
16
|
+
) : (
|
|
17
|
+
f.name
|
|
18
|
+
)}
|
|
19
|
+
</li>
|
|
20
|
+
))}
|
|
21
|
+
</ul>
|
|
22
|
+
</details>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -31,7 +31,9 @@ export function ResultView({
|
|
|
31
31
|
className="grid min-h-60 place-content-center justify-items-center gap-1.5 p-5 text-center text-muted-foreground"
|
|
32
32
|
>
|
|
33
33
|
<Spinner className="mb-1.5" />
|
|
34
|
-
<h3 className="font-semibold text-foreground">
|
|
34
|
+
<h3 className="font-semibold text-foreground">
|
|
35
|
+
{alive === false ? "The agent is not running" : `The agent is ${VERB[stage ?? ""] ?? "working"}`}
|
|
36
|
+
</h3>
|
|
35
37
|
<p className="line-clamp-3 max-w-[52ch]">{working}</p>
|
|
36
38
|
</div>
|
|
37
39
|
);
|