@spunto/design-system 0.40.0 → 0.41.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
CHANGED
|
@@ -235,6 +235,10 @@ opinions a dashboard doesn't want, so it gets an entry too.
|
|
|
235
235
|
footer, above View (or above a custom `footer`), muted once the task is over.
|
|
236
236
|
Before 0.40.0 the dashboard did it through `footer` and redrew the View button
|
|
237
237
|
by hand.
|
|
238
|
+
- **`WorkerCockpit`** takes `tasks` + `taskHref` (since 0.41.0): a "Tasks" section
|
|
239
|
+
at the top of its panel, drawn by `WorkerTaskHistory` (`/tasks`) — the live task
|
|
240
|
+
as a card, then every other task that ran on the workspace, most recent first.
|
|
241
|
+
The project's task list can be passed as is; the panel keeps this worker's.
|
|
238
242
|
- **Its bricks, exported individually** because the table view assembles them
|
|
239
243
|
differently: `WorkerStatusDot`/`WorkerStatusPill` (+`resolveWorkerStatus`,
|
|
240
244
|
`workerStatusConfig`), `SetupProgress` (+`setupProgress`, `phaseLabel`,
|
|
@@ -331,7 +335,7 @@ review. Every surface that shows one:
|
|
|
331
335
|
- **`NewTaskDialog`** — delegating: prompt, files, title, base branch, model, plus the app's own `fields` (`NewTaskCustomField`: label, hint, `defaultValue`, `required`, `render(value, onChange)`), read back in `value.fields`.
|
|
332
336
|
- Vocabulary and helpers: `TaskStateBadge`, `taskStateConfig`, `useElapsed`,
|
|
333
337
|
`AgentMarkdown`, `useAttachmentDraft`/`prepareFile`/`TaskFiles` (files, RFC 0022),
|
|
334
|
-
`runStats`/`toolVerb`/`toolSubject`, `bootSteps`, `indexTasksByWorker`.
|
|
338
|
+
`runStats`/`toolVerb`/`toolSubject`, `bootSteps`, `indexTasksByWorker`, `WorkerTaskHistory`.
|
|
335
339
|
|
|
336
340
|
Same rules as `/workers`: nothing fetches, types are structural and lax
|
|
337
341
|
(`TaskItem`, `TaskEvent`, `TaskDiff`…), links go through `render.link`.
|
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@ export { TaskList } from "./task-list"
|
|
|
27
27
|
export type { TaskListProps } from "./task-list"
|
|
28
28
|
export { TaskConversationList, TaskConversationPlaceholder } from "./conversation-list"
|
|
29
29
|
export type { TaskConversationListProps } from "./conversation-list"
|
|
30
|
-
export { TaskWorkerChip, WorkerTaskChip, indexTasksByWorker } from "./worker-link"
|
|
30
|
+
export { TaskWorkerChip, WorkerTaskChip, WorkerTaskHistory, indexTasksByWorker } from "./worker-link"
|
|
31
31
|
export type { WorkerTask } from "./worker-link"
|
|
32
32
|
export { NewTaskDialog } from "./new-task-dialog"
|
|
33
33
|
export type { NewTaskCustomField, NewTaskDialogProps, NewTaskModelGroup, NewTaskValue } from "./new-task-dialog"
|
|
@@ -22,7 +22,7 @@ import { taskSpan } from "./task-state"
|
|
|
22
22
|
import { TaskTitle } from "./task-title"
|
|
23
23
|
import { runStats, toolSubject, toolVerb, type ToolRun } from "./tool-stack"
|
|
24
24
|
import type { TaskCommand, TaskEvent, TaskItem } from "./types"
|
|
25
|
-
import { indexTasksByWorker } from "./worker-link"
|
|
25
|
+
import { WorkerTaskHistory, indexTasksByWorker } from "./worker-link"
|
|
26
26
|
import { WorkerCard } from "../workers/worker-card"
|
|
27
27
|
|
|
28
28
|
const ev = (seq: number, type: string, payload: Record<string, unknown>, ts = `2026-09-24T10:00:${String(seq).padStart(2, "0")}Z`): TaskEvent => ({
|
|
@@ -201,6 +201,31 @@ describe("worker ↔ task", () => {
|
|
|
201
201
|
expect(screen.getByRole("link", { name: /View/ }).getAttribute("href")).toBe("/w/w1")
|
|
202
202
|
})
|
|
203
203
|
|
|
204
|
+
it("lists a workspace's tasks: the live one on top, the rest as history, others left out", () => {
|
|
205
|
+
const tasks = [
|
|
206
|
+
task({ id: "a", title: "Old one", state: "done", workerId: "w1", lastActivityAt: "2026-09-24T08:00:00Z" }),
|
|
207
|
+
task({ id: "b", title: "Live one", state: "running", workerId: "w1", lastActivityAt: "2026-09-24T09:00:00Z" }),
|
|
208
|
+
task({ id: "c", title: "Elsewhere", state: "running", workerId: "w2" }),
|
|
209
|
+
]
|
|
210
|
+
render(<WorkerTaskHistory workerId="w1" tasks={tasks} href={(t) => `/t/${t.id}`} />)
|
|
211
|
+
const links = screen.getAllByRole("link").map((a) => a.getAttribute("href"))
|
|
212
|
+
expect(links).toEqual(["/t/b", "/t/a"])
|
|
213
|
+
expect(screen.queryByText("Elsewhere")).toBeNull()
|
|
214
|
+
expect(screen.queryByText("No task holds this workspace.")).toBeNull()
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
it("says no task holds the machine, and folds a long history", () => {
|
|
218
|
+
const tasks = Array.from({ length: 7 }, (_, i) =>
|
|
219
|
+
task({ id: `t${i}`, title: `Task ${i}`, state: "done", workerId: "w1", lastActivityAt: `2026-09-2${i}T10:00:00Z` }),
|
|
220
|
+
)
|
|
221
|
+
render(<WorkerTaskHistory workerId="w1" tasks={tasks} href={(t) => `/t/${t.id}`} limit={5} />)
|
|
222
|
+
expect(screen.getByText("No task holds this workspace.")).toBeTruthy()
|
|
223
|
+
expect(screen.getAllByRole("link")).toHaveLength(5)
|
|
224
|
+
expect(screen.getAllByRole("link")[0].getAttribute("href")).toBe("/t/t6")
|
|
225
|
+
fireEvent.click(screen.getByText("Show all 7"))
|
|
226
|
+
expect(screen.getAllByRole("link")).toHaveLength(7)
|
|
227
|
+
})
|
|
228
|
+
|
|
204
229
|
it("keeps the task line when the caller replaces the footer, and draws none without a task", () => {
|
|
205
230
|
const entry = indexTasksByWorker([task({ title: "Ship the card", workerId: "w1" })]).get("w1")!
|
|
206
231
|
const { rerender } = render(<WorkerCard worker={{ id: "w1" }} task={{ entry, href: "/t" }} footer={<button>IDE</button>} />)
|
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
// (workspaces, tasks) are one story told twice rather than two lists to correlate by hand. Both
|
|
8
8
|
// directions are resolved from the two lists the page already holds: no extra round trip.
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { useState } from "react"
|
|
11
|
+
import { GitBranchIcon, ServerIcon } from "lucide-react"
|
|
11
12
|
|
|
12
|
-
import { cn } from "../../utils"
|
|
13
|
+
import { cn, formatRelativeTime } from "../../utils"
|
|
13
14
|
import type { WorkerCardWorker } from "../workers/types"
|
|
14
15
|
import type { LinkRender } from "../workers/worker-card"
|
|
15
16
|
import { WorkerStatusDot, resolveWorkerStatus } from "../workers/worker-status"
|
|
16
|
-
import { isLiveTaskState, taskStateStyle } from "./task-state"
|
|
17
|
+
import { TaskStateBadge, isLiveTaskState, taskStateStyle } from "./task-state"
|
|
17
18
|
import { workerLabel } from "./machine"
|
|
18
19
|
import type { TaskItem } from "./types"
|
|
19
20
|
|
|
@@ -124,3 +125,91 @@ export function TaskWorkerChip({
|
|
|
124
125
|
</span>
|
|
125
126
|
)
|
|
126
127
|
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Every task that ran on one workspace, for the worker page: the one holding the machine on top,
|
|
131
|
+
* as a card, then the rest as history, most recent first.
|
|
132
|
+
*
|
|
133
|
+
* Takes the tasks the caller already has and keeps those whose `workerId` is this worker — so a
|
|
134
|
+
* project's task list can be passed as is. The pick on top is `indexTasksByWorker`'s: a live task
|
|
135
|
+
* wins; when none is, no card claims the machine and the most recent task leads the history.
|
|
136
|
+
*/
|
|
137
|
+
export function WorkerTaskHistory({
|
|
138
|
+
workerId,
|
|
139
|
+
tasks,
|
|
140
|
+
href,
|
|
141
|
+
render,
|
|
142
|
+
limit = 5,
|
|
143
|
+
className,
|
|
144
|
+
}: {
|
|
145
|
+
workerId: string
|
|
146
|
+
tasks: TaskItem[]
|
|
147
|
+
href: (task: TaskItem) => string
|
|
148
|
+
render?: { link?: LinkRender }
|
|
149
|
+
/** Rows of history shown before "Show all". */
|
|
150
|
+
limit?: number
|
|
151
|
+
className?: string
|
|
152
|
+
}) {
|
|
153
|
+
const [expanded, setExpanded] = useState(false)
|
|
154
|
+
const Link = render?.link ?? defaultLink
|
|
155
|
+
const mine = tasks.filter((t) => t.workerId === workerId)
|
|
156
|
+
const entry = indexTasksByWorker(mine).get(workerId)
|
|
157
|
+
if (!entry) return null
|
|
158
|
+
|
|
159
|
+
const at = (t: TaskItem) => t.lastActivityAt ?? t.createdAt
|
|
160
|
+
const current = entry.live ? entry.task : null
|
|
161
|
+
const history = mine
|
|
162
|
+
.filter((t) => t !== current)
|
|
163
|
+
.sort((a, b) => new Date(at(b)).getTime() - new Date(at(a)).getTime())
|
|
164
|
+
const shown = expanded ? history : history.slice(0, limit)
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<div className={cn("space-y-2", className)}>
|
|
168
|
+
{current ? (
|
|
169
|
+
<Link
|
|
170
|
+
href={href(current)}
|
|
171
|
+
className="block rounded-lg border border-border/50 bg-muted/20 px-3 py-2.5 transition-colors hover:bg-muted/40"
|
|
172
|
+
>
|
|
173
|
+
<div className="flex items-center justify-between gap-2">
|
|
174
|
+
<TaskStateBadge state={current.state} pendingAction={current.pendingAction} pendingSince={current.pendingSince} />
|
|
175
|
+
<span className="shrink-0 text-[10px] text-muted-foreground/60">{formatRelativeTime(at(current))}</span>
|
|
176
|
+
</div>
|
|
177
|
+
<p className="mt-1.5 line-clamp-2 text-xs font-medium text-foreground">{current.title}</p>
|
|
178
|
+
{current.branch && (
|
|
179
|
+
<div className="mt-1 flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground">
|
|
180
|
+
<GitBranchIcon className="h-3 w-3 shrink-0" />
|
|
181
|
+
<span className="truncate font-mono">{current.branch}</span>
|
|
182
|
+
</div>
|
|
183
|
+
)}
|
|
184
|
+
</Link>
|
|
185
|
+
) : (
|
|
186
|
+
<p className="text-[11px] text-muted-foreground">No task holds this workspace.</p>
|
|
187
|
+
)}
|
|
188
|
+
|
|
189
|
+
{history.length > 0 && (
|
|
190
|
+
<div className="divide-y divide-border/40 rounded-lg border border-border/50 bg-muted/10">
|
|
191
|
+
{shown.map((t) => (
|
|
192
|
+
<Link
|
|
193
|
+
key={t.id}
|
|
194
|
+
href={href(t)}
|
|
195
|
+
className="flex min-w-0 items-center gap-2 px-3 py-1.5 text-muted-foreground transition-colors hover:bg-muted/30 hover:text-foreground"
|
|
196
|
+
>
|
|
197
|
+
<span title={taskStateStyle(t.state).label} className={cn("h-1.5 w-1.5 shrink-0 rounded-full", taskStateStyle(t.state).dotClass)} />
|
|
198
|
+
<span className="min-w-0 flex-1 truncate text-[11px]">{t.title}</span>
|
|
199
|
+
<span className="shrink-0 text-[10px] text-muted-foreground/60">{formatRelativeTime(at(t))}</span>
|
|
200
|
+
</Link>
|
|
201
|
+
))}
|
|
202
|
+
{history.length > limit && (
|
|
203
|
+
<button
|
|
204
|
+
type="button"
|
|
205
|
+
onClick={() => setExpanded((v) => !v)}
|
|
206
|
+
className="w-full cursor-pointer px-3 py-1.5 text-left text-[11px] text-muted-foreground transition-colors hover:text-foreground"
|
|
207
|
+
>
|
|
208
|
+
{expanded ? "Show less" : `Show all ${history.length}`}
|
|
209
|
+
</button>
|
|
210
|
+
)}
|
|
211
|
+
</div>
|
|
212
|
+
)}
|
|
213
|
+
</div>
|
|
214
|
+
)
|
|
215
|
+
}
|
|
@@ -49,6 +49,8 @@ import { type LinkRender } from "./worker-card"
|
|
|
49
49
|
import { WorkerSetupTimeline } from "./worker-setup-timeline"
|
|
50
50
|
import { WorkerStatusDot, WorkerStatusPill, resolveWorkerStatus } from "./worker-status"
|
|
51
51
|
import { WorkerStatusHistory } from "./worker-status-history"
|
|
52
|
+
import { WorkerTaskHistory } from "../tasks/worker-link"
|
|
53
|
+
import type { TaskItem } from "../tasks/types"
|
|
52
54
|
|
|
53
55
|
type CockpitTab = "logs" | "terminal"
|
|
54
56
|
|
|
@@ -111,6 +113,15 @@ export interface WorkerCockpitProps {
|
|
|
111
113
|
*/
|
|
112
114
|
statusHistory?: WorkerStatusEvent[]
|
|
113
115
|
|
|
116
|
+
/**
|
|
117
|
+
* The tasks that ran on this workspace — the project's list can be passed as is, the panel keeps
|
|
118
|
+
* those whose `workerId` is this worker. Drawn as a "Tasks" section: the live one as a card on
|
|
119
|
+
* top, then the history, most recent first. Absent, or none ran here → no section.
|
|
120
|
+
*/
|
|
121
|
+
tasks?: TaskItem[]
|
|
122
|
+
/** Task → its page. Required for the section to render. */
|
|
123
|
+
taskHref?: (task: TaskItem) => string
|
|
124
|
+
|
|
114
125
|
/** A failed mutation, typically. */
|
|
115
126
|
error?: string | null
|
|
116
127
|
onDismissError?: () => void
|
|
@@ -188,6 +199,8 @@ export function WorkerCockpit({
|
|
|
188
199
|
deleting = false,
|
|
189
200
|
onCopySsh,
|
|
190
201
|
statusHistory,
|
|
202
|
+
tasks,
|
|
203
|
+
taskHref,
|
|
191
204
|
error,
|
|
192
205
|
onDismissError,
|
|
193
206
|
activeTab,
|
|
@@ -232,6 +245,7 @@ export function WorkerCockpit({
|
|
|
232
245
|
}
|
|
233
246
|
|
|
234
247
|
const showActions = !!((settled && onCopySsh) || (hasContainer && !status.settingUp && !isDeleting && onRebuild) || ((hasContainer || isDeleting) && nodeOnline !== false && onDelete))
|
|
248
|
+
const hasTasks = !!taskHref && !!tasks?.some((t) => t.workerId === worker.id)
|
|
235
249
|
const showTags = (worker.tags?.length ?? 0) > 0 || !!onAddTag
|
|
236
250
|
|
|
237
251
|
const controlPanel = (
|
|
@@ -268,6 +282,14 @@ export function WorkerCockpit({
|
|
|
268
282
|
</Banner>
|
|
269
283
|
)}
|
|
270
284
|
|
|
285
|
+
{/* Before Setup: on a task's machine, the work it is doing is the first thing to read. */}
|
|
286
|
+
{hasTasks && (
|
|
287
|
+
<div>
|
|
288
|
+
<SectionLabel>Tasks</SectionLabel>
|
|
289
|
+
<WorkerTaskHistory workerId={worker.id} tasks={tasks!} href={taskHref!} render={{ link: render?.link }} />
|
|
290
|
+
</div>
|
|
291
|
+
)}
|
|
292
|
+
|
|
271
293
|
{(status.settingUp || worker.setupStatus) && (
|
|
272
294
|
<div className="space-y-2">
|
|
273
295
|
<SectionLabel>Setup</SectionLabel>
|