@shipfox/client-workflows 14.0.0 → 15.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.
Files changed (223) hide show
  1. package/.storybook/preview.tsx +7 -2
  2. package/.turbo/turbo-build.log +1 -1
  3. package/CHANGELOG.md +35 -0
  4. package/dist/components/job-detail/agent-config-failure-callout.d.ts.map +1 -0
  5. package/dist/components/{workflow-run-view → job-detail}/agent-config-failure-callout.js +2 -2
  6. package/dist/components/job-detail/agent-config-failure-callout.js.map +1 -0
  7. package/dist/components/job-detail/job-detail-header.d.ts +8 -0
  8. package/dist/components/job-detail/job-detail-header.d.ts.map +1 -0
  9. package/dist/components/job-detail/job-detail-header.js +111 -0
  10. package/dist/components/job-detail/job-detail-header.js.map +1 -0
  11. package/dist/components/job-detail/job-detail-view.d.ts +16 -0
  12. package/dist/components/job-detail/job-detail-view.d.ts.map +1 -0
  13. package/dist/components/job-detail/job-detail-view.js +405 -0
  14. package/dist/components/job-detail/job-detail-view.js.map +1 -0
  15. package/dist/components/job-detail/job-empty-states.d.ts +10 -0
  16. package/dist/components/job-detail/job-empty-states.d.ts.map +1 -0
  17. package/dist/components/job-detail/job-empty-states.js +195 -0
  18. package/dist/components/job-detail/job-empty-states.js.map +1 -0
  19. package/dist/components/job-detail/job-execution-switcher.d.ts.map +1 -0
  20. package/dist/components/job-detail/job-execution-switcher.js.map +1 -0
  21. package/dist/components/job-detail/job-execution-time-text.d.ts.map +1 -0
  22. package/dist/components/job-detail/job-execution-time-text.js.map +1 -0
  23. package/dist/components/job-detail/job-selection.d.ts +24 -0
  24. package/dist/components/job-detail/job-selection.d.ts.map +1 -0
  25. package/dist/components/job-detail/job-selection.js +66 -0
  26. package/dist/components/job-detail/job-selection.js.map +1 -0
  27. package/dist/components/job-detail/step-attempt-log-panel.d.ts +15 -0
  28. package/dist/components/job-detail/step-attempt-log-panel.d.ts.map +1 -0
  29. package/dist/components/{workflow-run-view → job-detail}/step-attempt-log-panel.js +61 -16
  30. package/dist/components/job-detail/step-attempt-log-panel.js.map +1 -0
  31. package/dist/components/job-graph/job-graph-content.js +1 -1
  32. package/dist/components/job-graph/job-graph-content.js.map +1 -1
  33. package/dist/components/step-list/step-list-model.js +2 -2
  34. package/dist/components/step-list/step-list-model.js.map +1 -1
  35. package/dist/components/step-list/step-list.d.ts +1 -0
  36. package/dist/components/step-list/step-list.d.ts.map +1 -1
  37. package/dist/components/step-list/step-list.js +29 -4
  38. package/dist/components/step-list/step-list.js.map +1 -1
  39. package/dist/components/workflow-run-duration-label.d.ts +9 -4
  40. package/dist/components/workflow-run-duration-label.d.ts.map +1 -1
  41. package/dist/components/workflow-run-duration-label.js +27 -7
  42. package/dist/components/workflow-run-duration-label.js.map +1 -1
  43. package/dist/components/workflow-run-list/workflow-run-row.d.ts.map +1 -1
  44. package/dist/components/workflow-run-list/workflow-run-row.js +6 -5
  45. package/dist/components/workflow-run-list/workflow-run-row.js.map +1 -1
  46. package/dist/components/workflow-run-summary/workflow-run-summary.d.ts.map +1 -1
  47. package/dist/components/workflow-run-summary/workflow-run-summary.js +68 -64
  48. package/dist/components/workflow-run-summary/workflow-run-summary.js.map +1 -1
  49. package/dist/components/workflow-run-tabs/index.d.ts +0 -3
  50. package/dist/components/workflow-run-tabs/index.d.ts.map +1 -1
  51. package/dist/components/workflow-run-tabs/index.js +0 -3
  52. package/dist/components/workflow-run-tabs/index.js.map +1 -1
  53. package/dist/components/workflow-run-tabs/run-annotations-empty.d.ts +3 -1
  54. package/dist/components/workflow-run-tabs/run-annotations-empty.d.ts.map +1 -1
  55. package/dist/components/workflow-run-tabs/run-annotations-empty.js +2 -2
  56. package/dist/components/workflow-run-tabs/run-annotations-empty.js.map +1 -1
  57. package/dist/components/workflow-run-view/index.d.ts +0 -1
  58. package/dist/components/workflow-run-view/index.d.ts.map +1 -1
  59. package/dist/components/workflow-run-view/index.js +0 -1
  60. package/dist/components/workflow-run-view/index.js.map +1 -1
  61. package/dist/components/workflow-run-view/run-workspace-nav.d.ts +20 -0
  62. package/dist/components/workflow-run-view/run-workspace-nav.d.ts.map +1 -0
  63. package/dist/components/workflow-run-view/run-workspace-nav.js +271 -0
  64. package/dist/components/workflow-run-view/run-workspace-nav.js.map +1 -0
  65. package/dist/components/workflow-run-view/workflow-run-selection.d.ts.map +1 -1
  66. package/dist/components/workflow-run-view/workflow-run-selection.js +1 -14
  67. package/dist/components/workflow-run-view/workflow-run-selection.js.map +1 -1
  68. package/dist/components/workflow-run-view/workflow-run-view.d.ts +10 -8
  69. package/dist/components/workflow-run-view/workflow-run-view.d.ts.map +1 -1
  70. package/dist/components/workflow-run-view/workflow-run-view.js +250 -236
  71. package/dist/components/workflow-run-view/workflow-run-view.js.map +1 -1
  72. package/dist/components/workflow-status/status-visuals.d.ts.map +1 -1
  73. package/dist/components/workflow-status/status-visuals.js +10 -2
  74. package/dist/components/workflow-status/status-visuals.js.map +1 -1
  75. package/dist/components/workflow-status/workflow-status-icon.d.ts +3 -1
  76. package/dist/components/workflow-status/workflow-status-icon.d.ts.map +1 -1
  77. package/dist/components/workflow-status/workflow-status-icon.js +13 -2
  78. package/dist/components/workflow-status/workflow-status-icon.js.map +1 -1
  79. package/dist/core/entities/job-execution.d.ts +9 -0
  80. package/dist/core/entities/job-execution.d.ts.map +1 -1
  81. package/dist/core/entities/job-execution.js +13 -3
  82. package/dist/core/entities/job-execution.js.map +1 -1
  83. package/dist/core/entities/job.d.ts.map +1 -1
  84. package/dist/core/entities/step-attempt.d.ts.map +1 -1
  85. package/dist/core/entities/step.d.ts +2 -0
  86. package/dist/core/entities/step.d.ts.map +1 -1
  87. package/dist/core/entities/step.js +13 -0
  88. package/dist/core/entities/step.js.map +1 -1
  89. package/dist/core/entities/workflow-run-attempt.d.ts.map +1 -1
  90. package/dist/core/entities/workflow-run.d.ts +56 -1
  91. package/dist/core/entities/workflow-run.d.ts.map +1 -1
  92. package/dist/core/entities/workflow-run.js +98 -0
  93. package/dist/core/entities/workflow-run.js.map +1 -1
  94. package/dist/core/workflow-run.d.ts +4 -4
  95. package/dist/core/workflow-run.d.ts.map +1 -1
  96. package/dist/core/workflow-run.js +3 -3
  97. package/dist/core/workflow-run.js.map +1 -1
  98. package/dist/feature.d.ts +20 -16
  99. package/dist/feature.d.ts.map +1 -1
  100. package/dist/feature.js +5 -0
  101. package/dist/feature.js.map +1 -1
  102. package/dist/hooks/api/workflow-runs.d.ts +5 -3
  103. package/dist/hooks/api/workflow-runs.d.ts.map +1 -1
  104. package/dist/hooks/api/workflow-runs.js +5 -4
  105. package/dist/hooks/api/workflow-runs.js.map +1 -1
  106. package/dist/index.d.ts +1 -0
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js +1 -0
  109. package/dist/index.js.map +1 -1
  110. package/dist/pages/workflow-job-detail-page.d.ts +11 -0
  111. package/dist/pages/workflow-job-detail-page.d.ts.map +1 -0
  112. package/dist/pages/workflow-job-detail-page.js +66 -0
  113. package/dist/pages/workflow-job-detail-page.js.map +1 -0
  114. package/dist/pages/workflow-run-detail-page.d.ts.map +1 -1
  115. package/dist/pages/workflow-run-detail-page.js +4 -37
  116. package/dist/pages/workflow-run-detail-page.js.map +1 -1
  117. package/dist/routes/inputs.d.ts +47 -34
  118. package/dist/routes/inputs.d.ts.map +1 -1
  119. package/dist/routes/inputs.js +69 -37
  120. package/dist/routes/inputs.js.map +1 -1
  121. package/dist/routes/job-detail.d.ts +10 -0
  122. package/dist/routes/job-detail.d.ts.map +1 -0
  123. package/dist/routes/job-detail.js +27 -0
  124. package/dist/routes/job-detail.js.map +1 -0
  125. package/dist/routes/project-route.d.ts +1 -1
  126. package/dist/routes/run-detail.d.ts.map +1 -1
  127. package/dist/routes/runs.d.ts.map +1 -1
  128. package/dist/routes/workflows.d.ts.map +1 -1
  129. package/dist/tsconfig.test.tsbuildinfo +1 -1
  130. package/package.json +7 -7
  131. package/src/components/{workflow-run-view → job-detail}/agent-config-failure-callout.stories.tsx +1 -1
  132. package/src/components/{workflow-run-view → job-detail}/agent-config-failure-callout.tsx +2 -2
  133. package/src/components/job-detail/job-detail-header.test.tsx +31 -0
  134. package/src/components/job-detail/job-detail-header.tsx +111 -0
  135. package/src/components/job-detail/job-detail-view.stories.tsx +526 -0
  136. package/src/components/job-detail/job-detail-view.tsx +450 -0
  137. package/src/components/job-detail/job-empty-states.test.ts +27 -0
  138. package/src/components/job-detail/job-empty-states.tsx +248 -0
  139. package/src/components/job-detail/job-selection.test.ts +188 -0
  140. package/src/components/job-detail/job-selection.ts +96 -0
  141. package/src/components/{workflow-run-view → job-detail}/step-attempt-log-panel.test.tsx +32 -9
  142. package/src/components/{workflow-run-view → job-detail}/step-attempt-log-panel.tsx +52 -18
  143. package/src/components/job-graph/job-graph-content.tsx +1 -1
  144. package/src/components/step-list/step-list-model.test.ts +1 -1
  145. package/src/components/step-list/step-list-model.ts +2 -2
  146. package/src/components/step-list/step-list.stories.tsx +1 -1
  147. package/src/components/step-list/step-list.test.tsx +33 -0
  148. package/src/components/step-list/step-list.tsx +40 -9
  149. package/src/components/workflow-run-duration-label.tsx +50 -12
  150. package/src/components/workflow-run-list/workflow-run-row.tsx +6 -4
  151. package/src/components/workflow-run-summary/workflow-run-summary.stories.tsx +38 -0
  152. package/src/components/workflow-run-summary/workflow-run-summary.test.tsx +79 -5
  153. package/src/components/workflow-run-summary/workflow-run-summary.tsx +56 -60
  154. package/src/components/workflow-run-tabs/index.ts +0 -3
  155. package/src/components/workflow-run-tabs/run-annotations-empty.tsx +6 -2
  156. package/src/components/workflow-run-view/index.ts +0 -1
  157. package/src/components/workflow-run-view/run-workspace-nav.test.tsx +242 -0
  158. package/src/components/workflow-run-view/run-workspace-nav.tsx +301 -0
  159. package/src/components/workflow-run-view/workflow-run-selection.ts +1 -23
  160. package/src/components/workflow-run-view/workflow-run-view.test.tsx +62 -1136
  161. package/src/components/workflow-run-view/workflow-run-view.tsx +330 -321
  162. package/src/components/workflow-status/status-visuals.ts +5 -2
  163. package/src/components/workflow-status/workflow-status-icon.stories.tsx +1 -0
  164. package/src/components/workflow-status/workflow-status-icon.tsx +26 -1
  165. package/src/core/entities/job-execution.ts +17 -2
  166. package/src/core/entities/step.ts +26 -0
  167. package/src/core/entities/workflow-run-display.test.ts +159 -0
  168. package/src/core/entities/workflow-run.ts +139 -1
  169. package/src/core/workflow-run.ts +16 -1
  170. package/src/feature.ts +5 -0
  171. package/src/hooks/api/workflow-runs.ts +6 -2
  172. package/src/index.ts +1 -0
  173. package/src/page-harness-budget.test.ts +1 -0
  174. package/src/pages/workflow-job-detail-page.test.tsx +539 -0
  175. package/src/pages/workflow-job-detail-page.tsx +84 -0
  176. package/src/pages/workflow-run-detail-page.tsx +3 -43
  177. package/src/pages/workflow-run-pages.test.tsx +77 -332
  178. package/src/routes/inputs.test.ts +56 -6
  179. package/src/routes/inputs.ts +64 -17
  180. package/src/routes/job-detail.tsx +29 -0
  181. package/test/pages.tsx +25 -3
  182. package/test/render.tsx +6 -1
  183. package/tsconfig.build.tsbuildinfo +1 -1
  184. package/dist/components/workflow-run-tabs/run-jobs-list.d.ts +0 -18
  185. package/dist/components/workflow-run-tabs/run-jobs-list.d.ts.map +0 -1
  186. package/dist/components/workflow-run-tabs/run-jobs-list.js +0 -107
  187. package/dist/components/workflow-run-tabs/run-jobs-list.js.map +0 -1
  188. package/dist/components/workflow-run-tabs/run-tab-count.d.ts +0 -6
  189. package/dist/components/workflow-run-tabs/run-tab-count.d.ts.map +0 -1
  190. package/dist/components/workflow-run-tabs/run-tab-count.js +0 -27
  191. package/dist/components/workflow-run-tabs/run-tab-count.js.map +0 -1
  192. package/dist/components/workflow-run-tabs/run-tab-strip.d.ts +0 -8
  193. package/dist/components/workflow-run-tabs/run-tab-strip.d.ts.map +0 -1
  194. package/dist/components/workflow-run-tabs/run-tab-strip.js +0 -82
  195. package/dist/components/workflow-run-tabs/run-tab-strip.js.map +0 -1
  196. package/dist/components/workflow-run-view/agent-config-failure-callout.d.ts.map +0 -1
  197. package/dist/components/workflow-run-view/agent-config-failure-callout.js.map +0 -1
  198. package/dist/components/workflow-run-view/job-card.d.ts +0 -17
  199. package/dist/components/workflow-run-view/job-card.d.ts.map +0 -1
  200. package/dist/components/workflow-run-view/job-card.js +0 -496
  201. package/dist/components/workflow-run-view/job-card.js.map +0 -1
  202. package/dist/components/workflow-run-view/job-execution-switcher.d.ts.map +0 -1
  203. package/dist/components/workflow-run-view/job-execution-switcher.js.map +0 -1
  204. package/dist/components/workflow-run-view/job-execution-time-text.d.ts.map +0 -1
  205. package/dist/components/workflow-run-view/job-execution-time-text.js.map +0 -1
  206. package/dist/components/workflow-run-view/step-attempt-log-panel.d.ts +0 -9
  207. package/dist/components/workflow-run-view/step-attempt-log-panel.d.ts.map +0 -1
  208. package/dist/components/workflow-run-view/step-attempt-log-panel.js.map +0 -1
  209. package/src/components/workflow-run-tabs/run-jobs-list.tsx +0 -151
  210. package/src/components/workflow-run-tabs/run-tab-count.tsx +0 -28
  211. package/src/components/workflow-run-tabs/run-tab-strip.stories.tsx +0 -52
  212. package/src/components/workflow-run-tabs/run-tab-strip.test.tsx +0 -117
  213. package/src/components/workflow-run-tabs/run-tab-strip.tsx +0 -97
  214. package/src/components/workflow-run-view/job-card.stories.tsx +0 -789
  215. package/src/components/workflow-run-view/job-card.test.tsx +0 -115
  216. package/src/components/workflow-run-view/job-card.tsx +0 -614
  217. /package/dist/components/{workflow-run-view → job-detail}/agent-config-failure-callout.d.ts +0 -0
  218. /package/dist/components/{workflow-run-view → job-detail}/job-execution-switcher.d.ts +0 -0
  219. /package/dist/components/{workflow-run-view → job-detail}/job-execution-switcher.js +0 -0
  220. /package/dist/components/{workflow-run-view → job-detail}/job-execution-time-text.d.ts +0 -0
  221. /package/dist/components/{workflow-run-view → job-detail}/job-execution-time-text.js +0 -0
  222. /package/src/components/{workflow-run-view → job-detail}/job-execution-switcher.tsx +0 -0
  223. /package/src/components/{workflow-run-view → job-detail}/job-execution-time-text.tsx +0 -0
