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.
Files changed (57) hide show
  1. package/cli/activity.ts +2 -1
  2. package/cli/state.ts +15 -0
  3. package/cli/task-service.ts +23 -6
  4. package/cli/tasks.ts +4 -3
  5. package/cli/whats-new.json +26 -0
  6. package/package.json +1 -1
  7. package/web/components/decision/decision-bar.tsx +77 -26
  8. package/web/components/decision/index.ts +1 -0
  9. package/web/components/decision/plan-text.tsx +17 -0
  10. package/web/components/phone/phone-home.tsx +19 -14
  11. package/web/components/rail/rail-list.tsx +27 -4
  12. package/web/components/shared/action-menu.tsx +19 -2
  13. package/web/components/shared/index.ts +1 -0
  14. package/web/components/shared/panel-frame.tsx +212 -0
  15. package/web/components/shell/rail.tsx +5 -3
  16. package/web/components/task/agent-chip.tsx +56 -0
  17. package/web/components/task/agent-mark.tsx +34 -0
  18. package/web/components/task/changes-view.tsx +26 -0
  19. package/web/components/task/chat-bubble.tsx +8 -3
  20. package/web/components/task/composer.tsx +78 -0
  21. package/web/components/task/conversation.tsx +65 -0
  22. package/web/components/task/index.ts +12 -0
  23. package/web/components/task/plan-view.tsx +50 -0
  24. package/web/components/task/reference-files.tsx +24 -0
  25. package/web/components/task/result-view.tsx +3 -1
  26. package/web/components/task/review-view.tsx +40 -0
  27. package/web/components/task/saved-results.tsx +38 -0
  28. package/web/components/task/task-panel.tsx +143 -0
  29. package/web/components/task/task-phone.tsx +211 -0
  30. package/web/components/task/task-row.tsx +2 -2
  31. package/web/components/task/task-tabs.tsx +77 -0
  32. package/web/dist/annotate.js +1 -1
  33. package/web/dist/board.css +7 -5
  34. package/web/dist/board.js +59 -58
  35. package/web/dist/boot.js +1 -1
  36. package/web/dist/notebook.css +2 -2
  37. package/web/dist/notebook.js +33 -32
  38. package/web/dist/popup.css +1 -1
  39. package/web/dist/popup.js +1 -1
  40. package/web/dist/term.js +1 -1
  41. package/web/dist/ui.css +2 -2
  42. package/web/dist/video.js +18 -18
  43. package/web/lib/core/index.ts +1 -0
  44. package/web/lib/core/use-phone.ts +15 -0
  45. package/web/lib/router/route-rules.ts +17 -4
  46. package/web/lib/server/types.ts +1 -0
  47. package/web/lib/task/conversation.ts +56 -0
  48. package/web/lib/task/index.ts +5 -0
  49. package/web/lib/task/task-progress.ts +21 -0
  50. package/web/lib/task/task-tabs.ts +29 -0
  51. package/web/lib/task/tasks.ts +40 -1
  52. package/web/lib/task/use-task-page.ts +123 -0
  53. package/web/lib/task/use-task-run.ts +50 -0
  54. package/web/pages/board/panel.tsx +99 -4
  55. package/web/pages/task-page.tsx +319 -350
  56. package/web/ui/legacy/board.css +5 -3
  57. package/web/ui/theme.css +4 -0
