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/lib/core/index.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { isPhone } from "./utils.ts";
|
|
3
|
+
|
|
4
|
+
// True on a phone-width window, and follows the window as it is resized or turned.
|
|
5
|
+
export function usePhone() {
|
|
6
|
+
const [phone, setPhone] = useState(isPhone);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const q = matchMedia("(max-width:640px)"),
|
|
9
|
+
on = () => setPhone(q.matches);
|
|
10
|
+
on();
|
|
11
|
+
q.addEventListener("change", on);
|
|
12
|
+
return () => q.removeEventListener("change", on);
|
|
13
|
+
}, []);
|
|
14
|
+
return phone;
|
|
15
|
+
}
|
|
@@ -16,7 +16,8 @@ export function resolveView(name: string | null | undefined, phone: boolean): Vi
|
|
|
16
16
|
export const viewOf = (search: string, phone: boolean) => resolveView(new URLSearchParams(search).get("view"), phone);
|
|
17
17
|
// The view a page opens on. Only the board's own address names a view, wherever the board is served (at "/" or under a
|
|
18
18
|
// prefix): the Notebook page (<html data-kit>) lights the Board icon, as it always did.
|
|
19
|
-
export const startView = (search: string, phone: boolean, notebook: boolean): View =>
|
|
19
|
+
export const startView = (search: string, phone: boolean, notebook: boolean): View =>
|
|
20
|
+
notebook ? "board" : viewOf(search, phone);
|
|
20
21
|
|
|
21
22
|
// The classes on <body> that show one page area and its header buttons (web/ui/legacy/board.css keys on them).
|
|
22
23
|
export function bodyClasses(v: View, phone: boolean) {
|
|
@@ -47,7 +48,7 @@ const TITLES: Record<string, string> = {
|
|
|
47
48
|
run: "Run",
|
|
48
49
|
terminal: "Terminal",
|
|
49
50
|
chat: "Chat",
|
|
50
|
-
device: "
|
|
51
|
+
device: "Tasks",
|
|
51
52
|
};
|
|
52
53
|
// Home reads Chat on a computer and shows the wordmark on a phone (the header's title is the logo there).
|
|
53
54
|
export const viewTitle = (v: View, phone: boolean) =>
|
|
@@ -84,7 +85,13 @@ export function runOf(search: string): RunRoute | null {
|
|
|
84
85
|
// A link from a note (?run= or ?idea=, with dir, tab, item) names a card to open in the panel, on one of its tabs, a finding or
|
|
85
86
|
// backlog item marked. null: the address is not one (a workspace address, ?view=run&idea=, is the run view's own). An item's
|
|
86
87
|
// tab is its own when the link names none; `work` is the Work tab's old name.
|
|
87
|
-
export type Deep = {
|
|
88
|
+
export type Deep = {
|
|
89
|
+
dir: string | null;
|
|
90
|
+
run: string | null;
|
|
91
|
+
idea: string | null;
|
|
92
|
+
tab: string;
|
|
93
|
+
item: { type: "finding" | "backlog"; n: number } | null;
|
|
94
|
+
};
|
|
88
95
|
export function deepOf(search: string): Deep | null {
|
|
89
96
|
const p = new URLSearchParams(search),
|
|
90
97
|
run = p.get("run"),
|
|
@@ -92,5 +99,11 @@ export function deepOf(search: string): Deep | null {
|
|
|
92
99
|
if ((!run && idea === null) || p.get("view") === "run") return null;
|
|
93
100
|
const m = /^(finding|backlog)-(\d+)$/.exec(p.get("item") || ""),
|
|
94
101
|
n = p.get("tab") || (m ? (m[1] === "finding" ? "review" : "backlog") : "");
|
|
95
|
-
return {
|
|
102
|
+
return {
|
|
103
|
+
dir: p.get("dir"),
|
|
104
|
+
run,
|
|
105
|
+
idea,
|
|
106
|
+
tab: n === "work" ? "impl" : n,
|
|
107
|
+
item: m ? { type: m[1] as "finding" | "backlog", n: +m[2]! } : null,
|
|
108
|
+
};
|
|
96
109
|
}
|
package/web/lib/server/types.ts
CHANGED
|
@@ -26,6 +26,7 @@ export type RailTask = {
|
|
|
26
26
|
runIds?: string[];
|
|
27
27
|
legacy?: { kind: string; id?: string; index?: number };
|
|
28
28
|
attention: { category: string; reason: string; action: string };
|
|
29
|
+
agents?: { agent: string; state: string; current: boolean }[]; // the tools that worked on it, from its runs
|
|
29
30
|
};
|
|
30
31
|
// What the side menu and the phone's pages draw (/state?all=1 and /tasks?all=1).
|
|
31
32
|
export type RailData = { cards: any[]; projects: any[]; agents: Agent[]; tasks: RailTask[] | null };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// What the conversation draws, from the task's raw events: the plain messages, the lines that stand for an event
|
|
2
|
+
// (the plan waiting, a stop, an approval), and where one agent hands over to another.
|
|
3
|
+
import { agentName, cleanRequest, visibleMessages, type TaskMessage, type TaskView } from "./tasks.ts";
|
|
4
|
+
|
|
5
|
+
export type ConversationItem =
|
|
6
|
+
| { kind: "message"; m: TaskMessage; user: boolean; agent?: string }
|
|
7
|
+
| { kind: "line"; id: string; text: string; at?: number | string; tone?: "wait" | "warn" }
|
|
8
|
+
| { kind: "handoff"; id: string; from: string; to: string; fromAgent: string; toAgent: string };
|
|
9
|
+
|
|
10
|
+
// A stop is two events (asked, then done): one line says it. These system events are a quiet line, not a bubble.
|
|
11
|
+
const QUIET: Record<string, string> = {
|
|
12
|
+
stop: "Stopping the agent…",
|
|
13
|
+
stopped: "Agent stopped · edits kept",
|
|
14
|
+
resume: "Resumed",
|
|
15
|
+
finished: "The run finished",
|
|
16
|
+
confirm: "You approved the plan",
|
|
17
|
+
};
|
|
18
|
+
export function conversationItems(t: Pick<TaskView, "messages" | "decision" | "pendingDecision">): ConversationItem[] {
|
|
19
|
+
// Only a waiting plan has its line; a question that waits after an approved plan is the question itself.
|
|
20
|
+
const kind = (t.decision ?? (t.pendingDecision as { kind?: string } | null | undefined))?.kind;
|
|
21
|
+
const out: ConversationItem[] = [],
|
|
22
|
+
all = visibleMessages(t.messages),
|
|
23
|
+
waiting = kind === "proposal",
|
|
24
|
+
// Only the newest proposal can be the one still waiting; an answered one leaves the conversation.
|
|
25
|
+
lastProposal = all.reduce((at, m, i) => (m.type === "proposal" ? i : at), -1);
|
|
26
|
+
let last = "";
|
|
27
|
+
all.forEach((m, i) => {
|
|
28
|
+
if (m.type === "proposal") {
|
|
29
|
+
if (waiting && i === lastProposal)
|
|
30
|
+
out.push({ kind: "line", id: m.id, text: "Plan ready · needs your approval", at: m.at, tone: "wait" });
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (m.role === "user" && m.type !== "confirm")
|
|
34
|
+
return void out.push({ kind: "message", m: { ...m, text: cleanRequest(m.text) || m.text }, user: true });
|
|
35
|
+
const quiet = QUIET[m.type ?? ""];
|
|
36
|
+
if (quiet && m.role !== "assistant") {
|
|
37
|
+
const prev = out[out.length - 1];
|
|
38
|
+
// "stop" then "stopped": the second says it all.
|
|
39
|
+
if (m.type === "stopped" && prev?.kind === "line" && prev.text === QUIET.stop) out.pop();
|
|
40
|
+
return void out.push({ kind: "line", id: m.id, text: quiet, at: m.at });
|
|
41
|
+
}
|
|
42
|
+
if (m.role === "system") return void out.push({ kind: "line", id: m.id, text: m.text, at: m.at, tone: "warn" });
|
|
43
|
+
if (m.agent && last && m.agent !== last)
|
|
44
|
+
out.push({
|
|
45
|
+
kind: "handoff",
|
|
46
|
+
id: "h-" + m.id,
|
|
47
|
+
from: agentName(last),
|
|
48
|
+
to: agentName(m.agent),
|
|
49
|
+
fromAgent: last,
|
|
50
|
+
toAgent: m.agent,
|
|
51
|
+
});
|
|
52
|
+
if (m.agent) last = m.agent;
|
|
53
|
+
out.push({ kind: "message", m, user: false, agent: m.agent });
|
|
54
|
+
});
|
|
55
|
+
return out;
|
|
56
|
+
}
|
package/web/lib/task/index.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
export * from "./conversation.ts";
|
|
1
2
|
export * from "./task-results.ts";
|
|
3
|
+
export * from "./task-tabs.ts";
|
|
4
|
+
export * from "./use-task-page.ts";
|
|
5
|
+
export * from "./use-task-run.ts";
|
|
2
6
|
export * from "./tasks.ts";
|
|
3
7
|
export * from "./use-live-frame.ts";
|
|
4
8
|
export * from "./use-saved-text.ts";
|
|
5
9
|
export * from "./use-task.ts";
|
|
6
10
|
export * from "./use-tasks.ts";
|
|
7
11
|
export * from "./zoom.ts";
|
|
12
|
+
export * from "./task-progress.ts";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// The thin progress bar of the task panel: the stage word, how far along, and what the colour says. Coarse on purpose:
|
|
2
|
+
// a task knows its stage (plan, build, review), not a percentage, so the bar moves in fixed steps and the word says why.
|
|
3
|
+
import type { TaskView } from "./tasks.ts";
|
|
4
|
+
|
|
5
|
+
export type TaskProgress = { word: string; pct: number; tone: "wait" | "run" | "ok" | "idle" };
|
|
6
|
+
const STEP: Record<string, number> = { explore: 15, plan: 30, build: 62, review: 85 };
|
|
7
|
+
const WORD: Record<string, string> = { explore: "Explore", plan: "Plan", build: "Build", review: "Review" };
|
|
8
|
+
|
|
9
|
+
export function taskProgress(t: TaskView): TaskProgress {
|
|
10
|
+
const stage = t.runStage ?? "",
|
|
11
|
+
pct = STEP[stage] ?? (t.currentResultId ? 85 : 0);
|
|
12
|
+
if (t.attention?.category === "completed" || t.status === "accepted") return { word: "Done", pct: 100, tone: "ok" };
|
|
13
|
+
if (t.decision?.kind === "question") return { word: "Question, needs you", pct, tone: "wait" };
|
|
14
|
+
if (t.decision || t.pendingDecision) return { word: "Plan, needs you", pct: STEP.plan, tone: "wait" };
|
|
15
|
+
if (t.status === "draft") return { word: "Not started", pct: 0, tone: "idle" };
|
|
16
|
+
if (t.status === "working") return { word: WORD[stage] ?? "Working", pct: pct || 20, tone: "run" };
|
|
17
|
+
if (["interrupted", "failed", "stopping"].includes(t.status ?? ""))
|
|
18
|
+
return { word: (WORD[stage] ?? "Stopped") + (WORD[stage] ? ", stopped" : ""), pct, tone: "idle" };
|
|
19
|
+
if (t.status === "ready" || t.currentResultId) return { word: "Ready for you", pct: 90, tone: "wait" };
|
|
20
|
+
return { word: t.attention?.reason || "Working", pct: pct || 20, tone: "idle" };
|
|
21
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Which tab of the task page opens, and the mark on each, from the task's status. The page shows the tab that needs the
|
|
2
|
+
// person; a mark says why: amber waits on you, a ring is an agent working, green is finished.
|
|
3
|
+
import { canAcceptTask, type TaskView } from "./tasks.ts";
|
|
4
|
+
import type { TaskResult } from "./task-results.ts";
|
|
5
|
+
|
|
6
|
+
export type TabId = "plan" | "result" | "changes" | "review";
|
|
7
|
+
export type TabMark = "wait" | "run" | "ok" | null;
|
|
8
|
+
const PLANNING = ["plan", "explore"];
|
|
9
|
+
|
|
10
|
+
const waiting = (t: TaskView) => !!(t.decision || t.pendingDecision);
|
|
11
|
+
const planning = (t: TaskView) => t.status === "working" && PLANNING.includes(t.runStage ?? "") && !t.currentResultId;
|
|
12
|
+
// Plan while a decision waits, the task has not started, or the agent is still planning; Result from the build on.
|
|
13
|
+
export const tabFor = (t: TaskView): TabId => (waiting(t) || t.status === "draft" || planning(t) ? "plan" : "result");
|
|
14
|
+
export function tabMarks(t: TaskView, current?: TaskResult): Record<"plan" | "result", TabMark> {
|
|
15
|
+
const done = t.attention?.category === "completed" || t.status === "accepted";
|
|
16
|
+
return {
|
|
17
|
+
plan: waiting(t) ? "wait" : planning(t) ? "run" : null,
|
|
18
|
+
result:
|
|
19
|
+
planning(t) || waiting(t)
|
|
20
|
+
? null
|
|
21
|
+
: t.status === "working"
|
|
22
|
+
? "run"
|
|
23
|
+
: done
|
|
24
|
+
? "ok"
|
|
25
|
+
: canAcceptTask(t, current)
|
|
26
|
+
? "wait"
|
|
27
|
+
: null,
|
|
28
|
+
};
|
|
29
|
+
}
|
package/web/lib/task/tasks.ts
CHANGED
|
@@ -11,7 +11,16 @@ export type TaskDecision = {
|
|
|
11
11
|
details?: string;
|
|
12
12
|
options?: string[];
|
|
13
13
|
};
|
|
14
|
-
export type TaskMessage = {
|
|
14
|
+
export type TaskMessage = {
|
|
15
|
+
id: string;
|
|
16
|
+
role: string;
|
|
17
|
+
text: string;
|
|
18
|
+
type?: string;
|
|
19
|
+
at?: number | string;
|
|
20
|
+
agent?: string;
|
|
21
|
+
};
|
|
22
|
+
// One tool that worked on the task (the server reads it from the task's runs): working now, stopped, or finished.
|
|
23
|
+
export type TaskAgent = { agent: string; name: string; state: "working" | "stopped" | "done"; current: boolean };
|
|
15
24
|
export type TaskView = {
|
|
16
25
|
id: string;
|
|
17
26
|
dir: string;
|
|
@@ -37,6 +46,7 @@ export type TaskView = {
|
|
|
37
46
|
agentAlive?: boolean;
|
|
38
47
|
agentAsking?: boolean;
|
|
39
48
|
runStage?: string;
|
|
49
|
+
agents?: TaskAgent[];
|
|
40
50
|
// What the server allows now; the page draws this list and decides nothing itself.
|
|
41
51
|
actions?: {
|
|
42
52
|
accept: boolean;
|
|
@@ -132,3 +142,32 @@ export const closeActions = (t: TaskView) =>
|
|
|
132
142
|
export const runIdsOf = (t: TaskView) => [
|
|
133
143
|
...new Set([...(t.runs ?? []).map((r) => (typeof r === "string" ? r : r.id)), ...(t.activeRun ? [t.activeRun] : [])]),
|
|
134
144
|
];
|
|
145
|
+
|
|
146
|
+
// The words a person gave, without the board's own scaffolding: `#` marks, HTML comments, and a bare Request or Inbox heading.
|
|
147
|
+
// A request as the board stored it, without the scaffolding the inbox added around the person's words.
|
|
148
|
+
export function cleanRequest(raw = "") {
|
|
149
|
+
return raw
|
|
150
|
+
.replace(/<!--[\s\S]*?-->/g, "")
|
|
151
|
+
.replace(/^\s*#+\s*Request\s*$/gim, "")
|
|
152
|
+
.replace(/^\s*#+\s*Inbox\b[\s\S]*$/im, "")
|
|
153
|
+
.trim();
|
|
154
|
+
}
|
|
155
|
+
export function cleanTitle(raw = "") {
|
|
156
|
+
const line = raw
|
|
157
|
+
.replace(/<!--[\s\S]*?-->/g, "")
|
|
158
|
+
.split("\n")
|
|
159
|
+
.map((l) => l.replace(/^\s*#+\s*/, "").trim())
|
|
160
|
+
.find((l) => l && !/^(request|inbox)$/i.test(l));
|
|
161
|
+
return line ? line[0].toUpperCase() + line.slice(1, 160) : "";
|
|
162
|
+
}
|
|
163
|
+
export const taskTitle = (t: { title: string; goal?: string }) => cleanTitle(t.title) || cleanTitle(t.goal) || t.title;
|
|
164
|
+
// How a tool is named on screen: its own name, else the word the run recorded.
|
|
165
|
+
export const AGENT_NAMES: Record<string, string> = {
|
|
166
|
+
claude: "Claude",
|
|
167
|
+
codex: "Codex",
|
|
168
|
+
gemini: "Gemini",
|
|
169
|
+
agy: "Antigravity",
|
|
170
|
+
opencode: "OpenCode",
|
|
171
|
+
cursor: "Cursor",
|
|
172
|
+
};
|
|
173
|
+
export const agentName = (agent: string) => AGENT_NAMES[agent] ?? agent;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// Everything the task page works out from one task and the handlers it calls, shared by the desktop page and the phone's:
|
|
2
|
+
// which result is shown, what the server lets the person do, the ⋯ menu, and the one message send. The layouts only draw it.
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
import { useShallow } from "zustand/react/shallow";
|
|
5
|
+
import { host, useStore } from "@lib/core";
|
|
6
|
+
import { runAction, sendMessage } from "./use-task.ts";
|
|
7
|
+
import {
|
|
8
|
+
canAcceptTask,
|
|
9
|
+
closeActions,
|
|
10
|
+
queuedInputs,
|
|
11
|
+
runIdsOf,
|
|
12
|
+
sortedResults,
|
|
13
|
+
taskTitle,
|
|
14
|
+
type TaskPageData,
|
|
15
|
+
type TaskView,
|
|
16
|
+
} from "./tasks.ts";
|
|
17
|
+
|
|
18
|
+
export function useTaskPage(page: TaskPageData, t: TaskView, afterSend?: () => void) {
|
|
19
|
+
const { pending, receipt, draft } = useStore(
|
|
20
|
+
useShallow((s) => ({ pending: s.pending, receipt: s.receipt, draft: s.draft })),
|
|
21
|
+
);
|
|
22
|
+
const [picked, setPicked] = useState(""),
|
|
23
|
+
[follow, setFollow] = useState(true),
|
|
24
|
+
[artifactId, setArtifactId] = useState(""),
|
|
25
|
+
[confirm, setConfirm] = useState<"" | "abandon" | "delete">(""),
|
|
26
|
+
[denied, setDenied] = useState(false);
|
|
27
|
+
const input = useRef<HTMLTextAreaElement>(null);
|
|
28
|
+
const results = sortedResults(page.results),
|
|
29
|
+
current = results.find((r) => r.id === t.currentResultId),
|
|
30
|
+
selected =
|
|
31
|
+
follow && current ? current : (results.find((r) => r.id === picked) ?? current ?? results[results.length - 1]),
|
|
32
|
+
selectedId = selected?.id ?? "",
|
|
33
|
+
isCurrent = selectedId === t.currentResultId;
|
|
34
|
+
const stop = t.actions?.stop ?? (!!t.activeRun && !["interrupted", "failed"].includes(t.status ?? ""));
|
|
35
|
+
const resume = t.actions?.resume ?? ["interrupted", "failed"].includes(t.status ?? "");
|
|
36
|
+
const start = !(
|
|
37
|
+
t.actions?.start === false ||
|
|
38
|
+
!t.dir ||
|
|
39
|
+
!!t.activeRun ||
|
|
40
|
+
!!t.currentResultId ||
|
|
41
|
+
t.status !== "draft" ||
|
|
42
|
+
t.decision?.kind === "project"
|
|
43
|
+
);
|
|
44
|
+
const accept = isCurrent && canAcceptTask(t, current);
|
|
45
|
+
const queue = queuedInputs(t).filter((i) => i.state !== "dispatched");
|
|
46
|
+
const close = closeActions(t);
|
|
47
|
+
const runs = runIdsOf(t);
|
|
48
|
+
const workspace = runs.length ? `?view=run&id=${runs[runs.length - 1]}&dir=${encodeURIComponent(t.dir)}` : undefined;
|
|
49
|
+
const finish = async (op: string, extra: Record<string, unknown> = {}) => {
|
|
50
|
+
const r = await runAction(op, extra);
|
|
51
|
+
if (r?.ok) {
|
|
52
|
+
history.pushState(null, "", "?view=tasks");
|
|
53
|
+
host.go("tasks");
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const send = async () => {
|
|
57
|
+
if (!(await sendMessage(selectedId))) return void input.current?.focus();
|
|
58
|
+
setDenied(false);
|
|
59
|
+
setFollow(true);
|
|
60
|
+
afterSend?.();
|
|
61
|
+
input.current?.focus();
|
|
62
|
+
};
|
|
63
|
+
const menu = [
|
|
64
|
+
...runs.map((id) => ({
|
|
65
|
+
id: "run-" + id,
|
|
66
|
+
label: "Open workspace",
|
|
67
|
+
hint: id,
|
|
68
|
+
href: `?view=run&id=${id}&dir=${encodeURIComponent(t.dir)}`,
|
|
69
|
+
})),
|
|
70
|
+
{ id: "archive", label: "Archive", onSelect: () => void finish("archive") },
|
|
71
|
+
...(close.abandon
|
|
72
|
+
? [{ id: "abandon", label: "Abandon", danger: true, before: true, onSelect: () => setConfirm("abandon") }]
|
|
73
|
+
: []),
|
|
74
|
+
...(close.delete
|
|
75
|
+
? [{ id: "delete", label: "Delete", danger: true, before: !close.abandon, onSelect: () => setConfirm("delete") }]
|
|
76
|
+
: []),
|
|
77
|
+
];
|
|
78
|
+
const help = t.activeRun
|
|
79
|
+
? "Changes are saved for the next safe pass. Questions do not interrupt production."
|
|
80
|
+
: t.attention.category === "completed"
|
|
81
|
+
? "A new change stays in this task and starts a linked revision."
|
|
82
|
+
: "Ask a question or describe a change. Your message stays with this task.";
|
|
83
|
+
// Why a task that is not running says so: the failure, in plain words (the agent chip and the tabs carry the rest).
|
|
84
|
+
const note = ["failed", "interrupted", "stopping"].includes(t.status ?? "")
|
|
85
|
+
? [t.attention?.reason, t.attention?.action, t.error].filter(Boolean).join(" · ")
|
|
86
|
+
: "";
|
|
87
|
+
return {
|
|
88
|
+
title: taskTitle(t),
|
|
89
|
+
pending,
|
|
90
|
+
receipt,
|
|
91
|
+
draft,
|
|
92
|
+
results,
|
|
93
|
+
selected,
|
|
94
|
+
selectedId,
|
|
95
|
+
current,
|
|
96
|
+
isCurrent,
|
|
97
|
+
picked: (id: string) => {
|
|
98
|
+
setPicked(id);
|
|
99
|
+
setFollow(id === t.currentResultId);
|
|
100
|
+
setArtifactId("");
|
|
101
|
+
},
|
|
102
|
+
artifactId,
|
|
103
|
+
setArtifactId,
|
|
104
|
+
confirm,
|
|
105
|
+
setConfirm,
|
|
106
|
+
denied,
|
|
107
|
+
setDenied,
|
|
108
|
+
input,
|
|
109
|
+
stop,
|
|
110
|
+
resume,
|
|
111
|
+
start,
|
|
112
|
+
accept,
|
|
113
|
+
queue,
|
|
114
|
+
runs,
|
|
115
|
+
workspace,
|
|
116
|
+
finish,
|
|
117
|
+
send,
|
|
118
|
+
menu,
|
|
119
|
+
help,
|
|
120
|
+
note,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
export type TaskModel = ReturnType<typeof useTaskPage>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// The task's latest run, read from the board's own run route: the approved plan, its review findings and the files it
|
|
2
|
+
// changed. The Plan (once approved), Changes and Review tabs draw from it; nothing here writes.
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { runIdsOf, type TaskView } from "./tasks.ts";
|
|
5
|
+
|
|
6
|
+
export type RunFinding = { n: number; text: string; done?: boolean };
|
|
7
|
+
export type RunFile = { path: string; add: number; del: number; code: string };
|
|
8
|
+
export type RunDoc = {
|
|
9
|
+
id: string;
|
|
10
|
+
plan: string | null;
|
|
11
|
+
review: string | null;
|
|
12
|
+
findings: RunFinding[];
|
|
13
|
+
files: RunFile[];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function useTaskRun(t: TaskView): { run: RunDoc | null; loaded: boolean } {
|
|
17
|
+
const id = runIdsOf(t).at(-1) ?? "",
|
|
18
|
+
key = [id, t.revision, t.status, t.runStage].join("|");
|
|
19
|
+
const [state, setState] = useState<{ id: string; run: RunDoc | null; loaded: boolean }>({
|
|
20
|
+
id: "",
|
|
21
|
+
run: null,
|
|
22
|
+
loaded: false,
|
|
23
|
+
});
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!id || !t.dir) return void setState({ id: "", run: null, loaded: true });
|
|
26
|
+
const ac = new AbortController();
|
|
27
|
+
fetch(`/run/${encodeURIComponent(id)}?dir=${encodeURIComponent(t.dir)}`, { signal: ac.signal })
|
|
28
|
+
.then((r) => r.json())
|
|
29
|
+
.then(
|
|
30
|
+
(d) =>
|
|
31
|
+
setState({
|
|
32
|
+
id,
|
|
33
|
+
loaded: true,
|
|
34
|
+
run:
|
|
35
|
+
d && d.id === id
|
|
36
|
+
? {
|
|
37
|
+
id,
|
|
38
|
+
plan: d.plan ?? null,
|
|
39
|
+
review: d.review ?? null,
|
|
40
|
+
findings: d.findings ?? [],
|
|
41
|
+
files: d.git?.rows ?? [],
|
|
42
|
+
}
|
|
43
|
+
: null,
|
|
44
|
+
}),
|
|
45
|
+
() => ac.signal.aborted || setState((s) => ({ ...s, loaded: true })),
|
|
46
|
+
);
|
|
47
|
+
return () => ac.abort();
|
|
48
|
+
}, [key]);
|
|
49
|
+
return { run: state.id === id ? state.run : null, loaded: state.loaded };
|
|
50
|
+
}
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import { useEffect, useLayoutEffect, useRef } from "react";
|
|
2
|
-
import { cn } from "@lib/core";
|
|
2
|
+
import { cn, usePhone } from "@lib/core";
|
|
3
|
+
import { PanelFrame } from "@components/shared";
|
|
3
4
|
import { DocBody, PanelGrip, PanelHead, PanelTabs, ProjectNotes, RunFooter, RunPicker } from "@components/run";
|
|
4
5
|
import { NotesChat } from "@components/notes";
|
|
5
6
|
import { TerminalPane } from "@components/panes";
|
|
6
7
|
import { GitHost } from "@components/git";
|
|
7
8
|
import { bindSheetSwipe } from "@lib/phone";
|
|
8
9
|
import { isPhone } from "@lib/core";
|
|
9
|
-
import {
|
|
10
|
-
|
|
10
|
+
import {
|
|
11
|
+
dismissPanel,
|
|
12
|
+
openProjectNotes,
|
|
13
|
+
panelBody,
|
|
14
|
+
setFlip,
|
|
15
|
+
setPanel,
|
|
16
|
+
useRunView,
|
|
17
|
+
usePanel,
|
|
18
|
+
usePanelRun,
|
|
19
|
+
} from "@lib/run";
|
|
20
|
+
import { getRoute, useRoute } from "@lib/router";
|
|
11
21
|
import { SettingsPage } from "../settings-page.tsx";
|
|
12
22
|
import { Part } from "./host.tsx";
|
|
13
23
|
|
|
@@ -65,10 +75,14 @@ function PanelBody() {
|
|
|
65
75
|
// docked, wide, parked, its title) is the panel store's; usePanelRun reads the open run and writes what is drawn.
|
|
66
76
|
export function Panel() {
|
|
67
77
|
usePanelRun();
|
|
78
|
+
const inRun = useRoute((r) => r.view === "run"),
|
|
79
|
+
phone = usePhone(),
|
|
80
|
+
framed = inRun && !phone;
|
|
68
81
|
const cls = usePanel((s) =>
|
|
69
82
|
cn(s.open && "open", s.docked && "docked", s.wide && "wide", s.parked && "parked", s.pn && "pn", s.ro && "ro"),
|
|
70
83
|
),
|
|
71
84
|
on = usePanel((s) => s.open),
|
|
85
|
+
parked = usePanel((s) => s.parked),
|
|
72
86
|
title = usePanel((s) => s.title),
|
|
73
87
|
tip = usePanel((s) => s.titleTip),
|
|
74
88
|
instant = usePanel((s) => s.instant),
|
|
@@ -89,8 +103,89 @@ export function Panel() {
|
|
|
89
103
|
close: () => setFlip(false),
|
|
90
104
|
keep: "#panel,#rside,dialog,.toast,[data-sonner-toast]",
|
|
91
105
|
}),
|
|
92
|
-
|
|
106
|
+
// The panel element is another one when the frame is drawn (a window resized across 640px): bind again.
|
|
107
|
+
[framed],
|
|
93
108
|
);
|
|
109
|
+
// The run workspace on a computer: the panel is the shared PanelFrame (the layout the task page's panel uses too), with
|
|
110
|
+
// the panel's own pieces in its slots. A phone's sheet and the Board's drawer keep the markup below.
|
|
111
|
+
if (framed)
|
|
112
|
+
return (
|
|
113
|
+
<>
|
|
114
|
+
<div className={cn("scrim", on && "on")} id="scrim" onClick={dismissPanel} />
|
|
115
|
+
<PanelFrame
|
|
116
|
+
as="aside"
|
|
117
|
+
id="panel"
|
|
118
|
+
label="detail"
|
|
119
|
+
rootRef={aside as never}
|
|
120
|
+
className={cls || undefined}
|
|
121
|
+
hidden={parked}
|
|
122
|
+
flush
|
|
123
|
+
folded={false}
|
|
124
|
+
header={
|
|
125
|
+
<div className="t">
|
|
126
|
+
<div className="pwrap">
|
|
127
|
+
<Part>
|
|
128
|
+
<RunPicker />
|
|
129
|
+
</Part>
|
|
130
|
+
</div>
|
|
131
|
+
<b id="ptitle" title={tip}>
|
|
132
|
+
{title}
|
|
133
|
+
</b>
|
|
134
|
+
<div className="sub" id="psub">
|
|
135
|
+
<Part>
|
|
136
|
+
<PanelHead />
|
|
137
|
+
</Part>
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
}
|
|
141
|
+
strip={
|
|
142
|
+
<>
|
|
143
|
+
<nav id="ptabs">
|
|
144
|
+
<Part>
|
|
145
|
+
<PanelTabs />
|
|
146
|
+
</Part>
|
|
147
|
+
</nav>
|
|
148
|
+
<button
|
|
149
|
+
className="pnotes"
|
|
150
|
+
id="pnotes"
|
|
151
|
+
title="Project notes"
|
|
152
|
+
aria-label="Project notes"
|
|
153
|
+
onClick={openProjectNotes}
|
|
154
|
+
>
|
|
155
|
+
<Icon id="t-book" />
|
|
156
|
+
</button>
|
|
157
|
+
</>
|
|
158
|
+
}
|
|
159
|
+
body={
|
|
160
|
+
<>
|
|
161
|
+
<div className="body md" id="pnlist">
|
|
162
|
+
<Part>
|
|
163
|
+
<ProjectNotes />
|
|
164
|
+
</Part>
|
|
165
|
+
</div>
|
|
166
|
+
<PanelBody />
|
|
167
|
+
</>
|
|
168
|
+
}
|
|
169
|
+
foot={
|
|
170
|
+
<div
|
|
171
|
+
className="foot"
|
|
172
|
+
id="pfoot"
|
|
173
|
+
// The frame's footer metrics (the old rule gave them only to a footer that is a direct child of the panel).
|
|
174
|
+
style={{ padding: "var(--panel-foot-y) var(--panel-pad-x)", gap: "var(--panel-foot-gap)" }}
|
|
175
|
+
>
|
|
176
|
+
<Part>
|
|
177
|
+
<RunFooter />
|
|
178
|
+
</Part>
|
|
179
|
+
</div>
|
|
180
|
+
}
|
|
181
|
+
extra={
|
|
182
|
+
<Part>
|
|
183
|
+
<PanelGrip />
|
|
184
|
+
</Part>
|
|
185
|
+
}
|
|
186
|
+
/>
|
|
187
|
+
</>
|
|
188
|
+
);
|
|
94
189
|
return (
|
|
95
190
|
<>
|
|
96
191
|
<div className={cn("scrim", on && "on")} id="scrim" onClick={dismissPanel} />
|