@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,369 @@
1
+ import {
2
+ type StepAttemptDto,
3
+ type WorkflowRunStepDetailDto,
4
+ workflowRunStatusSchema,
5
+ } from '@shipfox/api-workflows-dto';
6
+ import {getWorkflowStatusVisual} from '#components/workflow-status/status-visuals.js';
7
+ import type {Job} from '#core/workflow-run.js';
8
+ import {
9
+ type JobDtoOverrides,
10
+ workflowJob,
11
+ workflowJobExecutionDto,
12
+ workflowStepAttemptDto,
13
+ workflowStepDto,
14
+ } from '#test/fixtures/workflow-run.js';
15
+ import {buildStepListModel, getStepStatusVisual, humanizeStatus} from './step-list-model.js';
16
+
17
+ describe('buildStepListModel', () => {
18
+ test('sorts steps by position and uses display names before fallback labels', () => {
19
+ const second = makeStep({
20
+ key: 'deploy',
21
+ name: 'deploy',
22
+ position: 2,
23
+ attempts: [makeAttempt({execution_order: 2})],
24
+ });
25
+ const first = makeStep({
26
+ key: null,
27
+ name: 'npm test',
28
+ position: 1,
29
+ config: {run: 'npm test'},
30
+ attempts: [makeAttempt({execution_order: 1})],
31
+ });
32
+ const unnamed = makeStep({
33
+ key: '',
34
+ name: '',
35
+ position: 3,
36
+ attempts: [makeAttempt({execution_order: 3})],
37
+ });
38
+
39
+ const result = buildStepListModel({job: makeJob({steps: [second, first, unnamed]})});
40
+
41
+ expect(result.entries.map((entry) => entry.step.label)).toEqual([
42
+ 'npm test',
43
+ 'deploy',
44
+ 'Step 3',
45
+ ]);
46
+ });
47
+
48
+ test('uses backend display labels for unnamed setup, run, and agent steps', () => {
49
+ const setup = makeStep({
50
+ key: null,
51
+ name: 'Set up job',
52
+ type: 'setup',
53
+ attempts: [makeAttempt()],
54
+ });
55
+ const run = makeStep({
56
+ key: null,
57
+ name: 'pnpm test',
58
+ position: 1,
59
+ type: 'run',
60
+ config: {run: 'pnpm test\npnpm build'},
61
+ attempts: [makeAttempt()],
62
+ });
63
+ const agent = makeStep({
64
+ key: null,
65
+ name: 'claude-opus-4-8 · Fix the failing tests.',
66
+ position: 2,
67
+ type: 'agent',
68
+ config: {model: 'claude-opus-4-8', prompt: 'Fix the failing tests.\nKeep it small.'},
69
+ attempts: [makeAttempt()],
70
+ });
71
+
72
+ const result = buildStepListModel({job: makeJob({steps: [setup, run, agent]})});
73
+
74
+ expect(result.entries.map((entry) => entry.step.label)).toEqual([
75
+ 'Set up job',
76
+ 'pnpm test',
77
+ 'claude-opus-4-8 · Fix the failing tests.',
78
+ ]);
79
+ });
80
+
81
+ test('falls back to the source name when the display label is empty', () => {
82
+ const step = makeStep({key: 'lint', name: '', attempts: [makeAttempt()]});
83
+
84
+ const result = buildStepListModel({job: makeJob({steps: [step]})});
85
+
86
+ expect(result.entries[0]?.step.label).toBe('lint');
87
+ });
88
+
89
+ test('uses a generic fallback when display name and source name are empty', () => {
90
+ const custom = makeStep({
91
+ key: null,
92
+ name: '',
93
+ type: 'deploy',
94
+ attempts: [makeAttempt()],
95
+ });
96
+
97
+ const result = buildStepListModel({job: makeJob({steps: [custom]})});
98
+
99
+ expect(result.entries[0]?.step.label).toBe('Step 1');
100
+ });
101
+
102
+ test('omits steps without attempts from the flat attempt list', () => {
103
+ const attempted = makeStep({name: 'build', attempts: [makeAttempt()]});
104
+ const pending = makeStep({name: 'deploy', position: 1});
105
+
106
+ const result = buildStepListModel({job: makeJob({steps: [attempted, pending]})});
107
+
108
+ expect(result.entries.map((entry) => entry.step.label)).toEqual(['build']);
109
+ });
110
+
111
+ test('has no active entry when no attempt is running', () => {
112
+ const step = makeStep({
113
+ attempts: [
114
+ makeAttempt({attempt: 1, status: 'failed'}),
115
+ makeAttempt({attempt: 2, status: 'succeeded'}),
116
+ ],
117
+ });
118
+
119
+ const result = buildStepListModel({job: makeJob({steps: [step]})});
120
+
121
+ expect(result.activeEntryId).toBeUndefined();
122
+ });
123
+
124
+ test('uses the latest running attempt by execution order as the active entry', () => {
125
+ const earlier = makeAttempt({status: 'running', execution_order: 2});
126
+ const later = makeAttempt({status: 'running', execution_order: 4});
127
+ const finished = makeAttempt({status: 'succeeded', execution_order: 5});
128
+
129
+ const result = buildStepListModel({
130
+ job: makeJob({
131
+ steps: [
132
+ makeStep({name: 'install', status: 'running', attempts: [earlier]}),
133
+ makeStep({name: 'deploy', position: 1, status: 'running', attempts: [later]}),
134
+ makeStep({name: 'notify', position: 2, status: 'succeeded', attempts: [finished]}),
135
+ ],
136
+ }),
137
+ });
138
+
139
+ expect(result.entries.map((entry) => entry.id)).toEqual([earlier.id, later.id, finished.id]);
140
+ expect(result.activeEntryId).toBe(later.id);
141
+ });
142
+
143
+ test('defaults to the running execution when no execution is provided', () => {
144
+ const failedStep = makeStep({
145
+ name: 'old attempt',
146
+ attempts: [makeAttempt({status: 'failed'})],
147
+ });
148
+ const runningStep = makeStep({
149
+ name: 'active attempt',
150
+ attempts: [makeAttempt({status: 'running'})],
151
+ });
152
+
153
+ const result = buildStepListModel({
154
+ job: makeJob({
155
+ job_executions: [
156
+ workflowJobExecutionDto({
157
+ id: 'execution-1',
158
+ sequence: 1,
159
+ status: 'failed',
160
+ steps: [failedStep],
161
+ }),
162
+ workflowJobExecutionDto({
163
+ id: 'execution-2',
164
+ sequence: 2,
165
+ status: 'running',
166
+ steps: [runningStep],
167
+ }),
168
+ ],
169
+ }),
170
+ });
171
+
172
+ expect(result.jobExecutionId).toBe('execution-2');
173
+ expect(result.entries[0]?.step.label).toBe('active attempt');
174
+ });
175
+
176
+ test('defaults to the highest sequence execution when none are running', () => {
177
+ const firstStep = makeStep({
178
+ name: 'first attempt',
179
+ attempts: [makeAttempt({status: 'failed'})],
180
+ });
181
+ const latestStep = makeStep({
182
+ name: 'latest attempt',
183
+ attempts: [makeAttempt({status: 'succeeded'})],
184
+ });
185
+
186
+ const result = buildStepListModel({
187
+ job: makeJob({
188
+ job_executions: [
189
+ workflowJobExecutionDto({
190
+ id: 'execution-1',
191
+ sequence: 1,
192
+ status: 'failed',
193
+ steps: [firstStep],
194
+ }),
195
+ workflowJobExecutionDto({
196
+ id: 'execution-3',
197
+ sequence: 3,
198
+ status: 'succeeded',
199
+ steps: [latestStep],
200
+ }),
201
+ workflowJobExecutionDto({id: 'execution-2', sequence: 2, status: 'cancelled'}),
202
+ ],
203
+ }),
204
+ });
205
+
206
+ expect(result.jobExecutionId).toBe('execution-3');
207
+ expect(result.entries[0]?.step.label).toBe('latest attempt');
208
+ });
209
+
210
+ test('breaks active running-attempt execution-order ties by sorted entry order', () => {
211
+ const first = makeAttempt({attempt: 1, execution_order: 7, status: 'running'});
212
+ const second = makeAttempt({attempt: 2, execution_order: 7, status: 'running'});
213
+ const step = makeStep({attempts: [second, first]});
214
+
215
+ const result = buildStepListModel({job: makeJob({steps: [step]})});
216
+
217
+ expect(result.entries.map((entry) => entry.id)).toEqual([first.id, second.id]);
218
+ expect(result.activeEntryId).toBe(second.id);
219
+ });
220
+
221
+ test.each(
222
+ workflowRunStatusSchema.options,
223
+ )('maps the %s step status through the shared visual', (status) => {
224
+ const visual = getStepStatusVisual(status);
225
+
226
+ expect(visual).toEqual({...getWorkflowStatusVisual(status), ripple: status === 'running'});
227
+ });
228
+
229
+ test('humanizes unknown snake_case and kebab-case statuses without throwing', () => {
230
+ expect(humanizeStatus('custom_blocked_state')).toBe('Custom blocked state');
231
+ expect(humanizeStatus('custom-blocked-state')).toBe('Custom blocked state');
232
+ expect(getStepStatusVisual('custom_blocked_state')).toMatchObject({
233
+ label: 'Custom blocked state',
234
+ dot: 'neutral',
235
+ });
236
+ });
237
+
238
+ test('preserves sorted attempt fields and visual status', () => {
239
+ const step = makeStep({
240
+ attempts: [
241
+ makeAttempt({attempt: 2, execution_order: 2, status: 'succeeded'}),
242
+ makeAttempt({attempt: 1, execution_order: 1, status: 'failed', exit_code: 1}),
243
+ ],
244
+ });
245
+
246
+ const result = buildStepListModel({job: makeJob({steps: [step]})});
247
+
248
+ expect(result.entries).toHaveLength(2);
249
+ expect(result.entries.map((entry) => entry.attempt)).toEqual([1, 2]);
250
+ expect(result.entries[1]).toMatchObject({
251
+ attempt: 2,
252
+ statusVisual: {label: 'Succeeded'},
253
+ });
254
+ });
255
+
256
+ test('orders flattened attempts by backend execution order', () => {
257
+ const step1 = makeStep({
258
+ name: 'step-1',
259
+ position: 0,
260
+ attempts: [makeAttempt({attempt: 1, execution_order: 1, status: 'succeeded'})],
261
+ });
262
+ const step2 = makeStep({
263
+ name: 'step-2',
264
+ position: 1,
265
+ attempts: [
266
+ makeAttempt({attempt: 1, execution_order: 2, status: 'failed'}),
267
+ makeAttempt({attempt: 2, execution_order: 4, status: 'succeeded'}),
268
+ ],
269
+ });
270
+ const step3 = makeStep({
271
+ name: 'step-3',
272
+ position: 2,
273
+ attempts: [
274
+ makeAttempt({attempt: 1, execution_order: 3, status: 'failed'}),
275
+ makeAttempt({attempt: 2, execution_order: 5, status: 'succeeded'}),
276
+ ],
277
+ });
278
+ const step4 = makeStep({
279
+ name: 'step-4',
280
+ position: 3,
281
+ attempts: [makeAttempt({attempt: 1, execution_order: 6, status: 'succeeded'})],
282
+ });
283
+
284
+ const result = buildStepListModel({
285
+ job: makeJob({steps: [step1, step2, step3, step4]}),
286
+ });
287
+
288
+ expect(result.entries.map((entry) => `${entry.step.label}#${entry.attempt}`)).toEqual([
289
+ 'step-1#1',
290
+ 'step-2#1',
291
+ 'step-3#1',
292
+ 'step-2#2',
293
+ 'step-3#2',
294
+ 'step-4#1',
295
+ ]);
296
+ });
297
+
298
+ test('shows restart feedback from the typed top-level attempt field', () => {
299
+ const step = makeStep({
300
+ attempts: [
301
+ makeAttempt({attempt: 1}),
302
+ makeAttempt({attempt: 2, restart_feedback: 'gate-opened'}),
303
+ ],
304
+ });
305
+
306
+ const result = buildStepListModel({job: makeJob({steps: [step]})});
307
+
308
+ expect(result.entries[1]).toMatchObject({restartFeedback: 'gate-opened'});
309
+ });
310
+
311
+ test('exposes typed step error metadata without parsing opaque attempt blobs', () => {
312
+ const step = makeStep({
313
+ status: 'failed',
314
+ error: {
315
+ message: 'Checkout failed',
316
+ category: 'setup',
317
+ reason: 'checkout_failed',
318
+ },
319
+ attempts: [
320
+ makeAttempt({
321
+ error: {message: 'Opaque nested value', exitCode: 127},
322
+ output: {tail: 'do not parse'},
323
+ gate_result: {kind: 'unknown', data: {status: 'do not parse'}},
324
+ }),
325
+ ],
326
+ });
327
+
328
+ const result = buildStepListModel({job: makeJob({steps: [step]})});
329
+
330
+ expect(result.entries[0]?.step.error).toStrictEqual({
331
+ message: 'Checkout failed',
332
+ exitCode: null,
333
+ signal: undefined,
334
+ category: 'setup',
335
+ reason: 'checkout_failed',
336
+ agentConfigIssue: undefined,
337
+ });
338
+ expect(result.entries[0]?.error).toEqual({message: 'Opaque nested value', exitCode: 127});
339
+ expect(result.entries[0]?.output).toEqual({tail: 'do not parse'});
340
+ expect(result.entries[0]?.gateResult).toEqual({
341
+ kind: 'unknown',
342
+ data: {status: 'do not parse'},
343
+ });
344
+ });
345
+
346
+ test('does not infer setup classification from step names', () => {
347
+ const step = makeStep({
348
+ name: 'checkout repository',
349
+ type: 'checkout',
350
+ attempts: [makeAttempt()],
351
+ });
352
+
353
+ const result = buildStepListModel({job: makeJob({steps: [step]})});
354
+
355
+ expect(result.entries[0]?.step.error).toBeNull();
356
+ });
357
+ });
358
+
359
+ function makeJob(overrides: JobDtoOverrides = {}): Job {
360
+ return workflowJob(overrides);
361
+ }
362
+
363
+ function makeStep(overrides: Partial<WorkflowRunStepDetailDto> = {}): WorkflowRunStepDetailDto {
364
+ return workflowStepDto(overrides);
365
+ }
366
+
367
+ function makeAttempt(overrides: Partial<StepAttemptDto> = {}): StepAttemptDto {
368
+ return workflowStepAttemptDto(overrides);
369
+ }
@@ -0,0 +1,205 @@
1
+ import {
2
+ getWorkflowStatusVisual,
3
+ type WorkflowStatusVisual,
4
+ } from '#components/workflow-status/status-visuals.js';
5
+ import {
6
+ defaultJobExecution,
7
+ isWorkflowStatus as isKnownWorkflowStatus,
8
+ type Job,
9
+ JobExecution,
10
+ type Step,
11
+ type StepAttempt,
12
+ type StepAttemptDisplayDuration,
13
+ } from '#core/workflow-run.js';
14
+
15
+ export interface StepStatusVisual extends Omit<WorkflowStatusVisual, 'kind'> {
16
+ kind: string;
17
+ ripple: boolean;
18
+ }
19
+
20
+ export interface StepAttemptModel extends StepAttempt {
21
+ displayDuration: StepAttemptDisplayDuration | null;
22
+ statusVisual: StepStatusVisual;
23
+ carriedOver: boolean;
24
+ }
25
+
26
+ export interface StepModel extends Omit<Step, 'attempts'> {
27
+ index: number;
28
+ label: string;
29
+ attempts: StepAttemptModel[];
30
+ }
31
+
32
+ export interface StepListEntryModel extends StepAttemptModel {
33
+ step: StepModel;
34
+ }
35
+
36
+ export interface StepListModel {
37
+ jobId: string;
38
+ jobName: string;
39
+ jobExecutionId: string;
40
+ stepCount: number;
41
+ activeEntryId: string | undefined;
42
+ entries: StepListEntryModel[];
43
+ }
44
+
45
+ export function buildStepListModel({
46
+ job,
47
+ jobExecution,
48
+ }: {
49
+ job: Job;
50
+ jobExecution?: JobExecution | undefined;
51
+ }): StepListModel {
52
+ const selectedJobExecution = jobExecution ?? defaultStepListJobExecution(job);
53
+ const steps = [...selectedJobExecution.steps].sort(compareSteps).map(toStepModel);
54
+ const entries = steps
55
+ .flatMap((step) => toStepEntries(step, job.carriedOver))
56
+ .sort(compareEntries);
57
+
58
+ return {
59
+ jobId: job.id,
60
+ jobName: job.name ?? job.key,
61
+ jobExecutionId: selectedJobExecution.id,
62
+ stepCount: steps.length,
63
+ activeEntryId: latestRunningEntryId(entries),
64
+ entries,
65
+ };
66
+ }
67
+
68
+ export function defaultStepListJobExecution(job: Job): JobExecution {
69
+ return defaultJobExecution(job) ?? emptyJobExecutionForJob(job);
70
+ }
71
+
72
+ export function emptyJobExecutionForJob(job: Job): JobExecution {
73
+ return new JobExecution({
74
+ id: `missing:${job.id}`,
75
+ jobId: job.id,
76
+ sequence: 1,
77
+ name: job.name ?? job.key,
78
+ status: job.status === 'skipped' ? 'cancelled' : job.status,
79
+ statusReason: job.statusReason,
80
+ triggerEvents: [],
81
+ queuedAt: null,
82
+ startedAt: null,
83
+ finishedAt: null,
84
+ timedOutAt: null,
85
+ createdAt: job.createdAt,
86
+ updatedAt: job.updatedAt,
87
+ steps: [],
88
+ });
89
+ }
90
+
91
+ export function getStepStatusVisual(status: string): StepStatusVisual {
92
+ const normalized = normalizeStatus(status);
93
+
94
+ if (isKnownWorkflowStatus(normalized)) {
95
+ const visual = getWorkflowStatusVisual(normalized);
96
+ return {...visual, ripple: normalized === 'running'};
97
+ }
98
+
99
+ return {
100
+ kind: status,
101
+ label: humanizeStatus(status),
102
+ dot: 'neutral',
103
+ badge: 'neutral',
104
+ ripple: false,
105
+ };
106
+ }
107
+
108
+ export function humanizeStatus(status: string): string {
109
+ const words = status.trim().replace(/[_-]+/g, ' ').replace(/\s+/g, ' ').toLowerCase();
110
+ if (!words) return 'Unknown';
111
+ const firstLetter = words.at(0);
112
+ return firstLetter === undefined ? 'Unknown' : firstLetter.toUpperCase() + words.slice(1);
113
+ }
114
+
115
+ function toStepModel(step: Step, index: number): StepModel {
116
+ const attempts = [...step.attempts].sort(compareAttempts).map((attempt) => ({
117
+ ...attempt,
118
+ displayDuration: attempt.displayDuration,
119
+ statusVisual: getStepStatusVisual(attempt.status),
120
+ carriedOver: false,
121
+ }));
122
+
123
+ return {
124
+ ...step,
125
+ index: index + 1,
126
+ label: stepLabel(step, index),
127
+ attempts,
128
+ };
129
+ }
130
+
131
+ function stepLabel(step: Step, index: number): string {
132
+ const name = step.name.trim();
133
+ if (name) return name;
134
+
135
+ const key = step.key?.trim();
136
+ if (key) return key;
137
+
138
+ return `Step ${index + 1}`;
139
+ }
140
+
141
+ function toStepEntries(step: StepModel, carriedOverJob: boolean): StepListEntryModel[] {
142
+ if (step.attempts.length > 0) {
143
+ return step.attempts.map((attempt) => ({
144
+ ...attempt,
145
+ step,
146
+ }));
147
+ }
148
+
149
+ if (!carriedOverJob) return [];
150
+
151
+ return [
152
+ {
153
+ id: `carried-over:${step.id}`,
154
+ stepId: step.id,
155
+ jobExecutionId: step.jobExecutionId,
156
+ attempt: step.currentAttempt,
157
+ executionOrder: step.position,
158
+ status: step.status,
159
+ exitCode: null,
160
+ output: null,
161
+ error: null,
162
+ gateResult: null,
163
+ restartFeedback: null,
164
+ startedAt: step.createdAt,
165
+ finishedAt: null,
166
+ displayDuration: null,
167
+ statusVisual: getStepStatusVisual(step.status),
168
+ carriedOver: true,
169
+ step,
170
+ },
171
+ ];
172
+ }
173
+
174
+ function compareSteps(left: Step, right: Step): number {
175
+ return (
176
+ left.position - right.position ||
177
+ (left.name ?? '').localeCompare(right.name ?? '') ||
178
+ left.id.localeCompare(right.id)
179
+ );
180
+ }
181
+
182
+ function compareAttempts(left: Step['attempts'][number], right: Step['attempts'][number]) {
183
+ return left.attempt - right.attempt || left.id.localeCompare(right.id);
184
+ }
185
+
186
+ function compareEntries(left: StepListEntryModel, right: StepListEntryModel): number {
187
+ return (
188
+ left.executionOrder - right.executionOrder ||
189
+ left.step.index - right.step.index ||
190
+ left.attempt - right.attempt ||
191
+ left.id.localeCompare(right.id)
192
+ );
193
+ }
194
+
195
+ function latestRunningEntryId(entries: readonly StepListEntryModel[]): string | undefined {
196
+ for (let index = entries.length - 1; index >= 0; index -= 1) {
197
+ const entry = entries[index];
198
+ if (entry?.statusVisual.kind === 'running') return entry.id;
199
+ }
200
+ return undefined;
201
+ }
202
+
203
+ function normalizeStatus(status: string): string {
204
+ return status.trim().toLowerCase().replace(/-/g, '_');
205
+ }