@@ -0,0 +1,40 @@
1
+ import { Markdown } from "@components/markdown";
2
+ import { cn } from "@lib/core";
3
+ import type { RunDoc } from "@lib/task";
4
+
5
+ // What the independent review found, numbered. Read-only: fixing findings is the run workspace's job.
6
+ export function ReviewView({ run, workspace }: { run: RunDoc | null; workspace?: string }) {
7
+ if (!run?.review) return <p className="p-2 text-muted-foreground">There is no review yet.</p>;
8
+ const open = run.findings.filter((f) => !f.done).length;
9
+ return (
10
+ <div className="flex flex-col gap-3">
11
+ {run.findings.length ? (
12
+ <>
13
+ <p className="text-sm text-muted-foreground">
14
+ {open ? `${open} open finding${open === 1 ? "" : "s"}` : "Every finding is closed"} of {run.findings.length}
15
+ </p>
16
+ <ol aria-label="Review findings" className="overflow-hidden rounded-lg border border-border bg-card">
17
+ {run.findings.map((f) => (
18
+ <li key={f.n} className="flex gap-3 border-b border-border px-3 py-2.5 last:border-b-0">
19
+ <span className="mt-0.5 grid size-5 shrink-0 place-items-center rounded-full bg-muted text-[11px] text-muted-foreground">
20
+ {f.n}
21
+ </span>
22
+ <Markdown
23
+ text={f.text}
24
+ className={cn("min-w-0 flex-1 [&_p]:mb-0", f.done && "text-muted-foreground line-through")}
25
+ />
26
+ </li>
27
+ ))}
28
+ </ol>
29
+ </>
30
+ ) : (
31
+ <p className="p-2 text-muted-foreground">The review found nothing to fix.</p>
32
+ )}
33
+ {workspace && (
34
+ <a href={workspace} className="text-sm text-muted-foreground underline">
35
+ Open in the run workspace
36
+ </a>
37
+ )}
38
+ </div>
39
+ );
40
+ }
@@ -0,0 +1,38 @@
1
+ import type { TaskResult } from "@lib/task";
2
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@web/ui";
3
+
4
+ // Which saved version of the result is shown; nothing to pick while there is one.
5
+ export function SavedResults({
6
+ results,
7
+ selectedId,
8
+ currentId,
9
+ onPick,
10
+ }: {
11
+ results: TaskResult[];
12
+ selectedId: string;
13
+ currentId?: string | null;
14
+ onPick: (id: string) => void;
15
+ }) {
16
+ if (results.length < 2) return null;
17
+ return (
18
+ <div className="mb-3.5">
19
+ <Select value={selectedId} onValueChange={onPick}>
20
+ <SelectTrigger
21
+ aria-label="Saved results"
22
+ size="sm"
23
+ title="Files are retained without automatic expiry. Live links remain mutable."
24
+ >
25
+ <SelectValue />
26
+ </SelectTrigger>
27
+ <SelectContent>
28
+ {[...results].reverse().map((r, i) => (
29
+ <SelectItem key={r.id} value={r.id}>
30
+ {r.title || "Version " + (results.length - i)}
31
+ {r.id === currentId ? " · current" : " · earlier saved output"}
32
+ </SelectItem>
33
+ ))}
34
+ </SelectContent>
35
+ </Select>
36
+ </div>
37
+ );
38
+ }
@@ -0,0 +1,143 @@
1
+ import { useEffect, useState, type ReactNode, type RefObject } from "react";
2
+ import {
3
+ IconButton,
4
+ PanelFrame,
5
+ PanelPicker,
6
+ PanelProgress,
7
+ PanelStrip,
8
+ StateDot,
9
+ type PanelStripItem,
10
+ } from "@components/shared";
11
+ import { openTask, taskDot } from "@lib/rail";
12
+ import { useServer } from "@lib/server";
13
+ import { cleanRequest, conversationItems, taskProgress, taskTitle, type TaskView } from "@lib/task";
14
+ import { AgentChip } from "./agent-chip.tsx";
15
+ import { ReferenceFiles } from "./reference-files.tsx";
16
+ import { Thread } from "./conversation.tsx";
17
+
18
+ type View = "chat" | "request" | "files";
19
+ const STRIP: PanelStripItem[] = [
20
+ { id: "chat", icon: "request", label: "Conversation" },
21
+ { id: "request", icon: "notes", label: "The request" },
22
+ { id: "files", icon: "book", label: "Files" },
23
+ ];
24
+
25
+ // The task page's right panel in the run workspace panel's frame: the task as a picker, its progress, the agent on it, the
26
+ // conversation (or the request, or the files) as the body, the message box and the quiet Archive and Abandon at the foot,
27
+ // and an icon strip down the edge. The strip folds the panel to itself. `controls` are Resume and Stop, `footer` the box.
28
+ export function TaskPanel({
29
+ t,
30
+ folded,
31
+ onFold,
32
+ controls,
33
+ threadRef,
34
+ footer,
35
+ actions,
36
+ after,
37
+ focusChat,
38
+ dot,
39
+ projectName,
40
+ }: {
41
+ t: TaskView;
42
+ folded: boolean;
43
+ onFold: (folded: boolean) => void;
44
+ controls?: ReactNode;
45
+ threadRef: RefObject<HTMLDivElement | null>;
46
+ footer: ReactNode;
47
+ actions: ReactNode;
48
+ after?: ReactNode; // under the thread: the requests waiting for the agent
49
+ focusChat?: number; // raised when the page opens the conversation itself (a send, Ask for changes)
50
+ dot?: boolean;
51
+ projectName: string;
52
+ }) {
53
+ const [view, setView] = useState<View>("chat"),
54
+ tasks = useServer((s) => s.tasks),
55
+ items = conversationItems(t),
56
+ progress = taskProgress(t),
57
+ mine = (tasks ?? []).filter((x) => x.dir === t.dir),
58
+ mineAll = mine.some((x) => x.id === t.id) ? mine : [{ ...t, attention: t.attention } as never, ...mine],
59
+ pick = (id: string) => {
60
+ if (!folded && id === view) return onFold(true);
61
+ setView(id as View);
62
+ onFold(false);
63
+ };
64
+ // The page opening the conversation (a send, Ask for changes) shows the Conversation view, at its newest message.
65
+ useEffect(() => {
66
+ if (focusChat) setView("chat");
67
+ }, [focusChat]);
68
+ useEffect(() => {
69
+ const el = threadRef.current?.parentElement;
70
+ if (view === "chat" && !folded && el) requestAnimationFrame(() => (el.scrollTop = el.scrollHeight));
71
+ }, [view, folded, items.length, threadRef]);
72
+ const header = (
73
+ <div className="flex flex-col gap-1.5">
74
+ <div className="flex items-center gap-1">
75
+ <div className="min-w-0 flex-1">
76
+ <PanelPicker
77
+ current={taskTitle(t)}
78
+ mark={<StateDot state={taskDot(t as never)} />}
79
+ items={mineAll.map((x) => ({
80
+ id: x.id,
81
+ label: taskTitle(x),
82
+ mark: <StateDot state={taskDot(x)} />,
83
+ hint: x.attention.reason,
84
+ }))}
85
+ onPick={(id) => id !== t.id && openTask(id, t.dir)}
86
+ />
87
+ </div>
88
+ <IconButton icon="side" label="Collapse the panel" onClick={() => onFold(true)} />
89
+ </div>
90
+ <div className="flex items-center gap-2.5">
91
+ <span className="max-w-[120px] shrink-0 truncate text-xs text-muted-foreground">{projectName}</span>
92
+ <PanelProgress {...progress} />
93
+ </div>
94
+ <div className="flex min-h-9 items-center gap-2">
95
+ <div className="mr-auto min-w-0">
96
+ <AgentChip agents={t.agents ?? []} stage={t.runStage} />
97
+ </div>
98
+ {controls}
99
+ </div>
100
+ </div>
101
+ );
102
+ const body =
103
+ view === "request" ? (
104
+ <p className="whitespace-pre-wrap break-words text-base">{cleanRequest(t.goal) || t.title}</p>
105
+ ) : view === "files" ? (
106
+ t.files?.length ? (
107
+ <ReferenceFiles files={t.files} />
108
+ ) : (
109
+ <p className="text-muted-foreground">No files are attached to this task.</p>
110
+ )
111
+ ) : (
112
+ <div ref={threadRef}>
113
+ <ReferenceFiles files={t.files} />
114
+ <Thread items={items} working={t.status === "working"} />
115
+ {after}
116
+ </div>
117
+ );
118
+ return (
119
+ <PanelFrame
120
+ // The task page pads its content by 28px; the run workspace's panel touches the edge of the card, so this one is pulled
121
+ // out by the same 28px (top, right and bottom).
122
+ className="-my-7 -mr-7"
123
+ label={folded ? "Conversation, collapsed" : "Conversation and requests"}
124
+ folded={folded}
125
+ header={header}
126
+ body={body}
127
+ foot={
128
+ <>
129
+ {footer}
130
+ <div className="mt-2 flex gap-1.5">{actions}</div>
131
+ </>
132
+ }
133
+ strip={
134
+ <PanelStrip
135
+ items={STRIP.map((s) => (s.id === "chat" ? { ...s, dot } : s))}
136
+ active={view}
137
+ folded={folded}
138
+ onPick={pick}
139
+ />
140
+ }
141
+ />
142
+ );
143
+ }
@@ -0,0 +1,211 @@
1
+ import { useEffect, useRef, useState, type ReactNode } from "react";
2
+ import { ActionMenu, IconButton } from "@components/shared";
3
+ import { DecisionBar, PlanText } from "@components/decision";
4
+ import { host } from "@lib/core";
5
+ import {
6
+ conversationItems,
7
+ projectLabel,
8
+ runAction,
9
+ savedLine,
10
+ setDraft,
11
+ taskStatus,
12
+ type TaskModel,
13
+ type TaskPageData,
14
+ type TaskView,
15
+ } from "@lib/task";
16
+ import { BottomSheetContent, Button, Sheet, SheetClose, SheetContent, SheetDescription, SheetTitle } from "@web/ui";
17
+ import { AgentChip } from "./agent-chip.tsx";
18
+ import { Composer } from "./composer.tsx";
19
+ import { Thread } from "./conversation.tsx";
20
+ import { ReferenceFiles } from "./reference-files.tsx";
21
+ import { ResultView } from "./result-view.tsx";
22
+ import { SavedResults } from "./saved-results.tsx";
23
+
24
+ // A phone's task: no tabs, the task is the chat. What waits on the person docks above the message box (the plan's
25
+ // Approve and Ask for changes, or Looks good), the detailed plan opens in a sheet, and the result is a card in the
26
+ // chat that opens full screen.
27
+ export function TaskPhone({
28
+ page,
29
+ t,
30
+ m,
31
+ permission,
32
+ }: {
33
+ page: TaskPageData;
34
+ t: TaskView;
35
+ m: TaskModel;
36
+ permission: ReactNode;
37
+ }) {
38
+ const [plan, setPlan] = useState<string | null>(null),
39
+ [full, setFull] = useState(false);
40
+ const items = conversationItems(t),
41
+ box = useRef<HTMLDivElement>(null);
42
+ const ask = () => m.input.current?.focus();
43
+ // The newest message, and the result card after it, are what a phone opens on.
44
+ useEffect(() => {
45
+ const el = box.current;
46
+ if (el) requestAnimationFrame(() => (el.scrollTop = el.scrollHeight));
47
+ }, [items.length, !!m.selected, !!t.decision]);
48
+ const waiting = !!t.decision || !t.dir;
49
+ const result = m.selected;
50
+ return (
51
+ <div className="flex min-h-0 flex-1 flex-col gap-2">
52
+ <header className="flex flex-none items-center gap-1.5">
53
+ <IconButton
54
+ icon="arrow"
55
+ label="Back to tasks"
56
+ href="?view=tasks"
57
+ className="[&_svg]:rotate-180"
58
+ onClick={(e) => (e.preventDefault(), host.go("tasks", true))}
59
+ />
60
+ <div className="mr-auto min-w-0">
61
+ <p className="truncate text-xs text-muted-foreground">{projectLabel(t, page.projects)}</p>
62
+ <h1 className="truncate text-base font-semibold leading-snug">{m.title}</h1>
63
+ </div>
64
+ <ActionMenu label="Task actions" items={m.menu}>
65
+ <p className="mb-2 text-sm text-muted-foreground">
66
+ Task {t.id} · revision {t.revision}
67
+ </p>
68
+ </ActionMenu>
69
+ </header>
70
+ <div className="flex flex-none items-center gap-2">
71
+ <div className="mr-auto min-w-0">
72
+ <AgentChip agents={t.agents ?? []} stage={t.runStage} />
73
+ </div>
74
+ {m.stop && (
75
+ <Button size="sm" disabled={m.pending || t.status === "stopping"} onClick={() => void runAction("stop")}>
76
+ {t.status === "stopping" ? "Stopping…" : "Stop"}
77
+ </Button>
78
+ )}
79
+ {m.resume && (
80
+ <Button size="sm" onClick={() => void runAction("resume")}>
81
+ {t.status === "failed" ? "Retry" : "Resume"}
82
+ </Button>
83
+ )}
84
+ {m.start && (
85
+ <Button
86
+ size="sm"
87
+ variant="primary"
88
+ onClick={() =>
89
+ host.runPopup(
90
+ { _k: "task:" + t.id, kind: "task", state: t.dir, text: t.title },
91
+ (pick) => void runAction("start", { pick }),
92
+ )
93
+ }
94
+ >
95
+ Start planning
96
+ </Button>
97
+ )}
98
+ </div>
99
+ {permission}
100
+ <div ref={box} className="min-h-0 flex-1 overflow-auto [scrollbar-gutter:stable]">
101
+ <ReferenceFiles files={t.files} />
102
+ <Thread items={items} working={t.status === "working"} />
103
+ {result && (
104
+ <button
105
+ type="button"
106
+ onClick={() => setFull(true)}
107
+ className="mb-3 flex w-full items-center gap-3 rounded-2xl border border-border bg-card p-3 text-left"
108
+ >
109
+ <span className="min-w-0 flex-1">
110
+ <b className="block truncate font-medium text-strong">{result.title || "The result"}</b>
111
+ {result.summary && <span className="line-clamp-2 text-sm text-muted-foreground">{result.summary}</span>}
112
+ <em className="mt-1.5 block text-sm not-italic">Open the result ›</em>
113
+ </span>
114
+ </button>
115
+ )}
116
+ {t.acceptedResultId && t.attention.category === "completed" && (
117
+ <p className="mb-3 text-success">Accepted. Publishing is a separate action.</p>
118
+ )}
119
+ {m.queue.length > 0 && (
120
+ <div aria-label="Requests awaiting completion" className="mb-1.5 flex justify-end gap-1.5 px-1">
121
+ {m.queue.map((i) => (
122
+ <span key={i.id} className="text-xs text-warning">
123
+ {i.state === "received" ? "Received" : "Queued for next pass"}
124
+ </span>
125
+ ))}
126
+ </div>
127
+ )}
128
+ </div>
129
+ {waiting && (
130
+ <div className="max-h-[45dvh] flex-none overflow-auto">
131
+ <DecisionBar
132
+ decision={t.decision}
133
+ needsProject={!t.dir || t.decision?.kind === "project"}
134
+ projects={page.projects}
135
+ pending={m.pending}
136
+ onApprove={(decisionId) => void runAction("confirm", { decisionId })}
137
+ onAnswer={(text) => (setDraft(text), void m.send())}
138
+ onProject={(choice) => void runAction("project", choice)}
139
+ onAsk={ask}
140
+ onDetails={setPlan}
141
+ />
142
+ </div>
143
+ )}
144
+ {m.accept && (
145
+ <div className="flex flex-none flex-col gap-2 rounded-lg border border-border bg-card p-3">
146
+ <p>
147
+ <b className="font-medium text-strong">Ready for you.</b> Check the result, then accept it.
148
+ </p>
149
+ <div className="flex gap-2">
150
+ <Button className="flex-1" onClick={ask}>
151
+ Ask for a change
152
+ </Button>
153
+ <Button
154
+ variant="primary"
155
+ className="flex-1"
156
+ onClick={() => void runAction("accept", { resultId: t.currentResultId })}
157
+ >
158
+ Looks good
159
+ </Button>
160
+ </div>
161
+ </div>
162
+ )}
163
+ <Composer
164
+ inputRef={m.input}
165
+ value={m.draft}
166
+ onChange={setDraft}
167
+ onSend={() => void m.send()}
168
+ pending={m.pending}
169
+ answering={t.decision?.kind === "question"}
170
+ help={m.help}
171
+ receipt={m.receipt}
172
+ />
173
+ <Sheet open={plan != null} onOpenChange={(o) => !o && setPlan(null)}>
174
+ <BottomSheetContent>
175
+ <SheetTitle>Detailed plan</SheetTitle>
176
+ <SheetDescription className="sr-only">The steps the agent will take once you approve.</SheetDescription>
177
+ {plan && <PlanText text={plan} className="mt-3" />}
178
+ </BottomSheetContent>
179
+ </Sheet>
180
+ <Sheet open={full} onOpenChange={setFull}>
181
+ <SheetContent className="w-full max-w-full border-l-0">
182
+ <div className="flex flex-none items-center gap-2 px-3 py-2">
183
+ <SheetClose asChild>
184
+ <IconButton icon="x" label="Close the result" />
185
+ </SheetClose>
186
+ <SheetTitle className="mr-auto">Result</SheetTitle>
187
+ <span className="text-xs text-muted-foreground">{savedLine(result)}</span>
188
+ </div>
189
+ <SheetDescription className="sr-only">The task's result.</SheetDescription>
190
+ <div className="flex min-h-0 flex-1 flex-col overflow-auto px-3 pb-3">
191
+ <SavedResults
192
+ results={m.results}
193
+ selectedId={m.selectedId}
194
+ currentId={t.currentResultId}
195
+ onPick={m.picked}
196
+ />
197
+ <ResultView
198
+ result={result}
199
+ artifactId={m.artifactId}
200
+ working={t.status === "working" ? taskStatus(t) : undefined}
201
+ stage={t.runStage}
202
+ alive={t.agentAlive}
203
+ waiting={t.status === "waiting"}
204
+ onSelect={m.setArtifactId}
205
+ />
206
+ </div>
207
+ </SheetContent>
208
+ </Sheet>
209
+ </div>
210
+ );
211
+ }
@@ -1,6 +1,6 @@
1
1
  import type { ComponentProps } from "react";