@@ -1,614 +0,0 @@
1
- import {TriggerSourceIcon} from '@shipfox/client-triggers';
2
- import {Badge} from '@shipfox/react-ui/badge';
3
- import {Button} from '@shipfox/react-ui/button';
4
- import {EmptyState} from '@shipfox/react-ui/empty-state';
5
- import {Icon} from '@shipfox/react-ui/icon';
6
- import {RelativeTime} from '@shipfox/react-ui/relative-time';
7
- import {useTimeTick} from '@shipfox/react-ui/time-ticker';
8
- import {Tooltip, TooltipContent, TooltipTrigger} from '@shipfox/react-ui/tooltip';
9
- import {Text} from '@shipfox/react-ui/typography';
10
- import type {ReactNode} from 'react';
11
- import {Fragment, useId, useRef, useState} from 'react';
12
- import {getWorkflowStatusVisual} from '#components/workflow-status/status-visuals.js';
13
- import {
14
- AGENT_CONFIG_ISSUES,
15
- defaultJobExecution,
16
- deriveJobDisplayStatus,
17
- deriveJobExecutionDisplayStatus,
18
- type Job,
19
- type JobDisplayStatus,
20
- type JobExecution,
21
- type JobExecutionTime,
22
- STEP_ERROR_REASONS,
23
- type Step,
24
- type StepError,
25
- type StepSourceLocation,
26
- WORKFLOW_JOB_STATUSES,
27
- workflowRunTriggerDisplayLabel,
28
- workflowRunTriggerLabel,
29
- } from '#core/workflow-run.js';
30
- import {type StepExpandedContext, StepList, type StepListEmptyState} from '../step-list/index.js';
31
- import {AgentConfigFailureCallout} from './agent-config-failure-callout.js';
32
- import {JobExecutionSwitcher} from './job-execution-switcher.js';
33
- import {formatJobExecutionTime, JobExecutionTimeText} from './job-execution-time-text.js';
34
- import {StepAttemptLogPanel} from './step-attempt-log-panel.js';
35
-
36
- const STATUS_BADGE_LABEL_WIDTH_CH = Math.max(
37
- ...[...WORKFLOW_JOB_STATUSES, 'listening' as const].map(
38
- (status) => getWorkflowStatusVisual(status).label.length,
39
- ),
40
- );
41
-
42
- interface LocalSelectedAttempt {
43
- jobExecutionId: string | undefined;
44
- attemptId: string | null;
45
- }
46
-
47
- export function JobCard({
48
- workspaceSlug,
49
- job,
50
- selectedJobExecution,
51
- selectedAttemptId,
52
- onSelectedJobExecutionChange,
53
- onSelectedAttemptChange,
54
- renderExpandedStep,
55
- sourcePanelId,
56
- sourceAvailable,
57
- focusedSourceStepId,
58
- onOpenStepSource,
59
- }: {
60
- workspaceSlug?: string | undefined;
61
- job: Job;
62
- selectedJobExecution: JobExecution | undefined;
63
- selectedAttemptId: string | null | undefined;
64
- onSelectedJobExecutionChange: ((jobExecutionId: string | undefined) => void) | undefined;
65
- onSelectedAttemptChange: ((attemptId: string | undefined) => void) | undefined;
66
- renderExpandedStep?: ((context: StepExpandedContext) => ReactNode) | undefined;
67
- sourcePanelId?: string | undefined;
68
- sourceAvailable?: boolean | undefined;
69
- focusedSourceStepId?: string | null | undefined;
70
- onOpenStepSource?:
71
- | ((stepId: string, location: StepSourceLocation, trigger: HTMLButtonElement | null) => void)
72
- | undefined;
73
- }) {
74
- const titleId = useId();
75
- const sourceButtonRef = useRef<HTMLButtonElement>(null);
76
- const [localSelectedAttempt, setLocalSelectedAttempt] = useState<LocalSelectedAttempt>({
77
- jobExecutionId: undefined,
78
- attemptId: null,
79
- });
80
- const title = selectedJobExecution?.displayName ?? job.displayName;
81
- const isNonDefaultExecutionSelected =
82
- selectedJobExecution !== undefined && selectedJobExecution.id !== defaultJobExecution(job)?.id;
83
- const selectedExecutionStatus = isNonDefaultExecutionSelected
84
- ? deriveJobExecutionDisplayStatus(selectedJobExecution)
85
- : deriveJobDisplayStatus(job);
86
- const effectiveSelectedAttemptId =
87
- selectedAttemptId === undefined &&
88
- localSelectedAttempt.jobExecutionId === selectedJobExecution?.id
89
- ? localSelectedAttempt.attemptId
90
- : selectedAttemptId;
91
- const selectedSourceAction = selectedStepSourceAction(
92
- selectedJobExecution,
93
- effectiveSelectedAttemptId,
94
- );
95
- const defaultRenderExpandedStep = ({
96
- step,
97
- stepId,
98
- attempt,
99
- attemptError,
100
- attemptStatus,
101
- carriedOver,
102
- }: StepExpandedContext) =>
103
- carriedOver ? (
104
- <CarriedOverStepPanel />
105
- ) : (
106
- <StepAttemptDetailPanel
107
- workspaceSlug={workspaceSlug}
108
- step={step}
109
- stepId={stepId}
110
- attempt={attempt}
111
- attemptError={attemptError}
112
- attemptStatus={attemptStatus}
113
- />
114
- );
115
-
116
- function selectAttempt(attemptId: string | undefined) {
117
- if (selectedAttemptId === undefined) {
118
- setLocalSelectedAttempt({
119
- jobExecutionId: selectedJobExecution?.id,
120
- attemptId: attemptId ?? null,
121
- });
122
- }
123
-
124
- onSelectedAttemptChange?.(attemptId);
125
- }
126
-
127
- return (
128
- <section
129
- aria-labelledby={titleId}
130
- className="flex min-h-0 flex-col rounded-8 border border-border-neutral-base bg-background-components-base"
131
- >
132
- <div className="grid min-h-52 min-w-0 grid-cols-1 gap-y-4 px-16 py-12">
133
- <div className="flex min-w-0 flex-wrap items-center justify-between gap-10">
134
- {job.mode === 'listening' &&
135
- job.jobExecutions.length > 0 &&
136
- onSelectedJobExecutionChange ? (
137
- <>
138
- <Text as="h2" id={titleId} size="sm" bold className="sr-only">
139
- {title}
140
- </Text>
141
- <div className="flex min-w-0 items-center gap-8">
142
- <JobStatusBadge status={selectedExecutionStatus} />
143
- <JobExecutionSwitcher
144
- job={job}
145
- selectedJobExecution={selectedJobExecution?.id ?? null}
146
- onSelectedJobExecutionChange={onSelectedJobExecutionChange}
147
- variant="title"
148
- />
149
- </div>
150
- </>
151
- ) : (
152
- <div className="flex min-w-0 items-center gap-8">
153
- <JobStatusBadge status={selectedExecutionStatus} />
154
- <div className="flex min-w-0 items-center gap-8">
155
- <Text
156
- as="h2"
157
- id={titleId}
158
- size="sm"
159
- bold
160
- className="min-w-0 truncate text-foreground-neutral-base"
161
- >
162
- {title}
163
- </Text>
164
- </div>
165
- </div>
166
- )}
167
- {sourceAvailable && selectedSourceAction && sourcePanelId && onOpenStepSource ? (
168
- <div className="flex min-w-max items-center gap-6">
169
- <Button
170
- ref={sourceButtonRef}
171
- type="button"
172
- variant="secondary"
173
- size="xs"
174
- aria-controls={sourcePanelId}
175
- aria-expanded={focusedSourceStepId === selectedSourceAction.stepId}
176
- onClick={() =>
177
- onOpenStepSource(
178
- selectedSourceAction.stepId,
179
- selectedSourceAction.location,
180
- sourceButtonRef.current,
181
- )
182
- }
183
- >
184
- View source
185
- </Button>
186
- </div>
187
- ) : null}
188
- </div>
189
- <JobExecutionMetadata execution={selectedJobExecution} />
190
- </div>
191
- <div className="min-h-0 border-t border-border-neutral-strong">
192
- {selectedJobExecution ? (
193
- <StepList
194
- job={job}
195
- jobExecution={selectedJobExecution}
196
- selectedAttemptId={selectedAttemptId}
197
- onSelectedAttemptChange={selectAttempt}
198
- autoSelectActiveAttempt
199
- emptyState={emptyStateForJob(job, selectedJobExecution)}
200
- showHeader={false}
201
- className="rounded-none border-0 bg-transparent"
202
- renderExpandedStep={renderExpandedStep ?? defaultRenderExpandedStep}
203
- />
204
- ) : (
205
- <JobExecutionEmptyState job={job} />
206
- )}
207
- </div>
208
- </section>
209
- );
210
- }
211
-
212
- function JobStatusBadge({status}: {status: JobDisplayStatus}) {
213
- const visual = getWorkflowStatusVisual(status);
214
-
215
- return (
216
- <Badge variant={visual.badge} size="xs">
217
- <span className="text-center" style={{width: `${STATUS_BADGE_LABEL_WIDTH_CH}ch`}}>
218
- {visual.label}
219
- </span>
220
- </Badge>
221
- );
222
- }
223
-
224
- function JobExecutionEmptyState({job}: {job: Job}) {
225
- const emptyState = emptyStateForMissingExecution(job);
226
-
227
- return (
228
- <EmptyState
229
- className="min-h-120 px-16 py-20"
230
- icon="componentLine"
231
- title={emptyState.title}
232
- description={emptyState.description}
233
- variant="compact"
234
- />
235
- );
236
- }
237
-
238
- function JobExecutionMetadata({execution}: {execution: JobExecution | undefined}) {
239
- if (!execution) return null;
240
-
241
- const queueTime = execution.queueTime;
242
- const runTime = execution.runTime;
243
- const executionStartedAt = execution.startedAt ?? execution.queuedAt ?? execution.createdAt;
244
- const items = [
245
- execution.triggerEvents.length > 0 ? {key: 'trigger', kind: 'trigger' as const} : null,
246
- {key: 'started', kind: 'started' as const, value: executionStartedAt},
247
- queueTime
248
- ? {key: 'queue', icon: 'hourglassLine' as const, kind: 'queue' as const, time: queueTime}
249
- : null,
250
- runTime ? {key: 'run', icon: 'timerLine' as const, kind: 'run' as const, time: runTime} : null,
251
- ].filter((item) => item !== null);
252
-
253
- if (items.length === 0) return null;
254
-
255
- return (
256
- <div className="flex min-w-0 items-center gap-12 overflow-hidden text-foreground-neutral-muted">
257
- {items.map((item, index) => (
258
- <Fragment key={item.key}>
259
- {index > 0 ? <MetadataSeparator /> : null}
260
- {item.kind === 'started' ? (
261
- <RelativeTime
262
- value={item.value}
263
- className="shrink-0 whitespace-nowrap text-xs leading-20 text-foreground-neutral-muted"
264
- />
265
- ) : item.kind === 'trigger' ? (
266
- <JobExecutionTriggerMetadata execution={execution} />
267
- ) : (
268
- <JobExecutionMetadataItem
269
- icon={item.icon}
270
- kind={item.kind}
271
- time={item.time}
272
- displayStatus={deriveJobExecutionDisplayStatus(execution)}
273
- />
274
- )}
275
- </Fragment>
276
- ))}
277
- </div>
278
- );
279
- }
280
-
281
- function JobExecutionTriggerMetadata({execution}: {execution: JobExecution}) {
282
- const triggerEvent = execution.triggerEvents[0];
283
- if (!triggerEvent) return null;
284
-
285
- const triggerLabel = workflowRunTriggerLabel({
286
- triggerSource: triggerEvent.source,
287
- triggerEvent: triggerEvent.event,
288
- });
289
- const triggerDisplayLabel = workflowRunTriggerDisplayLabel({
290
- triggerSource: triggerEvent.source,
291
- triggerEvent: triggerEvent.event,
292
- });
293
- const triggerCount = execution.triggerEvents.length;
294
- const countLabel = triggerCount > 1 ? ` (${triggerCount})` : '';
295
- const tooltip = triggerCount > 1 ? `${triggerLabel} (${triggerCount} events)` : triggerLabel;
296
-
297
- return (
298
- <Tooltip>
299
- <TooltipTrigger asChild>
300
- <button
301
- type="button"
302
- aria-label={tooltip}
303
- className="inline-flex min-w-0 max-w-full cursor-default items-center gap-4 rounded-4 border-0 bg-transparent p-0 text-left text-foreground-neutral-muted outline-none focus-visible:shadow-border-interactive-with-active"
304
- >
305
- <TriggerSourceIcon
306
- provider={triggerEvent.source}
307
- source={triggerEvent.source}
308
- aria-hidden="true"
309
- className="size-12 shrink-0"
310
- />
311
- <Text as="span" size="xs" className="min-w-0 truncate">
312
- {triggerDisplayLabel}
313
- {countLabel}
314
- </Text>
315
- </button>
316
- </TooltipTrigger>
317
- <TooltipContent>
318
- <Text as="span" size="xs" className="block max-w-[360px] break-words">
319
- {tooltip}
320
- </Text>
321
- </TooltipContent>
322
- </Tooltip>
323
- );
324
- }
325
-
326
- function JobExecutionMetadataItem({
327
- icon,
328
- kind,
329
- time,
330
- displayStatus,
331
- }: {
332
- icon: 'hourglassLine' | 'timerLine';
333
- kind: 'queue' | 'run';
334
- time: JobExecutionTime;
335
- displayStatus: JobExecution['status'];
336
- }) {
337
- useTimeTick();
338
-
339
- const tooltip = `${jobExecutionTimeVerb(kind, time, displayStatus)} for ${formatJobExecutionTime(time)}`;
340
-
341
- return (
342
- <Tooltip>
343
- <TooltipTrigger asChild>
344
- <button
345
- type="button"
346
- aria-label={tooltip}
347
- className="inline-flex min-w-0 cursor-default items-center gap-4 rounded-4 border-0 bg-transparent p-0 text-foreground-neutral-muted outline-none focus-visible:shadow-border-interactive-with-active"
348
- >
349
- <Icon name={icon} className="size-12 shrink-0" aria-hidden="true" />
350
- <span className="shrink-0 text-xs leading-20 text-foreground-neutral-muted tabular-nums">
351
- <JobExecutionTimeText time={time} />
352
- </span>
353
- </button>
354
- </TooltipTrigger>
355
- <TooltipContent>
356
- <Text as="span" size="xs">
357
- {tooltip}
358
- </Text>
359
- </TooltipContent>
360
- </Tooltip>
361
- );
362
- }
363
-
364
- function jobExecutionTimeVerb(
365
- kind: 'queue' | 'run',
366
- time: JobExecutionTime,
367
- displayStatus: JobExecution['status'],
368
- ): string {
369
- if (kind === 'queue') return time.state === 'live' ? 'Queueing' : 'Queued';
370
- if (time.state !== 'live') return 'Ran';
371
- if (displayStatus === 'running') return 'Running';
372
- return displayStatus === 'pending' ? 'Runner assigned' : 'Execution elapsed';
373
- }
374
-
375
- function MetadataSeparator() {
376
- return <span aria-hidden="true" className="h-12 w-px shrink-0 bg-border-neutral-strong" />;
377
- }
378
-
379
- function selectedStepSourceAction(
380
- jobExecution: JobExecution | undefined,
381
- selectedAttemptId: string | null | undefined,
382
- ): {stepId: string; location: StepSourceLocation} | null {
383
- if (!jobExecution || !selectedAttemptId) return null;
384
-
385
- for (const step of jobExecution.steps) {
386
- const selected =
387
- selectedAttemptId === `carried-over:${step.id}` ||
388
- step.attempts.some((attempt) => attempt.id === selectedAttemptId);
389
- if (selected && step.sourceLocation) {
390
- return {stepId: step.id, location: step.sourceLocation};
391
- }
392
- }
393
-
394
- return null;
395
- }
396
-
397
- function StepAttemptDetailPanel({
398
- workspaceSlug,
399
- step,
400
- stepId,
401
- attempt,
402
- attemptError,
403
- attemptStatus,
404
- }: {
405
- workspaceSlug?: string | undefined;
406
- step: Step;
407
- stepId: string;
408
- attempt: number;
409
- attemptError: Record<string, unknown> | null;
410
- attemptStatus: string;
411
- }) {
412
- const selectedAttemptError = toSelectedAttemptError(step, attemptError) ?? step.error;
413
-
414
- return (
415
- <div className="flex min-w-0 flex-col gap-10">
416
- {isAgentConfigFailure(step, selectedAttemptError) ? (
417
- <AgentConfigFailureCallout
418
- workspaceSlug={workspaceSlug}
419
- config={step.agentConfig}
420
- error={selectedAttemptError}
421
- />
422
- ) : null}
423
- <StepAttemptLogPanel stepId={stepId} attempt={attempt} attemptStatus={attemptStatus} />
424
- </div>
425
- );
426
- }
427
-
428
- function toSelectedAttemptError(
429
- step: Step,
430
- error: Record<string, unknown> | null,
431
- ): StepError | null {
432
- if (error === null) return null;
433
-
434
- const rawReason = error.reason;
435
- const parsedReason =
436
- typeof rawReason === 'string' &&
437
- STEP_ERROR_REASONS.has(rawReason as StepError['reason'] & string)
438
- ? (rawReason as NonNullable<StepError['reason']>)
439
- : undefined;
440
- const rawAgentConfigIssue = error.agentConfigIssue ?? error.agent_config_issue;
441
- const agentConfigIssue =
442
- typeof rawAgentConfigIssue === 'string' &&
443
- AGENT_CONFIG_ISSUES.has(rawAgentConfigIssue as NonNullable<StepError['agentConfigIssue']>)
444
- ? (rawAgentConfigIssue as NonNullable<StepError['agentConfigIssue']>)
445
- : undefined;
446
- const exitCode = error.exitCode ?? error.exit_code;
447
- const resolvedReason = parsedReason
448
- ? parsedReason
449
- : agentConfigIssue
450
- ? 'agent_config_invalid'
451
- : undefined;
452
-
453
- if (resolvedReason === undefined) return null;
454
-
455
- return {
456
- message: typeof error.message === 'string' ? error.message : '',
457
- exitCode: exitCode === null || typeof exitCode === 'number' ? exitCode : null,
458
- signal: typeof error.signal === 'string' ? error.signal : undefined,
459
- reason: resolvedReason,
460
- agentConfigIssue,
461
- category: step.type === 'setup' || step.type === 'checkout' ? 'setup' : 'user',
462
- };
463
- }
464
-
465
- function isAgentConfigFailure(step: Step, error: StepError | null): boolean {
466
- return step.type === 'agent' && error?.reason === 'agent_config_invalid';
467
- }
468
-
469
- function emptyStateForJob(job: Job, jobExecution: JobExecution): StepListEmptyState | undefined {
470
- if (job.carriedOver) {
471
- return {
472
- title: 'Carried over from a previous attempt',
473
- description: 'This job did not execute in this run.',
474
- status: 'succeeded',
475
- };
476
- }
477
-
478
- const displayStatus =
479
- job.mode === 'listening'
480
- ? deriveJobExecutionDisplayStatus(jobExecution)
481
- : deriveJobDisplayStatus(job);
482
-
483
- if (jobExecution.status === 'running' && displayStatus === 'pending') {
484
- return {
485
- title: 'Runner preparing job',
486
- description: 'A runner is assigned. Steps will appear here when work begins.',
487
- status: displayStatus,
488
- };
489
- }
490
-
491
- if (displayStatus === 'pending') {
492
- return {
493
- title: 'Waiting for this job to start',
494
- description: 'Steps will appear here once the job starts.',
495
- status: displayStatus,
496
- };
497
- }
498
-
499
- if (displayStatus === 'running') {
500
- return {
501
- title: 'Waiting for the first step',
502
- description: 'The first running step will appear here shortly.',
503
- status: displayStatus,
504
- };
505
- }
506
-
507
- if (displayStatus === 'cancelled') {
508
- return {
509
- title: 'Cancelled before start',
510
- description: 'This job was cancelled before any step started.',
511
- status: displayStatus,
512
- };
513
- }
514
-
515
- if (displayStatus === 'succeeded' || displayStatus === 'failed') {
516
- return {
517
- title: 'No steps recorded',
518
- description: `Execution #${jobExecution.sequence} finished without recorded steps.`,
519
- status: displayStatus,
520
- };
521
- }
522
-
523
- return undefined;
524
- }
525
-
526
- function emptyStateForMissingExecution(job: Job): StepListEmptyState {
527
- if (job.carriedOver) {
528
- return {
529
- title: 'Carried over from a previous attempt',
530
- description: 'This job did not execute in this run.',
531
- status: 'succeeded',
532
- };
533
- }
534
-
535
- if (job.mode === 'listening' && job.listenerStatus === 'listening') {
536
- return {
537
- title: 'Waiting for trigger events',
538
- description: 'Matching trigger events will create job executions here.',
539
- status: deriveJobDisplayStatus(job),
540
- };
541
- }
542
-
543
- if (job.mode === 'listening' && job.listenerStatus === 'resolved') {
544
- return {
545
- title: 'Listener resolved without executions',
546
- description: 'No matching trigger event created a job execution before the listener stopped.',
547
- status: job.status,
548
- };
549
- }
550
-
551
- if (job.status === 'pending') {
552
- return {
553
- title: 'Waiting for this job to start',
554
- description: 'No execution has been created for this job yet.',
555
- status: 'pending',
556
- };
557
- }
558
-
559
- if (job.status === 'skipped') {
560
- return {
561
- title: 'This job was skipped',
562
- description: skippedJobDescription(job.statusReason),
563
- status: 'skipped',
564
- };
565
- }
566
-
567
- if (job.status === 'cancelled') {
568
- return {
569
- title: 'Cancelled before start',
570
- description: 'This job was cancelled before an execution was created.',
571
- status: 'cancelled',
572
- };
573
- }
574
-
575
- return {
576
- title: 'Execution details unavailable',
577
- description: 'This job finished, but no job execution record is available.',
578
- status: job.status,
579
- };
580
- }
581
-
582
- function CarriedOverStepPanel() {
583
- return (
584
- <EmptyState
585
- className="min-h-120 rounded-8 border border-border-neutral-base bg-background-components-base px-16 py-20"
586
- icon="componentLine"
587
- title="Carried over from a previous attempt"
588
- description="Not executed in this run."
589
- variant="compact"
590
- />
591
- );
592
- }
593
-
594
- function skippedJobDescription(reason: Job['statusReason']): string {
595
- switch (reason) {
596
- case 'dependency_not_completed':
597
- return 'A required job did not complete, so this job was skipped.';
598
- case 'default_gate_rejected':
599
- return 'A required job did not succeed, so this job was skipped.';
600
- case 'condition_false':
601
- case 'condition_rejected':
602
- return 'The job condition did not match, so this job was skipped.';
603
- case 'condition_errored':
604
- return 'The job condition could not be evaluated, so this job was skipped.';
605
- case 'user_cancelled':
606
- case 'run_cancelled':
607
- case 'timed_out':
608
- case 'runner_lost':
609
- case 'step_failed':
610
- case 'unknown':
611
- case null:
612
- return 'This job did not start.';
613
- }
614
- }