@spunto/design-system 0.63.1 → 0.65.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
@@ -332,7 +332,7 @@ review. Every surface that shows one:
332
332
  optional `actions`, and a dark surface for the app's own shell (the socket is the
333
333
  app's), or a sentence saying why there is none. No composer under it.
334
334
  - **`TaskDetails`** (`sidebar` | `sheet`) with **`TaskMachine`**, **`TaskBoot`**,
335
- `TaskSessionUsage`, `TaskPullRequest`, `TaskCommandLog` — the facts about a task, in
335
+ `TaskSessionUsage`, `TaskAppTileContent`, `TaskCommandLog` — the facts about a task, in
336
336
  one order, instead of two hand-kept copies.
337
337
  - **`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`.
338
338
  - Vocabulary and helpers: `TaskStateBadge`, `taskStateConfig`, `useElapsed`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spunto/design-system",
3
- "version": "0.63.1",
3
+ "version": "0.65.0",
4
4
  "description": "Spunto's shared design system — green tokens (conservatory + sprout), color constants, and UI primitives.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -85,7 +85,6 @@ export { TaskDiffPanel } from "./diff-panel"
85
85
  export type { TaskDiffPanelProps } from "./diff-panel"
86
86
  export { TaskTerminalPanel } from "./terminal-panel"
87
87
  export type { TaskTerminalPanelProps } from "./terminal-panel"
88
- export { TaskPullRequest } from "./pull-request"
89
88
  export { TaskSharedFiles, TaskSharedLinks } from "./shared"
90
89
  export { TaskAppTileContent, TaskAppTileItems } from "./app-tiles"
91
90
  export { TaskSessionUsage, formatCost, formatTokens } from "./session-usage"
