@spunto/design-system 0.81.0 → 0.82.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/package.json +1 -1
- package/src/components/tasks/conversation-list.tsx +2 -0
- package/src/components/tasks/family.tsx +30 -0
- package/src/components/tasks/index.ts +2 -0
- package/src/components/tasks/task-details.tsx +72 -5
- package/src/components/tasks/task-list.tsx +2 -0
- package/src/components/tasks/tasks.test.tsx +28 -0
- package/src/components/tasks/types.ts +15 -0
package/package.json
CHANGED
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
} from "lucide-react"
|
|
38
38
|
|
|
39
39
|
import { cn, formatRelativeTime } from "../../utils"
|
|
40
|
+
import { TaskFamilyMark } from "./family"
|
|
40
41
|
import { Button } from "../button"
|
|
41
42
|
import { TASK_STATE_ORDER, TaskStateIcon, taskPendingActionConfig, taskStateStyle, useElapsed } from "./task-state"
|
|
42
43
|
import type { TaskConversation, TaskState } from "./types"
|
|
@@ -187,6 +188,7 @@ function ConversationRow({
|
|
|
187
188
|
<span className={cn("min-w-0 flex-1 truncate text-xs pointer-coarse:text-sm", selected ? "font-semibold" : "font-medium")}>
|
|
188
189
|
{task.title}
|
|
189
190
|
</span>
|
|
191
|
+
<TaskFamilyMark task={task} />
|
|
190
192
|
{/* When it last moved — replaced, while something is in flight, by how long it has been. */}
|
|
191
193
|
<RowTime task={task} />
|
|
192
194
|
{/* Touch has no hover to say "this leads somewhere", so the affordance is drawn. */}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
// Where a task sits in its family (docs/tasks.md § « Sous-tâches »), as a list row says it: a
|
|
4
|
+
// sub-task is marked as one, a task that delegated says how many. Small and muted — the title is
|
|
5
|
+
// the subject, this is a coordinate, like the project under it.
|
|
6
|
+
|
|
7
|
+
import { CornerDownRightIcon, ListTreeIcon } from "lucide-react"
|
|
8
|
+
|
|
9
|
+
import { cn } from "../../utils"
|
|
10
|
+
import type { TaskItem } from "./types"
|
|
11
|
+
|
|
12
|
+
export function TaskFamilyMark({ task, className }: { task: Pick<TaskItem, "parentTaskId" | "subtaskCount">; className?: string }) {
|
|
13
|
+
const count = task.subtaskCount ?? 0
|
|
14
|
+
if (!task.parentTaskId && count === 0) return null
|
|
15
|
+
return (
|
|
16
|
+
<span className={cn("flex shrink-0 items-center gap-1.5 text-[10px] text-muted-foreground", className)}>
|
|
17
|
+
{task.parentTaskId && (
|
|
18
|
+
<span title="Sub-task — delegated by another task" aria-label="Sub-task">
|
|
19
|
+
<CornerDownRightIcon className="h-3 w-3" />
|
|
20
|
+
</span>
|
|
21
|
+
)}
|
|
22
|
+
{count > 0 && (
|
|
23
|
+
<span className="flex items-center gap-0.5 tabular-nums" title={`${count} sub-task${count === 1 ? "" : "s"}`}>
|
|
24
|
+
<ListTreeIcon className="h-3 w-3" />
|
|
25
|
+
{count}
|
|
26
|
+
</span>
|
|
27
|
+
)}
|
|
28
|
+
</span>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
@@ -27,6 +27,7 @@ export type { TaskStateBadgeProps, TaskStateIconProps, TaskStateStyle } from "./
|
|
|
27
27
|
export { TaskList } from "./task-list"
|
|
28
28
|
export type { TaskListProps } from "./task-list"
|
|
29
29
|
export { TaskConversationList, TaskConversationPlaceholder } from "./conversation-list"
|
|
30
|
+
export { TaskFamilyMark } from "./family"
|
|
30
31
|
export type { TaskConversationListProps } from "./conversation-list"
|
|
31
32
|
export { TaskWorkerChip, WorkerTaskChip, WorkerTaskHistory, indexTasksByWorker } from "./worker-link"
|
|
32
33
|
export type { WorkerTask } from "./worker-link"
|
|
@@ -121,6 +122,7 @@ export type {
|
|
|
121
122
|
TaskPatchHunk,
|
|
122
123
|
TaskPatchLine,
|
|
123
124
|
TaskPendingAction,
|
|
125
|
+
TaskRelative,
|
|
124
126
|
TaskRepoDiff,
|
|
125
127
|
TaskSharedData,
|
|
126
128
|
TaskSharedFile,
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
// opens it in every conversation (`useBlockOpen`, this browser's `localStorage`).
|
|
19
19
|
|
|
20
20
|
import { createContext, useContext, useState, useSyncExternalStore, type ReactNode } from "react"
|
|
21
|
-
import { CheckIcon, ChevronRightIcon, CopyIcon, ExternalLinkIcon, GitBranchIcon, Loader2Icon, SlidersHorizontalIcon, XCircleIcon } from "lucide-react"
|
|
21
|
+
import { CheckIcon, ChevronRightIcon, CopyIcon, CornerLeftUpIcon, ExternalLinkIcon, GitBranchIcon, Loader2Icon, SlidersHorizontalIcon, XCircleIcon } from "lucide-react"
|
|
22
22
|
|
|
23
23
|
import { cn, formatRelativeTime } from "../../utils"
|
|
24
24
|
import { Avatar, AvatarFallback, AvatarImage } from "../avatar"
|
|
@@ -26,8 +26,9 @@ import { TaskCommandLog } from "./command-log"
|
|
|
26
26
|
import { TaskSessionUsage } from "./session-usage"
|
|
27
27
|
import { TaskSharedFiles, TaskSharedLinks } from "./shared"
|
|
28
28
|
import { TaskAppTileContent } from "./app-tiles"
|
|
29
|
-
import { isLiveTaskState, taskSpan } from "./task-state"
|
|
30
|
-
import type {
|
|
29
|
+
import { isLiveTaskState, taskSpan, TaskStateIcon, taskStateStyle, taskPendingActionConfig, taskStateConfig, TASK_STATE_ORDER } from "./task-state"
|
|
30
|
+
import type { LinkRender } from "../workers/worker-card"
|
|
31
|
+
import type { AttachmentUrl, TaskAppTile, TaskAppTileAction, TaskAppTileItem, TaskCommand, TaskItem, TaskPendingAction, TaskRelative, TaskSessionUsageData, TaskSharedData } from "./types"
|
|
31
32
|
|
|
32
33
|
/** Set by `TaskCockpitMobile` around its sheet, so Drop can close it. @internal */
|
|
33
34
|
export const TaskDetailsSheetContext = createContext<{ close: () => void } | null>(null)
|
|
@@ -75,6 +76,15 @@ export interface TaskDetailsProps {
|
|
|
75
76
|
/** `sheet` only: the Drop button at the bottom, on a live task. */
|
|
76
77
|
onDrop?: () => void
|
|
77
78
|
pendingAction?: TaskPendingAction | null
|
|
79
|
+
/** The task that delegated this one — a link back up, among the facts. */
|
|
80
|
+
parent?: TaskRelative | null
|
|
81
|
+
/**
|
|
82
|
+
* The tasks this one delegated (its session through `spunto-tasks`, or a member attaching them):
|
|
83
|
+
* the orchestrator's view of its threads, right under the machine. Omitted or empty = no block.
|
|
84
|
+
*/
|
|
85
|
+
subtasks?: TaskRelative[] | null
|
|
86
|
+
/** How the parent and sub-task links are drawn — the app's router link. A plain `<a>` otherwise. */
|
|
87
|
+
render?: { link?: LinkRender }
|
|
78
88
|
className?: string
|
|
79
89
|
}
|
|
80
90
|
|
|
@@ -228,6 +238,35 @@ function CustomizeLink({ tile, href }: { tile: TaskAppTile; href?: (tile: TaskAp
|
|
|
228
238
|
)
|
|
229
239
|
}
|
|
230
240
|
|
|
241
|
+
/** « 2 running · 1 in review » — where a family stands, in the cockpit's state order. */
|
|
242
|
+
function familyHint(subtasks: TaskRelative[]): string {
|
|
243
|
+
return TASK_STATE_ORDER.map((state) => [state, subtasks.filter((t) => t.state === state).length] as const)
|
|
244
|
+
.filter(([, n]) => n > 0)
|
|
245
|
+
.map(([state, n]) => `${n} ${taskStateConfig[state].label.toLowerCase()}`)
|
|
246
|
+
.join(" · ")
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** One sub-task: its state, its name, a link to its conversation. */
|
|
250
|
+
function SubtaskRow({ task, Link }: { task: TaskRelative; Link: LinkRender }) {
|
|
251
|
+
const tone = task.pendingAction ? taskPendingActionConfig[task.pendingAction].textClass : taskStateStyle(task.state).textClass
|
|
252
|
+
return (
|
|
253
|
+
<Link
|
|
254
|
+
href={task.href}
|
|
255
|
+
className="-mx-2 flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-xs transition-colors hover:bg-muted/50"
|
|
256
|
+
>
|
|
257
|
+
<span className={cn("shrink-0", tone)}>
|
|
258
|
+
{task.pendingAction ? (
|
|
259
|
+
<Loader2Icon className="h-3 w-3 animate-spin" />
|
|
260
|
+
) : (
|
|
261
|
+
<TaskStateIcon state={task.state} machine={task.machine} machinePaused={task.machinePaused} />
|
|
262
|
+
)}
|
|
263
|
+
</span>
|
|
264
|
+
<span className="min-w-0 flex-1 truncate">{task.title}</span>
|
|
265
|
+
<span className={cn("shrink-0 text-[10px]", tone)}>{taskStateStyle(task.state).label}</span>
|
|
266
|
+
</Link>
|
|
267
|
+
)
|
|
268
|
+
}
|
|
269
|
+
|
|
231
270
|
/** Anything to draw in a block — a tile with only `links` has none: its links go to the header. */
|
|
232
271
|
function hasBody(tile: TaskAppTile): boolean {
|
|
233
272
|
return !!(tile.meters?.length || tile.facts?.length || tile.items?.length || tile.lists?.length)
|
|
@@ -249,9 +288,13 @@ export function TaskDetails({
|
|
|
249
288
|
protocol = "none",
|
|
250
289
|
onDrop,
|
|
251
290
|
pendingAction = task.pendingAction ?? null,
|
|
291
|
+
parent,
|
|
292
|
+
subtasks,
|
|
293
|
+
render,
|
|
252
294
|
className,
|
|
253
295
|
}: TaskDetailsProps) {
|
|
254
296
|
const sheet = useContext(TaskDetailsSheetContext)
|
|
297
|
+
const Link: LinkRender = render?.link ?? (({ href, className, children }) => <a href={href} className={className}>{children}</a>)
|
|
255
298
|
const meta = task.meta && Object.keys(task.meta).length > 0 ? task.meta : null
|
|
256
299
|
// The task's own links, then those its org's apps add (Spunto IDE: « Open IDE »), once each.
|
|
257
300
|
const allLinks = [...(task.links ?? []), ...(appTiles ?? []).flatMap((tile) => tile.links ?? [])].filter(
|
|
@@ -262,7 +305,7 @@ export function TaskDetails({
|
|
|
262
305
|
const ran = task.completedAt ? taskSpan(task.startedAt ?? task.createdAt, task.completedAt) : null
|
|
263
306
|
// `baseBranch: null` is the project's default — saying so ("project default") on every task of a
|
|
264
307
|
// project with no branches was a fact with nothing in it. Only an explicit base is worth a line.
|
|
265
|
-
const facts = !!links || !!task.branch || !!task.baseBranch || !!task.outcomeUrl
|
|
308
|
+
const facts = !!links || !!task.branch || !!task.baseBranch || !!task.outcomeUrl || !!parent
|
|
266
309
|
|
|
267
310
|
return (
|
|
268
311
|
<div className={className}>
|
|
@@ -303,7 +346,19 @@ export function TaskDetails({
|
|
|
303
346
|
|
|
304
347
|
{facts && (
|
|
305
348
|
<div className={cn("grid grid-cols-2 gap-3", variant === "sidebar" && "mt-3")}>
|
|
306
|
-
{/*
|
|
349
|
+
{/* Where the work came from is what a reader arriving from a list asks before anything
|
|
350
|
+
else — and a sub-task came from its parent first. */}
|
|
351
|
+
{parent && (
|
|
352
|
+
<div className="col-span-2">
|
|
353
|
+
<Fact label="Delegated by task">
|
|
354
|
+
<Link href={parent.href} className="flex min-w-0 items-center gap-1.5 text-primary hover:underline">
|
|
355
|
+
<CornerLeftUpIcon className="h-3 w-3 shrink-0" />
|
|
356
|
+
<span className="truncate">{parent.title}</span>
|
|
357
|
+
<span className={cn("shrink-0 text-[10px]", taskStateStyle(parent.state).textClass)}>{taskStateStyle(parent.state).label}</span>
|
|
358
|
+
</Link>
|
|
359
|
+
</Fact>
|
|
360
|
+
</div>
|
|
361
|
+
)}
|
|
307
362
|
{links && (
|
|
308
363
|
<div className="col-span-2">
|
|
309
364
|
<Fact label={links.length === 1 ? "Link" : "Links"}>
|
|
@@ -361,6 +416,18 @@ export function TaskDetails({
|
|
|
361
416
|
</Block>
|
|
362
417
|
)}
|
|
363
418
|
|
|
419
|
+
{/* The orchestrator's view: what it delegated and where each thread stands — open, since a
|
|
420
|
+
parent waiting on its sub-tasks is read for exactly this. */}
|
|
421
|
+
{subtasks && subtasks.length > 0 && (
|
|
422
|
+
<Block id="subtasks" variant={variant} title="Sub-tasks" hint={familyHint(subtasks)} pinned>
|
|
423
|
+
<div className="space-y-0.5">
|
|
424
|
+
{subtasks.map((t) => (
|
|
425
|
+
<SubtaskRow key={t.id} task={t} Link={Link} />
|
|
426
|
+
))}
|
|
427
|
+
</div>
|
|
428
|
+
</Block>
|
|
429
|
+
)}
|
|
430
|
+
|
|
364
431
|
{usage && (
|
|
365
432
|
<Block id="session" variant={variant} title="Session">
|
|
366
433
|
<TaskSessionUsage usage={usage} />
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import { useState, type ReactNode } from "react"
|
|
15
15
|
import { CheckCircle2Icon, GitBranchIcon, GitPullRequestIcon, Loader2Icon, SparklesIcon, XCircleIcon } from "lucide-react"
|
|
16
|
+
import { TaskFamilyMark } from "./family"
|
|
16
17
|
|
|
17
18
|
import { cn, formatRelativeTime } from "../../utils"
|
|
18
19
|
import type { LinkRender } from "../workers/worker-card"
|
|
@@ -95,6 +96,7 @@ function TaskRow<T extends TaskItem>({
|
|
|
95
96
|
<Link href={href} className="truncate text-sm font-medium underline-offset-2 hover:underline">
|
|
96
97
|
{task.title}
|
|
97
98
|
</Link>
|
|
99
|
+
<TaskFamilyMark task={task} />
|
|
98
100
|
<TaskStateBadge state={task.state} machine={task.machine} machinePaused={task.machinePaused} pendingAction={pendingAction} pendingSince={task.pendingSince} />
|
|
99
101
|
|
|
100
102
|
{/* Actions live on the row, not behind a menu: reviewing is the moment the panel exists
|
|
@@ -528,6 +528,34 @@ describe("TaskDetails", () => {
|
|
|
528
528
|
expect(screen.getByText("release/2.0")).toBeTruthy()
|
|
529
529
|
})
|
|
530
530
|
|
|
531
|
+
it("links back up to the parent, and lists the sub-tasks open, right under the machine", () => {
|
|
532
|
+
window.localStorage.clear()
|
|
533
|
+
const { container } = render(
|
|
534
|
+
<TaskDetails
|
|
535
|
+
task={task()}
|
|
536
|
+
machine={<p>machine panel</p>}
|
|
537
|
+
parent={{ id: "p", title: "Orchestrate the migration", state: "running", href: "/t/p" }}
|
|
538
|
+
subtasks={[
|
|
539
|
+
{ id: "a", title: "Migrate the API", state: "in-review", href: "/t/a" },
|
|
540
|
+
{ id: "b", title: "Migrate the dashboard", state: "running", href: "/t/b" },
|
|
541
|
+
{ id: "c", title: "Migrate the docs", state: "running", href: "/t/c" },
|
|
542
|
+
]}
|
|
543
|
+
commands={[]}
|
|
544
|
+
/>,
|
|
545
|
+
)
|
|
546
|
+
expect(screen.getByText("Orchestrate the migration").closest("a")?.getAttribute("href")).toBe("/t/p")
|
|
547
|
+
const blocks = [...container.querySelectorAll("[data-block]")].map((el) => el.getAttribute("data-block"))
|
|
548
|
+
expect(blocks.slice(0, 2)).toEqual(["machine", "subtasks"])
|
|
549
|
+
expect(screen.getByText("Migrate the dashboard").closest("a")?.getAttribute("href")).toBe("/t/b")
|
|
550
|
+
expect(screen.getByText("2 running · 1 in review")).toBeTruthy()
|
|
551
|
+
})
|
|
552
|
+
|
|
553
|
+
it("draws no family when there is none", () => {
|
|
554
|
+
const { container } = render(<TaskDetails task={task()} subtasks={[]} commands={[]} />)
|
|
555
|
+
expect(container.querySelector('[data-block="subtasks"]')).toBeNull()
|
|
556
|
+
expect(screen.queryByText("Delegated by task")).toBeNull()
|
|
557
|
+
})
|
|
558
|
+
|
|
531
559
|
it("names the member who delegated the task", () => {
|
|
532
560
|
render(<TaskDetails task={task()} delegatedBy={{ name: "Ada" }} commands={[]} />)
|
|
533
561
|
expect(screen.getByText("Ada")).toBeTruthy()
|
|
@@ -68,6 +68,21 @@ export interface TaskItem {
|
|
|
68
68
|
userArchivedAt?: string | null
|
|
69
69
|
/** When a member set this task in review aside for later — it then lives in the « On hold » view. Null = not on hold. */
|
|
70
70
|
onHoldAt?: string | null
|
|
71
|
+
/** The task that delegated this one — the API's `parentTaskId`. Null = a task of its own. */
|
|
72
|
+
parentTaskId?: string | null
|
|
73
|
+
/** How many tasks this one delegated — drawn as a count on its row. */
|
|
74
|
+
subtaskCount?: number
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** A task of the same family — a parent or a sub-task — as `TaskDetails` links to it. */
|
|
78
|
+
export interface TaskRelative {
|
|
79
|
+
id: string
|
|
80
|
+
title: string
|
|
81
|
+
state: TaskState
|
|
82
|
+
href: string
|
|
83
|
+
machine?: TaskMachineState | null
|
|
84
|
+
machinePaused?: boolean
|
|
85
|
+
pendingAction?: TaskPendingAction | null
|
|
71
86
|
}
|
|
72
87
|
|
|
73
88
|
/** A row of the org-wide conversation list: a task plus the project it belongs to. */
|