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
package/web/pages/task-page.tsx
CHANGED
|
@@ -1,37 +1,43 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
import { useShallow } from "zustand/react/shallow";
|
|
3
2
|
import { useRoute } from "@lib/router";
|
|
4
3
|
import { ActionMenu, ConfirmDialog, EmptyState, IconButton } from "@components/shared";
|
|
5
4
|
import {
|
|
6
|
-
|
|
5
|
+
ChangesView,
|
|
6
|
+
Composer,
|
|
7
|
+
PlanView,
|
|
7
8
|
ResultChecks,
|
|
8
9
|
ResultView,
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
ReviewView,
|
|
11
|
+
SavedResults,
|
|
12
|
+
TaskPhone,
|
|
13
|
+
TaskPanel,
|
|
14
|
+
TaskTabs,
|
|
15
|
+
type TabItem,
|
|
11
16
|
} from "@components/task";
|
|
12
17
|
import { DecisionBar } from "@components/decision";
|
|
13
18
|
import {
|
|
19
|
+
conversationItems,
|
|
14
20
|
runAction,
|
|
15
|
-
|
|
21
|
+
savedLine,
|
|
16
22
|
setDraft,
|
|
23
|
+
tabFor,
|
|
24
|
+
tabMarks,
|
|
25
|
+
taskStatus,
|
|
17
26
|
useTask,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
closeActions,
|
|
27
|
+
useTaskPage,
|
|
28
|
+
useTaskRun,
|
|
21
29
|
projectLabel,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
visibleMessages,
|
|
30
|
+
type TabId,
|
|
31
|
+
type TaskModel,
|
|
32
|
+
type TaskPageData,
|
|
33
|
+
type TaskView,
|
|
27
34
|
} from "@lib/task";
|
|
28
|
-
import { host, useStore,
|
|
29
|
-
import { Button
|
|
35
|
+
import { host, useStore, usePhone } from "@lib/core";
|
|
36
|
+
import { Button } from "@web/ui";
|
|
30
37
|
|
|
31
38
|
const ACCEPT_HINT = "Accepting a result does not publish it. A preview alone does not prove that a backend works.";
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
// conversation in a drawer, one message bar.
|
|
39
|
+
// One durable task across clarification, production, saved outputs and revisions: the tab that needs the person opens
|
|
40
|
+
// first, the conversation sits beside it (a chat on its own on a phone), one message bar.
|
|
35
41
|
export function TaskPage() {
|
|
36
42
|
const on = useRoute((r) => r.page === "task"),
|
|
37
43
|
open = useStore((s) => (on ? s.taskId + "\n" + s.taskDir : ""));
|
|
@@ -40,33 +46,9 @@ export function TaskPage() {
|
|
|
40
46
|
}
|
|
41
47
|
function Task() {
|
|
42
48
|
useTask();
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
pageError: s.pageError,
|
|
47
|
-
pending: s.pending,
|
|
48
|
-
receipt: s.receipt,
|
|
49
|
-
draft: s.draft,
|
|
50
|
-
})),
|
|
51
|
-
);
|
|
52
|
-
const [picked, setPicked] = useState(""),
|
|
53
|
-
[follow, setFollow] = useState(true),
|
|
54
|
-
[artifactId, setArtifactId] = useState(""),
|
|
55
|
-
[drawer, setDrawer] = useState<boolean | null>(null),
|
|
56
|
-
[confirm, setConfirm] = useState<"" | "abandon" | "delete">(""),
|
|
57
|
-
[denied, setDenied] = useState(false);
|
|
58
|
-
const thread = useRef<HTMLDivElement>(null),
|
|
59
|
-
input = useRef<HTMLTextAreaElement>(null);
|
|
60
|
-
const t = page?.task;
|
|
61
|
-
const count = t?.messages?.length ?? 0;
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
if (t) document.title = t.title + " · kaizen";
|
|
64
|
-
}, [t?.title]);
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
const el = thread.current;
|
|
67
|
-
if (el) requestAnimationFrame(() => (el.scrollTop = el.scrollHeight));
|
|
68
|
-
}, [count, !!t]);
|
|
69
|
-
if (!page || !t)
|
|
49
|
+
const page = useStore((s) => s.page),
|
|
50
|
+
pageError = useStore((s) => s.pageError);
|
|
51
|
+
if (!page?.task)
|
|
70
52
|
return pageError ? (
|
|
71
53
|
<EmptyState
|
|
72
54
|
title={pageError === "offline" ? "The server could not be reached" : "This task could not be opened"}
|
|
@@ -81,330 +63,317 @@ function Task() {
|
|
|
81
63
|
Opening task…
|
|
82
64
|
</p>
|
|
83
65
|
);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
!!
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
setDrawer(true);
|
|
116
|
-
input.current?.focus();
|
|
117
|
-
};
|
|
118
|
-
const menu = [
|
|
119
|
-
...runIdsOf(t).map((id) => ({
|
|
120
|
-
id: "run-" + id,
|
|
121
|
-
label: "Open workspace · " + id,
|
|
122
|
-
href: `?view=run&id=${id}&dir=${encodeURIComponent(t.dir)}`,
|
|
123
|
-
})),
|
|
124
|
-
{ id: "archive", label: "Archive", onSelect: () => void finish("archive") },
|
|
125
|
-
...(close.abandon
|
|
126
|
-
? [{ id: "abandon", label: "Abandon", danger: true, onSelect: () => setConfirm("abandon") }]
|
|
127
|
-
: []),
|
|
128
|
-
...(close.delete ? [{ id: "delete", label: "Delete", danger: true, onSelect: () => setConfirm("delete") }] : []),
|
|
129
|
-
];
|
|
130
|
-
const help = t.activeRun
|
|
131
|
-
? "Changes are saved for the next safe pass. Questions do not interrupt production."
|
|
132
|
-
: t.attention.category === "completed"
|
|
133
|
-
? "A new change stays in this task and starts a linked revision."
|
|
134
|
-
: "Ask a question or describe a change. Your message stays with this task.";
|
|
135
|
-
const dot = !showDrawer && !!(t.pendingDecision || t.inputs?.some((i) => i.state === "queued"));
|
|
66
|
+
return <Loaded page={page} t={page.task} />;
|
|
67
|
+
}
|
|
68
|
+
function Loaded({ page, t }: { page: TaskPageData; t: TaskView }) {
|
|
69
|
+
const phone = usePhone();
|
|
70
|
+
return phone ? <PhoneLoaded page={page} t={t} /> : <DesktopLoaded page={page} t={t} />;
|
|
71
|
+
}
|
|
72
|
+
// The title in the browser's tab follows the task.
|
|
73
|
+
const useDocTitle = (title: string) =>
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
document.title = title + " · kaizen";
|
|
76
|
+
}, [title]);
|
|
77
|
+
const Confirm = ({ m, t }: { m: TaskModel; t: TaskView }) => (
|
|
78
|
+
<ConfirmDialog
|
|
79
|
+
open={!!m.confirm}
|
|
80
|
+
title={m.confirm === "delete" ? "Delete this task?" : "Abandon this run?"}
|
|
81
|
+
description={m.confirm === "delete" ? "It is not recorded anywhere." : "Saved files are not rolled back."}
|
|
82
|
+
confirmLabel={m.confirm === "delete" ? "Delete" : "Abandon"}
|
|
83
|
+
danger
|
|
84
|
+
onCancel={() => m.setConfirm("")}
|
|
85
|
+
onConfirm={() => {
|
|
86
|
+
const op = m.confirm as string;
|
|
87
|
+
m.setConfirm("");
|
|
88
|
+
void m.finish(op, op === "abandon" ? { why: "abandoned from the task page" } : {});
|
|
89
|
+
}}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
// While the agent waits on a permission the page says so with Allow and Deny; after Deny it waits for an instruction.
|
|
93
|
+
function Permission({ t, m }: { t: TaskView; m: TaskModel }) {
|
|
94
|
+
const asking = !!(t.agentAsking && t.agentAlive),
|
|
95
|
+
why = m.isCurrent && !t.decision ? t.actions?.acceptWhy : undefined;
|
|
96
|
+
if (!m.note && !(m.denied && !t.agentAsking) && !why && !asking) return null;
|
|
136
97
|
return (
|
|
137
|
-
<div className="
|
|
138
|
-
<
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
href="?view=tasks"
|
|
143
|
-
className="[&_svg]:rotate-180"
|
|
144
|
-
onClick={(e) => (e.preventDefault(), host.go("tasks", true))}
|
|
145
|
-
/>
|
|
146
|
-
<h1 className="min-w-0 truncate text-[18px] font-semibold leading-snug">{t.title}</h1>
|
|
147
|
-
<span className="mr-auto shrink-0 whitespace-nowrap text-sm text-muted-foreground">
|
|
148
|
-
{projectLabel(t, page.projects)}
|
|
98
|
+
<div role="status" className="flex flex-wrap items-baseline gap-x-2.5 gap-y-1 text-base">
|
|
99
|
+
{m.note && <span className="text-muted-foreground">{m.note}</span>}
|
|
100
|
+
{m.denied && !t.agentAsking && (
|
|
101
|
+
<span className="text-muted-foreground">
|
|
102
|
+
Denied. The agent is waiting for your instruction: tell it what to do instead in the message box.
|
|
149
103
|
</span>
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
{resume && (
|
|
156
|
-
<Button onClick={() => void runAction("resume")}>{t.status === "failed" ? "Retry" : "Resume"}</Button>
|
|
157
|
-
)}
|
|
158
|
-
{start && (
|
|
104
|
+
)}
|
|
105
|
+
{why && <span className="text-muted-foreground">{why}</span>}
|
|
106
|
+
{asking && (
|
|
107
|
+
<span className="flex items-baseline gap-2 text-warning">
|
|
108
|
+
Waiting for permission
|
|
159
109
|
<Button
|
|
160
|
-
|
|
161
|
-
onClick={() =>
|
|
162
|
-
host.runPopup(
|
|
163
|
-
{ _k: "task:" + t.id, kind: "task", state: t.dir, text: t.title },
|
|
164
|
-
(pick) => void runAction("start", { pick }),
|
|
165
|
-
)
|
|
166
|
-
}
|
|
110
|
+
disabled={m.pending}
|
|
111
|
+
onClick={() => (m.setDenied(false), void runAction("prompt", { answer: "yes" }))}
|
|
167
112
|
>
|
|
168
|
-
|
|
113
|
+
Allow
|
|
169
114
|
</Button>
|
|
170
|
-
)}
|
|
171
|
-
{accept && (
|
|
172
115
|
<Button
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
onClick={() => void runAction("accept", { resultId: t.currentResultId })}
|
|
116
|
+
disabled={m.pending}
|
|
117
|
+
onClick={() => void runAction("prompt", { answer: "no" }).then((r) => r?.ok && m.setDenied(true))}
|
|
176
118
|
>
|
|
177
|
-
|
|
119
|
+
Deny
|
|
178
120
|
</Button>
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
>
|
|
229
|
-
{
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
/>
|
|
121
|
+
</span>
|
|
122
|
+
)}
|
|
123
|
+
</div>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
function DesktopLoaded({ page, t }: { page: TaskPageData; t: TaskView }) {
|
|
127
|
+
const [drawer, setDrawer] = useState<boolean | null>(null),
|
|
128
|
+
[chatTick, setChatTick] = useState(0);
|
|
129
|
+
const m = useTaskPage(page, t, () => (setDrawer(true), setChatTick((n) => n + 1)));
|
|
130
|
+
const { run, loaded } = useTaskRun(t);
|
|
131
|
+
const thread = useRef<HTMLDivElement>(null),
|
|
132
|
+
items = conversationItems(t),
|
|
133
|
+
showDrawer = drawer ?? true;
|
|
134
|
+
useDocTitle(m.title);
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
const el = thread.current?.parentElement;
|
|
137
|
+
if (el) requestAnimationFrame(() => (el.scrollTop = el.scrollHeight));
|
|
138
|
+
}, [items.length, showDrawer]);
|
|
139
|
+
// The tab that needs the person opens by itself, and again when what needs them changes.
|
|
140
|
+
const target = tabFor(t),
|
|
141
|
+
[tab, setTab] = useState<TabId>(target),
|
|
142
|
+
seen = useRef(target);
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
if (seen.current !== target) {
|
|
145
|
+
seen.current = target;
|
|
146
|
+
setTab(target);
|
|
147
|
+
}
|
|
148
|
+
}, [target]);
|
|
149
|
+
const marks = tabMarks(t, m.current);
|
|
150
|
+
const tabs: TabItem[] = [
|
|
151
|
+
{ id: "plan", label: "Plan", mark: marks.plan },
|
|
152
|
+
{ id: "result", label: "Result", mark: marks.result },
|
|
153
|
+
...(m.runs.length
|
|
154
|
+
? ([
|
|
155
|
+
{ id: "changes", label: "Changes", count: run?.files.length || undefined },
|
|
156
|
+
{ id: "review", label: "Review", count: run?.findings.filter((f) => !f.done).length || undefined },
|
|
157
|
+
] as TabItem[])
|
|
158
|
+
: []),
|
|
159
|
+
];
|
|
160
|
+
const ask = () => {
|
|
161
|
+
setDrawer(true);
|
|
162
|
+
setChatTick((n) => n + 1);
|
|
163
|
+
requestAnimationFrame(() => m.input.current?.focus());
|
|
164
|
+
};
|
|
165
|
+
const dot = !showDrawer && !!(t.pendingDecision || t.inputs?.some((i) => i.state === "queued"));
|
|
166
|
+
// Resume and Stop sit beside the agent in the conversation; with the conversation collapsed they are in the page's header.
|
|
167
|
+
const controls = (
|
|
168
|
+
<>
|
|
169
|
+
{m.stop && (
|
|
170
|
+
<Button size="sm" disabled={m.pending || t.status === "stopping"} onClick={() => void runAction("stop")}>
|
|
171
|
+
{t.status === "stopping" ? "Stopping…" : "Stop"}
|
|
172
|
+
</Button>
|
|
173
|
+
)}
|
|
174
|
+
{m.resume && (
|
|
175
|
+
<Button size="sm" onClick={() => void runAction("resume")}>
|
|
176
|
+
{t.status === "failed" ? "Retry" : "Resume"}
|
|
177
|
+
</Button>
|
|
178
|
+
)}
|
|
179
|
+
</>
|
|
180
|
+
);
|
|
181
|
+
const lookGood = (
|
|
182
|
+
<Button
|
|
183
|
+
variant="primary"
|
|
184
|
+
title={ACCEPT_HINT}
|
|
185
|
+
onClick={() => void runAction("accept", { resultId: t.currentResultId })}
|
|
186
|
+
>
|
|
187
|
+
Looks good
|
|
188
|
+
</Button>
|
|
189
|
+
);
|
|
190
|
+
return (
|
|
191
|
+
<div className="relative flex min-h-0 flex-1">
|
|
192
|
+
<section
|
|
193
|
+
aria-label="Task"
|
|
194
|
+
className="flex min-h-0 min-w-0 flex-1 flex-col gap-3 pr-6 max-md:pr-0 max-md:data-[drawer=true]:hidden"
|
|
195
|
+
data-drawer={showDrawer}
|
|
196
|
+
>
|
|
197
|
+
<header className="flex flex-none items-center gap-2.5 max-sm:flex-wrap">
|
|
198
|
+
<IconButton
|
|
199
|
+
icon="arrow"
|
|
200
|
+
label="Back to tasks"
|
|
201
|
+
href="?view=tasks"
|
|
202
|
+
className="[&_svg]:rotate-180"
|
|
203
|
+
onClick={(e) => (e.preventDefault(), host.go("tasks", true))}
|
|
204
|
+
/>
|
|
205
|
+
<div className="mr-auto min-w-0">
|
|
206
|
+
<p className="truncate text-xs text-muted-foreground">{projectLabel(t, page.projects)}</p>
|
|
207
|
+
<h1 className="truncate text-[18px] font-semibold leading-snug">{m.title}</h1>
|
|
267
208
|
</div>
|
|
268
|
-
{
|
|
269
|
-
|
|
209
|
+
{!showDrawer && controls}
|
|
210
|
+
{m.start && (
|
|
211
|
+
<Button
|
|
212
|
+
variant="primary"
|
|
213
|
+
onClick={() =>
|
|
214
|
+
host.runPopup(
|
|
215
|
+
{ _k: "task:" + t.id, kind: "task", state: t.dir, text: t.title },
|
|
216
|
+
(pick) => void runAction("start", { pick }),
|
|
217
|
+
)
|
|
218
|
+
}
|
|
219
|
+
>
|
|
220
|
+
Start planning
|
|
221
|
+
</Button>
|
|
270
222
|
)}
|
|
271
|
-
|
|
223
|
+
{m.accept && tab !== "result" && lookGood}
|
|
224
|
+
<ActionMenu
|
|
225
|
+
label="Task details"
|
|
226
|
+
items={m.menu}
|
|
227
|
+
footer={
|
|
228
|
+
<div className="px-2 py-1.5 text-muted-foreground">
|
|
229
|
+
<ResultChecks result={m.selected} />
|
|
230
|
+
<p className="mb-2 text-sm">
|
|
231
|
+
{page.defaults?.agent
|
|
232
|
+
? "Agent: " + page.defaults.agent + ". "
|
|
233
|
+
: "Configured project agent and workflow. "}
|
|
234
|
+
{page.defaults?.workflow ? "Workflow: " + page.defaults.workflow + ". " : ""}
|
|
235
|
+
{page.defaults?.permissions || "Tool permissions follow the existing project settings."}
|
|
236
|
+
</p>
|
|
237
|
+
<p className="mb-2 text-sm text-muted-foreground">
|
|
238
|
+
Permission prompts show here with Allow and Deny. Stop requests cancellation; it does not undo files.
|
|
239
|
+
</p>
|
|
240
|
+
{!m.runs.length && <p className="mb-2 text-sm">No run has started yet.</p>}
|
|
241
|
+
<small className="mb-1 block break-words text-muted-foreground">
|
|
242
|
+
Task {t.id} · revision {t.revision}
|
|
243
|
+
</small>
|
|
244
|
+
</div>
|
|
245
|
+
}
|
|
246
|
+
/>
|
|
247
|
+
</header>
|
|
248
|
+
<Permission t={t} m={m} />
|
|
249
|
+
<TaskTabs tabs={tabs} active={tab} onPick={setTab} />
|
|
272
250
|
<div
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
"visible ml-6 w-[380px] border-l border-[color:color-mix(in_srgb,var(--line)_50%,transparent)] pl-5 opacity-100 max-md:ml-0 max-md:w-full max-md:border-l-0 max-md:pl-0",
|
|
279
|
-
)}
|
|
251
|
+
key={tab}
|
|
252
|
+
role="tabpanel"
|
|
253
|
+
id={`task-pane-${tab}`}
|
|
254
|
+
aria-labelledby={`task-tab-${tab}`}
|
|
255
|
+
className="flex min-h-0 flex-1 flex-col overflow-auto motion-safe:animate-pane"
|
|
280
256
|
>
|
|
281
|
-
|
|
282
|
-
<
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
className="min-h-0 min-w-[340px] flex-1 overflow-auto max-md:min-w-0 [scrollbar-gutter:stable]"
|
|
288
|
-
>
|
|
289
|
-
<DecisionBar
|
|
290
|
-
decision={t.decision}
|
|
291
|
-
needsProject={!t.dir || t.decision?.kind === "project"}
|
|
292
|
-
projects={page.projects}
|
|
293
|
-
pending={pending}
|
|
294
|
-
onApprove={(decisionId) => void runAction("confirm", { decisionId })}
|
|
295
|
-
onAnswer={(text) => (setDraft(text), void send())}
|
|
296
|
-
onProject={(choice) => void runAction("project", choice)}
|
|
297
|
-
/>
|
|
298
|
-
{!!t.files?.length && (
|
|
299
|
-
<details className="mb-3">
|
|
300
|
-
<summary className="cursor-pointer">Reference files · {t.files.length}</summary>
|
|
301
|
-
<ul className="list-disc pl-5">
|
|
302
|
-
{t.files.map((f, i) => (
|
|
303
|
-
<li key={i} className="my-1">
|
|
304
|
-
{f.url && /^\/file\?/.test(f.url) ? (
|
|
305
|
-
<a href={f.url} target="_blank" rel="noopener noreferrer" className="underline">
|
|
306
|
-
{f.name}
|
|
307
|
-
</a>
|
|
308
|
-
) : (
|
|
309
|
-
f.name
|
|
310
|
-
)}
|
|
311
|
-
</li>
|
|
312
|
-
))}
|
|
313
|
-
</ul>
|
|
314
|
-
</details>
|
|
315
|
-
)}
|
|
316
|
-
<div
|
|
317
|
-
role="log"
|
|
318
|
-
aria-label="Task conversation"
|
|
319
|
-
aria-live="polite"
|
|
320
|
-
aria-relevant="additions"
|
|
321
|
-
className="flex flex-col gap-3 pb-2 pt-1"
|
|
257
|
+
{tab === "plan" && (
|
|
258
|
+
<PlanView
|
|
259
|
+
run={run}
|
|
260
|
+
loaded={loaded}
|
|
261
|
+
waiting={!!t.decision || !t.dir}
|
|
262
|
+
planning={t.status === "working" && ["plan", "explore"].includes(t.runStage ?? "")}
|
|
322
263
|
>
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
264
|
+
<DecisionBar
|
|
265
|
+
decision={t.decision}
|
|
266
|
+
needsProject={!t.dir || t.decision?.kind === "project"}
|
|
267
|
+
projects={page.projects}
|
|
268
|
+
pending={m.pending}
|
|
269
|
+
onApprove={(decisionId) => void runAction("confirm", { decisionId })}
|
|
270
|
+
onAnswer={(text) => (setDraft(text), void m.send())}
|
|
271
|
+
onProject={(choice) => void runAction("project", choice)}
|
|
272
|
+
onAsk={ask}
|
|
273
|
+
/>
|
|
274
|
+
</PlanView>
|
|
275
|
+
)}
|
|
276
|
+
{tab === "result" && (
|
|
277
|
+
<>
|
|
278
|
+
{m.accept && (
|
|
279
|
+
<div className="mb-3 flex flex-wrap items-center gap-3 rounded-lg border border-border bg-card px-4 py-3">
|
|
280
|
+
<span className="min-w-0 flex-1">
|
|
281
|
+
<b className="font-medium text-strong">Ready for you.</b> Check the result, then accept it.
|
|
282
|
+
</span>
|
|
283
|
+
{lookGood}
|
|
284
|
+
<Button onClick={ask}>Ask for a change</Button>
|
|
285
|
+
</div>
|
|
286
|
+
)}
|
|
287
|
+
<SavedResults
|
|
288
|
+
results={m.results}
|
|
289
|
+
selectedId={m.selectedId}
|
|
290
|
+
currentId={t.currentResultId}
|
|
291
|
+
onPick={m.picked}
|
|
292
|
+
/>
|
|
293
|
+
<div className="flex min-h-0 flex-1 flex-col">
|
|
294
|
+
<ResultView
|
|
295
|
+
result={m.selected}
|
|
296
|
+
artifactId={m.artifactId}
|
|
297
|
+
working={t.status === "working" ? taskStatus(t) : undefined}
|
|
298
|
+
stage={t.runStage}
|
|
299
|
+
alive={t.agentAlive}
|
|
300
|
+
waiting={t.status === "waiting"}
|
|
301
|
+
onSelect={m.setArtifactId}
|
|
330
302
|
/>
|
|
303
|
+
</div>
|
|
304
|
+
<p className="mt-2 text-right text-xs text-muted-foreground">{savedLine(m.selected)}</p>
|
|
305
|
+
{t.acceptedResultId && t.attention.category === "completed" && (
|
|
306
|
+
<div className="mt-2.5 text-success">Accepted. Publishing is a separate action.</div>
|
|
307
|
+
)}
|
|
308
|
+
</>
|
|
309
|
+
)}
|
|
310
|
+
{tab === "changes" && <ChangesView run={run} workspace={m.workspace} />}
|
|
311
|
+
{tab === "review" && <ReviewView run={run} workspace={m.workspace} />}
|
|
312
|
+
</div>
|
|
313
|
+
</section>
|
|
314
|
+
<TaskPanel
|
|
315
|
+
t={t}
|
|
316
|
+
folded={!showDrawer}
|
|
317
|
+
onFold={(folded) => setDrawer(!folded)}
|
|
318
|
+
projectName={projectLabel(t, page.projects)}
|
|
319
|
+
controls={controls}
|
|
320
|
+
threadRef={thread}
|
|
321
|
+
dot={dot}
|
|
322
|
+
focusChat={chatTick}
|
|
323
|
+
after={
|
|
324
|
+
m.queue.length > 0 && (
|
|
325
|
+
<div aria-label="Requests awaiting completion" className="mb-1.5 flex justify-end gap-1.5 px-1">
|
|
326
|
+
{m.queue.map((i) => (
|
|
327
|
+
<span key={i.id} title={`Receipt ${i.id.slice(0, 8)}`} className="text-xs text-warning">
|
|
328
|
+
{i.state === "received" ? "Received" : "Queued for next pass"}
|
|
329
|
+
</span>
|
|
331
330
|
))}
|
|
332
331
|
</div>
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
332
|
+
)
|
|
333
|
+
}
|
|
334
|
+
footer={
|
|
335
|
+
<Composer
|
|
336
|
+
inputRef={m.input}
|
|
337
|
+
value={m.draft}
|
|
338
|
+
onChange={setDraft}
|
|
339
|
+
onSend={() => void m.send()}
|
|
340
|
+
pending={m.pending}
|
|
341
|
+
answering={t.decision?.kind === "question"}
|
|
342
|
+
help={m.help}
|
|
343
|
+
receipt={m.receipt}
|
|
344
|
+
/>
|
|
345
|
+
}
|
|
346
|
+
actions={
|
|
347
|
+
<>
|
|
348
|
+
{m.menu.find((x) => x.id === "archive") && (
|
|
349
|
+
<Button size="sm" variant="ghost" onClick={() => m.menu.find((x) => x.id === "archive")?.onSelect?.()}>
|
|
350
|
+
Archive
|
|
351
|
+
</Button>
|
|
339
352
|
)}
|
|
340
|
-
{
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
</
|
|
353
|
+
{m.menu.find((x) => x.id === "abandon") && (
|
|
354
|
+
<Button
|
|
355
|
+
size="sm"
|
|
356
|
+
variant="ghost"
|
|
357
|
+
className="text-danger"
|
|
358
|
+
onClick={() => m.menu.find((x) => x.id === "abandon")?.onSelect?.()}
|
|
359
|
+
>
|
|
360
|
+
Abandon
|
|
361
|
+
</Button>
|
|
349
362
|
)}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
</div>
|
|
353
|
-
<form
|
|
354
|
-
className="flex-none"
|
|
355
|
-
onSubmit={(e) => {
|
|
356
|
-
e.preventDefault();
|
|
357
|
-
void send();
|
|
358
|
-
}}
|
|
359
|
-
>
|
|
360
|
-
<div className="flex items-end gap-2 rounded-lg border border-border bg-card py-2 pl-3.5 pr-2 shadow-sm focus-within:border-muted-foreground">
|
|
361
|
-
<Textarea
|
|
362
|
-
ref={input}
|
|
363
|
-
rows={1}
|
|
364
|
-
aria-label="Your message"
|
|
365
|
-
aria-describedby="task-composer-help"
|
|
366
|
-
placeholder="Message the agent"
|
|
367
|
-
title="Enter to send, Shift+Enter for a new line"
|
|
368
|
-
value={draft}
|
|
369
|
-
onChange={(e) => setDraft(e.target.value)}
|
|
370
|
-
onKeyDown={(e) => {
|
|
371
|
-
// Enter sends, Shift+Enter adds a line. A phone keyboard keeps Enter as a new line.
|
|
372
|
-
if (
|
|
373
|
-
e.key === "Enter" &&
|
|
374
|
-
!e.shiftKey &&
|
|
375
|
-
!e.nativeEvent.isComposing &&
|
|
376
|
-
!matchMedia("(pointer:coarse)").matches
|
|
377
|
-
) {
|
|
378
|
-
e.preventDefault();
|
|
379
|
-
void send();
|
|
380
|
-
}
|
|
381
|
-
}}
|
|
382
|
-
className="max-h-[140px] min-h-[30px] min-w-0 flex-1 py-1 [field-sizing:content]"
|
|
383
|
-
/>
|
|
384
|
-
<Button type="submit" variant="primary" disabled={pending}>
|
|
385
|
-
{pending ? "Sending…" : t.decision?.kind === "question" ? "Send answer" : "Send"}
|
|
386
|
-
</Button>
|
|
387
|
-
</div>
|
|
388
|
-
<p id="task-composer-help" className="sr-only">
|
|
389
|
-
{help}
|
|
390
|
-
</p>
|
|
391
|
-
<p role="status" className={cn("mx-0.5 mt-1.5 text-sm text-muted-foreground", !receipt && "hidden")}>
|
|
392
|
-
{receipt}
|
|
393
|
-
</p>
|
|
394
|
-
</form>
|
|
395
|
-
<ConfirmDialog
|
|
396
|
-
open={!!confirm}
|
|
397
|
-
title={confirm === "delete" ? "Delete this task?" : "Abandon this run?"}
|
|
398
|
-
description={confirm === "delete" ? "It is not recorded anywhere." : "Saved files are not rolled back."}
|
|
399
|
-
confirmLabel={confirm === "delete" ? "Delete" : "Abandon"}
|
|
400
|
-
danger
|
|
401
|
-
onCancel={() => setConfirm("")}
|
|
402
|
-
onConfirm={() => {
|
|
403
|
-
const op = confirm as string;
|
|
404
|
-
setConfirm("");
|
|
405
|
-
void finish(op, op === "abandon" ? { why: "abandoned from the task page" } : {});
|
|
406
|
-
}}
|
|
363
|
+
</>
|
|
364
|
+
}
|
|
407
365
|
/>
|
|
366
|
+
<Confirm m={m} t={t} />
|
|
408
367
|
</div>
|
|
409
368
|
);
|
|
410
369
|
}
|
|
370
|
+
function PhoneLoaded({ page, t }: { page: TaskPageData; t: TaskView }) {
|
|
371
|
+
const m = useTaskPage(page, t);
|
|
372
|
+
useDocTitle(m.title);
|
|
373
|
+
return (
|
|
374
|
+
<>
|
|
375
|
+
<TaskPhone page={page} t={t} m={m} permission={<Permission t={t} m={m} />} />
|
|
376
|
+
<Confirm m={m} t={t} />
|
|
377
|
+
</>
|
|
378
|
+
);
|
|
379
|
+
}
|