@spunto/design-system 0.64.0 → 0.66.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 +1 -1
- package/package.json +1 -1
- package/src/components/tasks/composer.tsx +2 -2
- package/src/components/tasks/index.ts +0 -3
- package/src/components/tasks/machine.tsx +10 -6
- package/src/components/tasks/new-task-composer.tsx +19 -11
- package/src/components/tasks/task-details.tsx +5 -15
- package/src/components/tasks/task-list.tsx +1 -1
- package/src/components/tasks/tasks.test.tsx +11 -4
- package/src/components/tasks/types.ts +0 -21
- package/src/components/tasks/pull-request.tsx +0 -179
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`, `
|
|
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
|
@@ -12,7 +12,7 @@ import type { DraftFile, TaskPendingAction } from "./types"
|
|
|
12
12
|
* Answering a task — the bottom of the cockpit's centre column.
|
|
13
13
|
*
|
|
14
14
|
* What it does is a **new turn, not an interruption**: the harness is resumed with what you wrote,
|
|
15
|
-
*
|
|
15
|
+
* in the same sandbox, on whatever the checkout holds, and its events continue the timeline above. Which is
|
|
16
16
|
* why it only appears while the task is in review — a session that is still talking has no open
|
|
17
17
|
* stdin to interrupt, and a box that pretended otherwise would be the worst kind of lie: one that
|
|
18
18
|
* looks like it worked.
|
|
@@ -250,7 +250,7 @@ export function TaskComposer({
|
|
|
250
250
|
? // Both paths are real and the composer cannot know which one it will take:
|
|
251
251
|
// the session is usually still listening, and is resumed if it has exited.
|
|
252
252
|
"Goes to the live session — or resumes it if it has exited."
|
|
253
|
-
: "Resumes the session with your message — same
|
|
253
|
+
: "Resumes the session with your message — same sandbox, same checkout.")}
|
|
254
254
|
</span>
|
|
255
255
|
{interactive && state === "running" && onInterrupt && (
|
|
256
256
|
<Button
|
|
@@ -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,
|
|
@@ -317,8 +317,9 @@ export function bootSteps({
|
|
|
317
317
|
detail: setup ? phaseLabel(setup) : worker ? "waiting for the container's first report…" : undefined,
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
-
//
|
|
321
|
-
//
|
|
320
|
+
// Tasks from before RFC 0056 only: the platform created the task's branch in every repository
|
|
321
|
+
// before the session started — one recorded command per repo, which is where this reads from.
|
|
322
|
+
// A task since has no such command, and no Branch step: the agent branches, if it wants to.
|
|
322
323
|
const branchCommands = commands.filter((c) => (c.label ?? "").startsWith("Branch setup"))
|
|
323
324
|
const branchState: StepState =
|
|
324
325
|
branchCommands.length === 0
|
|
@@ -336,8 +337,9 @@ export function bootSteps({
|
|
|
336
337
|
commands: branchCommands.length > 0 ? branchCommands : undefined,
|
|
337
338
|
}
|
|
338
339
|
|
|
340
|
+
const legacyBranch = branchCommands.length > 0
|
|
339
341
|
const queued = task.state === "queued"
|
|
340
|
-
const ready = branchState === "done"
|
|
342
|
+
const ready = legacyBranch ? branchState === "done" : setupState === "done"
|
|
341
343
|
const session: TaskBootStep = {
|
|
342
344
|
key: "session",
|
|
343
345
|
label: "Agent session",
|
|
@@ -345,15 +347,17 @@ export function bootSteps({
|
|
|
345
347
|
detail: task.startedAt
|
|
346
348
|
? "started"
|
|
347
349
|
: queued
|
|
348
|
-
?
|
|
350
|
+
? legacyBranch
|
|
351
|
+
? "starts as soon as the branch is ready"
|
|
352
|
+
: "starts as soon as the machine is ready"
|
|
349
353
|
: "never started",
|
|
350
354
|
}
|
|
351
355
|
|
|
352
356
|
// A post-mortem drops the container and setup rows on purpose. Their only source is the
|
|
353
357
|
// machine's state *now* — and a task that is over no longer owns its machine, so those two rows
|
|
354
358
|
// would describe someone else's boot. What is left is recorded: which worker it got, whether
|
|
355
|
-
// its branch commands ran, whether a session ever started.
|
|
356
|
-
const rest = [branch, session]
|
|
359
|
+
// its branch commands ran (an old task), whether a session ever started.
|
|
360
|
+
const rest = legacyBranch ? [branch, session] : [session]
|
|
357
361
|
return queued ? [machine, container, setupStep, ...rest] : [machine, ...rest]
|
|
358
362
|
}
|
|
359
363
|
|
|
@@ -49,6 +49,11 @@ export interface NewTaskComposerProps {
|
|
|
49
49
|
/** Branches common to the project's repositories. Any name typed is accepted too. */
|
|
50
50
|
branches?: string[]
|
|
51
51
|
defaultBranch?: string | null
|
|
52
|
+
/**
|
|
53
|
+
* No Base branch chip: the starting point is decided elsewhere — a snapshot, which is cloned from
|
|
54
|
+
* nothing. The value typed so far is not sent either.
|
|
55
|
+
*/
|
|
56
|
+
hideBaseBranch?: boolean
|
|
52
57
|
modelGroups?: NewTaskModelGroup[]
|
|
53
58
|
/** The project's default model — what the chip says when nobody picked one. */
|
|
54
59
|
defaultModel?: string | null
|
|
@@ -226,6 +231,7 @@ export function NewTaskComposer({
|
|
|
226
231
|
onProjectChange,
|
|
227
232
|
branches = [],
|
|
228
233
|
defaultBranch = null,
|
|
234
|
+
hideBaseBranch = false,
|
|
229
235
|
modelGroups = [],
|
|
230
236
|
defaultModel = null,
|
|
231
237
|
fields = [],
|
|
@@ -281,7 +287,7 @@ export function NewTaskComposer({
|
|
|
281
287
|
onSubmit({
|
|
282
288
|
...(asksProject ? { projectId } : {}),
|
|
283
289
|
prompt: prompt.trim(),
|
|
284
|
-
...(baseBranch.trim() ? { baseBranch: baseBranch.trim() } : {}),
|
|
290
|
+
...(baseBranch.trim() && !hideBaseBranch ? { baseBranch: baseBranch.trim() } : {}),
|
|
285
291
|
...(model.trim() ? { model: model.trim() } : {}),
|
|
286
292
|
files: draft.files,
|
|
287
293
|
...(Object.keys(values).length > 0 ? { fields: values } : {}),
|
|
@@ -320,7 +326,7 @@ export function NewTaskComposer({
|
|
|
320
326
|
<p className="mt-3 text-base font-semibold">What should the agent do?</p>
|
|
321
327
|
<p className="mt-1 text-xs leading-relaxed text-muted-foreground">
|
|
322
328
|
{description ??
|
|
323
|
-
"It gets its own machine
|
|
329
|
+
"It gets its own machine. Its session streams right here as soon as it starts — answer it as it works."}
|
|
324
330
|
</p>
|
|
325
331
|
</div>
|
|
326
332
|
</div>
|
|
@@ -392,15 +398,17 @@ export function NewTaskComposer({
|
|
|
392
398
|
</span>
|
|
393
399
|
))}
|
|
394
400
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
401
|
+
{!hideBaseBranch && (
|
|
402
|
+
<FreeTextChip
|
|
403
|
+
label="Base branch"
|
|
404
|
+
icon={<GitBranchIcon />}
|
|
405
|
+
value={baseBranch}
|
|
406
|
+
onChange={setBaseBranch}
|
|
407
|
+
placeholder={defaultBranch ?? "default branch"}
|
|
408
|
+
groups={[{ id: "branches", items: branches.map((b) => ({ value: b })) }]}
|
|
409
|
+
searchPlaceholder="Start from…"
|
|
410
|
+
/>
|
|
411
|
+
)}
|
|
404
412
|
|
|
405
413
|
<FreeTextChip
|
|
406
414
|
label="Model"
|
|
@@ -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
|
|
4
|
-
//
|
|
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;
|
|
@@ -18,12 +18,11 @@ import { CheckIcon, ChevronRightIcon, CopyIcon, ExternalLinkIcon, GitBranchIcon,
|
|
|
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,
|
|
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.
|
|
@@ -155,7 +152,6 @@ export function TaskDetails({
|
|
|
155
152
|
task,
|
|
156
153
|
variant = "sidebar",
|
|
157
154
|
usage,
|
|
158
|
-
pullRequests,
|
|
159
155
|
shared,
|
|
160
156
|
appTiles,
|
|
161
157
|
appTileSettingsHref,
|
|
@@ -257,14 +253,8 @@ export function TaskDetails({
|
|
|
257
253
|
</Block>
|
|
258
254
|
))}
|
|
259
255
|
|
|
260
|
-
{
|
|
261
|
-
|
|
262
|
-
<TaskPullRequest data={pullRequests} />
|
|
263
|
-
</Block>
|
|
264
|
-
)}
|
|
265
|
-
|
|
266
|
-
{/* Right under the branch's own PR: what the org's apps make of the links the conversation
|
|
267
|
-
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. */}
|
|
268
258
|
{appTiles?.filter((tile) => !tile.session).map((tile) => (
|
|
269
259
|
<Block key={tile.appId} variant={variant} title={tile.title} hint={tile.appName === tile.title ? undefined : tile.appName}>
|
|
270
260
|
<TaskAppTileContent tile={tile} />
|
|
@@ -261,7 +261,7 @@ export function TaskList<T extends TaskItem>({
|
|
|
261
261
|
<div>
|
|
262
262
|
<p className="text-sm font-medium">No tasks yet</p>
|
|
263
263
|
<p className="mt-0.5 text-xs text-muted-foreground">
|
|
264
|
-
Delegate a unit of work — it gets its own
|
|
264
|
+
Delegate a unit of work — it gets its own sandbox and agent session
|
|
265
265
|
</p>
|
|
266
266
|
</div>
|
|
267
267
|
{emptyAction}
|
|
@@ -92,19 +92,26 @@ describe("boot steps", () => {
|
|
|
92
92
|
|
|
93
93
|
it("is looking for a machine while queued without a worker", () => {
|
|
94
94
|
const steps = bootSteps({ task: task({ state: "queued" }), worker: null, commands: [] })
|
|
95
|
-
|
|
95
|
+
// RFC 0056: no Branch step — Spunto creates no branch, the agent does if it wants one.
|
|
96
|
+
expect(steps.map((s) => s.key)).toEqual(["machine", "container", "setup", "session"])
|
|
96
97
|
expect(steps[0].state).toBe("running")
|
|
97
98
|
})
|
|
98
99
|
|
|
100
|
+
it("starts the session step once the machine is set up, with nothing in between", () => {
|
|
101
|
+
const worker = { id: "w1", name: "sbx-1", state: "ready", dockerState: "running", createdAt: "2026-09-20T00:00:00Z" }
|
|
102
|
+
const steps = bootSteps({ task: task({ state: "queued", branch: null }), worker, commands: [] })
|
|
103
|
+
expect(steps.find((s) => s.key === "session")).toMatchObject({ state: "running", detail: "starts as soon as the machine is ready" })
|
|
104
|
+
})
|
|
105
|
+
|
|
99
106
|
it("says the machine was never allocated on a task that died before one", () => {
|
|
100
107
|
const steps = bootSteps({ task: task({ state: "failed" }), worker: null, commands: [] })
|
|
101
108
|
// A post-mortem drops the container/setup rows: the machine is no longer the task's.
|
|
102
|
-
expect(steps.map((s) => s.key)).toEqual(["machine", "
|
|
109
|
+
expect(steps.map((s) => s.key)).toEqual(["machine", "session"])
|
|
103
110
|
expect(steps[0].state).toBe("error")
|
|
104
|
-
expect(steps[
|
|
111
|
+
expect(steps[1].detail).toBe("never started")
|
|
105
112
|
})
|
|
106
113
|
|
|
107
|
-
it("starts the session step once the branch is ready
|
|
114
|
+
it("an older task, branched by the platform: starts the session step once the branch is ready", () => {
|
|
108
115
|
const worker = { id: "w1", name: "pool-1", state: "ready", dockerState: "running", createdAt: "2026-09-20T00:00:00Z" }
|
|
109
116
|
const steps = bootSteps({ task: task({ state: "queued" }), worker, commands: [branchSetup("succeeded")] })
|
|
110
117
|
expect(steps.find((s) => s.key === "machine")?.detail).toBe("recycled from the pool · pool-1")
|
|
@@ -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. */
|
|
@@ -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
|
-
}
|