@shipfox/client-workflows 15.0.0 → 16.0.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/.storybook/preview.css +4 -0
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +21 -0
- package/dist/components/job-detail/job-detail-header.d.ts +8 -1
- package/dist/components/job-detail/job-detail-header.d.ts.map +1 -1
- package/dist/components/job-detail/job-detail-header.js +25 -12
- package/dist/components/job-detail/job-detail-header.js.map +1 -1
- package/dist/components/job-detail/job-detail-view.d.ts.map +1 -1
- package/dist/components/job-detail/job-detail-view.js +17 -2
- package/dist/components/job-detail/job-detail-view.js.map +1 -1
- package/dist/components/workflow-run-summary/workflow-run-summary.js +1 -0
- package/dist/components/workflow-run-summary/workflow-run-summary.js.map +1 -1
- package/dist/components/workflow-run-tabs/index.d.ts +3 -0
- package/dist/components/workflow-run-tabs/index.d.ts.map +1 -1
- package/dist/components/workflow-run-tabs/index.js +3 -0
- package/dist/components/workflow-run-tabs/index.js.map +1 -1
- package/dist/components/workflow-run-tabs/run-annotation-count-chip.d.ts +16 -0
- package/dist/components/workflow-run-tabs/run-annotation-count-chip.d.ts.map +1 -0
- package/dist/components/workflow-run-tabs/run-annotation-count-chip.js +50 -0
- package/dist/components/workflow-run-tabs/run-annotation-count-chip.js.map +1 -0
- package/dist/components/workflow-run-tabs/run-annotation-item.d.ts +20 -0
- package/dist/components/workflow-run-tabs/run-annotation-item.d.ts.map +1 -0
- package/dist/components/workflow-run-tabs/run-annotation-item.js +102 -0
- package/dist/components/workflow-run-tabs/run-annotation-item.js.map +1 -0
- package/dist/components/workflow-run-tabs/run-annotation-list.d.ts +32 -0
- package/dist/components/workflow-run-tabs/run-annotation-list.d.ts.map +1 -0
- package/dist/components/workflow-run-tabs/run-annotation-list.js +202 -0
- package/dist/components/workflow-run-tabs/run-annotation-list.js.map +1 -0
- package/dist/components/workflow-run-tabs/run-annotation-summary-line.d.ts +1 -1
- package/dist/components/workflow-run-tabs/run-annotation-summary-line.d.ts.map +1 -1
- package/dist/components/workflow-run-tabs/run-annotation-summary-line.js +87 -22
- package/dist/components/workflow-run-tabs/run-annotation-summary-line.js.map +1 -1
- package/dist/components/workflow-run-tabs/severity-visuals.d.ts +20 -0
- package/dist/components/workflow-run-tabs/severity-visuals.d.ts.map +1 -0
- package/dist/components/workflow-run-tabs/severity-visuals.js +31 -0
- package/dist/components/workflow-run-tabs/severity-visuals.js.map +1 -0
- package/dist/components/workflow-run-view/run-workspace-nav.d.ts +1 -1
- package/dist/components/workflow-run-view/run-workspace-nav.d.ts.map +1 -1
- package/dist/components/workflow-run-view/run-workspace-nav.js +9 -3
- package/dist/components/workflow-run-view/run-workspace-nav.js.map +1 -1
- package/dist/components/workflow-run-view/workflow-run-view.d.ts +1 -3
- package/dist/components/workflow-run-view/workflow-run-view.d.ts.map +1 -1
- package/dist/components/workflow-run-view/workflow-run-view.js +150 -52
- package/dist/components/workflow-run-view/workflow-run-view.js.map +1 -1
- package/dist/core/run-annotation.d.ts +73 -0
- package/dist/core/run-annotation.d.ts.map +1 -0
- package/dist/core/run-annotation.js +125 -0
- package/dist/core/run-annotation.js.map +1 -0
- package/dist/hooks/api/run-annotation-mapper.d.ts +10 -0
- package/dist/hooks/api/run-annotation-mapper.d.ts.map +1 -0
- package/dist/hooks/api/run-annotation-mapper.js +22 -0
- package/dist/hooks/api/run-annotation-mapper.js.map +1 -0
- package/dist/hooks/api/run-annotations.d.ts +25 -0
- package/dist/hooks/api/run-annotations.d.ts.map +1 -0
- package/dist/hooks/api/run-annotations.js +78 -0
- package/dist/hooks/api/run-annotations.js.map +1 -0
- package/dist/routes/inputs.d.ts +7 -2
- package/dist/routes/inputs.d.ts.map +1 -1
- package/dist/routes/inputs.js +5 -6
- package/dist/routes/inputs.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +10 -9
- package/src/components/job-detail/job-detail-header.test.tsx +3 -0
- package/src/components/job-detail/job-detail-header.tsx +30 -5
- package/src/components/job-detail/job-detail-view.stories.tsx +5 -0
- package/src/components/job-detail/job-detail-view.tsx +18 -1
- package/src/components/workflow-run-summary/workflow-run-summary.tsx +1 -1
- package/src/components/workflow-run-tabs/index.ts +3 -0
- package/src/components/workflow-run-tabs/run-annotation-count-chip.tsx +63 -0
- package/src/components/workflow-run-tabs/run-annotation-item.tsx +123 -0
- package/src/components/workflow-run-tabs/run-annotation-list.tsx +258 -0
- package/src/components/workflow-run-tabs/run-annotation-summary-line.test.tsx +77 -3
- package/src/components/workflow-run-tabs/run-annotation-summary-line.tsx +92 -17
- package/src/components/workflow-run-tabs/run-annotations.stories.tsx +293 -0
- package/src/components/workflow-run-tabs/severity-visuals.ts +37 -0
- package/src/components/workflow-run-view/run-workspace-nav.test.tsx +44 -0
- package/src/components/workflow-run-view/run-workspace-nav.tsx +15 -2
- package/src/components/workflow-run-view/workflow-run-view.test.tsx +246 -20
- package/src/components/workflow-run-view/workflow-run-view.tsx +148 -30
- package/src/core/run-annotation.test.ts +315 -0
- package/src/core/run-annotation.ts +238 -0
- package/src/hooks/api/run-annotation-mapper.ts +30 -0
- package/src/hooks/api/run-annotations.ts +137 -0
- package/src/pages/workflow-job-detail-page.test.tsx +66 -0
- package/src/routes/inputs.ts +7 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/core/workflow-run-tabs.d.ts +0 -9
- package/dist/core/workflow-run-tabs.d.ts.map +0 -1
- package/dist/core/workflow-run-tabs.js +0 -3
- package/dist/core/workflow-run-tabs.js.map +0 -1
- package/src/core/workflow-run-tabs.ts +0 -8
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shipfox/client-workflows",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "16.0.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/ShipfoxHQ/shipfox.git",
|
|
@@ -27,15 +27,16 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@swc/helpers": "^0.5.17",
|
|
29
29
|
"date-fns": "^4.1.0",
|
|
30
|
-
"@shipfox/
|
|
31
|
-
"@shipfox/api-
|
|
30
|
+
"@shipfox/annotations-dto": "12.0.0",
|
|
31
|
+
"@shipfox/api-definitions-dto": "12.2.0",
|
|
32
|
+
"@shipfox/api-workflows-dto": "12.2.0",
|
|
33
|
+
"@shipfox/client-logs": "16.0.0",
|
|
32
34
|
"@shipfox/client-api": "6.0.1",
|
|
33
|
-
"@shipfox/client-
|
|
34
|
-
"@shipfox/
|
|
35
|
-
"@shipfox/client-
|
|
36
|
-
"@shipfox/client-triggers": "
|
|
37
|
-
"@shipfox/client-
|
|
38
|
-
"@shipfox/react-ui": "1.0.0"
|
|
35
|
+
"@shipfox/client-shell": "16.0.0",
|
|
36
|
+
"@shipfox/react-ui": "1.1.0",
|
|
37
|
+
"@shipfox/client-ui": "16.0.0",
|
|
38
|
+
"@shipfox/client-triggers": "16.0.0",
|
|
39
|
+
"@shipfox/client-projects": "16.0.0"
|
|
39
40
|
},
|
|
40
41
|
"peerDependencies": {
|
|
41
42
|
"@tanstack/react-query": "^5.101.0",
|
|
@@ -4,6 +4,7 @@ import {Code, Text} from '@shipfox/react-ui/typography';
|
|
|
4
4
|
import {formatTimestamp} from '@shipfox/react-ui/utils';
|
|
5
5
|
import {getWorkflowStatusVisual} from '#components/workflow-status/status-visuals.js';
|
|
6
6
|
import {WorkflowStatusIcon} from '#components/workflow-status/workflow-status-icon.js';
|
|
7
|
+
import type {RunAnnotationSummary} from '#core/run-annotation.js';
|
|
7
8
|
import {
|
|
8
9
|
defaultJobExecution,
|
|
9
10
|
deriveJobDisplayStatus,
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
type Job,
|
|
12
13
|
type JobExecution,
|
|
13
14
|
} from '#core/workflow-run.js';
|
|
15
|
+
import {RunAnnotationCountChip} from '../workflow-run-tabs/index.js';
|
|
14
16
|
import {JobExecutionSwitcher} from './job-execution-switcher.js';
|
|
15
17
|
import {JobExecutionTimeText} from './job-execution-time-text.js';
|
|
16
18
|
|
|
@@ -18,12 +20,23 @@ export interface JobDetailHeaderProps {
|
|
|
18
20
|
job: Job;
|
|
19
21
|
selectedJobExecution: JobExecution | undefined;
|
|
20
22
|
onSelectedJobExecutionChange: (jobExecutionId: string) => void;
|
|
23
|
+
workspaceSlug: string;
|
|
24
|
+
projectSlug: string;
|
|
25
|
+
workflowRunId: string;
|
|
26
|
+
runAttempt?: number | undefined;
|
|
27
|
+
/** Counts for this job only. Renders a link into the run's Annotations section, never a body. */
|
|
28
|
+
annotationSummary?: RunAnnotationSummary | undefined;
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
export function JobDetailHeader({
|
|
24
32
|
job,
|
|
25
33
|
selectedJobExecution,
|
|
26
34
|
onSelectedJobExecutionChange,
|
|
35
|
+
workspaceSlug,
|
|
36
|
+
projectSlug,
|
|
37
|
+
workflowRunId,
|
|
38
|
+
runAttempt,
|
|
39
|
+
annotationSummary,
|
|
27
40
|
}: JobDetailHeaderProps) {
|
|
28
41
|
const selectedStatus = selectedExecutionStatus(job, selectedJobExecution);
|
|
29
42
|
const jobStatus = getWorkflowStatusVisual(selectedStatus);
|
|
@@ -39,7 +52,7 @@ export function JobDetailHeader({
|
|
|
39
52
|
ariaLabel={`Job status: ${jobStatus.label}`}
|
|
40
53
|
/>
|
|
41
54
|
<Code
|
|
42
|
-
as="
|
|
55
|
+
as="h2"
|
|
43
56
|
variant="paragraph"
|
|
44
57
|
bold
|
|
45
58
|
tabIndex={-1}
|
|
@@ -50,9 +63,9 @@ export function JobDetailHeader({
|
|
|
50
63
|
</Code>
|
|
51
64
|
</div>
|
|
52
65
|
|
|
53
|
-
{selectedJobExecution ? (
|
|
66
|
+
{selectedJobExecution || annotationSummary?.total ? (
|
|
54
67
|
<div className="flex min-w-0 flex-wrap items-center gap-10 text-foreground-neutral-muted">
|
|
55
|
-
{job.executionCountVisible ? (
|
|
68
|
+
{selectedJobExecution && job.executionCountVisible ? (
|
|
56
69
|
<JobExecutionSwitcher
|
|
57
70
|
job={job}
|
|
58
71
|
selectedJobExecution={selectedJobExecution.id}
|
|
@@ -60,8 +73,20 @@ export function JobDetailHeader({
|
|
|
60
73
|
variant="title"
|
|
61
74
|
/>
|
|
62
75
|
) : null}
|
|
63
|
-
|
|
64
|
-
|
|
76
|
+
{selectedJobExecution ? (
|
|
77
|
+
<>
|
|
78
|
+
<JobDurationMeta execution={selectedJobExecution} kind="queue" />
|
|
79
|
+
<JobDurationMeta execution={selectedJobExecution} kind="run" />
|
|
80
|
+
</>
|
|
81
|
+
) : null}
|
|
82
|
+
<RunAnnotationCountChip
|
|
83
|
+
summary={annotationSummary}
|
|
84
|
+
workspaceSlug={workspaceSlug}
|
|
85
|
+
projectSlug={projectSlug}
|
|
86
|
+
workflowRunId={workflowRunId}
|
|
87
|
+
runAttempt={runAttempt}
|
|
88
|
+
jobId={job.id}
|
|
89
|
+
/>
|
|
65
90
|
</div>
|
|
66
91
|
) : null}
|
|
67
92
|
</div>
|
|
@@ -7,6 +7,7 @@ import type {Meta, StoryObj} from '@storybook/react';
|
|
|
7
7
|
import {QueryClient, QueryClientProvider} from '@tanstack/react-query';
|
|
8
8
|
import {type ReactNode, useState} from 'react';
|
|
9
9
|
import type {Job, JobExecution, WorkflowRunDetail} from '#core/workflow-run.js';
|
|
10
|
+
import {runAnnotationsQueryKeys} from '#hooks/api/run-annotations.js';
|
|
10
11
|
import type {useWorkflowRunAttemptQuery} from '#hooks/api/workflow-runs.js';
|
|
11
12
|
import {
|
|
12
13
|
workflowJob,
|
|
@@ -170,6 +171,10 @@ function StoryQueryProvider({
|
|
|
170
171
|
defaultOptions: {queries: {staleTime: Number.POSITIVE_INFINITY}},
|
|
171
172
|
});
|
|
172
173
|
if (run) {
|
|
174
|
+
client.setQueryData(runAnnotationsQueryKeys.list(run.id, run.runAttempt.attempt), {
|
|
175
|
+
pages: [{annotations: [], hasMore: false, nextCursor: null}],
|
|
176
|
+
pageParams: [undefined],
|
|
177
|
+
});
|
|
173
178
|
for (const job of run.jobs) {
|
|
174
179
|
for (const execution of job.jobExecutions) {
|
|
175
180
|
for (const step of execution.steps) {
|
|
@@ -10,7 +10,9 @@ import {TimeTickerProvider} from '@shipfox/react-ui/time-ticker';
|
|
|
10
10
|
import {Text} from '@shipfox/react-ui/typography';
|
|
11
11
|
import {Link} from '@tanstack/react-router';
|
|
12
12
|
import {type RefObject, useEffect, useRef} from 'react';
|
|
13
|
+
import {summarizeJobAnnotations} from '#core/run-annotation.js';
|
|
13
14
|
import type {Job, JobExecution} from '#core/workflow-run.js';
|
|
15
|
+
import {useRunAnnotationsQuery} from '#hooks/api/run-annotations.js';
|
|
14
16
|
import type {useWorkflowRunAttemptQuery} from '#hooks/api/workflow-runs.js';
|
|
15
17
|
import {
|
|
16
18
|
type WorkflowJobSearch,
|
|
@@ -66,6 +68,16 @@ export function JobDetailView({
|
|
|
66
68
|
const pageScrollRef = useRef<HTMLDivElement>(null);
|
|
67
69
|
const landingSelectionRef = useRef<FrozenLandingSelection | undefined>(undefined);
|
|
68
70
|
const hasLoadedData = query.data !== undefined;
|
|
71
|
+
// Same query key as the run workspace, so this reads the cache instead of fetching again.
|
|
72
|
+
const annotations = useRunAnnotationsQuery({
|
|
73
|
+
workflowRunId,
|
|
74
|
+
runAttempt: query.data?.runAttempt.attempt,
|
|
75
|
+
});
|
|
76
|
+
const jobAnnotationSummary = annotations.annotations
|
|
77
|
+
? summarizeJobAnnotations(annotations.annotations, jobId, {
|
|
78
|
+
truncated: annotations.summary?.truncated ?? false,
|
|
79
|
+
})
|
|
80
|
+
: undefined;
|
|
69
81
|
|
|
70
82
|
useEffect(() => {
|
|
71
83
|
if (!jobId || !hasLoadedData) return;
|
|
@@ -206,8 +218,13 @@ export function JobDetailView({
|
|
|
206
218
|
job={job}
|
|
207
219
|
selectedJobExecution={selectedJobExecution}
|
|
208
220
|
onSelectedJobExecutionChange={selectExecution}
|
|
221
|
+
workspaceSlug={workspaceSlug}
|
|
222
|
+
projectSlug={projectSlug}
|
|
223
|
+
workflowRunId={workflowRunId}
|
|
224
|
+
runAttempt={run.runAttempt.attempt}
|
|
225
|
+
annotationSummary={jobAnnotationSummary}
|
|
209
226
|
/>
|
|
210
|
-
<Text as="
|
|
227
|
+
<Text as="h3" className="sr-only">
|
|
211
228
|
Logs
|
|
212
229
|
</Text>
|
|
213
230
|
{selectedJobExecution ? (
|
|
@@ -89,7 +89,7 @@ export function WorkflowRunSummary({
|
|
|
89
89
|
|
|
90
90
|
<Tooltip>
|
|
91
91
|
<TooltipTrigger asChild>
|
|
92
|
-
<Header id={headingId} variant="h3" className="min-w-0 truncate">
|
|
92
|
+
<Header as="h1" id={headingId} variant="h3" className="min-w-0 truncate">
|
|
93
93
|
<span ref={headingTextRef} className="block min-w-0 truncate">
|
|
94
94
|
{run.name}
|
|
95
95
|
</span>
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
export {RunAnnotationCountChip} from './run-annotation-count-chip.js';
|
|
2
|
+
export {annotationElementId, RunAnnotationItem} from './run-annotation-item.js';
|
|
3
|
+
export {RunAnnotationList, type RunAnnotationListQuery} from './run-annotation-list.js';
|
|
1
4
|
export {RunAnnotationSummaryLine} from './run-annotation-summary-line.js';
|
|
2
5
|
export {RunAnnotationsEmpty} from './run-annotations-empty.js';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {Icon} from '@shipfox/react-ui/icon';
|
|
2
|
+
import {cn} from '@shipfox/react-ui/utils';
|
|
3
|
+
import {Link} from '@tanstack/react-router';
|
|
4
|
+
import {highestRunAnnotationSeverity, type RunAnnotationSummary} from '#core/run-annotation.js';
|
|
5
|
+
import {type WorkflowRunsSearch, workflowRunSearchParams} from '#routes/inputs.js';
|
|
6
|
+
import {SEVERITY_CHIP_TONE, SEVERITY_ICON} from './severity-visuals.js';
|
|
7
|
+
|
|
8
|
+
export interface RunAnnotationCountChipProps {
|
|
9
|
+
summary: RunAnnotationSummary | undefined;
|
|
10
|
+
workspaceSlug: string;
|
|
11
|
+
projectSlug: string;
|
|
12
|
+
workflowRunId: string;
|
|
13
|
+
runAttempt?: number | undefined;
|
|
14
|
+
/** Scopes the destination list to one job. */
|
|
15
|
+
jobId?: string | undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A bounded reference into the run's Annotations section: a count, its highest severity, and one
|
|
20
|
+
* link. Never a body, so an annotation is rendered exactly once per page.
|
|
21
|
+
*/
|
|
22
|
+
export function RunAnnotationCountChip({
|
|
23
|
+
summary,
|
|
24
|
+
workspaceSlug,
|
|
25
|
+
projectSlug,
|
|
26
|
+
workflowRunId,
|
|
27
|
+
runAttempt,
|
|
28
|
+
jobId,
|
|
29
|
+
}: RunAnnotationCountChipProps) {
|
|
30
|
+
if (!summary || summary.total === 0) return null;
|
|
31
|
+
|
|
32
|
+
const severity = highestRunAnnotationSeverity(summary);
|
|
33
|
+
const count = `${summary.total}${summary.truncated ? '+' : ''}`;
|
|
34
|
+
const label = `${count} ${summary.total === 1 && !summary.truncated ? 'annotation' : 'annotations'}`;
|
|
35
|
+
const accessibleLabel = severity
|
|
36
|
+
? `View ${label}, highest severity ${severity}`
|
|
37
|
+
: `View ${label}`;
|
|
38
|
+
const search: WorkflowRunsSearch = {tab: 'annotations', ...(runAttempt ? {runAttempt} : {})};
|
|
39
|
+
if (jobId) search.jobId = jobId;
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Link
|
|
43
|
+
to="/w/$workspaceSlug/p/$projectSlug/runs/$workflowRunId"
|
|
44
|
+
params={{workspaceSlug, projectSlug, workflowRunId}}
|
|
45
|
+
search={workflowRunSearchParams(search, search) as never}
|
|
46
|
+
aria-label={accessibleLabel}
|
|
47
|
+
className={cn(
|
|
48
|
+
'inline-flex h-20 shrink-0 items-center gap-4 rounded-4 border px-6 font-code text-xs leading-16 tabular-nums outline-none transition-colors hover:bg-background-neutral-hover focus-visible:shadow-border-interactive-with-active',
|
|
49
|
+
// The chip stays 20px optically so it sits level with the duration metadata beside it;
|
|
50
|
+
// the hit area grows to the 44px minimum only where the pointer is coarse.
|
|
51
|
+
'[@media(pointer:coarse)]:h-44 [@media(pointer:coarse)]:px-10',
|
|
52
|
+
severity ? SEVERITY_CHIP_TONE[severity] : 'border-border-neutral-base',
|
|
53
|
+
)}
|
|
54
|
+
>
|
|
55
|
+
<Icon
|
|
56
|
+
name={severity ? SEVERITY_ICON[severity] : 'fileTextLine'}
|
|
57
|
+
size={12}
|
|
58
|
+
aria-hidden="true"
|
|
59
|
+
/>
|
|
60
|
+
<span className="text-foreground-neutral-base">{count}</span>
|
|
61
|
+
</Link>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {AnnotationCard} from '@shipfox/client-ui';
|
|
2
|
+
import {Button} from '@shipfox/react-ui/button';
|
|
3
|
+
import {Icon} from '@shipfox/react-ui/icon';
|
|
4
|
+
import {Text} from '@shipfox/react-ui/typography';
|
|
5
|
+
import {cn} from '@shipfox/react-ui/utils';
|
|
6
|
+
import {Link} from '@tanstack/react-router';
|
|
7
|
+
import {useEffect, useRef} from 'react';
|
|
8
|
+
import type {RunAnnotationEntry} from '#core/run-annotation.js';
|
|
9
|
+
import {workflowJobSearchParams} from '#routes/inputs.js';
|
|
10
|
+
|
|
11
|
+
export interface RunAnnotationItemProps {
|
|
12
|
+
entry: RunAnnotationEntry;
|
|
13
|
+
workspaceSlug?: string | undefined;
|
|
14
|
+
projectSlug?: string | undefined;
|
|
15
|
+
workflowRunId: string;
|
|
16
|
+
runAttempt?: number | undefined;
|
|
17
|
+
/** Deep-link target from `?annotation=`, which takes focus rather than only being scrolled to. */
|
|
18
|
+
selected?: boolean | undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* One annotation, and the only place in the product that renders an annotation body.
|
|
23
|
+
*
|
|
24
|
+
* The title is the annotation's `context`, which is what the emitting step named the block.
|
|
25
|
+
* Everything below it exists so a reader can get from a diagnostic back to its cause.
|
|
26
|
+
*/
|
|
27
|
+
export function RunAnnotationItem({
|
|
28
|
+
entry,
|
|
29
|
+
workspaceSlug,
|
|
30
|
+
projectSlug,
|
|
31
|
+
workflowRunId,
|
|
32
|
+
runAttempt,
|
|
33
|
+
selected = false,
|
|
34
|
+
}: RunAnnotationItemProps) {
|
|
35
|
+
const {annotation, origin} = entry;
|
|
36
|
+
const canLink = Boolean(origin && workspaceSlug && projectSlug);
|
|
37
|
+
const itemRef = useRef<HTMLLIElement>(null);
|
|
38
|
+
const focusedRef = useRef(false);
|
|
39
|
+
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!selected) {
|
|
42
|
+
focusedRef.current = false;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (focusedRef.current) return;
|
|
46
|
+
|
|
47
|
+
// A deep link that only scrolls leaves a keyboard or screen-reader user at the document
|
|
48
|
+
// start while the page moves under them.
|
|
49
|
+
focusedRef.current = true;
|
|
50
|
+
itemRef.current?.focus({preventScroll: true});
|
|
51
|
+
itemRef.current?.scrollIntoView({block: 'nearest'});
|
|
52
|
+
}, [selected]);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<li
|
|
56
|
+
ref={itemRef}
|
|
57
|
+
tabIndex={-1}
|
|
58
|
+
aria-current={selected ? 'true' : undefined}
|
|
59
|
+
className={cn(
|
|
60
|
+
'rounded-8 outline-none focus-visible:shadow-border-interactive-with-active',
|
|
61
|
+
selected && 'shadow-border-interactive-with-active',
|
|
62
|
+
)}
|
|
63
|
+
>
|
|
64
|
+
<AnnotationCard
|
|
65
|
+
id={annotationElementId(annotation.id)}
|
|
66
|
+
style={annotation.style}
|
|
67
|
+
title={annotation.context}
|
|
68
|
+
titleAs="h3"
|
|
69
|
+
provenance={<RunAnnotationProvenance entry={entry} />}
|
|
70
|
+
body={annotation.body}
|
|
71
|
+
action={
|
|
72
|
+
canLink && origin ? (
|
|
73
|
+
<Button
|
|
74
|
+
asChild
|
|
75
|
+
size="xs"
|
|
76
|
+
variant="transparent"
|
|
77
|
+
className="[@media(pointer:coarse)]:min-h-44"
|
|
78
|
+
>
|
|
79
|
+
<Link
|
|
80
|
+
to="/w/$workspaceSlug/p/$projectSlug/runs/$workflowRunId/jobs/$jobId"
|
|
81
|
+
params={{
|
|
82
|
+
workspaceSlug: workspaceSlug ?? '',
|
|
83
|
+
projectSlug: projectSlug ?? '',
|
|
84
|
+
workflowRunId,
|
|
85
|
+
jobId: origin.jobId,
|
|
86
|
+
}}
|
|
87
|
+
search={
|
|
88
|
+
workflowJobSearchParams({
|
|
89
|
+
jobExecutionId: origin.jobExecutionId,
|
|
90
|
+
stepId: origin.stepId,
|
|
91
|
+
stepAttemptId: origin.stepAttemptId,
|
|
92
|
+
runAttempt,
|
|
93
|
+
}) as never
|
|
94
|
+
}
|
|
95
|
+
>
|
|
96
|
+
Open step
|
|
97
|
+
<Icon name="arrowRightLine" size={12} aria-hidden="true" />
|
|
98
|
+
</Link>
|
|
99
|
+
</Button>
|
|
100
|
+
) : null
|
|
101
|
+
}
|
|
102
|
+
/>
|
|
103
|
+
</li>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** `job · execution #2 · run tests · attempt 1`, dropping any part the run no longer resolves. */
|
|
108
|
+
function RunAnnotationProvenance({entry}: {entry: RunAnnotationEntry}) {
|
|
109
|
+
const parts = [entry.jobName, entry.executionLabel, entry.stepLabel, entry.attemptLabel].filter(
|
|
110
|
+
(part): part is string => Boolean(part),
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<Text as="p" size="xs" className="min-w-0 break-words font-code text-foreground-neutral-subtle">
|
|
115
|
+
{parts.join(' · ')}
|
|
116
|
+
</Text>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Stable element id so `?annotation=<id>` can scroll to and highlight one annotation. */
|
|
121
|
+
export function annotationElementId(annotationId: string): string {
|
|
122
|
+
return `run-annotation-${annotationId}`;
|
|
123
|
+
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import {QueryLoadError, type QueryLoadErrorQuery} from '@shipfox/client-ui';
|
|
2
|
+
import {Button} from '@shipfox/react-ui/button';
|
|
3
|
+
import {Callout} from '@shipfox/react-ui/callout';
|
|
4
|
+
import {EmptyState} from '@shipfox/react-ui/empty-state';
|
|
5
|
+
import {Skeleton} from '@shipfox/react-ui/skeleton';
|
|
6
|
+
import {Text} from '@shipfox/react-ui/typography';
|
|
7
|
+
import {useState} from 'react';
|
|
8
|
+
import type {RunAnnotationEntry} from '#core/run-annotation.js';
|
|
9
|
+
import {RunAnnotationItem} from './run-annotation-item.js';
|
|
10
|
+
import {RunAnnotationsEmpty} from './run-annotations-empty.js';
|
|
11
|
+
|
|
12
|
+
export interface RunAnnotationListQuery extends QueryLoadErrorQuery {
|
|
13
|
+
isPending: boolean;
|
|
14
|
+
hasNextPage: boolean;
|
|
15
|
+
isFetchingNextPage: boolean;
|
|
16
|
+
fetchNextPage: () => unknown;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface RunAnnotationListProps {
|
|
20
|
+
query: RunAnnotationListQuery;
|
|
21
|
+
entries: RunAnnotationEntry[] | undefined;
|
|
22
|
+
workflowRunId: string;
|
|
23
|
+
workspaceSlug?: string | undefined;
|
|
24
|
+
projectSlug?: string | undefined;
|
|
25
|
+
runAttempt?: number | undefined;
|
|
26
|
+
/** Name of the job the list is filtered to, used only for empty-state copy. */
|
|
27
|
+
filteredJobName?: string | undefined;
|
|
28
|
+
/** Active severity filter, named in the empty state so the reader knows what to clear. */
|
|
29
|
+
filteredSeverity?: string | undefined;
|
|
30
|
+
filtered: boolean;
|
|
31
|
+
onClearFilters?: (() => void) | undefined;
|
|
32
|
+
/** Annotation id from `?annotation=`, which the matching card scrolls to and focuses. */
|
|
33
|
+
selectedAnnotationId?: string | undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* How many annotations render at once.
|
|
38
|
+
*
|
|
39
|
+
* A page holds up to 500 rows and each one mounts a Markdown pipeline, so the fetch budget is
|
|
40
|
+
* not a render budget. The window grows on demand and the server page only loads once the
|
|
41
|
+
* reader has actually seen everything already fetched.
|
|
42
|
+
*/
|
|
43
|
+
const RENDER_WINDOW = 25;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The annotations list.
|
|
47
|
+
*
|
|
48
|
+
* Loading, empty, error, and stale are four distinct renderings on purpose: coalescing a failed
|
|
49
|
+
* fetch into an empty result tells a reader their run is clean when the truth is unknown.
|
|
50
|
+
*/
|
|
51
|
+
export function RunAnnotationList({
|
|
52
|
+
query,
|
|
53
|
+
entries,
|
|
54
|
+
workflowRunId,
|
|
55
|
+
workspaceSlug,
|
|
56
|
+
projectSlug,
|
|
57
|
+
runAttempt,
|
|
58
|
+
filteredJobName,
|
|
59
|
+
filteredSeverity,
|
|
60
|
+
filtered,
|
|
61
|
+
onClearFilters,
|
|
62
|
+
selectedAnnotationId,
|
|
63
|
+
}: RunAnnotationListProps) {
|
|
64
|
+
const [visibleCount, setVisibleCount] = useState(RENDER_WINDOW);
|
|
65
|
+
|
|
66
|
+
// A deep-linked annotation past the window would otherwise be unreachable: it is in the data,
|
|
67
|
+
// absent from the DOM, and nothing on screen says so.
|
|
68
|
+
const selectedIndex = selectedAnnotationId
|
|
69
|
+
? (entries?.findIndex((entry) => entry.annotation.id === selectedAnnotationId) ?? -1)
|
|
70
|
+
: -1;
|
|
71
|
+
const renderCount = Math.max(visibleCount, selectedIndex + 1);
|
|
72
|
+
|
|
73
|
+
if (query.isPending) return <RunAnnotationListSkeleton />;
|
|
74
|
+
|
|
75
|
+
if (query.isError && entries === undefined) {
|
|
76
|
+
return <QueryLoadError query={query} subject="annotations" icon="fileDamageLine" />;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (entries === undefined) return <RunAnnotationListSkeleton />;
|
|
80
|
+
|
|
81
|
+
const visible = entries.slice(0, renderCount);
|
|
82
|
+
const hiddenCount = entries.length - visible.length;
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<div className="flex min-w-0 flex-col gap-12">
|
|
86
|
+
{query.isError ? <RunAnnotationStaleError query={query} /> : null}
|
|
87
|
+
|
|
88
|
+
{entries.length === 0 ? (
|
|
89
|
+
filtered ? (
|
|
90
|
+
<RunAnnotationsFilteredEmpty
|
|
91
|
+
jobName={filteredJobName}
|
|
92
|
+
severity={filteredSeverity}
|
|
93
|
+
incomplete={query.hasNextPage}
|
|
94
|
+
onClearFilters={onClearFilters}
|
|
95
|
+
/>
|
|
96
|
+
) : (
|
|
97
|
+
<RunAnnotationsEmpty />
|
|
98
|
+
)
|
|
99
|
+
) : (
|
|
100
|
+
<ol className="flex min-w-0 flex-col gap-12">
|
|
101
|
+
{visible.map((entry) => (
|
|
102
|
+
<RunAnnotationItem
|
|
103
|
+
key={entry.annotation.id}
|
|
104
|
+
entry={entry}
|
|
105
|
+
workspaceSlug={workspaceSlug}
|
|
106
|
+
projectSlug={projectSlug}
|
|
107
|
+
workflowRunId={workflowRunId}
|
|
108
|
+
runAttempt={runAttempt}
|
|
109
|
+
selected={entry.annotation.id === selectedAnnotationId}
|
|
110
|
+
/>
|
|
111
|
+
))}
|
|
112
|
+
</ol>
|
|
113
|
+
)}
|
|
114
|
+
|
|
115
|
+
{hiddenCount > 0 ? (
|
|
116
|
+
<Button
|
|
117
|
+
type="button"
|
|
118
|
+
size="sm"
|
|
119
|
+
variant="secondary"
|
|
120
|
+
className="self-start [@media(pointer:coarse)]:min-h-44"
|
|
121
|
+
onClick={() => setVisibleCount((current) => current + RENDER_WINDOW)}
|
|
122
|
+
>
|
|
123
|
+
Show {Math.min(hiddenCount, RENDER_WINDOW)} more of {entries.length}
|
|
124
|
+
</Button>
|
|
125
|
+
) : query.hasNextPage ? (
|
|
126
|
+
<Button
|
|
127
|
+
type="button"
|
|
128
|
+
size="sm"
|
|
129
|
+
variant="secondary"
|
|
130
|
+
className="self-start [@media(pointer:coarse)]:min-h-44"
|
|
131
|
+
isLoading={query.isFetchingNextPage}
|
|
132
|
+
onClick={() => {
|
|
133
|
+
void query.fetchNextPage();
|
|
134
|
+
}}
|
|
135
|
+
>
|
|
136
|
+
Load more annotations
|
|
137
|
+
</Button>
|
|
138
|
+
) : null}
|
|
139
|
+
</div>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Names the filters that are actually active.
|
|
145
|
+
*
|
|
146
|
+
* Blaming severity for a job-only filter sends the reader to change the wrong control, which
|
|
147
|
+
* is worse than saying nothing.
|
|
148
|
+
*/
|
|
149
|
+
function filteredEmptyDescription({
|
|
150
|
+
jobName,
|
|
151
|
+
severity,
|
|
152
|
+
incomplete,
|
|
153
|
+
}: {
|
|
154
|
+
jobName: string | undefined;
|
|
155
|
+
severity: string | undefined;
|
|
156
|
+
incomplete: boolean;
|
|
157
|
+
}): string {
|
|
158
|
+
if (incomplete) {
|
|
159
|
+
if (jobName && severity) {
|
|
160
|
+
return `None of the loaded annotations are from ${jobName} at ${severity} severity. Load more annotations to continue searching.`;
|
|
161
|
+
}
|
|
162
|
+
if (jobName) {
|
|
163
|
+
return `None of the loaded annotations are from ${jobName}. Load more annotations to continue searching.`;
|
|
164
|
+
}
|
|
165
|
+
if (severity) {
|
|
166
|
+
return `None of the loaded annotations are at ${severity} severity. Load more annotations to continue searching.`;
|
|
167
|
+
}
|
|
168
|
+
return 'None of the loaded annotations match the current filters. Load more annotations to continue searching.';
|
|
169
|
+
}
|
|
170
|
+
if (jobName && severity) {
|
|
171
|
+
return `This run has annotations, but none from ${jobName} at ${severity} severity.`;
|
|
172
|
+
}
|
|
173
|
+
if (jobName) return `This run has annotations, but none from ${jobName}.`;
|
|
174
|
+
if (severity) return `This run has annotations, but none at ${severity} severity.`;
|
|
175
|
+
return 'This run has annotations, but none match the current filters.';
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function RunAnnotationsFilteredEmpty({
|
|
179
|
+
jobName,
|
|
180
|
+
severity,
|
|
181
|
+
incomplete,
|
|
182
|
+
onClearFilters,
|
|
183
|
+
}: {
|
|
184
|
+
jobName: string | undefined;
|
|
185
|
+
severity: string | undefined;
|
|
186
|
+
incomplete: boolean;
|
|
187
|
+
onClearFilters: (() => void) | undefined;
|
|
188
|
+
}) {
|
|
189
|
+
return (
|
|
190
|
+
<div className="flex flex-col items-center gap-12">
|
|
191
|
+
<EmptyState
|
|
192
|
+
icon="fileDamageLine"
|
|
193
|
+
title={incomplete ? 'No matches in loaded annotations' : 'No matching annotations'}
|
|
194
|
+
description={filteredEmptyDescription({jobName, severity, incomplete})}
|
|
195
|
+
/>
|
|
196
|
+
{onClearFilters ? (
|
|
197
|
+
<Button
|
|
198
|
+
type="button"
|
|
199
|
+
size="sm"
|
|
200
|
+
variant="secondary"
|
|
201
|
+
className="[@media(pointer:coarse)]:min-h-44"
|
|
202
|
+
onClick={onClearFilters}
|
|
203
|
+
>
|
|
204
|
+
Clear filters
|
|
205
|
+
</Button>
|
|
206
|
+
) : null}
|
|
207
|
+
</div>
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* A failed poll keeps the annotations already on screen and marks them stale rather than
|
|
213
|
+
* clearing. Polite rather than assertive: the poll runs every 4s and a flapping API would
|
|
214
|
+
* otherwise interrupt a screen reader on every cycle.
|
|
215
|
+
*/
|
|
216
|
+
function RunAnnotationStaleError({query}: {query: QueryLoadErrorQuery}) {
|
|
217
|
+
return (
|
|
218
|
+
<Callout role="status" aria-live="polite" type="error">
|
|
219
|
+
<div className="flex w-full items-center justify-between gap-8">
|
|
220
|
+
<Text size="xs">Could not refresh annotations.</Text>
|
|
221
|
+
<Button
|
|
222
|
+
type="button"
|
|
223
|
+
size="2xs"
|
|
224
|
+
variant="secondary"
|
|
225
|
+
className="[@media(pointer:coarse)]:min-h-44"
|
|
226
|
+
isLoading={query.isFetching}
|
|
227
|
+
onClick={() => {
|
|
228
|
+
void query.refetch();
|
|
229
|
+
}}
|
|
230
|
+
>
|
|
231
|
+
Retry
|
|
232
|
+
</Button>
|
|
233
|
+
</div>
|
|
234
|
+
</Callout>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const ANNOTATION_SKELETON_ROWS = ['first', 'second', 'third'];
|
|
239
|
+
|
|
240
|
+
function RunAnnotationListSkeleton() {
|
|
241
|
+
return (
|
|
242
|
+
<section aria-label="Loading annotations" className="flex flex-col gap-12">
|
|
243
|
+
{ANNOTATION_SKELETON_ROWS.map((row) => (
|
|
244
|
+
<div
|
|
245
|
+
key={row}
|
|
246
|
+
className="flex gap-12 rounded-8 border border-border-neutral-base bg-background-components-base px-12 py-8"
|
|
247
|
+
>
|
|
248
|
+
<Skeleton className="h-40 w-4 rounded-full" />
|
|
249
|
+
<div className="flex min-w-0 flex-1 flex-col gap-6">
|
|
250
|
+
<Skeleton className="h-20 w-160 rounded-4" />
|
|
251
|
+
<Skeleton className="h-16 w-240 rounded-4" />
|
|
252
|
+
<Skeleton className="h-40 w-full rounded-4" />
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
255
|
+
))}
|
|
256
|
+
</section>
|
|
257
|
+
);
|
|
258
|
+
}
|