@shipfox/client-workflows 0.2.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 (327) hide show
  1. package/.storybook/main.ts +1 -0
  2. package/.storybook/preview.css +10 -0
  3. package/.storybook/preview.tsx +97 -0
  4. package/.swcrc +42 -0
  5. package/.turbo/turbo-build.log +2 -0
  6. package/.turbo/turbo-type$colon$emit.log +1 -0
  7. package/.turbo/turbo-type.log +1 -0
  8. package/CHANGELOG.md +162 -0
  9. package/LICENSE +21 -0
  10. package/dist/components/identifier/identifier.d.ts +6 -0
  11. package/dist/components/identifier/identifier.d.ts.map +1 -0
  12. package/dist/components/identifier/identifier.js +144 -0
  13. package/dist/components/identifier/identifier.js.map +1 -0
  14. package/dist/components/identifier/index.d.ts +2 -0
  15. package/dist/components/identifier/index.d.ts.map +1 -0
  16. package/dist/components/identifier/index.js +3 -0
  17. package/dist/components/identifier/index.js.map +1 -0
  18. package/dist/components/job-graph/graph-model.d.ts +27 -0
  19. package/dist/components/job-graph/graph-model.d.ts.map +1 -0
  20. package/dist/components/job-graph/graph-model.js +107 -0
  21. package/dist/components/job-graph/graph-model.js.map +1 -0
  22. package/dist/components/job-graph/index.d.ts +3 -0
  23. package/dist/components/job-graph/index.d.ts.map +1 -0
  24. package/dist/components/job-graph/index.js +3 -0
  25. package/dist/components/job-graph/index.js.map +1 -0
  26. package/dist/components/job-graph/job-duration-format.d.ts +4 -0
  27. package/dist/components/job-graph/job-duration-format.d.ts.map +1 -0
  28. package/dist/components/job-graph/job-duration-format.js +41 -0
  29. package/dist/components/job-graph/job-duration-format.js.map +1 -0
  30. package/dist/components/job-graph/job-duration-label.d.ts +5 -0
  31. package/dist/components/job-graph/job-duration-label.d.ts.map +1 -0
  32. package/dist/components/job-graph/job-duration-label.js +33 -0
  33. package/dist/components/job-graph/job-duration-label.js.map +1 -0
  34. package/dist/components/job-graph/job-graph-content.d.ts +9 -0
  35. package/dist/components/job-graph/job-graph-content.d.ts.map +1 -0
  36. package/dist/components/job-graph/job-graph-content.js +181 -0
  37. package/dist/components/job-graph/job-graph-content.js.map +1 -0
  38. package/dist/components/job-graph/job-graph-view.d.ts +11 -0
  39. package/dist/components/job-graph/job-graph-view.d.ts.map +1 -0
  40. package/dist/components/job-graph/job-graph-view.js +24 -0
  41. package/dist/components/job-graph/job-graph-view.js.map +1 -0
  42. package/dist/components/job-graph/job-graph.d.ts +3 -0
  43. package/dist/components/job-graph/job-graph.d.ts.map +1 -0
  44. package/dist/components/job-graph/job-graph.js +21 -0
  45. package/dist/components/job-graph/job-graph.js.map +1 -0
  46. package/dist/components/job-graph/job-node.d.ts +16 -0
  47. package/dist/components/job-graph/job-node.d.ts.map +1 -0
  48. package/dist/components/job-graph/job-node.js +196 -0
  49. package/dist/components/job-graph/job-node.js.map +1 -0
  50. package/dist/components/job-graph/types.d.ts +9 -0
  51. package/dist/components/job-graph/types.d.ts.map +1 -0
  52. package/dist/components/job-graph/types.js +3 -0
  53. package/dist/components/job-graph/types.js.map +1 -0
  54. package/dist/components/step-list/index.d.ts +3 -0
  55. package/dist/components/step-list/index.d.ts.map +1 -0
  56. package/dist/components/step-list/index.js +3 -0
  57. package/dist/components/step-list/index.js.map +1 -0
  58. package/dist/components/step-list/step-list-model.d.ts +36 -0
  59. package/dist/components/step-list/step-list-model.d.ts.map +1 -0
  60. package/dist/components/step-list/step-list-model.js +135 -0
  61. package/dist/components/step-list/step-list-model.js.map +1 -0
  62. package/dist/components/step-list/step-list.d.ts +32 -0
  63. package/dist/components/step-list/step-list.d.ts.map +1 -0
  64. package/dist/components/step-list/step-list.js +409 -0
  65. package/dist/components/step-list/step-list.js.map +1 -0
  66. package/dist/components/workflow-run-duration-label.d.ts +8 -0
  67. package/dist/components/workflow-run-duration-label.d.ts.map +1 -0
  68. package/dist/components/workflow-run-duration-label.js +84 -0
  69. package/dist/components/workflow-run-duration-label.js.map +1 -0
  70. package/dist/components/workflow-run-list/index.d.ts +2 -0
  71. package/dist/components/workflow-run-list/index.d.ts.map +1 -0
  72. package/dist/components/workflow-run-list/index.js +3 -0
  73. package/dist/components/workflow-run-list/index.js.map +1 -0
  74. package/dist/components/workflow-run-list/run-display.d.ts +5 -0
  75. package/dist/components/workflow-run-list/run-display.d.ts.map +1 -0
  76. package/dist/components/workflow-run-list/run-display.js +19 -0
  77. package/dist/components/workflow-run-list/run-display.js.map +1 -0
  78. package/dist/components/workflow-run-list/types.d.ts +21 -0
  79. package/dist/components/workflow-run-list/types.d.ts.map +1 -0
  80. package/dist/components/workflow-run-list/types.js +3 -0
  81. package/dist/components/workflow-run-list/types.js.map +1 -0
  82. package/dist/components/workflow-run-list/workflow-run-list-content.d.ts +14 -0
  83. package/dist/components/workflow-run-list/workflow-run-list-content.d.ts.map +1 -0
  84. package/dist/components/workflow-run-list/workflow-run-list-content.js +37 -0
  85. package/dist/components/workflow-run-list/workflow-run-list-content.js.map +1 -0
  86. package/dist/components/workflow-run-list/workflow-run-list-header.d.ts +10 -0
  87. package/dist/components/workflow-run-list/workflow-run-list-header.d.ts.map +1 -0
  88. package/dist/components/workflow-run-list/workflow-run-list-header.js +55 -0
  89. package/dist/components/workflow-run-list/workflow-run-list-header.js.map +1 -0
  90. package/dist/components/workflow-run-list/workflow-run-list-states.d.ts +15 -0
  91. package/dist/components/workflow-run-list/workflow-run-list-states.d.ts.map +1 -0
  92. package/dist/components/workflow-run-list/workflow-run-list-states.js +103 -0
  93. package/dist/components/workflow-run-list/workflow-run-list-states.js.map +1 -0
  94. package/dist/components/workflow-run-list/workflow-run-list-view.d.ts +3 -0
  95. package/dist/components/workflow-run-list/workflow-run-list-view.d.ts.map +1 -0
  96. package/dist/components/workflow-run-list/workflow-run-list-view.js +46 -0
  97. package/dist/components/workflow-run-list/workflow-run-list-view.js.map +1 -0
  98. package/dist/components/workflow-run-list/workflow-run-list.d.ts +3 -0
  99. package/dist/components/workflow-run-list/workflow-run-list.d.ts.map +1 -0
  100. package/dist/components/workflow-run-list/workflow-run-list.js +20 -0
  101. package/dist/components/workflow-run-list/workflow-run-list.js.map +1 -0
  102. package/dist/components/workflow-run-list/workflow-run-row.d.ts +14 -0
  103. package/dist/components/workflow-run-list/workflow-run-row.d.ts.map +1 -0
  104. package/dist/components/workflow-run-list/workflow-run-row.js +172 -0
  105. package/dist/components/workflow-run-list/workflow-run-row.js.map +1 -0
  106. package/dist/components/workflow-run-summary/index.d.ts +2 -0
  107. package/dist/components/workflow-run-summary/index.d.ts.map +1 -0
  108. package/dist/components/workflow-run-summary/index.js +3 -0
  109. package/dist/components/workflow-run-summary/index.js.map +1 -0
  110. package/dist/components/workflow-run-summary/workflow-run-attempt-switcher.d.ts +9 -0
  111. package/dist/components/workflow-run-summary/workflow-run-attempt-switcher.d.ts.map +1 -0
  112. package/dist/components/workflow-run-summary/workflow-run-attempt-switcher.js +138 -0
  113. package/dist/components/workflow-run-summary/workflow-run-attempt-switcher.js.map +1 -0
  114. package/dist/components/workflow-run-summary/workflow-run-summary.d.ts +20 -0
  115. package/dist/components/workflow-run-summary/workflow-run-summary.d.ts.map +1 -0
  116. package/dist/components/workflow-run-summary/workflow-run-summary.js +252 -0
  117. package/dist/components/workflow-run-summary/workflow-run-summary.js.map +1 -0
  118. package/dist/components/workflow-run-view/agent-config-failure-callout.d.ts +7 -0
  119. package/dist/components/workflow-run-view/agent-config-failure-callout.d.ts.map +1 -0
  120. package/dist/components/workflow-run-view/agent-config-failure-callout.js +84 -0
  121. package/dist/components/workflow-run-view/agent-config-failure-callout.js.map +1 -0
  122. package/dist/components/workflow-run-view/index.d.ts +3 -0
  123. package/dist/components/workflow-run-view/index.d.ts.map +1 -0
  124. package/dist/components/workflow-run-view/index.js +4 -0
  125. package/dist/components/workflow-run-view/index.js.map +1 -0
  126. package/dist/components/workflow-run-view/job-card.d.ts +17 -0
  127. package/dist/components/workflow-run-view/job-card.d.ts.map +1 -0
  128. package/dist/components/workflow-run-view/job-card.js +476 -0
  129. package/dist/components/workflow-run-view/job-card.js.map +1 -0
  130. package/dist/components/workflow-run-view/job-execution-switcher.d.ts +10 -0
  131. package/dist/components/workflow-run-view/job-execution-switcher.d.ts.map +1 -0
  132. package/dist/components/workflow-run-view/job-execution-switcher.js +171 -0
  133. package/dist/components/workflow-run-view/job-execution-switcher.js.map +1 -0
  134. package/dist/components/workflow-run-view/job-execution-time-text.d.ts +6 -0
  135. package/dist/components/workflow-run-view/job-execution-time-text.d.ts.map +1 -0
  136. package/dist/components/workflow-run-view/job-execution-time-text.js +24 -0
  137. package/dist/components/workflow-run-view/job-execution-time-text.js.map +1 -0
  138. package/dist/components/workflow-run-view/step-attempt-log-panel.d.ts +9 -0
  139. package/dist/components/workflow-run-view/step-attempt-log-panel.d.ts.map +1 -0
  140. package/dist/components/workflow-run-view/step-attempt-log-panel.js +152 -0
  141. package/dist/components/workflow-run-view/step-attempt-log-panel.js.map +1 -0
  142. package/dist/components/workflow-run-view/workflow-run-selection.d.ts +14 -0
  143. package/dist/components/workflow-run-view/workflow-run-selection.d.ts.map +1 -0
  144. package/dist/components/workflow-run-view/workflow-run-selection.js +56 -0
  145. package/dist/components/workflow-run-view/workflow-run-selection.js.map +1 -0
  146. package/dist/components/workflow-run-view/workflow-run-states.d.ts +12 -0
  147. package/dist/components/workflow-run-view/workflow-run-states.d.ts.map +1 -0
  148. package/dist/components/workflow-run-view/workflow-run-states.js +91 -0
  149. package/dist/components/workflow-run-view/workflow-run-states.js.map +1 -0
  150. package/dist/components/workflow-run-view/workflow-run-view.d.ts +15 -0
  151. package/dist/components/workflow-run-view/workflow-run-view.d.ts.map +1 -0
  152. package/dist/components/workflow-run-view/workflow-run-view.js +285 -0
  153. package/dist/components/workflow-run-view/workflow-run-view.js.map +1 -0
  154. package/dist/components/workflow-source-panel/index.d.ts +2 -0
  155. package/dist/components/workflow-source-panel/index.d.ts.map +1 -0
  156. package/dist/components/workflow-source-panel/index.js +3 -0
  157. package/dist/components/workflow-source-panel/index.js.map +1 -0
  158. package/dist/components/workflow-source-panel/workflow-source-panel.d.ts +13 -0
  159. package/dist/components/workflow-source-panel/workflow-source-panel.d.ts.map +1 -0
  160. package/dist/components/workflow-source-panel/workflow-source-panel.js +91 -0
  161. package/dist/components/workflow-source-panel/workflow-source-panel.js.map +1 -0
  162. package/dist/components/workflow-status/status-visuals.d.ts +12 -0
  163. package/dist/components/workflow-status/status-visuals.d.ts.map +1 -0
  164. package/dist/components/workflow-status/status-visuals.js +54 -0
  165. package/dist/components/workflow-status/status-visuals.js.map +1 -0
  166. package/dist/components/workflow-status/workflow-status-icon.d.ts +22 -0
  167. package/dist/components/workflow-status/workflow-status-icon.d.ts.map +1 -0
  168. package/dist/components/workflow-status/workflow-status-icon.js +100 -0
  169. package/dist/components/workflow-status/workflow-status-icon.js.map +1 -0
  170. package/dist/core/entities/job-execution.d.ts +69 -0
  171. package/dist/core/entities/job-execution.d.ts.map +1 -0
  172. package/dist/core/entities/job-execution.js +83 -0
  173. package/dist/core/entities/job-execution.js.map +1 -0
  174. package/dist/core/entities/job.d.ts +56 -0
  175. package/dist/core/entities/job.d.ts.map +1 -0
  176. package/dist/core/entities/job.js +71 -0
  177. package/dist/core/entities/job.js.map +1 -0
  178. package/dist/core/entities/step-attempt.d.ts +49 -0
  179. package/dist/core/entities/step-attempt.d.ts.map +1 -0
  180. package/dist/core/entities/step-attempt.js +48 -0
  181. package/dist/core/entities/step-attempt.js.map +1 -0
  182. package/dist/core/entities/step.d.ts +41 -0
  183. package/dist/core/entities/step.d.ts.map +1 -0
  184. package/dist/core/entities/step.js +51 -0
  185. package/dist/core/entities/step.js.map +1 -0
  186. package/dist/core/entities/workflow-run-attempt.d.ts +44 -0
  187. package/dist/core/entities/workflow-run-attempt.d.ts.map +1 -0
  188. package/dist/core/entities/workflow-run-attempt.js +51 -0
  189. package/dist/core/entities/workflow-run-attempt.js.map +1 -0
  190. package/dist/core/entities/workflow-run.d.ts +61 -0
  191. package/dist/core/entities/workflow-run.d.ts.map +1 -0
  192. package/dist/core/entities/workflow-run.js +104 -0
  193. package/dist/core/entities/workflow-run.js.map +1 -0
  194. package/dist/core/workflow-run-url-state.d.ts +13 -0
  195. package/dist/core/workflow-run-url-state.d.ts.map +1 -0
  196. package/dist/core/workflow-run-url-state.js +43 -0
  197. package/dist/core/workflow-run-url-state.js.map +1 -0
  198. package/dist/core/workflow-run.d.ts +13 -0
  199. package/dist/core/workflow-run.d.ts.map +1 -0
  200. package/dist/core/workflow-run.js +8 -0
  201. package/dist/core/workflow-run.js.map +1 -0
  202. package/dist/env.d.js +2 -0
  203. package/dist/env.d.js.map +1 -0
  204. package/dist/feature.d.ts +20 -0
  205. package/dist/feature.d.ts.map +1 -0
  206. package/dist/feature.js +27 -0
  207. package/dist/feature.js.map +1 -0
  208. package/dist/hooks/api/workflow-runs.d.ts +109 -0
  209. package/dist/hooks/api/workflow-runs.d.ts.map +1 -0
  210. package/dist/hooks/api/workflow-runs.js +394 -0
  211. package/dist/hooks/api/workflow-runs.js.map +1 -0
  212. package/dist/index.d.ts +5 -0
  213. package/dist/index.d.ts.map +1 -0
  214. package/dist/index.js +5 -0
  215. package/dist/index.js.map +1 -0
  216. package/dist/pages/workflow-run-first-time-use.d.ts +6 -0
  217. package/dist/pages/workflow-run-first-time-use.d.ts.map +1 -0
  218. package/dist/pages/workflow-run-first-time-use.js +17 -0
  219. package/dist/pages/workflow-run-first-time-use.js.map +1 -0
  220. package/dist/pages/workflow-run-page.d.ts +8 -0
  221. package/dist/pages/workflow-run-page.d.ts.map +1 -0
  222. package/dist/pages/workflow-run-page.js +83 -0
  223. package/dist/pages/workflow-run-page.js.map +1 -0
  224. package/dist/routes/run-detail.d.ts +8 -0
  225. package/dist/routes/run-detail.d.ts.map +1 -0
  226. package/dist/routes/run-detail.js +21 -0
  227. package/dist/routes/run-detail.js.map +1 -0
  228. package/dist/routes/runs.d.ts +8 -0
  229. package/dist/routes/runs.d.ts.map +1 -0
  230. package/dist/routes/runs.js +20 -0
  231. package/dist/routes/runs.js.map +1 -0
  232. package/dist/tsconfig.test.tsbuildinfo +1 -0
  233. package/package.json +114 -0
  234. package/src/components/identifier/identifier.tsx +178 -0
  235. package/src/components/identifier/index.ts +1 -0
  236. package/src/components/job-graph/graph-model.test.ts +189 -0
  237. package/src/components/job-graph/graph-model.ts +178 -0
  238. package/src/components/job-graph/index.ts +2 -0
  239. package/src/components/job-graph/job-duration-format.ts +54 -0
  240. package/src/components/job-graph/job-duration-label.tsx +29 -0
  241. package/src/components/job-graph/job-graph-content.tsx +225 -0
  242. package/src/components/job-graph/job-graph-view.test.tsx +298 -0
  243. package/src/components/job-graph/job-graph-view.tsx +45 -0
  244. package/src/components/job-graph/job-graph.stories.tsx +182 -0
  245. package/src/components/job-graph/job-graph.tsx +24 -0
  246. package/src/components/job-graph/job-node.stories.tsx +364 -0
  247. package/src/components/job-graph/job-node.test.tsx +347 -0
  248. package/src/components/job-graph/job-node.tsx +202 -0
  249. package/src/components/job-graph/types.ts +9 -0
  250. package/src/components/step-list/index.ts +6 -0
  251. package/src/components/step-list/step-list-model.test.ts +369 -0
  252. package/src/components/step-list/step-list-model.ts +205 -0
  253. package/src/components/step-list/step-list.stories.tsx +419 -0
  254. package/src/components/step-list/step-list.test.tsx +566 -0
  255. package/src/components/step-list/step-list.tsx +494 -0
  256. package/src/components/workflow-run-duration-label.tsx +118 -0
  257. package/src/components/workflow-run-list/index.ts +1 -0
  258. package/src/components/workflow-run-list/run-display.test.ts +53 -0
  259. package/src/components/workflow-run-list/run-display.ts +22 -0
  260. package/src/components/workflow-run-list/types.ts +22 -0
  261. package/src/components/workflow-run-list/workflow-run-list-content.tsx +58 -0
  262. package/src/components/workflow-run-list/workflow-run-list-header.tsx +53 -0
  263. package/src/components/workflow-run-list/workflow-run-list-states.tsx +86 -0
  264. package/src/components/workflow-run-list/workflow-run-list-view.test.tsx +178 -0
  265. package/src/components/workflow-run-list/workflow-run-list-view.tsx +57 -0
  266. package/src/components/workflow-run-list/workflow-run-list.stories.tsx +111 -0
  267. package/src/components/workflow-run-list/workflow-run-list.tsx +29 -0
  268. package/src/components/workflow-run-list/workflow-run-row.tsx +176 -0
  269. package/src/components/workflow-run-summary/index.ts +1 -0
  270. package/src/components/workflow-run-summary/workflow-run-attempt-switcher.test.tsx +230 -0
  271. package/src/components/workflow-run-summary/workflow-run-attempt-switcher.tsx +146 -0
  272. package/src/components/workflow-run-summary/workflow-run-summary.stories.tsx +414 -0
  273. package/src/components/workflow-run-summary/workflow-run-summary.test.tsx +354 -0
  274. package/src/components/workflow-run-summary/workflow-run-summary.tsx +295 -0
  275. package/src/components/workflow-run-view/agent-config-failure-callout.stories.tsx +140 -0
  276. package/src/components/workflow-run-view/agent-config-failure-callout.tsx +93 -0
  277. package/src/components/workflow-run-view/index.ts +2 -0
  278. package/src/components/workflow-run-view/job-card.stories.tsx +788 -0
  279. package/src/components/workflow-run-view/job-card.tsx +566 -0
  280. package/src/components/workflow-run-view/job-execution-switcher.tsx +170 -0
  281. package/src/components/workflow-run-view/job-execution-time-text.tsx +34 -0
  282. package/src/components/workflow-run-view/step-attempt-log-panel.test.tsx +290 -0
  283. package/src/components/workflow-run-view/step-attempt-log-panel.tsx +152 -0
  284. package/src/components/workflow-run-view/workflow-run-selection.test.ts +280 -0
  285. package/src/components/workflow-run-view/workflow-run-selection.ts +89 -0
  286. package/src/components/workflow-run-view/workflow-run-states.tsx +70 -0
  287. package/src/components/workflow-run-view/workflow-run-view.test.tsx +1214 -0
  288. package/src/components/workflow-run-view/workflow-run-view.tsx +341 -0
  289. package/src/components/workflow-source-panel/index.ts +1 -0
  290. package/src/components/workflow-source-panel/workflow-source-panel.stories.tsx +110 -0
  291. package/src/components/workflow-source-panel/workflow-source-panel.test.tsx +96 -0
  292. package/src/components/workflow-source-panel/workflow-source-panel.tsx +136 -0
  293. package/src/components/workflow-status/status-visuals.test.ts +38 -0
  294. package/src/components/workflow-status/status-visuals.ts +36 -0
  295. package/src/components/workflow-status/workflow-status-icon.stories.tsx +90 -0
  296. package/src/components/workflow-status/workflow-status-icon.tsx +135 -0
  297. package/src/core/entities/job-execution.ts +139 -0
  298. package/src/core/entities/job.ts +149 -0
  299. package/src/core/entities/step-attempt.ts +89 -0
  300. package/src/core/entities/step.ts +105 -0
  301. package/src/core/entities/workflow-run-attempt.ts +87 -0
  302. package/src/core/entities/workflow-run.ts +183 -0
  303. package/src/core/workflow-run-url-state.ts +61 -0
  304. package/src/core/workflow-run.test.ts +640 -0
  305. package/src/core/workflow-run.ts +66 -0
  306. package/src/env.d.ts +8 -0
  307. package/src/feature.ts +26 -0
  308. package/src/hooks/api/workflow-runs.test.tsx +410 -0
  309. package/src/hooks/api/workflow-runs.ts +485 -0
  310. package/src/index.ts +45 -0
  311. package/src/page-harness-budget.test.ts +33 -0
  312. package/src/pages/workflow-run-first-time-use.tsx +17 -0
  313. package/src/pages/workflow-run-page.test.tsx +517 -0
  314. package/src/pages/workflow-run-page.tsx +89 -0
  315. package/src/routes/run-detail.tsx +15 -0
  316. package/src/routes/runs.tsx +11 -0
  317. package/test/fixtures/logs.ts +13 -0
  318. package/test/fixtures/workflow-run.ts +311 -0
  319. package/test/pages.tsx +79 -0
  320. package/test/render.tsx +40 -0
  321. package/test/setup.ts +3 -0
  322. package/tsconfig.build.json +9 -0
  323. package/tsconfig.build.tsbuildinfo +1 -0
  324. package/tsconfig.json +3 -0
  325. package/tsconfig.test.json +8 -0
  326. package/vercel.json +8 -0
  327. package/vitest.config.ts +70 -0
