@spunto/design-system 0.70.0 → 0.72.0
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/README.md +9 -0
- package/package.json +1 -1
- package/src/components/sidebar-menus.tsx +211 -0
- package/src/components/sidebar.test.tsx +61 -0
- package/src/components/sidebar.tsx +755 -0
- package/src/components/tasks/index.ts +2 -2
- package/src/components/tasks/machine.tsx +108 -75
- package/src/components/tasks/task-details.tsx +53 -11
- package/src/components/tasks/tasks.test.tsx +39 -1
- package/src/index.ts +43 -0
|
@@ -89,10 +89,10 @@ export { TaskSharedFiles, TaskSharedLinks } from "./shared"
|
|
|
89
89
|
export { TaskAppTileContent, TaskAppTileItems } from "./app-tiles"
|
|
90
90
|
export { TaskSessionUsage, formatCost, formatTokens } from "./session-usage"
|
|
91
91
|
export { TaskCommandLog } from "./command-log"
|
|
92
|
-
export { TaskBoot, TaskMachine, bootSteps, workerLabel } from "./machine"
|
|
92
|
+
export { TaskBoot, TaskMachine, TaskMonitoring, bootSteps, workerLabel } from "./machine"
|
|
93
93
|
export { TaskCommandTerminal, emptyCommandTerminalState, planCommandTerminalWrites } from "./command-terminal"
|
|
94
94
|
export type { CommandTerminalState, TaskCommandTerminalProps } from "./command-terminal"
|
|
95
|
-
export type { TaskBootLogs, TaskBootProps, TaskBootStep, TaskMachineProps, TaskMachineTask } from "./machine"
|
|
95
|
+
export type { TaskBootLogs, TaskBootProps, TaskBootStep, TaskMachineProps, TaskMachineTask, TaskMonitoringProps } from "./machine"
|
|
96
96
|
|
|
97
97
|
export type {
|
|
98
98
|
AttachmentUrl,
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import { useState, type ReactNode } from "react"
|
|
4
4
|
import {
|
|
5
|
+
ActivityIcon,
|
|
5
6
|
ChevronRightIcon,
|
|
6
7
|
Code2Icon,
|
|
7
8
|
ExternalLinkIcon,
|
|
8
9
|
GitBranchIcon,
|
|
9
10
|
MoonIcon,
|
|
10
11
|
ServerIcon,
|
|
11
|
-
SparklesIcon,
|
|
12
12
|
TerminalIcon,
|
|
13
13
|
WifiOffIcon,
|
|
14
14
|
} from "lucide-react"
|
|
@@ -43,8 +43,12 @@ import type { TaskCommand, TaskItem, TaskMachineNode, TaskMachinePort } from "./
|
|
|
43
43
|
* agent thinking and an agent stuck in a test suite.
|
|
44
44
|
*
|
|
45
45
|
* Everything here is observed, never guessed: the worker row, its container-side setup status,
|
|
46
|
-
* its live stats, and the task's own command history.
|
|
47
|
-
*
|
|
46
|
+
* its live stats, and the task's own command history.
|
|
47
|
+
*
|
|
48
|
+
* Since every task gets a sandbox of its own (no pool to recycle from), this block only says which
|
|
49
|
+
* machine it is and what it serves: its name opens its own page (logs, terminal, files, the
|
|
50
|
+
* editor), and where it runs and how it is doing — CPU, memory, their history — is
|
|
51
|
+
* `TaskMonitoring`, the sidebar's last block.
|
|
48
52
|
*/
|
|
49
53
|
|
|
50
54
|
/** The task fields the machine block and the boot panel read. */
|
|
@@ -56,44 +60,39 @@ export function workerLabel(worker: WorkerCardWorker): string {
|
|
|
56
60
|
return worker.name?.trim() || (worker.index != null ? `Workspace #${worker.index}` : "Workspace")
|
|
57
61
|
}
|
|
58
62
|
|
|
59
|
-
/**
|
|
60
|
-
* Did this task get a machine that already existed?
|
|
61
|
-
*
|
|
62
|
-
* The pool is the whole point — the first task of a project pays for an image build and a clone,
|
|
63
|
-
* the tenth should not — and "recycled" vs "fresh" is exactly the difference between a boot of
|
|
64
|
-
* seconds and one of minutes. Read from the timestamps rather than recorded: a worker older than
|
|
65
|
-
* the task that took it was not created for it.
|
|
66
|
-
*/
|
|
67
|
-
function recycled(task: TaskMachineTask, worker: WorkerCardWorker): boolean {
|
|
68
|
-
if (!worker.createdAt) return false
|
|
69
|
-
return new Date(worker.createdAt).getTime() < new Date(task.createdAt).getTime()
|
|
70
|
-
}
|
|
71
|
-
|
|
72
63
|
// ── The sidebar block ────────────────────────────────────────────────────────────────────────
|
|
73
64
|
|
|
74
65
|
export interface TaskMachineProps {
|
|
75
66
|
task: TaskMachineTask
|
|
76
67
|
/** The worker row, as the app reads it. `null` → the task has no machine (yet). */
|
|
77
68
|
worker: WorkerCardWorker | null | undefined
|
|
78
|
-
/** The node it lives on. `online: false` draws "offline". */
|
|
79
|
-
node?: TaskMachineNode | null
|
|
80
|
-
/** Live container stats — pass them only while the task is live and the container up. */
|
|
81
|
-
stats?: WorkerStats | null
|
|
82
69
|
/**
|
|
83
70
|
* Its ports (editor and SSH are filtered out): detected listening, and those the project declares
|
|
84
71
|
* — green while something listens, greyed (no link) while nothing does. Declared ones show even
|
|
85
72
|
* with the machine parked: the reader sees what the app will serve, and that it doesn't now.
|
|
86
73
|
*/
|
|
87
74
|
ports?: TaskMachinePort[]
|
|
88
|
-
/** The
|
|
75
|
+
/** The machine's own page (logs, terminal, files, the editor) — its name links there. */
|
|
89
76
|
workerHref?: string
|
|
90
|
-
/** The editor (code-server). Shown only while the container runs. */
|
|
91
|
-
editorHref?: string
|
|
92
77
|
portHref?: (port: number) => string | undefined
|
|
93
78
|
render?: { link?: LinkRender }
|
|
79
|
+
/**
|
|
80
|
+
* @deprecated Since 0.72.0 — pass it to `TaskMonitoring` (the sidebar's Monitoring block). Still
|
|
81
|
+
* drawn here, as before, when given.
|
|
82
|
+
*/
|
|
83
|
+
node?: TaskMachineNode | null
|
|
84
|
+
/**
|
|
85
|
+
* @deprecated Since 0.72.0 — pass it to `TaskMonitoring`. Still drawn here, as before, when given.
|
|
86
|
+
*/
|
|
87
|
+
stats?: WorkerStats | null
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated Since 0.72.0 — the machine's page (`workerHref`) opens the editor. Still drawn
|
|
90
|
+
* here ("Open the editor", while the machine runs) when given.
|
|
91
|
+
*/
|
|
92
|
+
editorHref?: string
|
|
94
93
|
}
|
|
95
94
|
|
|
96
|
-
export function TaskMachine({ task, worker,
|
|
95
|
+
export function TaskMachine({ task, worker, ports = [], workerHref, portHref, render, node, stats, editorHref }: TaskMachineProps) {
|
|
97
96
|
const [showBreakdown, setShowBreakdown] = useState(false)
|
|
98
97
|
const Link: LinkRender =
|
|
99
98
|
render?.link ?? (({ href, className, children }) => <a href={href} className={className}>{children}</a>)
|
|
@@ -102,7 +101,7 @@ export function TaskMachine({ task, worker, node = null, stats = null, ports = [
|
|
|
102
101
|
return (
|
|
103
102
|
<p className="text-[11px] leading-relaxed text-muted-foreground">
|
|
104
103
|
{task.state === "queued"
|
|
105
|
-
? "
|
|
104
|
+
? "Starting a sandbox for this task."
|
|
106
105
|
: "This task never got a machine."}
|
|
107
106
|
</p>
|
|
108
107
|
)
|
|
@@ -112,8 +111,8 @@ export function TaskMachine({ task, worker, node = null, stats = null, ports = [
|
|
|
112
111
|
const setup = worker.setupStatus ?? null
|
|
113
112
|
const running = worker.dockerState === "running"
|
|
114
113
|
const startup = setupTotalMs(setup)
|
|
115
|
-
// A terminal task no longer holds its
|
|
116
|
-
//
|
|
114
|
+
// A terminal task no longer holds its machine: accepted, its sandbox is destroyed; failed, it is
|
|
115
|
+
// stopped. What is drawn is the box's last known state, not a task still at work.
|
|
117
116
|
const released = task.state === "done" || task.state === "failed"
|
|
118
117
|
const parked = task.state === "in-review" && !running
|
|
119
118
|
const label = workerLabel(worker)
|
|
@@ -132,32 +131,14 @@ export function TaskMachine({ task, worker, node = null, stats = null, ports = [
|
|
|
132
131
|
<WorkerStatusPill status={status} label={status.settingUp ? phaseLabel(setup) : undefined} />
|
|
133
132
|
</div>
|
|
134
133
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
<ServerIcon className="h-3 w-3 shrink-0" />
|
|
138
|
-
{node ? node.name : "node unknown"}
|
|
139
|
-
</span>
|
|
140
|
-
{node && !node.online && (
|
|
141
|
-
<span className="flex items-center gap-1 text-orange-600 dark:text-orange-400">
|
|
142
|
-
<WifiOffIcon className="h-3 w-3 shrink-0" />
|
|
143
|
-
offline
|
|
144
|
-
</span>
|
|
145
|
-
)}
|
|
146
|
-
<span aria-hidden>·</span>
|
|
147
|
-
<span className="flex items-center gap-1">
|
|
148
|
-
<SparklesIcon className="h-3 w-3 shrink-0" />
|
|
149
|
-
{recycled(task, worker) ? "recycled from the pool" : "spawned for this task"}
|
|
150
|
-
</span>
|
|
151
|
-
</div>
|
|
134
|
+
{/* Deprecated props, kept so an app that still passes them sees no change (0.72.0). */}
|
|
135
|
+
{node && <MachinePlace node={node} />}
|
|
152
136
|
|
|
153
137
|
{/* Not while the task is `queued`: the boot panel in the centre column is showing this very
|
|
154
138
|
timeline, in full, and two copies of a cloning repository on one screen is one too many.
|
|
155
139
|
It stays here for the rest — a parked machine restarting for a follow-up, say. */}
|
|
156
140
|
{status.settingUp && task.state !== "queued" && <WorkerSetupTimeline status={setup} settingUp />}
|
|
157
141
|
|
|
158
|
-
{/* `@container`, deliberately: ResourceBars decides to go two-up from its *nearest container
|
|
159
|
-
ancestor*'s width, and outside a WorkerCard there is none — the bars would stay stacked
|
|
160
|
-
for ever (docs/design-system.md § "une brique réutilisée hors de sa carte"). */}
|
|
161
142
|
{stats && (
|
|
162
143
|
<div className="@container">
|
|
163
144
|
<ResourceBars stats={stats} />
|
|
@@ -168,38 +149,30 @@ export function TaskMachine({ task, worker, node = null, stats = null, ports = [
|
|
|
168
149
|
<p className="flex items-start gap-1.5 rounded-md border border-border/60 bg-muted/30 px-2.5 py-2 text-[11px] leading-relaxed text-muted-foreground">
|
|
169
150
|
<MoonIcon className="mt-0.5 h-3 w-3 shrink-0" />
|
|
170
151
|
<span>
|
|
171
|
-
Parked for review — stopped, disk kept as it was
|
|
172
|
-
|
|
152
|
+
Parked for review — stopped, disk kept as it was, until the task is accepted or
|
|
153
|
+
dropped.
|
|
173
154
|
</span>
|
|
174
155
|
</p>
|
|
175
156
|
)}
|
|
176
157
|
|
|
177
158
|
{released && (
|
|
178
159
|
<p className="text-[11px] leading-relaxed text-muted-foreground">
|
|
179
|
-
This task is over
|
|
180
|
-
another task.
|
|
160
|
+
This task is over — its machine is no longer kept for it.
|
|
181
161
|
</p>
|
|
182
162
|
)}
|
|
183
163
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
)}
|
|
197
|
-
{workerHref && (
|
|
198
|
-
<Link href={workerHref} className="flex items-center gap-1 text-muted-foreground transition-colors hover:text-foreground">
|
|
199
|
-
Logs, terminal, files →
|
|
200
|
-
</Link>
|
|
201
|
-
)}
|
|
202
|
-
</div>
|
|
164
|
+
{editorHref && running && (
|
|
165
|
+
<a
|
|
166
|
+
href={editorHref}
|
|
167
|
+
target="_blank"
|
|
168
|
+
rel="noreferrer"
|
|
169
|
+
className="flex items-center gap-1 text-[11px] text-primary hover:underline"
|
|
170
|
+
>
|
|
171
|
+
<Code2Icon className="h-3 w-3 shrink-0" />
|
|
172
|
+
Open the editor
|
|
173
|
+
<ExternalLinkIcon className="h-3 w-3 shrink-0" />
|
|
174
|
+
</a>
|
|
175
|
+
)}
|
|
203
176
|
|
|
204
177
|
{portHref && <MachinePorts ports={ports} running={running} portHref={portHref} />}
|
|
205
178
|
|
|
@@ -220,6 +193,68 @@ export function TaskMachine({ task, worker, node = null, stats = null, ports = [
|
|
|
220
193
|
)
|
|
221
194
|
}
|
|
222
195
|
|
|
196
|
+
/** Where the machine runs, and whether its agent is reachable. */
|
|
197
|
+
function MachinePlace({ node }: { node: TaskMachineNode }) {
|
|
198
|
+
return (
|
|
199
|
+
<div className="flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground">
|
|
200
|
+
<span className="flex items-center gap-1">
|
|
201
|
+
<ServerIcon className="h-3 w-3 shrink-0" />
|
|
202
|
+
{node.name}
|
|
203
|
+
</span>
|
|
204
|
+
{!node.online && (
|
|
205
|
+
<span className="flex items-center gap-1 text-orange-600 dark:text-orange-400">
|
|
206
|
+
<WifiOffIcon className="h-3 w-3 shrink-0" />
|
|
207
|
+
offline
|
|
208
|
+
</span>
|
|
209
|
+
)}
|
|
210
|
+
</div>
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// ── The monitoring block ─────────────────────────────────────────────────────────────────────
|
|
215
|
+
|
|
216
|
+
export interface TaskMonitoringProps {
|
|
217
|
+
/** Where the machine runs ("Spunto Cloud", a node…). `online: false` draws "offline". */
|
|
218
|
+
node?: TaskMachineNode | null
|
|
219
|
+
/** Live container stats — pass them only while the task is live and the machine up. */
|
|
220
|
+
stats?: WorkerStats | null
|
|
221
|
+
/**
|
|
222
|
+
* Its history, drawn by the app (the package reads no metrics endpoint) — in the dashboard, the
|
|
223
|
+
* same charts as the sandbox's own page (`SandboxMetricsHistory`).
|
|
224
|
+
*/
|
|
225
|
+
history?: ReactNode
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* How the task's machine is doing: the live CPU and memory bars, then their history.
|
|
230
|
+
*
|
|
231
|
+
* Its own block, last in the sidebar, rather than inside Machine: Machine is what a reader acts on
|
|
232
|
+
* (open its page, a port), this is what they glance at when the agent seems slow — charts in the
|
|
233
|
+
* middle of the links pushed the ports below the fold.
|
|
234
|
+
*/
|
|
235
|
+
export function TaskMonitoring({ node = null, stats = null, history }: TaskMonitoringProps) {
|
|
236
|
+
return (
|
|
237
|
+
<div className="space-y-3">
|
|
238
|
+
{node && <MachinePlace node={node} />}
|
|
239
|
+
{!stats && !history && (
|
|
240
|
+
<p className="flex items-center gap-1.5 text-[11px] text-muted-foreground">
|
|
241
|
+
<ActivityIcon className="h-3 w-3 shrink-0" />
|
|
242
|
+
Nothing to measure — the machine is not running.
|
|
243
|
+
</p>
|
|
244
|
+
)}
|
|
245
|
+
{/* `@container`, deliberately: ResourceBars decides to go two-up from its *nearest container
|
|
246
|
+
ancestor*'s width, and outside a WorkerCard there is none — the bars would stay stacked
|
|
247
|
+
for ever (docs/design-system.md § "une brique réutilisée hors de sa carte"). */}
|
|
248
|
+
{stats && (
|
|
249
|
+
<div className="@container">
|
|
250
|
+
<ResourceBars stats={stats} />
|
|
251
|
+
</div>
|
|
252
|
+
)}
|
|
253
|
+
{history}
|
|
254
|
+
</div>
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
|
|
223
258
|
// ── The boot panel, centre column ────────────────────────────────────────────────────────────
|
|
224
259
|
|
|
225
260
|
export type TaskBootStep = {
|
|
@@ -265,9 +300,7 @@ export function bootSteps({
|
|
|
265
300
|
key: "machine",
|
|
266
301
|
label: "Machine",
|
|
267
302
|
state: "done",
|
|
268
|
-
detail:
|
|
269
|
-
? `recycled from the pool · ${workerLabel(worker)}`
|
|
270
|
-
: `spawned for this task · ${workerLabel(worker)}`,
|
|
303
|
+
detail: workerLabel(worker),
|
|
271
304
|
}
|
|
272
305
|
: {
|
|
273
306
|
key: "machine",
|
|
@@ -275,7 +308,7 @@ export function bootSteps({
|
|
|
275
308
|
// A queued task with no worker is being allocated one; a task that stopped here never got
|
|
276
309
|
// one at all, and pretending it is still looking would be a lie with a spinner on it.
|
|
277
310
|
state: task.state === "queued" ? "running" : "error",
|
|
278
|
-
detail: task.state === "queued" ? "
|
|
311
|
+
detail: task.state === "queued" ? "starting a sandbox for this task…" : "never allocated",
|
|
279
312
|
}
|
|
280
313
|
|
|
281
314
|
// `ready` and nothing else: it is the platform's own definition of a usable machine (what
|
|
@@ -562,7 +595,7 @@ export function TaskBoot({ task, worker, commands, logs }: TaskBootProps) {
|
|
|
562
595
|
<GitBranchIcon className="mt-0.5 h-3 w-3 shrink-0" />
|
|
563
596
|
<span>
|
|
564
597
|
{queued
|
|
565
|
-
? "The session appears here on its own as soon as the agent starts.
|
|
598
|
+
? "The session appears here on its own as soon as the agent starts."
|
|
566
599
|
: "Nothing was streamed for this task. The sidebar has every command the platform ran."}
|
|
567
600
|
</span>
|
|
568
601
|
</p>
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
//
|
|
11
11
|
// Before, those were two hand-kept copies of the same list (a sidebar and a mobile sheet) that
|
|
12
12
|
// had to agree on order and wording. The order is an argument, so it lives once: the machine first
|
|
13
|
-
// — the one block always open, since it is what a reader acts on (
|
|
14
|
-
//
|
|
13
|
+
// — the one block always open, since it is what a reader acts on (its page, a port) —, then what
|
|
14
|
+
// the session is spending, then did it land (the PR), then how it was set up, and last how the
|
|
15
|
+
// machine is doing (Monitoring: CPU and memory, live and over time).
|
|
15
16
|
//
|
|
16
17
|
// Every other block starts folded, and stays the way the reader leaves it: opening "Session" once
|
|
17
18
|
// opens it in every conversation (`useBlockOpen`, this browser's `localStorage`).
|
|
@@ -20,6 +21,7 @@ import { createContext, useContext, useState, useSyncExternalStore, type ReactNo
|
|
|
20
21
|
import { CheckIcon, ChevronRightIcon, CopyIcon, ExternalLinkIcon, GitBranchIcon, Loader2Icon, SlidersHorizontalIcon, XCircleIcon } from "lucide-react"
|
|
21
22
|
|
|
22
23
|
import { cn, formatRelativeTime } from "../../utils"
|
|
24
|
+
import { Avatar, AvatarFallback, AvatarImage } from "../avatar"
|
|
23
25
|
import { TaskCommandLog } from "./command-log"
|
|
24
26
|
import { TaskSessionUsage } from "./session-usage"
|
|
25
27
|
import { TaskSharedFiles, TaskSharedLinks } from "./shared"
|
|
@@ -52,8 +54,15 @@ export interface TaskDetailsProps {
|
|
|
52
54
|
*/
|
|
53
55
|
appTileSettingsHref?: (tile: TaskAppTile) => string | null
|
|
54
56
|
attachmentUrl?: AttachmentUrl
|
|
57
|
+
/**
|
|
58
|
+
* The member who delegated the task — drawn in the header, avatar and name. Absent → just
|
|
59
|
+
* "Delegated …" (a task whose owner left the org, or an app that doesn't know).
|
|
60
|
+
*/
|
|
61
|
+
delegatedBy?: { name: string; avatarUrl?: string | null } | null
|
|
55
62
|
/** The Machine block's content — typically a `TaskMachine`. */
|
|
56
63
|
machine?: ReactNode
|
|
64
|
+
/** The Monitoring block's content, last in the list — typically a `TaskMonitoring`. Absent → no block. */
|
|
65
|
+
monitoring?: ReactNode
|
|
57
66
|
/** Every command the platform ran for the task, oldest first. */
|
|
58
67
|
commands?: TaskCommand[]
|
|
59
68
|
/** The project's `taskAgentProtocol` — only for a footnote. */
|
|
@@ -222,7 +231,9 @@ export function TaskDetails({
|
|
|
222
231
|
appTiles,
|
|
223
232
|
appTileSettingsHref,
|
|
224
233
|
attachmentUrl,
|
|
234
|
+
delegatedBy,
|
|
225
235
|
machine,
|
|
236
|
+
monitoring,
|
|
226
237
|
commands = [],
|
|
227
238
|
protocol = "none",
|
|
228
239
|
onDrop,
|
|
@@ -234,15 +245,35 @@ export function TaskDetails({
|
|
|
234
245
|
const links = task.links && task.links.length > 0 ? task.links : null
|
|
235
246
|
const metadata = task.metadata && Object.keys(task.metadata).length > 0 ? Object.entries(task.metadata) : null
|
|
236
247
|
const ran = task.completedAt ? taskSpan(task.startedAt ?? task.createdAt, task.completedAt) : null
|
|
248
|
+
// `baseBranch: null` is the project's default — saying so ("project default") on every task of a
|
|
249
|
+
// project with no branches was a fact with nothing in it. Only an explicit base is worth a line.
|
|
250
|
+
const facts = !!links || !!task.branch || !!task.baseBranch || !!task.outcomeUrl
|
|
237
251
|
|
|
238
252
|
return (
|
|
239
253
|
<div className={className}>
|
|
240
254
|
<div className={cn("border-b", variant === "sidebar" ? "border-border/60 px-4 py-3" : "space-y-3 px-4 py-3")}>
|
|
241
|
-
<
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
255
|
+
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
|
256
|
+
{delegatedBy && (
|
|
257
|
+
<Avatar size="xs" className="shrink-0">
|
|
258
|
+
{delegatedBy.avatarUrl && <AvatarImage src={delegatedBy.avatarUrl} alt="" />}
|
|
259
|
+
<AvatarFallback className="bg-primary/15 font-semibold text-primary">
|
|
260
|
+
{delegatedBy.name.slice(0, 2).toUpperCase()}
|
|
261
|
+
</AvatarFallback>
|
|
262
|
+
</Avatar>
|
|
263
|
+
)}
|
|
264
|
+
<p className="min-w-0">
|
|
265
|
+
{delegatedBy ? (
|
|
266
|
+
<>
|
|
267
|
+
<span className="font-medium text-foreground">{delegatedBy.name}</span> delegated{" "}
|
|
268
|
+
{formatRelativeTime(task.createdAt)}
|
|
269
|
+
</>
|
|
270
|
+
) : (
|
|
271
|
+
<>Delegated {formatRelativeTime(task.createdAt)}</>
|
|
272
|
+
)}
|
|
273
|
+
{/* From `startedAt`, not `createdAt`: the wait for a machine is not run time. */}
|
|
274
|
+
{ran && ` · ran ${ran}`}
|
|
275
|
+
</p>
|
|
276
|
+
</div>
|
|
246
277
|
|
|
247
278
|
{task.error && (
|
|
248
279
|
<p
|
|
@@ -255,6 +286,7 @@ export function TaskDetails({
|
|
|
255
286
|
</p>
|
|
256
287
|
)}
|
|
257
288
|
|
|
289
|
+
{facts && (
|
|
258
290
|
<div className={cn("grid grid-cols-2 gap-3", variant === "sidebar" && "mt-3")}>
|
|
259
291
|
{/* First: where the work came from is what a reader arriving from a list asks before anything else. */}
|
|
260
292
|
{links && (
|
|
@@ -290,9 +322,11 @@ export function TaskDetails({
|
|
|
290
322
|
</Fact>
|
|
291
323
|
</div>
|
|
292
324
|
)}
|
|
293
|
-
|
|
294
|
-
<
|
|
295
|
-
|
|
325
|
+
{task.baseBranch && (
|
|
326
|
+
<Fact label="Base">
|
|
327
|
+
<span className="font-mono text-muted-foreground">{task.baseBranch}</span>
|
|
328
|
+
</Fact>
|
|
329
|
+
)}
|
|
296
330
|
{task.outcomeUrl && (
|
|
297
331
|
<Fact label="Result">
|
|
298
332
|
<a href={task.outcomeUrl} target="_blank" rel="noreferrer" className="flex items-center gap-1 text-primary hover:underline">
|
|
@@ -302,9 +336,10 @@ export function TaskDetails({
|
|
|
302
336
|
</Fact>
|
|
303
337
|
)}
|
|
304
338
|
</div>
|
|
339
|
+
)}
|
|
305
340
|
</div>
|
|
306
341
|
|
|
307
|
-
{/* First and always open: the machine is what a reader acts on —
|
|
342
|
+
{/* First and always open: the machine is what a reader acts on — its page, a port. */}
|
|
308
343
|
{machine && (
|
|
309
344
|
<Block id="machine" variant={variant} title="Machine" pinned>
|
|
310
345
|
{machine}
|
|
@@ -395,6 +430,13 @@ export function TaskDetails({
|
|
|
395
430
|
</Block>
|
|
396
431
|
)}
|
|
397
432
|
|
|
433
|
+
{/* Last: CPU and memory, live and over time — glanced at when the agent seems slow, not acted on. */}
|
|
434
|
+
{monitoring && (
|
|
435
|
+
<Block id="monitoring" variant={variant} title="Monitoring">
|
|
436
|
+
{monitoring}
|
|
437
|
+
</Block>
|
|
438
|
+
)}
|
|
439
|
+
|
|
398
440
|
{variant === "sheet" && onDrop && isLiveTaskState(task.state) && (
|
|
399
441
|
<div className="px-4 py-4">
|
|
400
442
|
<button
|
|
@@ -114,7 +114,7 @@ describe("boot steps", () => {
|
|
|
114
114
|
it("an older task, branched by the platform: starts the session step once the branch is ready", () => {
|
|
115
115
|
const worker = { id: "w1", name: "pool-1", state: "ready", dockerState: "running", createdAt: "2026-09-20T00:00:00Z" }
|
|
116
116
|
const steps = bootSteps({ task: task({ state: "queued" }), worker, commands: [branchSetup("succeeded")] })
|
|
117
|
-
expect(steps.find((s) => s.key === "machine")?.detail).toBe("
|
|
117
|
+
expect(steps.find((s) => s.key === "machine")?.detail).toBe("pool-1")
|
|
118
118
|
expect(steps.find((s) => s.key === "branch")?.state).toBe("done")
|
|
119
119
|
expect(steps.find((s) => s.key === "session")?.state).toBe("running")
|
|
120
120
|
})
|
|
@@ -495,7 +495,45 @@ describe("TaskCockpit panels", () => {
|
|
|
495
495
|
})
|
|
496
496
|
})
|
|
497
497
|
|
|
498
|
+
describe("TaskMachine deprecated props (0.72.0)", () => {
|
|
499
|
+
const worker = { id: "sbx1", name: "task-1", state: "ready", dockerState: "running" } as never
|
|
500
|
+
it("still draws node, stats and the editor link when an app passes them", () => {
|
|
501
|
+
render(
|
|
502
|
+
<TaskMachine
|
|
503
|
+
task={{ state: "running", createdAt: "2026-09-24T10:00:00Z" }}
|
|
504
|
+
worker={worker}
|
|
505
|
+
node={{ name: "hetzner-fsn1-2", online: true }}
|
|
506
|
+
stats={{ cpuPercent: 12, memUsageMb: 512 }}
|
|
507
|
+
editorHref="https://editor"
|
|
508
|
+
/>,
|
|
509
|
+
)
|
|
510
|
+
expect(screen.getByText("hetzner-fsn1-2")).toBeTruthy()
|
|
511
|
+
expect(screen.getByText("CPU")).toBeTruthy()
|
|
512
|
+
expect(screen.getByText("Open the editor").closest("a")?.getAttribute("href")).toBe("https://editor")
|
|
513
|
+
})
|
|
514
|
+
|
|
515
|
+
it("draws none of them when they are not passed", () => {
|
|
516
|
+
render(<TaskMachine task={{ state: "running", createdAt: "2026-09-24T10:00:00Z" }} worker={worker} />)
|
|
517
|
+
expect(screen.queryByText("CPU")).toBeNull()
|
|
518
|
+
expect(screen.queryByText("Open the editor")).toBeNull()
|
|
519
|
+
})
|
|
520
|
+
})
|
|
521
|
+
|
|
498
522
|
describe("TaskDetails", () => {
|
|
523
|
+
it("shows the base only when the task has an explicit one", () => {
|
|
524
|
+
const { rerender } = render(<TaskDetails task={task({ branch: undefined as never, baseBranch: null })} commands={[]} />)
|
|
525
|
+
expect(screen.queryByText("Base")).toBeNull()
|
|
526
|
+
expect(screen.queryByText("project default")).toBeNull()
|
|
527
|
+
rerender(<TaskDetails task={task({ baseBranch: "release/2.0" })} commands={[]} />)
|
|
528
|
+
expect(screen.getByText("release/2.0")).toBeTruthy()
|
|
529
|
+
})
|
|
530
|
+
|
|
531
|
+
it("names the member who delegated the task", () => {
|
|
532
|
+
render(<TaskDetails task={task()} delegatedBy={{ name: "Ada" }} commands={[]} />)
|
|
533
|
+
expect(screen.getByText("Ada")).toBeTruthy()
|
|
534
|
+
expect(screen.getByText(/delegated/)).toBeTruthy()
|
|
535
|
+
})
|
|
536
|
+
|
|
499
537
|
it("puts the machine first and always open; every other block starts folded", () => {
|
|
500
538
|
window.localStorage.clear()
|
|
501
539
|
const { container } = render(
|
package/src/index.ts
CHANGED
|
@@ -149,6 +149,49 @@ export {
|
|
|
149
149
|
} from "./components/sheet"
|
|
150
150
|
export type { SheetContentProps, SheetSide, SheetSize } from "./components/sheet"
|
|
151
151
|
|
|
152
|
+
// Sidebar — the app shell's left rail: provider (open state, ⌘B, cookie, mobile sheet), the
|
|
153
|
+
// rail itself (`collapsible` offcanvas / icon / none, `variant` sidebar / floating / inset),
|
|
154
|
+
// and the parts that fill it (header, content, groups, menu buttons, sub-menus, footer).
|
|
155
|
+
// Router-agnostic: `render={<Link />}` on a menu button, `mobileCloseKey={pathname}` on the provider.
|
|
156
|
+
export {
|
|
157
|
+
Sidebar,
|
|
158
|
+
SidebarContent,
|
|
159
|
+
SidebarFooter,
|
|
160
|
+
SidebarGroup,
|
|
161
|
+
SidebarGroupAction,
|
|
162
|
+
SidebarGroupContent,
|
|
163
|
+
SidebarGroupLabel,
|
|
164
|
+
SidebarHeader,
|
|
165
|
+
SidebarInput,
|
|
166
|
+
SidebarInset,
|
|
167
|
+
SidebarMenu,
|
|
168
|
+
SidebarMenuAction,
|
|
169
|
+
SidebarMenuBadge,
|
|
170
|
+
SidebarMenuButton,
|
|
171
|
+
SidebarMenuItem,
|
|
172
|
+
SidebarMenuSkeleton,
|
|
173
|
+
SidebarMenuSub,
|
|
174
|
+
SidebarMenuSubButton,
|
|
175
|
+
SidebarMenuSubItem,
|
|
176
|
+
SidebarProvider,
|
|
177
|
+
SidebarRail,
|
|
178
|
+
SidebarSeparator,
|
|
179
|
+
SidebarTrigger,
|
|
180
|
+
useSidebar,
|
|
181
|
+
} from "./components/sidebar"
|
|
182
|
+
|
|
183
|
+
// The two ends of a sidebar: the organization switcher (header) and the signed-in member's menu
|
|
184
|
+
// (footer) — each an `ActionMenu` behind a full-width button, so entries are data and links go through
|
|
185
|
+
// the app's router (`render.link`).
|
|
186
|
+
export { SidebarBrand, SidebarOrgSwitcher, SidebarUserMenu } from "./components/sidebar-menus"
|
|
187
|
+
export type {
|
|
188
|
+
SidebarBrandProps,
|
|
189
|
+
SidebarOrg,
|
|
190
|
+
SidebarOrgSwitcherProps,
|
|
191
|
+
SidebarUser,
|
|
192
|
+
SidebarUserMenuProps,
|
|
193
|
+
} from "./components/sidebar-menus"
|
|
194
|
+
|
|
152
195
|
// Table — presentational only (no sorting, no pagination): apps own that logic,
|
|
153
196
|
// what they were duplicating is the markup and the tokens.
|
|
154
197
|
export {
|