2
2
  import { age, cn } from "@lib/core";
3
- import { dirName, taskStatus, type TaskView } from "@lib/task";
3
+ import { dirName, taskStatus, taskTitle, type TaskView } from "@lib/task";
4
4
  import { StatusBadge } from "./status-badge.tsx";
5
5
 
6
6
  // One row of the Tasks list: marker, title and project, state and next step, age. `kb` is the keyboard's row.
@@ -17,7 +17,7 @@ export function TaskRow({ task, kb, ...props }: { task: TaskView; kb?: boolean }
17
17
  >
18
18
  <StatusBadge dot category={t.attention.category} />
19
19
  <span className="min-w-0">
20
- <strong className="block break-words font-normal">{t.title}</strong>
20
+ <strong className="block break-words font-normal">{taskTitle(t)}</strong>
21
21
  <small className="mt-0.5 block break-words text-xs text-muted-foreground">
22
22
  {t.projectName || (t.dir ? dirName(t.dir) : "Project needed")}
23
23
  {t.currentResultId ? " · Result available" : ""}
@@ -0,0 +1,77 @@
1
+ import { useLayoutEffect, useRef, useState } from "react";
2
+ import { cn } from "@lib/core";
3
+ import type { TabId, TabMark } from "@lib/task";
4
+
5
+ export type TabItem = { id: TabId; label: string; mark?: TabMark; count?: number };
6
+
7
+ // The mark on a tab says why it wants you: amber waits on you (and pings three times when it appears), a ring is an
8
+ // agent working, green is finished. It is keyed by its kind, so a change replays the ping.
9
+ function Mark({ mark }: { mark?: TabMark }) {
10
+ if (!mark) return null;
11
+ return mark === "run" ? (
12
+ <span
13
+ key={mark}
14
+ aria-hidden="true"
15
+ className="size-3 rounded-full border-[1.5px] border-muted-foreground border-t-transparent motion-safe:animate-spin"
16
+ />
17
+ ) : (
18
+ <span
19
+ key={mark}
20
+ aria-hidden="true"
21
+ className={cn(
22
+ "relative size-2 rounded-full",
23
+ mark === "wait"
24
+ ? "bg-warning after:absolute after:inset-0 after:rounded-full after:bg-warning motion-safe:after:animate-ping3"
25
+ : "bg-success after:absolute after:inset-0 after:rounded-full after:bg-success motion-safe:after:animate-ping3",
26
+ )}
27
+ />
28
+ );
29
+ }
30
+ // The task page's tabs. The underline slides to the tab that is open.
31
+ export function TaskTabs({ tabs, active, onPick }: { tabs: TabItem[]; active: TabId; onPick: (id: TabId) => void }) {
32
+ const refs = useRef<Partial<Record<TabId, HTMLButtonElement | null>>>({}),
33
+ [bar, setBar] = useState({ left: 0, width: 0 });
34
+ const sig = tabs.map((t) => t.id + t.label + (t.count ?? "") + (t.mark ?? "")).join();
35
+ useLayoutEffect(() => {
36
+ const el = refs.current[active];
37
+ if (el) setBar({ left: el.offsetLeft + 8, width: el.offsetWidth - 16 });
38
+ }, [active, sig]);
39
+ const move = (e: React.KeyboardEvent, i: number) => {
40
+ const to = e.key === "ArrowRight" ? i + 1 : e.key === "ArrowLeft" ? i - 1 : -1;
41
+ if (to < 0 || to >= tabs.length) return;
42
+ e.preventDefault();
43
+ onPick(tabs[to].id);
44
+ refs.current[tabs[to].id]?.focus();
45
+ };
46
+ return (
47
+ <div role="tablist" aria-label="Task" className="relative flex flex-none gap-0.5 border-b border-border">
48
+ {tabs.map((t, i) => (
49
+ <button
50
+ key={t.id}
51
+ ref={(el) => void (refs.current[t.id] = el)}
52
+ type="button"
53
+ role="tab"
54
+ id={`task-tab-${t.id}`}
55
+ aria-selected={t.id === active}
56
+ aria-controls={`task-pane-${t.id}`}
57
+ tabIndex={t.id === active ? 0 : -1}
58
+ onClick={() => onPick(t.id)}
59
+ onKeyDown={(e) => move(e, i)}
60
+ className={cn(
61
+ "flex items-center gap-1.5 px-3 py-2 text-base text-muted-foreground transition-colors motion-reduce:transition-none",
62
+ t.id === active && "text-strong",
63
+ )}
64
+ >
65
+ {t.label}
66
+ <Mark mark={t.mark} />
67
+ {t.count != null && <i className="rounded-full bg-muted px-1.5 text-[10px] not-italic">{t.count}</i>}
68
+ </button>
69
+ ))}
70
+ <span
71
+ aria-hidden="true"
72
+ className="absolute -bottom-px h-0.5 rounded-sm bg-strong transition-[left,width] duration-300 ease-out motion-reduce:transition-none"
73
+ style={{ left: bar.left, width: bar.width }}
74
+ />
75
+ </div>
76
+ );
77
+ }
@@ -1,4 +1,4 @@
1
- /* kaizen annotator page script afd2e1864afda466 -- generated by bun run build:web from web/annotate/annotate.ts; do not edit */
1
+ /* kaizen annotator page script 1376ef13d4c5d273 -- generated by bun run build:web from web/annotate/annotate.ts; do not edit */
2
2
  (()=>{var Z=(o)=>o.length<24&&!/\d{3,}|^css-|^_|^sc-|^jsx-/.test(o),dt=(o)=>{let i=Math.min(...o.map((f)=>f.left)),d=Math.min(...o.map((f)=>f.top)),u=Math.max(...o.map((f)=>f.right)),b=Math.max(...o.map((f)=>f.bottom));return{left:i,top:d,right:u,bottom:b,width:u-i,height:b-d}},tt=(o)=>{let i=Math.min(o.x0,o.x1),d=Math.min(o.y0,o.y1),u=Math.abs(o.x1-o.x0),b=Math.abs(o.y1-o.y0);return{left:i,top:d,width:u,height:b,right:i+u,bottom:d+b}},pt=(o)=>o.width>=8&&o.height>=8,ut=(o,i)=>o.width>=4&&o.height>=4&&o.left>=i.left-1&&o.top>=i.top-1&&o.right<=i.right+1&&o.bottom<=i.bottom+1,mt=20,ft=(o,i)=>{let d=o.replace(/\s+/g," ").trim();return d?`"${d.slice(0,60)}${d.length>60?"…":""}"`:i},gt=(o,i)=>`area ${Math.round(o.width)}x${Math.round(o.height)} (${i} elements)`,ht=(o,i,d)=>({left:Math.max(8,Math.min(i-316,o.left)),top:o.bottom+330<d?Math.min(o.bottom+8,d-200):Math.max(8,o.top-190)}),xt=(o,i)=>({left:Math.min(i-12,o.left+o.width),top:Math.max(12,o.top)}),bt=(o,i,d)=>({left:Math.max(8,Math.min(i-268,o.left)),top:Math.min(o.top+o.height+8,d-90)}),yt=(o,i,d,u)=>({kind:o.kind,comment:d.comment,intent:d.intent,severity:d.severity,selector:i.selector,items:o.count>1?i.items:[],path:i.path,text:i.text.slice(0,200),tag:i.tag,url:i.url,box:`${Math.round(o.rect.left+u.x)},${Math.round(o.rect.top+u.y)} ${Math.round(o.rect.width)}x${Math.round(o.rect.height)}`,pb:{x:o.rect.left+u.x,y:o.rect.top+u.y,w:o.rect.width,h:o.rect.height},page:i.page,attrs:i.attrs,styles:i.styles,nearby:i.nearby,selected:o.selected||"",source:i.source,components:i.components});var wt=1500,kt=1300000,et=(o)=>o.width>2400||o.height>2400,vt=(o,i)=>{if(o.width<2||o.height<2||et(o))return null;let d=Math.ceil(o.width),u=Math.ceil(o.height),b=Math.max(0,i.left-o.left),f=Math.max(0,i.top-o.top),l=Math.min(d-b,i.width),C=Math.min(u-f,i.height);return l<2||C<2?null:{w:d,h:u,sx:b,sy:f,sw:l,sh:C}},Et=(o,i,d)=>{let u=[];for(let b=Math.min(2,d||1);b>=0.5;b-=0.5)u.push(Math.min(b,1600/Math.max(o,i)));return u};(()=>{let o=window,i=window.parent!==window||o.__kzHost===!0;if(o.__kzAnnotate||!i)return;o.__kzAnnotate=!0;let d=document.currentScript,u=typeof o.__kzAnnToken==="string"?o.__kzAnnToken:"";if(!u)try{u=new URL(d.src).searchParams.get("t")||""}catch{}let b=window.parent,f=(e)=>b.postMessage({kz:1,t:u,out:1,...e},"*"),l={on:!1,mode:"element",hide:!1,block:!0,color:"#3c82f7",components:!0},C=[],g=null,y=[],E=null,U=!1,j=[],I=[],F=[],nt=window.requestAnimationFrame.bind(window);window.requestAnimationFrame=(e)=>U?(F.push(e),F.length):nt(e);let H=document.createElement("style");H.textContent="*,*::before,*::after{animation-play-state:paused!important;transition:none!important}";function At(e){if(e===U)return;if(U=e,e){document.documentElement.append(H);try{j=document.getAnimations().filter((t)=>t.playState==="running"),j.forEach((t)=>t.pause())}catch{}I=[...document.querySelectorAll("video,audio")].filter((t)=>!t.paused),I.forEach((t)=>t.pause())}else H.remove(),j.forEach((t)=>{try{t.play()}catch{}}),I.forEach((t)=>t.play().catch(()=>{})),j=[],I=[],F.splice(0).forEach((t)=>nt(t))}let z=(e)=>window.CSS&&CSS.escape?CSS.escape(e):e.replace(/[^\w-]/g,"\\$&"),D=(e)=>{try{return document.querySelectorAll(e).length===1}catch{return!1}};function ot(e){if(e.id&&D("#"+z(e.id)))return"#"+z(e.id);let t=e.getAttribute("data-testid");if(t&&D(`[data-testid="${t.replace(/"/g,"\\\"")}"]`))return`[data-testid="${t.replace(/"/g,"\\\"")}"]`;let n=[];for(let r=e;r&&r.nodeType===1&&r!==document.documentElement;r=r.parentElement){let s=r.tagName.toLowerCase();if(r.id){if(n.unshift("#"+z(r.id)),D(n.join(" > ")))break;n.shift()}let c=[...r.classList].filter(Z).slice(0,2);if(c.length)s+=c.map((w)=>"."+z(w)).join("");let p=r.parentElement?[...r.parentElement.children].filter((w)=>w.tagName===r.tagName):[];if(p.length>1&&!(c.length&&r.parentElement.querySelectorAll(":scope > "+s).length===1))s+=`:nth-of-type(${p.indexOf(r)+1})`;if(n.unshift(s),D(n.join(" > ")))break}return n.join(" > ")}let Ct=(e)=>{let t=[];for(let n=e;n&&n.nodeType===1;n=n.parentElement)t.unshift(n.tagName.toLowerCase()+(n.id?"#"+n.id:""));return t.join(" > ")},K=(e)=>e.tagName.toLowerCase()+(e.id?"#"+e.id:"")+[...e.classList].filter(Z).slice(0,2).map((t)=>"."+t).join(""),Y=(e)=>(e.innerText||e.textContent||e.getAttribute("aria-label")||e.getAttribute("alt")||"").replace(/\s+/g," ").trim(),_t=["id","class","role","aria-label","href","type","name","placeholder","alt","data-testid"],St=(e)=>_t.filter((t)=>e.hasAttribute(t)).map((t)=>`${t}="${e.getAttribute(t).slice(0,80)}"`).join(" "),Rt=["color","background-color","font-family","font-size","font-weight","line-height","padding","margin","display","position","border-radius","width","height"],Mt=(e)=>{let t=getComputedStyle(e);return Rt.map((n)=>`${n}: ${t.getPropertyValue(n)}`).join("; ")};function $t(e){let t="",n=[];for(let r=e,s=0;r&&r.nodeType===1&&s<14;r=r.parentElement,s++){let c=r.getAttribute("data-astro-source-file");if(c&&!t)t=c+(r.getAttribute("data-astro-source-loc")?":"+r.getAttribute("data-astro-source-loc").replace(/:/,":"):"");let p=r.__svelte_meta&&r.__svelte_meta.loc;if(p&&!t)t=`${p.file}:${p.line}`;let w=r.__vueParentComponent;for(let a=w,v=0;a&&v<6;a=a.parent,v++){let m=a.type&&(a.type.name||a.type.__name);if(m&&!n.includes(m))n.push(m);if(a.type&&a.type.__file&&!t)t=a.type.__file}if(r.__vue__&&r.__vue__.$options){let a=r.__vue__.$options;if(a.name&&!n.includes(a.name))n.push(a.name);if(a.__file&&!t)t=a.__file}let P=Object.keys(r).find((a)=>a.startsWith("__reactFiber$"));if(P)for(let a=r[P],v=0;a&&v<40;a=a.return,v++){if(a._debugSource&&!t)t=`${a._debugSource.fileName}:${a._debugSource.lineNumber}`;let m=a.type;if(typeof m==="function"||m&&typeof m==="object"){let S=m.displayName||m.name||m.render&&m.render.name||"";if(S&&!n.includes(S)&&n.length<8)n.push(S)}}if(t&&n.length)break}return{source:t,components:n.reverse().join(" > ")}}let M=document.createElement("div");M.style.cssText="all:initial;position:fixed;inset:0;z-index:2147483647;pointer-events:none";let Tt=M.attachShadow({mode:"closed"}),rt=document.createElement("style");rt.textContent=`
3
3
  *{box-sizing:border-box;font:12px/1.4 system-ui,sans-serif}
4
4
  .b{position:fixed;pointer-events:none;border:2px solid var(--c);background:color-mix(in srgb,var(--c) 14%,transparent);border-radius:2px}