@@ -0,0 +1,354 @@
1
+ import {render, screen, waitFor, within} from '@testing-library/react';
2
+ import userEvent from '@testing-library/user-event';
3
+ import type {workflowRunDetailDto} from '#test/fixtures/workflow-run.js';
4
+ import {workflowJobDto, workflowRunDetail} from '#test/fixtures/workflow-run.js';
5
+ import {WorkflowRunSummary} from './workflow-run-summary.js';
6
+
7
+ const RUN_ID = '66666666-6666-4666-8666-666666666666';
8
+ const RELATIVE_TIME_TEXT_PATTERN = /ago$/;
9
+ const OLD_ROOT_TIME_TEXT_PATTERN = /(?:1d|24h) ago/;
10
+ const COPY_RUN_BUTTON_NAME = /Copy run/;
11
+
12
+ const originalScrollWidth = Object.getOwnPropertyDescriptor(
13
+ window.HTMLElement.prototype,
14
+ 'scrollWidth',
15
+ );
16
+ const originalClientWidth = Object.getOwnPropertyDescriptor(
17
+ window.HTMLElement.prototype,
18
+ 'clientWidth',
19
+ );
20
+
21
+ beforeEach(() => {
22
+ setElementWidths({scrollWidth: 80, clientWidth: 120});
23
+ });
24
+
25
+ describe('WorkflowRunSummary', () => {
26
+ afterEach(() => {
27
+ vi.useRealTimers();
28
+ vi.restoreAllMocks();
29
+ restoreElementWidthDescriptors();
30
+ });
31
+
32
+ test('renders status, trigger metadata, and trigger time', async () => {
33
+ renderSummary();
34
+
35
+ const summary = await screen.findByRole('region', {name: 'deploy-web'});
36
+
37
+ expect(within(summary).getByRole('heading', {name: 'deploy-web'})).toBeInTheDocument();
38
+ expect(within(summary).getAllByText('Running')).not.toHaveLength(0);
39
+ expect(within(summary).getByText('fire')).toBeInTheDocument();
40
+ expect(within(summary).queryByText('manual')).not.toBeInTheDocument();
41
+ expect(within(summary).getByText(RELATIVE_TIME_TEXT_PATTERN)).toBeInTheDocument();
42
+ expect(within(summary).queryByText('Triggered')).not.toBeInTheDocument();
43
+ expect(within(summary).queryByText('Updated')).not.toBeInTheDocument();
44
+ expect(
45
+ within(summary).queryByRole('button', {name: COPY_RUN_BUTTON_NAME}),
46
+ ).not.toBeInTheDocument();
47
+ });
48
+
49
+ test('uses the selected run attempt for summary status and trigger time', async () => {
50
+ const rootCreatedAt = new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString();
51
+ const attemptCreatedAt = new Date(Date.now() - 5 * 60 * 1000).toISOString();
52
+ renderSummary({
53
+ created_at: rootCreatedAt,
54
+ run_attempt: {
55
+ id: '22222222-2222-4222-8222-222222222222',
56
+ workflow_run_id: RUN_ID,
57
+ attempt: 2,
58
+ status: 'failed',
59
+ created_at: attemptCreatedAt,
60
+ started_at: null,
61
+ finished_at: null,
62
+ rerun_mode: 'all',
63
+ },
64
+ });
65
+
66
+ const summary = await screen.findByRole('region', {name: 'deploy-web'});
67
+
68
+ expect(
69
+ within(summary).queryByRole('button', {name: COPY_RUN_BUTTON_NAME}),
70
+ ).not.toBeInTheDocument();
71
+ expect(within(summary).getAllByText('Failed')).not.toHaveLength(0);
72
+ expect(within(summary).getByText('5m ago')).toBeInTheDocument();
73
+ expect(within(summary).queryByText(OLD_ROOT_TIME_TEXT_PATTERN)).not.toBeInTheDocument();
74
+ });
75
+
76
+ test('omits empty trigger metadata', async () => {
77
+ renderSummary({trigger_source: '', trigger_event: ''});
78
+
79
+ await screen.findByRole('region', {name: 'deploy-web'});
80
+
81
+ expect(screen.queryByText('fire')).not.toBeInTheDocument();
82
+ });
83
+
84
+ test('does not show a run name tooltip when the heading is not truncated', async () => {
85
+ const user = userEvent.setup();
86
+ renderSummary();
87
+
88
+ await user.hover(await screen.findByRole('heading', {name: 'deploy-web'}));
89
+
90
+ expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
91
+ });
92
+
93
+ test('wires the full run name tooltip when the heading is truncated', async () => {
94
+ const runName = 'release-production-multi-region-with-canary-and-smoke-tests';
95
+ setElementWidths({scrollWidth: 160, clientWidth: 80});
96
+ renderSummary({name: runName});
97
+
98
+ const heading = await screen.findByRole('heading', {name: runName});
99
+
100
+ expect(heading).toHaveAttribute('data-slot', 'tooltip-trigger');
101
+ await waitFor(() =>
102
+ expect(within(heading).getByText(runName)).toHaveAttribute('title', runName),
103
+ );
104
+ });
105
+
106
+ test('renders source control only when source is available', async () => {
107
+ const user = userEvent.setup();
108
+ const onSourceToggle = vi.fn();
109
+ renderSummary(
110
+ {source_snapshot: {format: 'yaml', content: 'name: deploy-web'}},
111
+ {
112
+ sourceAvailable: true,
113
+ sourceOpen: false,
114
+ sourcePanelId: 'workflow-source-panel',
115
+ onSourceToggle,
116
+ },
117
+ );
118
+
119
+ const sourceButton = await screen.findByRole('button', {name: 'View source'});
120
+ await user.click(sourceButton);
121
+
122
+ expect(sourceButton).toHaveAttribute('aria-controls', 'workflow-source-panel');
123
+ expect(sourceButton).toHaveAttribute('aria-expanded', 'false');
124
+ expect(onSourceToggle).toHaveBeenCalledTimes(1);
125
+ });
126
+
127
+ test('shows the selected attempt duration, not the top-level run duration', async () => {
128
+ renderSummary({
129
+ started_at: '2026-05-07T00:00:00.000Z',
130
+ finished_at: '2026-05-07T00:10:00.000Z',
131
+ run_attempt: {
132
+ id: '11111111-1111-4111-8111-000000000001',
133
+ workflow_run_id: RUN_ID,
134
+ attempt: 1,
135
+ status: 'succeeded',
136
+ created_at: '2026-05-07T01:01:00.000Z',
137
+ started_at: '2026-05-07T01:00:00.000Z',
138
+ finished_at: '2026-05-07T01:02:14.000Z',
139
+ rerun_mode: null,
140
+ },
141
+ });
142
+
143
+ await screen.findByRole('region', {name: 'deploy-web'});
144
+
145
+ expect(screen.getByText('2m 14s')).toBeInTheDocument();
146
+ expect(screen.queryByText('10m 00s')).not.toBeInTheDocument();
147
+ });
148
+
149
+ test('shows a live selected attempt duration for running runs', async () => {
150
+ vi.spyOn(Date, 'now').mockReturnValue(Date.parse('2026-05-07T01:02:14.000Z'));
151
+ renderSummary({
152
+ run_attempt: {
153
+ id: '11111111-1111-4111-8111-000000000001',
154
+ workflow_run_id: RUN_ID,
155
+ attempt: 1,
156
+ status: 'running',
157
+ created_at: '2026-05-07T01:01:00.000Z',
158
+ started_at: '2026-05-07T01:00:00.000Z',
159
+ finished_at: null,
160
+ rerun_mode: null,
161
+ },
162
+ });
163
+
164
+ await screen.findByRole('region', {name: 'deploy-web'});
165
+
166
+ const duration = screen.getByText('2m 14s');
167
+ expect(duration).toBeInTheDocument();
168
+ expect(duration).toHaveAttribute('aria-label', 'running 2m 14s');
169
+ });
170
+
171
+ test('omits source control when source is unavailable', async () => {
172
+ renderSummary();
173
+
174
+ await screen.findByRole('region', {name: 'deploy-web'});
175
+
176
+ expect(screen.queryByRole('button', {name: 'View source'})).not.toBeInTheDocument();
177
+ });
178
+
179
+ test('shows the cancel action when the run can be cancelled', async () => {
180
+ const user = userEvent.setup();
181
+ const onCancel = vi.fn();
182
+ renderSummary({}, {onCancel});
183
+
184
+ await user.click(await screen.findByRole('button', {name: 'Cancel workflow'}));
185
+
186
+ expect(onCancel).toHaveBeenCalledTimes(1);
187
+ });
188
+
189
+ test('omits the cancel action for terminal runs', async () => {
190
+ renderSummary({status: 'succeeded'});
191
+
192
+ await screen.findByRole('region', {name: 'deploy-web'});
193
+
194
+ expect(screen.queryByRole('button', {name: 'Cancel workflow'})).not.toBeInTheDocument();
195
+ });
196
+
197
+ test('disables the cancel action while cancellation is pending', async () => {
198
+ renderSummary({}, {cancelling: true, onCancel: vi.fn()});
199
+
200
+ const button = await screen.findByRole('button', {name: 'Cancel workflow'});
201
+ expect(button).toBeDisabled();
202
+ expect(button).toHaveAttribute('aria-busy', 'true');
203
+ });
204
+
205
+ test('hides the cancel action when no cancel handler is provided', async () => {
206
+ renderSummary({status: 'running'});
207
+
208
+ await screen.findByRole('region', {name: 'deploy-web'});
209
+
210
+ expect(screen.queryByRole('button', {name: 'Cancel workflow'})).not.toBeInTheDocument();
211
+ });
212
+
213
+ test('derives the cancel action for non-terminal runs', async () => {
214
+ const onCancel = vi.fn();
215
+ const onRerun = vi.fn();
216
+ renderSummary({status: 'running'}, {onCancel, onRerun});
217
+
218
+ await screen.findByRole('button', {name: 'Cancel workflow'});
219
+
220
+ expect(screen.queryByRole('button', {name: 'Re-run workflow'})).not.toBeInTheDocument();
221
+ expect(screen.queryByRole('button', {name: 'Re-run jobs'})).not.toBeInTheDocument();
222
+ });
223
+
224
+ test('re-runs all jobs from a succeeded run', async () => {
225
+ const user = userEvent.setup();
226
+ const onRerun = vi.fn();
227
+ renderSummary({status: 'succeeded'}, {onRerun});
228
+
229
+ await user.click(await screen.findByRole('button', {name: 'Re-run workflow'}));
230
+
231
+ expect(onRerun).toHaveBeenCalledWith('all');
232
+ });
233
+
234
+ test('hides the re-run action when no re-run handler is provided', async () => {
235
+ renderSummary({status: 'succeeded'});
236
+
237
+ await screen.findByRole('region', {name: 'deploy-web'});
238
+
239
+ expect(screen.queryByRole('button', {name: 'Re-run workflow'})).not.toBeInTheDocument();
240
+ });
241
+
242
+ test('shows re-run choices for a failed run', async () => {
243
+ const user = userEvent.setup();
244
+ const onRerun = vi.fn();
245
+ renderSummary({status: 'failed', jobs: [workflowJobDto({status: 'failed'})]}, {onRerun});
246
+
247
+ await user.click(await screen.findByRole('button', {name: 'Re-run jobs'}));
248
+ expect(await screen.findByRole('menuitem', {name: 'Re-run all jobs'})).toBeInTheDocument();
249
+ await user.click(await screen.findByRole('menuitem', {name: 'Re-run failed jobs'}));
250
+
251
+ expect(onRerun).toHaveBeenCalledWith('failed');
252
+ });
253
+
254
+ test('shows re-run choices for a cancelled run', async () => {
255
+ const user = userEvent.setup();
256
+ const onRerun = vi.fn();
257
+ renderSummary({status: 'cancelled', jobs: [workflowJobDto({status: 'cancelled'})]}, {onRerun});
258
+
259
+ await user.click(await screen.findByRole('button', {name: 'Re-run jobs'}));
260
+
261
+ expect(await screen.findByRole('menuitem', {name: 'Re-run all jobs'})).toBeInTheDocument();
262
+ expect(screen.getByRole('menuitem', {name: 'Re-run failed jobs'})).toBeInTheDocument();
263
+ });
264
+
265
+ test('re-runs the full workflow when a failed run has no failed jobs', async () => {
266
+ const user = userEvent.setup();
267
+ const onRerun = vi.fn();
268
+ renderSummary({status: 'failed', jobs: [workflowJobDto({status: 'succeeded'})]}, {onRerun});
269
+
270
+ await user.click(await screen.findByRole('button', {name: 'Re-run workflow'}));
271
+
272
+ expect(screen.queryByRole('button', {name: 'Re-run jobs'})).not.toBeInTheDocument();
273
+ expect(onRerun).toHaveBeenCalledWith('all');
274
+ });
275
+
276
+ test('hides run actions when viewing a historical attempt', async () => {
277
+ renderSummary(
278
+ {
279
+ status: 'failed',
280
+ current_attempt: 2,
281
+ run_attempt: {
282
+ id: '11111111-1111-4111-8111-000000000001',
283
+ workflow_run_id: RUN_ID,
284
+ attempt: 1,
285
+ status: 'failed',
286
+ created_at: '2026-05-07T01:01:00.000Z',
287
+ started_at: null,
288
+ finished_at: null,
289
+ rerun_mode: null,
290
+ },
291
+ jobs: [workflowJobDto({status: 'failed'})],
292
+ },
293
+ {onCancel: vi.fn(), onRerun: vi.fn()},
294
+ );
295
+
296
+ await screen.findByRole('region', {name: 'deploy-web'});
297
+
298
+ expect(screen.queryByRole('button', {name: 'Cancel workflow'})).not.toBeInTheDocument();
299
+ expect(screen.queryByRole('button', {name: 'Re-run workflow'})).not.toBeInTheDocument();
300
+ expect(screen.queryByRole('button', {name: 'Re-run jobs'})).not.toBeInTheDocument();
301
+ });
302
+ });
303
+
304
+ function renderSummary(
305
+ overrides: Parameters<typeof workflowRunDetailDto>[0] = {},
306
+ props: Omit<Parameters<typeof WorkflowRunSummary>[0], 'run'> = {},
307
+ ) {
308
+ const run = workflowRunDetail({
309
+ id: RUN_ID,
310
+ project_id: '44444444-4444-4444-8444-444444444444',
311
+ definition_id: '55555555-5555-4555-8555-555555555555',
312
+ name: 'deploy-web',
313
+ status: 'running',
314
+ trigger_source: 'manual',
315
+ trigger_event: 'fire',
316
+ created_at: '2026-05-07T01:01:00.000Z',
317
+ updated_at: '2026-05-07T01:02:00.000Z',
318
+ ...overrides,
319
+ });
320
+
321
+ // These cases never mount the attempt switcher links, so no router is needed.
322
+ render(<WorkflowRunSummary run={run} {...props} />);
323
+ }
324
+
325
+ function setElementWidths({scrollWidth, clientWidth}: {scrollWidth: number; clientWidth: number}) {
326
+ Object.defineProperty(window.HTMLElement.prototype, 'scrollWidth', {
327
+ configurable: true,
328
+ get() {
329
+ return scrollWidth;
330
+ },
331
+ });
332
+ Object.defineProperty(window.HTMLElement.prototype, 'clientWidth', {
333
+ configurable: true,
334
+ get() {
335
+ return clientWidth;
336
+ },
337
+ });
338
+ }
339
+
340
+ function restoreElementWidthDescriptors() {
341
+ restoreElementWidthDescriptor('scrollWidth', originalScrollWidth);
342
+ restoreElementWidthDescriptor('clientWidth', originalClientWidth);
343
+ }
344
+
345
+ function restoreElementWidthDescriptor(
346
+ property: 'scrollWidth' | 'clientWidth',
347
+ descriptor: PropertyDescriptor | undefined,
348
+ ) {
349
+ if (descriptor) {
350
+ Object.defineProperty(window.HTMLElement.prototype, property, descriptor);
351
+ return;
352
+ }
353
+ delete window.HTMLElement.prototype[property];
354
+ }
@@ -0,0 +1,295 @@
1
+ import type {WorkflowRunRerunModeDto} from '@shipfox/api-workflows-dto';
2
+ import {TriggerSourceIcon} from '@shipfox/client-triggers';
3
+ import {Badge} from '@shipfox/react-ui/badge';
4
+ import {Button} from '@shipfox/react-ui/button';
5
+ import {
6
+ DropdownMenu,
7
+ DropdownMenuContent,
8
+ DropdownMenuItem,
9
+ DropdownMenuTrigger,
10
+ } from '@shipfox/react-ui/dropdown-menu';
11
+ import {useIsTextTruncated} from '@shipfox/react-ui/hooks';
12
+ import {RelativeTime} from '@shipfox/react-ui/relative-time';
13
+ import {TimeTickerProvider} from '@shipfox/react-ui/time-ticker';
14
+ import {Tooltip, TooltipContent, TooltipTrigger} from '@shipfox/react-ui/tooltip';
15
+ import {Header, Text} from '@shipfox/react-ui/typography';
16
+ import type {Ref} from 'react';
17
+ import {useId} from 'react';
18
+ import {
19
+ isWorkflowRunTerminal,
20
+ type Job,
21
+ WORKFLOW_RUN_STATUSES,
22
+ type WorkflowRunDetail,
23
+ } from '#core/workflow-run.js';
24
+ import {WorkflowRunDurationLabel} from '../workflow-run-duration-label.js';
25
+ import {getWorkflowStatusVisual} from '../workflow-status/status-visuals.js';
26
+ import {WorkflowRunAttemptSwitcher} from './workflow-run-attempt-switcher.js';
27
+
28
+ const STATUS_BADGE_LABEL_WIDTH_CH = Math.max(
29
+ ...WORKFLOW_RUN_STATUSES.map((status) => getWorkflowStatusVisual(status).label.length),
30
+ );
31
+
32
+ type WorkflowRunAction = 'cancel' | 'rerun-all' | 'rerun-menu' | 'none';
33
+
34
+ export interface WorkflowRunSummaryProps {
35
+ workspaceId?: string | undefined;
36
+ projectId?: string | undefined;
37
+ run: WorkflowRunDetail;
38
+ sourceAvailable?: boolean | undefined;
39
+ sourceOpen?: boolean | undefined;
40
+ sourcePanelId?: string | undefined;
41
+ sourceButtonRef?: Ref<HTMLButtonElement> | undefined;
42
+ onSourceToggle?: (() => void) | undefined;
43
+ cancelling?: boolean | undefined;
44
+ onCancel?: (() => void) | undefined;
45
+ rerunPending?: boolean | undefined;
46
+ onRerun?: ((mode: WorkflowRunRerunModeDto) => void) | undefined;
47
+ latestAttempt?: number | undefined;
48
+ }
49
+
50
+ export function WorkflowRunSummary({
51
+ workspaceId,
52
+ projectId,
53
+ run,
54
+ sourceAvailable = false,
55
+ sourceOpen = false,
56
+ sourcePanelId,
57
+ sourceButtonRef,
58
+ onSourceToggle,
59
+ cancelling = false,
60
+ onCancel,
61
+ rerunPending = false,
62
+ onRerun,
63
+ latestAttempt,
64
+ }: WorkflowRunSummaryProps) {
65
+ const headingId = useId();
66
+ const status = getWorkflowStatusVisual(run.runAttempt.status);
67
+ const action = workflowRunActionForRun(run);
68
+ const attemptSwitcher =
69
+ latestAttempt && latestAttempt > 1 && workspaceId && projectId
70
+ ? {workspaceId, projectId, latestAttempt}
71
+ : null;
72
+ const displayDuration = run.runAttempt.displayDuration;
73
+ const {ref: headingTextRef, isTruncated: isHeadingTruncated} =
74
+ useIsTextTruncated<HTMLSpanElement>(run.name);
75
+
76
+ return (
77
+ <TimeTickerProvider intervalMs={1000} reducedMotionIntervalMs={10_000}>
78
+ <section
79
+ aria-labelledby={headingId}
80
+ className="border-b border-border-neutral-base bg-background-subtle-base px-16 py-8"
81
+ >
82
+ <div className="grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-12 gap-y-4 overflow-hidden">
83
+ <div className="col-start-1 row-start-1 flex min-w-0 items-center gap-8">
84
+ <Badge variant={status.badge} size="xs">
85
+ <span className="text-center" style={{width: `${STATUS_BADGE_LABEL_WIDTH_CH}ch`}}>
86
+ {status.label}
87
+ </span>
88
+ </Badge>
89
+
90
+ <Tooltip>
91
+ <TooltipTrigger asChild>
92
+ <Header id={headingId} variant="h3" className="min-w-0 truncate">
93
+ <span
94
+ ref={headingTextRef}
95
+ title={isHeadingTruncated ? run.name : undefined}
96
+ className="block min-w-0 truncate"
97
+ >
98
+ {run.name}
99
+ </span>
100
+ </Header>
101
+ </TooltipTrigger>
102
+ {isHeadingTruncated ? (
103
+ <TooltipContent>
104
+ <Text as="span" size="xs" className="max-w-[360px] break-words">
105
+ {run.name}
106
+ </Text>
107
+ </TooltipContent>
108
+ ) : null}
109
+ </Tooltip>
110
+ </div>
111
+
112
+ <div className="col-start-2 row-start-1 flex min-w-max items-center gap-6 justify-self-end">
113
+ <WorkflowRunActionSlot
114
+ action={action}
115
+ cancelling={cancelling}
116
+ onCancel={onCancel}
117
+ rerunPending={rerunPending}
118
+ onRerun={onRerun}
119
+ />
120
+ {sourceAvailable ? (
121
+ <Button
122
+ ref={sourceButtonRef}
123
+ type="button"
124
+ variant="secondary"
125
+ size="xs"
126
+ aria-controls={sourcePanelId}
127
+ aria-expanded={sourceOpen}
128
+ onClick={onSourceToggle}
129
+ >
130
+ View source
131
+ </Button>
132
+ ) : null}
133
+ </div>
134
+
135
+ <div className="col-span-2 row-start-2 flex min-w-0 items-center gap-12 overflow-hidden text-foreground-neutral-muted">
136
+ {attemptSwitcher ? (
137
+ <WorkflowRunAttemptSwitcher
138
+ workspaceId={attemptSwitcher.workspaceId}
139
+ projectId={attemptSwitcher.projectId}
140
+ run={run}
141
+ latestAttempt={attemptSwitcher.latestAttempt}
142
+ />
143
+ ) : null}
144
+
145
+ {run.triggerDisplayLabel ? (
146
+ <>
147
+ {attemptSwitcher ? <MetadataSeparator /> : null}
148
+ <span className="min-w-0">
149
+ <Tooltip>
150
+ <TooltipTrigger asChild>
151
+ <button
152
+ type="button"
153
+ aria-label={run.triggerLabel}
154
+ className="inline-flex max-w-full min-w-0 items-center gap-4 rounded-6 border-0 bg-transparent p-0 text-left text-foreground-neutral-muted outline-none focus-visible:shadow-button-neutral-focus"
155
+ >
156
+ <TriggerSourceIcon
157
+ provider={run.triggerProvider}
158
+ source={run.triggerSource}
159
+ aria-hidden="true"
160
+ className="size-12 shrink-0"
161
+ />
162
+ <Text as="span" size="xs" className="min-w-0 truncate">
163
+ {run.triggerDisplayLabel}
164
+ </Text>
165
+ </button>
166
+ </TooltipTrigger>
167
+ <TooltipContent>
168
+ <Text as="span" size="xs" className="block max-w-[360px] break-words">
169
+ {run.triggerLabel}
170
+ </Text>
171
+ </TooltipContent>
172
+ </Tooltip>
173
+ </span>
174
+ </>
175
+ ) : null}
176
+
177
+ {attemptSwitcher || run.triggerDisplayLabel ? <MetadataSeparator /> : null}
178
+ <RelativeTime
179
+ value={run.runAttempt.createdAt}
180
+ className="shrink-0 whitespace-nowrap text-xs leading-20 text-foreground-neutral-muted"
181
+ />
182
+
183
+ {displayDuration ? (
184
+ <>
185
+ <MetadataSeparator />
186
+ <WorkflowRunDurationLabel
187
+ duration={displayDuration}
188
+ className="text-foreground-neutral-muted"
189
+ />
190
+ </>
191
+ ) : null}
192
+ </div>
193
+ </div>
194
+ </section>
195
+ </TimeTickerProvider>
196
+ );
197
+ }
198
+
199
+ function WorkflowRunActionSlot({
200
+ action,
201
+ cancelling,
202
+ onCancel,
203
+ rerunPending,
204
+ onRerun,
205
+ }: {
206
+ action: WorkflowRunAction;
207
+ cancelling: boolean;
208
+ onCancel?: (() => void) | undefined;
209
+ rerunPending: boolean;
210
+ onRerun?: ((mode: WorkflowRunRerunModeDto) => void) | undefined;
211
+ }) {
212
+ if (action === 'none') return null;
213
+
214
+ if (action === 'cancel') {
215
+ if (!onCancel) return null;
216
+
217
+ return (
218
+ <Button
219
+ type="button"
220
+ variant="danger"
221
+ size="xs"
222
+ isLoading={cancelling}
223
+ disabled={cancelling}
224
+ onClick={onCancel}
225
+ >
226
+ Cancel workflow
227
+ </Button>
228
+ );
229
+ }
230
+
231
+ if (action === 'rerun-all') {
232
+ if (!onRerun) return null;
233
+
234
+ return (
235
+ <Button
236
+ type="button"
237
+ variant="secondary"
238
+ size="xs"
239
+ isLoading={rerunPending}
240
+ disabled={rerunPending}
241
+ onClick={() => onRerun('all')}
242
+ >
243
+ Re-run workflow
244
+ </Button>
245
+ );
246
+ }
247
+
248
+ if (!onRerun) return null;
249
+
250
+ return (
251
+ <DropdownMenu>
252
+ <DropdownMenuTrigger asChild>
253
+ <Button
254
+ type="button"
255
+ variant="secondary"
256
+ size="xs"
257
+ iconRight="arrowDownSLine"
258
+ isLoading={rerunPending}
259
+ disabled={rerunPending}
260
+ >
261
+ Re-run jobs
262
+ </Button>
263
+ </DropdownMenuTrigger>
264
+ <DropdownMenuContent align="end">
265
+ <DropdownMenuItem disabled={rerunPending} onSelect={() => onRerun('all')}>
266
+ Re-run all jobs
267
+ </DropdownMenuItem>
268
+ <DropdownMenuItem disabled={rerunPending} onSelect={() => onRerun('failed')}>
269
+ Re-run failed jobs
270
+ </DropdownMenuItem>
271
+ </DropdownMenuContent>
272
+ </DropdownMenu>
273
+ );
274
+ }
275
+
276
+ function workflowRunActionForRun(run: WorkflowRunDetail): WorkflowRunAction {
277
+ if (run.runAttempt.attempt !== run.currentAttempt) return 'none';
278
+ if (!isWorkflowRunTerminal(run.runAttempt.status)) return 'cancel';
279
+ if (run.runAttempt.status === 'succeeded' || !hasFailedOrCancelledJobs(run)) return 'rerun-all';
280
+ return 'rerun-menu';
281
+ }
282
+
283
+ function hasFailedOrCancelledJobs(run: WorkflowRunDetail): boolean {
284
+ if (!workflowRunHasJobs(run)) return false;
285
+
286
+ return run.jobs.some((job) => job.status === 'failed' || job.status === 'cancelled');
287
+ }
288
+
289
+ function workflowRunHasJobs(run: WorkflowRunDetail): run is WorkflowRunDetail & {jobs: Job[]} {
290
+ return 'jobs' in run && Array.isArray(run.jobs);
291
+ }
292
+
293
+ function MetadataSeparator() {
294
+ return <span aria-hidden="true" className="h-12 w-px shrink-0 bg-border-neutral-base" />;
295
+ }