@@ -121,8 +120,6 @@ export type {
121
120
  TaskPatchHunk,
122
121
  TaskPatchLine,
123
122
  TaskPendingAction,
124
- TaskPullRequestData,
125
- TaskPullRequests,
126
123
  TaskRepoDiff,
127
124
  TaskSharedData,
128
125
  TaskSharedFile,
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
 
3
- // Everything that is a *fact about* a task rather than a moment in it — branch, cost, the pull
4
- // request, what was shared in the conversation, the machine, the prompt, what ran — in one component with two shapes:
3
+ // Everything that is a *fact about* a task rather than a moment in it — branch, cost, what the
4
+ // org's apps draw (GitHub: the pull requests), what was shared in the conversation, the machine, the prompt, what ran — in one component with two shapes:
5
5
  //
6
6
  // - `sidebar`: the cockpit's right column, each block a fold, glanced at without pushing the
7
7
  // work off screen;
@@ -14,16 +14,15 @@
14
14
  // machine), then how it was set up.
15
15
 
16
16
  import { createContext, useContext, useState, type ReactNode } from "react"
17
- import { CheckIcon, ChevronRightIcon, CopyIcon, ExternalLinkIcon, GitBranchIcon, Loader2Icon, XCircleIcon } from "lucide-react"
17
+ import { CheckIcon, ChevronRightIcon, CopyIcon, ExternalLinkIcon, GitBranchIcon, Loader2Icon, SlidersHorizontalIcon, XCircleIcon } from "lucide-react"
18
18
 
19
19
  import { cn, formatRelativeTime } from "../../utils"
20
20
  import { TaskCommandLog } from "./command-log"
21
- import { TaskPullRequest } from "./pull-request"
22
21
  import { TaskSessionUsage } from "./session-usage"
23
22
  import { TaskSharedFiles, TaskSharedLinks } from "./shared"
24
23
  import { TaskAppTileContent } from "./app-tiles"
25
24
  import { isLiveTaskState, taskSpan } from "./task-state"
26
- import type { AttachmentUrl, TaskAppTile, TaskCommand, TaskItem, TaskPendingAction, TaskPullRequests, TaskSessionUsageData, TaskSharedData } from "./types"
25
+ import type { AttachmentUrl, TaskAppTile, TaskCommand, TaskItem, TaskPendingAction, TaskSessionUsageData, TaskSharedData } from "./types"
27
26
 
28
27
  /** Set by `TaskCockpitMobile` around its sheet, so Drop can close it. @internal */
29
28
  export const TaskDetailsSheetContext = createContext<{ close: () => void } | null>(null)
@@ -34,8 +33,6 @@ export interface TaskDetailsProps {
34
33
  variant?: "sidebar" | "sheet"
35
34
  /** What the session consumed. Absent → no Session block (nothing measured is not "free"). */
36
35
  usage?: TaskSessionUsageData | null
37
- /** What the forge says about the branch. Absent or `supported: false` → no block at all. */
38
- pullRequests?: TaskPullRequests | null
39
36
  /**
40
37
  * The links and files that circulated in the conversation (`GET .../shared`). Each list is its
41
38
  * own block, absent while empty. Files need `attachmentUrl` to be drawn.
@@ -46,6 +43,11 @@ export interface TaskDetailsProps {
46
43
  * the pull requests, and where each stands. One block per app, absent when it has nothing.
47
44
  */
48
45
  appTiles?: TaskAppTile[] | null
46
+ /**
47
+ * Where a reader changes what a `customizable` block shows — the app's card in the org's
48
+ * integrations. Absent (or null for a tile) = no link.
49
+ */
50
+ appTileSettingsHref?: (tile: TaskAppTile) => string | null
49
51
  attachmentUrl?: AttachmentUrl
50
52
  /** The Machine block's content — typically a `TaskMachine`. */
51
53
  machine?: ReactNode
@@ -131,13 +133,28 @@ function Block({
131
133
  )
132
134
  }
133
135
 
136
+ /** « Customize » under a block whose app lets each reader choose what it shows (RFC 0053 § 6). */
137
+ function CustomizeLink({ tile, href }: { tile: TaskAppTile; href?: (tile: TaskAppTile) => string | null }) {
138
+ const to = tile.customizable && href ? href(tile) : null
139
+ if (!to) return null
140
+ return (
141
+ <a
142
+ href={to}
143
+ className="mt-3 inline-flex items-center gap-1 text-[10px] text-muted-foreground transition-colors hover:text-foreground"
144
+ >
145
+ <SlidersHorizontalIcon className="h-3 w-3" />
146
+ Customize
147
+ </a>
148
+ )
149
+ }
150
+
134
151
  export function TaskDetails({
135
152
  task,
136
153
  variant = "sidebar",
137
154
  usage,
138
- pullRequests,
139
155
  shared,
140
156
  appTiles,
157
+ appTileSettingsHref,
141
158
  attachmentUrl,
142
159
  machine,
143
160
  commands = [],
@@ -232,20 +249,16 @@ export function TaskDetails({
232
249
  {appTiles?.filter((tile) => tile.session).map((tile) => (
233
250
  <Block key={tile.appId} variant={variant} title={tile.title} hint={tile.appName === tile.title ? undefined : tile.appName}>
234
251
  <TaskAppTileContent tile={tile} />
252
+ <CustomizeLink tile={tile} href={appTileSettingsHref} />
235
253
  </Block>
236
254
  ))}
237
255
 
238
- {pullRequests?.supported && (
239
- <Block variant={variant} title="Pull request">
240
- <TaskPullRequest data={pullRequests} />
241
- </Block>
242
- )}
243
-
244
- {/* Right under the branch's own PR: what the org's apps make of the links the conversation
245
- shared — the other pull requests it talked about, with where each one stands. */}
256
+ {/* What the org's apps make of the links the conversation shared — GitHub: the pull requests
257
+ it talked about, with where each one stands. */}
246
258
  {appTiles?.filter((tile) => !tile.session).map((tile) => (
247
259
  <Block key={tile.appId} variant={variant} title={tile.title} hint={tile.appName === tile.title ? undefined : tile.appName}>
248
260
  <TaskAppTileContent tile={tile} />
261
+ <CustomizeLink tile={tile} href={appTileSettingsHref} />
249
262
  </Block>
250
263
  ))}
251
264
 
@@ -216,27 +216,6 @@ export interface TaskFilePatch {
216
216
  hunks: TaskPatchHunk[]
217
217
  }
218
218
 
219
- // ── Pull request ─────────────────────────────────────────────────────────────────────────────
220
-
221
- /** A proposal at the forge for the task's branch — reported, never observed. */
222
- export interface TaskPullRequestData {
223
- /** Short reference, e.g. `#289` or `!42`. */
224
- label: string
225
- url: string
226
- title: string
227
- state: "draft" | "open" | "merged" | "closed"
228
- checks?: "pending" | "passing" | "failing" | null
229
- review?: "approved" | "changes-requested" | "pending" | null
230
- comments?: number | null
231
- updatedAt?: string | null
232
- }
233
-
234
- export interface TaskPullRequests {
235
- /** `false` → nothing connected can answer; the section is absent, not empty. */
236
- supported: boolean
237
- repos: { repo: string; pullRequest: TaskPullRequestData | null; error?: string | null }[]
238
- }
239
-
240
219
  // ── Shared in the conversation ──────────────────────────────────────────────────────────────
241
220
 
242
221
  /** A link written in the conversation (`GET .../tasks/{id}/shared`), deduplicated on its URL. */
@@ -313,6 +292,8 @@ export interface TaskAppTile {
313
292
  title: string
314
293
  /** From the app running the task's session: drawn right under Session rather than with the others. */
315
294
  session?: boolean
295
+ /** The app lets each reader choose what this block shows (RFC 0053 § 6): `TaskDetails` links to where. */
296
+ customizable?: boolean
316
297
  meters?: TaskAppTileMeter[]
317
298
  facts?: TaskAppTileFact[]
318
299
  items?: TaskAppTileItem[]
@@ -1,179 +0,0 @@
1
- "use client"
2
-
3
- import type { ReactNode } from "react"
4
- import {
5
- CheckCircle2Icon,
6
- CircleDotIcon,
7
- CircleSlashIcon,
8
- ExternalLinkIcon,
9
- GitMergeIcon,
10
- GitPullRequestDraftIcon,
11
- GitPullRequestIcon,
12
- Loader2Icon,
13
- MessageSquareIcon,
14
- TriangleAlertIcon,
15
- XCircleIcon,
16
- } from "lucide-react"
17
-
18
- import { cn, formatRelativeTime } from "../../utils"
19
- import { Badge } from "../badge"
20
- import type { TaskPullRequestData, TaskPullRequests } from "./types"
21
-
22
- /**
23
- * What the forge says about the task's branch.
24
- *
25
- * The one thing on this screen the platform cannot read off the machine it started — a proposal
26
- * lives at the forge, with the discussion, the CI and the approvals around it. Everything else
27
- * here (the diff, the session, the machine) is observed; this is *reported*, by whichever app
28
- * implements `git.pullRequestForBranch`.
29
- *
30
- * So the whole block is conditional on the answer, not on a provider id: `supported: false` means
31
- * nothing connected can answer, and the section is **absent** rather than empty. That is the rule
32
- * RFC 0024 asks for — read `operations`, never `if (provider === "github")` — and it is why this
33
- * component names no forge anywhere in its markup.
34
- *
35
- * **It never moves the task.** A merged proposal does not mark the task `done`, and this
36
- * deliberately does not offer an Accept button of its own: accepting is the project's command,
37
- * run by the human who read the diff.
38
- */
39
-
40
- type PullRequest = TaskPullRequestData
41
-
42
- /**
43
- * Colours borrowed from the task states they mean the same thing as: merged is a `done`, closed
44
- * a `failed`, open the flame that says "a human is expected here". A draft is muted on purpose —
45
- * it is work someone has not yet asked to be looked at.
46
- */
47
- const STATE_STYLES: Record<PullRequest["state"], { label: string; className: string }> = {
48
- draft: { label: "Draft", className: "bg-muted text-muted-foreground border-border" },
49
- open: { label: "Open", className: "bg-primary/15 text-primary border-primary/30" },
50
- merged: { label: "Merged", className: "bg-green-500/15 text-green-700 dark:text-green-400 border-green-500/30" },
51
- closed: { label: "Closed", className: "bg-red-500/15 text-red-700 dark:text-red-400 border-red-500/30" },
52
- }
53
-
54
- function StateIcon({ state }: { state: PullRequest["state"] }) {
55
- if (state === "merged") return <GitMergeIcon className="h-3 w-3" />
56
- if (state === "closed") return <XCircleIcon className="h-3 w-3" />
57
- if (state === "draft") return <GitPullRequestDraftIcon className="h-3 w-3" />
58
- return <GitPullRequestIcon className="h-3 w-3" />
59
- }
60
-
61
- /** A verdict and its colour — the same three-way vocabulary for checks and for review. */
62
- function Signal({
63
- icon,
64
- label,
65
- tone,
66
- }: {
67
- icon: ReactNode
68
- label: string
69
- tone: "good" | "bad" | "waiting"
70
- }) {
71
- return (
72
- <span
73
- className={cn(
74
- "inline-flex items-center gap-1 text-[10px]",
75
- tone === "good" && "text-green-700 dark:text-green-400",
76
- tone === "bad" && "text-red-700 dark:text-red-400",
77
- tone === "waiting" && "text-muted-foreground",
78
- )}
79
- >
80
- {icon}
81
- {label}
82
- </span>
83
- )
84
- }
85
-
86
- function Checks({ checks = null }: { checks?: PullRequest["checks"] }) {
87
- // Null is not "passing": a repository with no CI has not passed anything, and drawing a green
88
- // tick for it would be the panel's one outright lie.
89
- if (checks === null) return null
90
- if (checks === "passing") return <Signal icon={<CheckCircle2Icon className="h-3 w-3" />} label="Checks passing" tone="good" />
91
- if (checks === "failing") return <Signal icon={<TriangleAlertIcon className="h-3 w-3" />} label="Checks failing" tone="bad" />
92
- return <Signal icon={<Loader2Icon className="h-3 w-3 animate-spin" />} label="Checks running" tone="waiting" />
93
- }
94
-
95
- function Review({ review = null }: { review?: PullRequest["review"] }) {
96
- if (review === null) return null
97
- if (review === "approved") return <Signal icon={<CheckCircle2Icon className="h-3 w-3" />} label="Approved" tone="good" />
98
- if (review === "changes-requested")
99
- return <Signal icon={<CircleSlashIcon className="h-3 w-3" />} label="Changes requested" tone="bad" />
100
- return <Signal icon={<CircleDotIcon className="h-3 w-3" />} label="Review requested" tone="waiting" />
101
- }
102
-
103
- function PullRequestCard({ repo, pr, showRepo }: { repo: string; pr: PullRequest; showRepo: boolean }) {
104
- const style = STATE_STYLES[pr.state] ?? STATE_STYLES.open
105
- return (
106
- <a
107
- href={pr.url}
108
- target="_blank"
109
- rel="noreferrer"
110
- className="group block rounded-md border border-border/60 bg-background/60 px-2.5 py-2 transition-colors hover:border-border hover:bg-muted/40"
111
- >
112
- <div className="flex items-center gap-1.5">
113
- <Badge variant="outline" className={cn("h-5 shrink-0 gap-1 px-1.5 text-[10px]", style.className)}>
114
- <StateIcon state={pr.state} />
115
- {style.label}
116
- </Badge>
117
- <span className="shrink-0 font-mono text-[11px] text-muted-foreground">{pr.label}</span>
118
- <ExternalLinkIcon className="ml-auto h-3 w-3 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100" />
119
- </div>
120
- {/* The title is the proposal's own, not the task's: an agent that renamed its work on the
121
- way out is telling the reviewer something, and echoing the task title would hide it. */}
122
- <p className="mt-1.5 line-clamp-2 text-xs leading-snug">{pr.title}</p>
123
- {showRepo && <p className="mt-1 truncate font-mono text-[10px] text-muted-foreground">{repo}</p>}
124
- {(pr.checks || pr.review || pr.comments) && (
125
- <div className="mt-1.5 flex flex-wrap items-center gap-x-2.5 gap-y-1">
126
- <Checks checks={pr.checks} />
127
- <Review review={pr.review} />
128
- {!!pr.comments && (
129
- <Signal icon={<MessageSquareIcon className="h-3 w-3" />} label={String(pr.comments)} tone="waiting" />
130
- )}
131
- </div>
132
- )}
133
- {pr.updatedAt && (
134
- <p className="mt-1.5 text-[10px] text-muted-foreground">Updated {formatRelativeTime(pr.updatedAt)}</p>
135
- )}
136
- </a>
137
- )
138
- }
139
-
140
- /**
141
- * The proposals open for the task's branch, one card per repository that has one. Render it only
142
- * when `data.supported` — the cockpit's details panel does exactly that.
143
- */
144
- export function TaskPullRequest({ data }: { data: TaskPullRequests }) {
145
- const withProposal = data.repos.filter((r) => r.pullRequest)
146
- const failed = data.repos.filter((r) => r.error)
147
-
148
- if (withProposal.length === 0) {
149
- return (
150
- <p className="text-[11px] leading-relaxed text-muted-foreground">
151
- {failed.length > 0
152
- ? failed.map((r) => r.error).join(" · ")
153
- : // Said plainly, because it is the normal state of a task that has not pushed yet —
154
- // not a failure, and not something the reader has to do anything about.
155
- "No pull request for this branch yet."}
156
- </p>
157
- )
158
- }
159
-
160
- return (
161
- <div className="space-y-1.5">
162
- {withProposal.map((row) => (
163
- <PullRequestCard
164
- key={row.repo}
165
- repo={row.repo}
166
- pr={row.pullRequest!}
167
- // Named only when there is more than one — on the single-repository project that most
168
- // are, the repo name is the project's name repeated under every card.
169
- showRepo={data.repos.length > 1}
170
- />
171
- ))}
172
- {failed.map((row) => (
173
- <p key={row.repo} className="text-[10px] text-muted-foreground">
174
- {row.repo}: {row.error}
175
- </p>
176
- ))}
177
- </div>
178
- )
179
- }