@fluidgrids/fe-sdk 0.0.0-stage → 2026.1203.8

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 (323) hide show
  1. package/README.md +564 -2
  2. package/dist/ActivityOptionsFields-C2u-hY2U.js +142 -0
  3. package/dist/AiStudioPage-B_hNTj-_.js +1137 -0
  4. package/dist/ApprovalInboxPage-ClITra3n.js +1312 -0
  5. package/dist/ChoiceSelect-LkK-uS9J.js +65 -0
  6. package/dist/ConfirmActionDialog-DHWTDRbp.js +31 -0
  7. package/dist/ConnectionFormDialog-C0kDgcrZ.js +153 -0
  8. package/dist/CreateFluidgridsTagDocument-Dtp9KPLJ.js +1055 -0
  9. package/dist/DataSinkDashboardPage-b4ezeqa6.js +278 -0
  10. package/dist/DataTablesPage-C1d9YGHz.js +5575 -0
  11. package/dist/DateTimeField-B1qR4ruo.js +51 -0
  12. package/dist/Disclosure-BNKij7-v.js +45 -0
  13. package/dist/ElementLibraryPage-8jNO6YmE.js +2256 -0
  14. package/dist/ElementLibrarySequenceDocument-B-W8SPzn.js +3979 -0
  15. package/dist/EnsureThemeProvider-BvlNjAd0.js +24 -0
  16. package/dist/EntityTagBadge-1OlP6p0c.js +25 -0
  17. package/dist/EntityTagPicker-BBrU5cE0.js +137 -0
  18. package/dist/ExecuteStepDocument-B4j1mdRT.js +189 -0
  19. package/dist/ExecutionDetailDocument-D6QuM-kp.js +875 -0
  20. package/dist/ExecutionDetailPage-D4CBtFdo.js +12217 -0
  21. package/dist/ExecutionDetailPage-DvQ667OE.d.ts +10 -0
  22. package/dist/ExecutionStatusBadge-BsDVor9t.js +221 -0
  23. package/dist/ExecutionsListDocument-Dan7ZiqB.js +459 -0
  24. package/dist/ExecutionsListPage-B3XT8ITL.js +4307 -0
  25. package/dist/FailureTriagePanel-DOJMaJ0n.js +1285 -0
  26. package/dist/FileDownloadUrlDocument-CVOYKcL5.js +92 -0
  27. package/dist/FluidGridsDocsLink-bX0Hnhxr.js +66 -0
  28. package/dist/FluidGridsMark-CE2blT7K.js +74 -0
  29. package/dist/HeldLoadRegion-BtTxbvOW.js +34 -0
  30. package/dist/HistoryPage-BLoRpJ1R.d.ts +6 -0
  31. package/dist/HistoryPage-BSBISXoj.js +2835 -0
  32. package/dist/Icon-BtQ0HXLh.js +160 -0
  33. package/dist/InsightsPage-D7ybj8N9.js +11245 -0
  34. package/dist/IsolationSetting-vy911E8b.js +1153 -0
  35. package/dist/LibraryParts-DOeNgR8A.js +413 -0
  36. package/dist/ManagedAiPolicyAuthority-BxwJ3ptd.js +40 -0
  37. package/dist/ManagedAiPolicyAuthority-DM3t3wNr.d.ts +18 -0
  38. package/dist/ManagedAiPolicyAuthorityContext-CNkxIOZ1.js +10 -0
  39. package/dist/McpTriggerServers-BCPCAOWB.js +459 -0
  40. package/dist/MissingNodesInstallModal-rO_SEDrC.js +224 -0
  41. package/dist/NavigationV2Provider-DCDt35eG.js +17 -0
  42. package/dist/NodeSchemaIntrospectionDocument-C1vAIcHd.js +95 -0
  43. package/dist/NodesPage-DEbnz9iU.d.ts +6 -0
  44. package/dist/NodesPage-O7KeeKtd.js +653 -0
  45. package/dist/OfflineIcon-TwMKYWjA.js +207 -0
  46. package/dist/OpenTemplateAsCodeButton-BhWJWIF3.js +94 -0
  47. package/dist/PaidTemplateConfirm-_G3ag6S4.js +28 -0
  48. package/dist/PublishCustomNodeAction-CIySbK4c.js +134 -0
  49. package/dist/RecordTaskDialog-BkpCDvhR.js +2078 -0
  50. package/dist/RunActionsMenu-DodOgIQm.js +59 -0
  51. package/dist/RunnerStatusPill-C1v967iq.js +24 -0
  52. package/dist/RunnersPage-dB0RSdY_.js +1929 -0
  53. package/dist/SandboxRuntimeExhaustedNotice-BFOIF93C.js +120 -0
  54. package/dist/SchedulesPage-DPWr1yvf.js +1607 -0
  55. package/dist/SearchBox-BGtYjvfs.js +49 -0
  56. package/dist/SequenceEditor-CFiHeHkR.js +497 -0
  57. package/dist/SettingsPage-0CQBNPZV.js +8695 -0
  58. package/dist/StewardPages-DAJhepen.js +47 -0
  59. package/dist/StewardRunImportPanel-Kva2DO0u.js +2844 -0
  60. package/dist/StoreTemplateCardCompact-CHn5kP7A.js +2166 -0
  61. package/dist/TagFilterSelect-CyA8QrS7.js +42 -0
  62. package/dist/TaskQueuesPage-DdnDCyat.js +3571 -0
  63. package/dist/TechnicalDetails-B0Oi4aZw.js +19 -0
  64. package/dist/TemplateConfigurationModal-CdvCYJLM.js +332 -0
  65. package/dist/TemplateDetailPanel-CbiKciuB.js +222 -0
  66. package/dist/TemplatePreview-cx7-NOeG.js +868 -0
  67. package/dist/TemplatesPage-BG3H-6v6.d.ts +10 -0
  68. package/dist/TemplatesPage-BVQpGYIV.js +3251 -0
  69. package/dist/TerminateExecutionDocument-B_HKNVrN.js +581 -0
  70. package/dist/TranslationBridge-Bd4aJKMs.d.ts +11 -0
  71. package/dist/TranslationBridge-Da-TPgQm.js +68 -0
  72. package/dist/TriggerWorkflowDocument-D9Km2Vv2.js +460 -0
  73. package/dist/UiSequencePickerSequenceDocument-BSYnSDV7.js +607 -0
  74. package/dist/UiStepScreenshot-Qh4QMyUp.js +146 -0
  75. package/dist/UsageTimeSeriesDocument-DcInx9-z.js +177 -0
  76. package/dist/VariablesPage-ChfGuW22.js +2243 -0
  77. package/dist/VersionDiffDialog-Bd2AeUwf.js +1702 -0
  78. package/dist/VersionLifecycleBar-BBeWVtz-.js +143 -0
  79. package/dist/WebhookDeliveriesPage-D66bua0j.js +1563 -0
  80. package/dist/WorkflowBuilder-B6wQD1TK.js +539 -0
  81. package/dist/WorkflowBuilder-DR4ku8Tr.js +1611 -0
  82. package/dist/WorkflowDefinitionDocument-DZLbTPUZ.js +321 -0
  83. package/dist/WorkflowEmbed-BXfFGy0i.js +708 -0
  84. package/dist/WorkflowEmbed-Cbqe1s1z.d.ts +6 -0
  85. package/dist/WorkflowPinnedDataDocument-BODT5omd.js +782 -0
  86. package/dist/WorkflowProposalCard-BruukdeF.js +96 -0
  87. package/dist/WorkflowProposalDocument-BdUbsrd0.js +620 -0
  88. package/dist/WorkflowSearchRedirect-C7zJ2MKH.js +40 -0
  89. package/dist/WorkflowSettingsDrawer-MVU1BKfY.d.ts +18 -0
  90. package/dist/WorkflowSettingsDrawer-gazs97WR.js +196 -0
  91. package/dist/WorkflowShareDialog-e8jJtLjU.js +469 -0
  92. package/dist/WorkflowVersionsDocument-DRVOp8Uj.js +3213 -0
  93. package/dist/WorkflowsList--hR2_8gf.js +4593 -0
  94. package/dist/WorkflowsList-CcNDQge5.d.ts +6 -0
  95. package/dist/WorkflowsListPageDocument-CnzcQm_o.js +934 -0
  96. package/dist/addonCatalog-CbZS4deh.js +58 -0
  97. package/dist/addonCatalog-sjlonAmR.d.ts +15 -0
  98. package/dist/addons.d.ts +3 -0
  99. package/dist/addons.js +4 -0
  100. package/dist/agent-form-Bfvm32j1.js +83 -0
  101. package/dist/agent-tools.d.ts +3 -0
  102. package/dist/agent-tools.js +5 -0
  103. package/dist/agentTools-CyL7DLOF.js +320 -0
  104. package/dist/ai-usage-BrxDgvdR.js +240 -0
  105. package/dist/aiCreditsBridge-BuE92tKo.js +49 -0
  106. package/dist/api-BKq-nIOZ.js +2286 -0
  107. package/dist/api-Ol7I8NxE.js +8289 -0
  108. package/dist/apollo-type-policies.d.ts +11 -0
  109. package/dist/apollo-type-policies.js +64 -0
  110. package/dist/askAboutBridge-ByYsQams.js +106 -0
  111. package/dist/askQuestions-Cmx7VnMm.js +742 -0
  112. package/dist/assert-rules-lfYEMc99.js +318 -0
  113. package/dist/assistant.d.ts +94 -0
  114. package/dist/assistant.js +99 -0
  115. package/dist/attach-node-helpers-HDKQOtrD.js +32 -0
  116. package/dist/badge-CXfPhoMH.js +26 -0
  117. package/dist/basil.generated-BK-EHbwN.js +10 -0
  118. package/dist/browser-steps-DMpS5TyB.js +533 -0
  119. package/dist/builderTimings-pvGnK1m-.js +510 -0
  120. package/dist/button-DG7y_FVJ.js +48 -0
  121. package/dist/canvasNoteTools-BxuP_AYO.js +137 -0
  122. package/dist/card-Bomy_1UG.js +44 -0
  123. package/dist/catalogGrid-BOrfMgi-.js +41 -0
  124. package/dist/channel-CPyQ1NR1.js +212 -0
  125. package/dist/chips-CvNrYJZa.js +27 -0
  126. package/dist/client-holder-C0M5Cfwl.js +68 -0
  127. package/dist/cn-QqidFIgr.js +10 -0
  128. package/dist/code-editor-diagnostics-Zr0cIcx1.js +46 -0
  129. package/dist/code-editor-field-x_JrY8KR.js +113 -0
  130. package/dist/codec-client-DPuD6mw7.js +515 -0
  131. package/dist/conditionBuilder-DwfEF0Q-.js +1144 -0
  132. package/dist/config-DO68jw5k.js +322 -0
  133. package/dist/constants-DgbVc24O.d.ts +296 -0
  134. package/dist/constants-DlRnHBfQ.js +217 -0
  135. package/dist/convert-browser-action-pfecelF7.js +347 -0
  136. package/dist/convert-dialog-B_o22NiJ.js +382 -0
  137. package/dist/create-workflow-first-Azg3JUdX.js +120 -0
  138. package/dist/definition-canvas-Bsda-rDT.js +31 -0
  139. package/dist/dialog-BVd152GS.js +94 -0
  140. package/dist/durable-nodes-BXyYCLxT.js +91 -0
  141. package/dist/duration-CDb7-mT_.js +33 -0
  142. package/dist/edge-mapper-wEAdGVU2.js +4477 -0
  143. package/dist/element-library-DkSlg_VE.js +727 -0
  144. package/dist/entities-I_0kio3q.js +38 -0
  145. package/dist/error-advice-QLr5NCm7.js +65 -0
  146. package/dist/errors-ClKb5sEt.js +188 -0
  147. package/dist/executions.d.ts +3 -0
  148. package/dist/executions.js +5 -0
  149. package/dist/feature-flags-B2qetXKd.js +385 -0
  150. package/dist/field-label-DPZRmE_B.js +153 -0
  151. package/dist/firstWorkflow-C_h0KMB2.js +133 -0
  152. package/dist/flags.d.ts +3 -0
  153. package/dist/flags.js +4 -0
  154. package/dist/flow-builder-DIvLOhz0.js +28038 -0
  155. package/dist/flow-store-holder-CUN7Terz.js +52 -0
  156. package/dist/fluent.generated-CA_e6-4l.js +14 -0
  157. package/dist/fluidgridsEvents-bbEQbwU6.js +175 -0
  158. package/dist/fluidgridsTheme-DUhvOgoy.js +297 -0
  159. package/dist/global-client-BQPuFrFa.js +433 -0
  160. package/dist/global-operations-BG6YgxrM.js +136 -0
  161. package/dist/graphql-types-UTYtujY9.js +21358 -0
  162. package/dist/history.d.ts +3 -0
  163. package/dist/history.js +4 -0
  164. package/dist/index-AoJAa5vU.d.ts +164958 -0
  165. package/dist/index-DEMT3iAM.d.ts +120 -0
  166. package/dist/index-ROZzNGyY.d.ts +76 -0
  167. package/dist/index.d.ts +20 -0
  168. package/dist/index.js +8123 -0
  169. package/dist/ion.generated-mbajjcAg.js +10 -0
  170. package/dist/label-Lzb8ZXf_.js +29 -0
  171. package/dist/labels-rXd9gYQz.js +1236 -0
  172. package/dist/liveCanvas-D5ytXDp8.js +103 -0
  173. package/dist/logos.generated-X6_0kjVR.js +21 -0
  174. package/dist/logs-panel-Cw0DkG0l.js +468 -0
  175. package/dist/lucide.generated-B6NVd3GT.js +29 -0
  176. package/dist/marksStore-a9oIMMot.js +175 -0
  177. package/dist/mcp-trigger-D0nRdvq5.js +307 -0
  178. package/dist/mdi.generated-D1BV74d6.js +292 -0
  179. package/dist/menus-CU3hDGYl.js +160 -0
  180. package/dist/mynaui.generated-DMWr5cXz.js +66 -0
  181. package/dist/navigation-v2.d.ts +3 -0
  182. package/dist/navigation-v2.js +5 -0
  183. package/dist/node-detail-view-Cgm5H1P-.js +1372 -0
  184. package/dist/node-editor-tab-body-CZ0fVuVP.js +187 -0
  185. package/dist/node-operation-selection-CdV3KI_V.js +3534 -0
  186. package/dist/node-registry-refresh-s3okf83X.js +27 -0
  187. package/dist/node-role-TMbnkmeP.js +132 -0
  188. package/dist/node-type-icon-BZa8n4iG.js +33 -0
  189. package/dist/nodes.d.ts +3 -0
  190. package/dist/nodes.js +4 -0
  191. package/dist/notesKey-5EaREBGA.js +12 -0
  192. package/dist/observability.d.ts +3 -0
  193. package/dist/observability.js +5 -0
  194. package/dist/offset-pages-zghoClB3.js +55 -0
  195. package/dist/operations-BBmT9ToP.js +663 -0
  196. package/dist/operations-WxRJWeqO.js +3133 -0
  197. package/dist/output-files-Ba8bu5lv.js +196 -0
  198. package/dist/page-operation-DrWuhd6Y.js +129 -0
  199. package/dist/page-twins.d.ts +13 -0
  200. package/dist/page-twins.js +186 -0
  201. package/dist/pageControlSpecs-DZJ9K37m.js +134 -0
  202. package/dist/pageControlsBridge-0pX9s-3k.js +54 -0
  203. package/dist/pageControlsBridge-DAuT3w7L.d.ts +36 -0
  204. package/dist/panels-PfBBAToE.js +346 -0
  205. package/dist/parts-B7fBcw-B.js +346 -0
  206. package/dist/popover-Dms9Vz3j.js +3389 -0
  207. package/dist/preloadable-lazy-Pp47mqQ9.js +65 -0
  208. package/dist/proactive.d.ts +66 -0
  209. package/dist/proactive.js +237 -0
  210. package/dist/quick-config-panel-DFd77xho.js +451 -0
  211. package/dist/quota-DeA_CJ2e.js +175 -0
  212. package/dist/quota.d.ts +3 -0
  213. package/dist/quota.js +4 -0
  214. package/dist/read-only-context-Dt9N9SIG.js +18 -0
  215. package/dist/relative-time-Dxt8ZIIu.js +55 -0
  216. package/dist/results-CwK_yDxK.js +325 -0
  217. package/dist/rolldown-runtime-hDbaFkMy.js +18 -0
  218. package/dist/route-data.d.ts +12 -0
  219. package/dist/route-data.js +69 -0
  220. package/dist/route-match-C-0_EnAt.d.ts +5 -0
  221. package/dist/route-match-DMkUICYV.js +41 -0
  222. package/dist/route-preload-C4DlGoCd.js +120 -0
  223. package/dist/run-display-UjLAoYqQ.js +81 -0
  224. package/dist/run-history-arGiHzGU.js +285 -0
  225. package/dist/run-list-links-DJn4Mf1T.js +98 -0
  226. package/dist/run-mode-USmM0-Uo.js +82 -0
  227. package/dist/run-parity-CWXqEJqM.js +144 -0
  228. package/dist/runsQuota-B6SyTbne.js +100 -0
  229. package/dist/runsQuota-DsniKiSg.d.ts +20 -0
  230. package/dist/safe-expression-Cw7-SCsm.js +1251 -0
  231. package/dist/save-status-store-C7nEYpfb.js +631 -0
  232. package/dist/schedule-panel-B4GYXzXQ.js +13774 -0
  233. package/dist/schedule-rules-ggVKRkBH.js +358 -0
  234. package/dist/secrets-Re_wSiE3.js +153 -0
  235. package/dist/settings.d.ts +4 -0
  236. package/dist/settings.js +6 -0
  237. package/dist/shared-DAWGGMSM.js +177 -0
  238. package/dist/sidebar-node-editor-6eSSgCzc.js +178 -0
  239. package/dist/solar.generated-CGYuUQAC.js +10 -0
  240. package/dist/stableTabbedDialog-BBhrfXGe.js +20 -0
  241. package/dist/start-url-CT6Yz96K.js +24 -0
  242. package/dist/status-CessxGpm.js +55 -0
  243. package/dist/store-icon-OctYp5zP.js +155 -0
  244. package/dist/styles-WGmTnZ2n.js +26 -0
  245. package/dist/styles.css +139 -0
  246. package/dist/svg-spinners.generated-CIPT7IhM.js +10 -0
  247. package/dist/template-code-CzN6JWNV.js +191 -0
  248. package/dist/template-graph-DLF9dygU.js +20 -0
  249. package/dist/template-preview-DcIIKOOL.js +32 -0
  250. package/dist/template-price-CdUHZRMF.js +40 -0
  251. package/dist/templates.d.ts +3 -0
  252. package/dist/templates.js +5 -0
  253. package/dist/theme-provider-CntfC4_i.js +23 -0
  254. package/dist/transient-DgZfhDfN.js +57 -0
  255. package/dist/typed-calls-C5tO03wq.js +26 -0
  256. package/dist/ui-script-By74Guk3.js +1094 -0
  257. package/dist/ui-script-editor-CqPu2bCN.js +2447 -0
  258. package/dist/ui-step-fix-8uM2_Hft.js +67 -0
  259. package/dist/ui-step-fix-store-CcO1FdRx.js +19 -0
  260. package/dist/ui-step-run-context-o7bLE6KP.js +46 -0
  261. package/dist/ui-target-editor-D2JhB_lD.js +673 -0
  262. package/dist/uiMarkTools-CSznnO1i.js +1054 -0
  263. package/dist/upgradePrompt-BAFBKKW5.js +72 -0
  264. package/dist/use-bare-node-registry-O6mKJO_n.js +11498 -0
  265. package/dist/use-browser-available-hj8wc3Kb.js +241 -0
  266. package/dist/use-edge-mapper-schemas-Bonofxow.js +496 -0
  267. package/dist/use-extension-bridge-B9ZreOkQ.js +608 -0
  268. package/dist/use-mobile-BTqCUjzS.js +27 -0
  269. package/dist/use-sdk-query-C697xZVv.js +116 -0
  270. package/dist/use-workflow-code-editor-CFoRFrZ5.js +753 -0
  271. package/dist/useActionParam-B2tU2BlY.js +85 -0
  272. package/dist/useAgentTokenStream-Bko_J0d0.js +4217 -0
  273. package/dist/useBrowserClients-3v95-gSh.js +103 -0
  274. package/dist/useCodeWorkflowInsights-w0tz9Ap_.js +600 -0
  275. package/dist/useConnections-DsgEJs05.js +439 -0
  276. package/dist/useDebouncedValue-BFekcv6n.js +18 -0
  277. package/dist/useDurableParity-8fnMZmBc.js +1787 -0
  278. package/dist/useEntityTags-D0spL6Ut.js +460 -0
  279. package/dist/useExecutions-2u5nGJJk.js +681 -0
  280. package/dist/useFluidGridsAnalytics-VM8lAi2x.js +238 -0
  281. package/dist/useGlobalStoreClient-BTdhkA2I.js +24 -0
  282. package/dist/useHumanRequests-zlYDp3l1.js +221 -0
  283. package/dist/useNavigationV2-C2WeqN7d.js +29 -0
  284. package/dist/useNavigationV2-DANUmg12.d.ts +9 -0
  285. package/dist/useObservability-BRlQ0tOA.js +285 -0
  286. package/dist/useRequestedProposal-B7uPXfZB.js +51 -0
  287. package/dist/useRunHistory-CXCMUPyf.js +2759 -0
  288. package/dist/useRunLive-D0JvVZT2.js +1060 -0
  289. package/dist/useRunnerList-Dbi59i1K.js +446 -0
  290. package/dist/useRunners-URUc5quU.js +173 -0
  291. package/dist/useRunsPage-DG656UCK.js +2709 -0
  292. package/dist/useVariables-BIelxcWr.js +463 -0
  293. package/dist/useVersionHistoryData-CTjqVw7l.js +292 -0
  294. package/dist/useWorkflowCodeExport-pqxyLHD1.js +522 -0
  295. package/dist/useWorkflowListExport-hcZNvTaB.js +232 -0
  296. package/dist/useWorkflowOrganization-CpBbOrs7.js +1772 -0
  297. package/dist/useWorkflowProposal-BH0VdNMA.js +3280 -0
  298. package/dist/useWorkflows-Cvg-Z_IE.js +1606 -0
  299. package/dist/utils-fvBb5qOD.js +89 -0
  300. package/dist/webhook-deliveries-AvQujaZy.js +99 -0
  301. package/dist/workflow-builder-CJygVkVv.d.ts +2 -0
  302. package/dist/workflow-builder.d.ts +3 -0
  303. package/dist/workflow-builder.js +8 -0
  304. package/dist/workflow-code-transfer-Bsy0JKAZ.js +323 -0
  305. package/dist/workflow-embed.d.ts +3 -0
  306. package/dist/workflow-embed.js +4 -0
  307. package/dist/workflow-git-sync--K9ZsPDC.js +263 -0
  308. package/dist/workflow-host.d.ts +6 -0
  309. package/dist/workflow-host.js +11 -0
  310. package/dist/workflow-pages-D-7ByLTB.d.ts +68 -0
  311. package/dist/workflow-pages.d.ts +3 -0
  312. package/dist/workflow-pages.js +115 -0
  313. package/dist/workflow-preview-canvas-CO8yzdE3.js +848 -0
  314. package/dist/workflow-preview.d.ts +65 -0
  315. package/dist/workflow-preview.js +4 -0
  316. package/dist/workflow-route.d.ts +33 -0
  317. package/dist/workflow-route.js +4 -0
  318. package/dist/workflow-save-state-D0l-DkLf.js +767 -0
  319. package/dist/workflow-transfer-CQnQC-ke.js +104 -0
  320. package/dist/workflowRouteData-BkfVOc-O.js +169 -0
  321. package/dist/workflows-list.d.ts +10 -0
  322. package/dist/workflows-list.js +5 -0
  323. package/package.json +320 -4
@@ -0,0 +1,2759 @@
1
+ "use client";
2
+ import { s as throwIfResultError, t as describeOperationError } from "./errors-ClKb5sEt.js";
3
+ import { n as getFluidGridsClient, r as getFluidGridsClientSafe } from "./client-holder-C0M5Cfwl.js";
4
+ import { r as useTr } from "./TranslationBridge-Da-TPgQm.js";
5
+ import { t as Icon } from "./Icon-BtQ0HXLh.js";
6
+ import { i as mergeHistoryEvents, n as groupRunHistory, r as lastSeqOf } from "./run-history-arGiHzGU.js";
7
+ import { C as RunLogsDocument, S as RunLogAppendedDocument } from "./labels-rXd9gYQz.js";
8
+ import { D as signalPayloadCard, T as payloadFromCardValues, w as parseRawSignalPayload } from "./askQuestions-Cmx7VnMm.js";
9
+ import { d as isSandboxRuntimeExhausted } from "./quota-DeA_CJ2e.js";
10
+ import { ug as ExecutionKind } from "./graphql-types-UTYtujY9.js";
11
+ import { n as errorAdvice } from "./error-advice-QLr5NCm7.js";
12
+ import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
13
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
14
+ import { cn } from "@burdenoff/fe-libs/utils";
15
+ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, EmptyState, Input, Label, Textarea, ThemedSelect } from "@burdenoff/fe-libs/ui";
16
+ import { Button as Button$1 } from "@burdenoff/fe-libs/button";
17
+ import * as AdaptiveCards from "adaptivecards";
18
+
19
+ // src/generated/documents/wspace/SignalWorkflowRunDocument.ts
20
+ const SignalWorkflowRunDocument = {
21
+ "kind": "Document",
22
+ "definitions": [{
23
+ "kind": "OperationDefinition",
24
+ "operation": "mutation",
25
+ "name": {
26
+ "kind": "Name",
27
+ "value": "SignalWorkflowRun"
28
+ },
29
+ "variableDefinitions": [
30
+ {
31
+ "kind": "VariableDefinition",
32
+ "variable": {
33
+ "kind": "Variable",
34
+ "name": {
35
+ "kind": "Name",
36
+ "value": "runId"
37
+ }
38
+ },
39
+ "type": {
40
+ "kind": "NonNullType",
41
+ "type": {
42
+ "kind": "NamedType",
43
+ "name": {
44
+ "kind": "Name",
45
+ "value": "ID"
46
+ }
47
+ }
48
+ },
49
+ "directives": []
50
+ },
51
+ {
52
+ "kind": "VariableDefinition",
53
+ "variable": {
54
+ "kind": "Variable",
55
+ "name": {
56
+ "kind": "Name",
57
+ "value": "name"
58
+ }
59
+ },
60
+ "type": {
61
+ "kind": "NonNullType",
62
+ "type": {
63
+ "kind": "NamedType",
64
+ "name": {
65
+ "kind": "Name",
66
+ "value": "String"
67
+ }
68
+ }
69
+ },
70
+ "directives": []
71
+ },
72
+ {
73
+ "kind": "VariableDefinition",
74
+ "variable": {
75
+ "kind": "Variable",
76
+ "name": {
77
+ "kind": "Name",
78
+ "value": "payload"
79
+ }
80
+ },
81
+ "type": {
82
+ "kind": "NamedType",
83
+ "name": {
84
+ "kind": "Name",
85
+ "value": "JSON"
86
+ }
87
+ },
88
+ "directives": []
89
+ },
90
+ {
91
+ "kind": "VariableDefinition",
92
+ "variable": {
93
+ "kind": "Variable",
94
+ "name": {
95
+ "kind": "Name",
96
+ "value": "idempotencyKey"
97
+ }
98
+ },
99
+ "type": {
100
+ "kind": "NamedType",
101
+ "name": {
102
+ "kind": "Name",
103
+ "value": "String"
104
+ }
105
+ },
106
+ "directives": []
107
+ }
108
+ ],
109
+ "directives": [],
110
+ "selectionSet": {
111
+ "kind": "SelectionSet",
112
+ "selections": [{
113
+ "kind": "Field",
114
+ "name": {
115
+ "kind": "Name",
116
+ "value": "signalWorkflowRun"
117
+ },
118
+ "arguments": [
119
+ {
120
+ "kind": "Argument",
121
+ "name": {
122
+ "kind": "Name",
123
+ "value": "runId"
124
+ },
125
+ "value": {
126
+ "kind": "Variable",
127
+ "name": {
128
+ "kind": "Name",
129
+ "value": "runId"
130
+ }
131
+ }
132
+ },
133
+ {
134
+ "kind": "Argument",
135
+ "name": {
136
+ "kind": "Name",
137
+ "value": "name"
138
+ },
139
+ "value": {
140
+ "kind": "Variable",
141
+ "name": {
142
+ "kind": "Name",
143
+ "value": "name"
144
+ }
145
+ }
146
+ },
147
+ {
148
+ "kind": "Argument",
149
+ "name": {
150
+ "kind": "Name",
151
+ "value": "payload"
152
+ },
153
+ "value": {
154
+ "kind": "Variable",
155
+ "name": {
156
+ "kind": "Name",
157
+ "value": "payload"
158
+ }
159
+ }
160
+ },
161
+ {
162
+ "kind": "Argument",
163
+ "name": {
164
+ "kind": "Name",
165
+ "value": "idempotencyKey"
166
+ },
167
+ "value": {
168
+ "kind": "Variable",
169
+ "name": {
170
+ "kind": "Name",
171
+ "value": "idempotencyKey"
172
+ }
173
+ }
174
+ }
175
+ ],
176
+ "directives": [],
177
+ "selectionSet": {
178
+ "kind": "SelectionSet",
179
+ "selections": [
180
+ {
181
+ "kind": "Field",
182
+ "name": {
183
+ "kind": "Name",
184
+ "value": "accepted"
185
+ },
186
+ "arguments": [],
187
+ "directives": []
188
+ },
189
+ {
190
+ "kind": "Field",
191
+ "name": {
192
+ "kind": "Name",
193
+ "value": "delivered"
194
+ },
195
+ "arguments": [],
196
+ "directives": []
197
+ },
198
+ {
199
+ "kind": "Field",
200
+ "name": {
201
+ "kind": "Name",
202
+ "value": "buffered"
203
+ },
204
+ "arguments": [],
205
+ "directives": []
206
+ },
207
+ {
208
+ "kind": "Field",
209
+ "name": {
210
+ "kind": "Name",
211
+ "value": "forwardedToRunId"
212
+ },
213
+ "arguments": [],
214
+ "directives": []
215
+ },
216
+ {
217
+ "kind": "Field",
218
+ "name": {
219
+ "kind": "Name",
220
+ "value": "seq"
221
+ },
222
+ "arguments": [],
223
+ "directives": []
224
+ },
225
+ {
226
+ "kind": "Field",
227
+ "name": {
228
+ "kind": "Name",
229
+ "value": "duplicate"
230
+ },
231
+ "arguments": [],
232
+ "directives": []
233
+ }
234
+ ]
235
+ }
236
+ }]
237
+ }
238
+ }]
239
+ };
240
+
241
+ // src/generated/documents/wspace/TerminateWorkflowRunDocument.ts
242
+ const TerminateWorkflowRunDocument = {
243
+ "kind": "Document",
244
+ "definitions": [{
245
+ "kind": "OperationDefinition",
246
+ "operation": "mutation",
247
+ "name": {
248
+ "kind": "Name",
249
+ "value": "TerminateWorkflowRun"
250
+ },
251
+ "variableDefinitions": [{
252
+ "kind": "VariableDefinition",
253
+ "variable": {
254
+ "kind": "Variable",
255
+ "name": {
256
+ "kind": "Name",
257
+ "value": "runId"
258
+ }
259
+ },
260
+ "type": {
261
+ "kind": "NonNullType",
262
+ "type": {
263
+ "kind": "NamedType",
264
+ "name": {
265
+ "kind": "Name",
266
+ "value": "ID"
267
+ }
268
+ }
269
+ },
270
+ "directives": []
271
+ }, {
272
+ "kind": "VariableDefinition",
273
+ "variable": {
274
+ "kind": "Variable",
275
+ "name": {
276
+ "kind": "Name",
277
+ "value": "reason"
278
+ }
279
+ },
280
+ "type": {
281
+ "kind": "NamedType",
282
+ "name": {
283
+ "kind": "Name",
284
+ "value": "String"
285
+ }
286
+ },
287
+ "directives": []
288
+ }],
289
+ "directives": [],
290
+ "selectionSet": {
291
+ "kind": "SelectionSet",
292
+ "selections": [{
293
+ "kind": "Field",
294
+ "name": {
295
+ "kind": "Name",
296
+ "value": "terminateWorkflowRun"
297
+ },
298
+ "arguments": [{
299
+ "kind": "Argument",
300
+ "name": {
301
+ "kind": "Name",
302
+ "value": "runId"
303
+ },
304
+ "value": {
305
+ "kind": "Variable",
306
+ "name": {
307
+ "kind": "Name",
308
+ "value": "runId"
309
+ }
310
+ }
311
+ }, {
312
+ "kind": "Argument",
313
+ "name": {
314
+ "kind": "Name",
315
+ "value": "reason"
316
+ },
317
+ "value": {
318
+ "kind": "Variable",
319
+ "name": {
320
+ "kind": "Name",
321
+ "value": "reason"
322
+ }
323
+ }
324
+ }],
325
+ "directives": [],
326
+ "selectionSet": {
327
+ "kind": "SelectionSet",
328
+ "selections": [
329
+ {
330
+ "kind": "Field",
331
+ "name": {
332
+ "kind": "Name",
333
+ "value": "id"
334
+ },
335
+ "arguments": [],
336
+ "directives": []
337
+ },
338
+ {
339
+ "kind": "Field",
340
+ "name": {
341
+ "kind": "Name",
342
+ "value": "status"
343
+ },
344
+ "arguments": [],
345
+ "directives": []
346
+ },
347
+ {
348
+ "kind": "Field",
349
+ "name": {
350
+ "kind": "Name",
351
+ "value": "completedAt"
352
+ },
353
+ "arguments": [],
354
+ "directives": []
355
+ }
356
+ ]
357
+ }
358
+ }]
359
+ }
360
+ }]
361
+ };
362
+
363
+ // src/generated/documents/wspace/DurableRunFieldsDocument.ts
364
+ const DurableRunFieldsDocument = {
365
+ "kind": "Document",
366
+ "definitions": [{
367
+ "kind": "OperationDefinition",
368
+ "operation": "query",
369
+ "name": {
370
+ "kind": "Name",
371
+ "value": "DurableRunFields"
372
+ },
373
+ "variableDefinitions": [{
374
+ "kind": "VariableDefinition",
375
+ "variable": {
376
+ "kind": "Variable",
377
+ "name": {
378
+ "kind": "Name",
379
+ "value": "id"
380
+ }
381
+ },
382
+ "type": {
383
+ "kind": "NonNullType",
384
+ "type": {
385
+ "kind": "NamedType",
386
+ "name": {
387
+ "kind": "Name",
388
+ "value": "ID"
389
+ }
390
+ }
391
+ },
392
+ "directives": []
393
+ }],
394
+ "directives": [],
395
+ "selectionSet": {
396
+ "kind": "SelectionSet",
397
+ "selections": [{
398
+ "kind": "Field",
399
+ "name": {
400
+ "kind": "Name",
401
+ "value": "workflowRun"
402
+ },
403
+ "arguments": [{
404
+ "kind": "Argument",
405
+ "name": {
406
+ "kind": "Name",
407
+ "value": "id"
408
+ },
409
+ "value": {
410
+ "kind": "Variable",
411
+ "name": {
412
+ "kind": "Name",
413
+ "value": "id"
414
+ }
415
+ }
416
+ }],
417
+ "directives": [],
418
+ "selectionSet": {
419
+ "kind": "SelectionSet",
420
+ "selections": [
421
+ {
422
+ "kind": "Field",
423
+ "name": {
424
+ "kind": "Name",
425
+ "value": "id"
426
+ },
427
+ "arguments": [],
428
+ "directives": []
429
+ },
430
+ {
431
+ "kind": "Field",
432
+ "name": {
433
+ "kind": "Name",
434
+ "value": "executionKind"
435
+ },
436
+ "arguments": [],
437
+ "directives": []
438
+ },
439
+ {
440
+ "kind": "Field",
441
+ "name": {
442
+ "kind": "Name",
443
+ "value": "workflowFn"
444
+ },
445
+ "arguments": [],
446
+ "directives": []
447
+ },
448
+ {
449
+ "kind": "Field",
450
+ "name": {
451
+ "kind": "Name",
452
+ "value": "taskQueue"
453
+ },
454
+ "arguments": [],
455
+ "directives": []
456
+ },
457
+ {
458
+ "kind": "Field",
459
+ "name": {
460
+ "kind": "Name",
461
+ "value": "buildId"
462
+ },
463
+ "arguments": [],
464
+ "directives": []
465
+ },
466
+ {
467
+ "kind": "Field",
468
+ "name": {
469
+ "kind": "Name",
470
+ "value": "historyLength"
471
+ },
472
+ "arguments": [],
473
+ "directives": []
474
+ }
475
+ ]
476
+ }
477
+ }]
478
+ }
479
+ }]
480
+ };
481
+
482
+ // src/generated/documents/wspace/WorkflowRunDeterminismStatusDocument.ts
483
+ const WorkflowRunDeterminismStatusDocument = {
484
+ "kind": "Document",
485
+ "definitions": [{
486
+ "kind": "OperationDefinition",
487
+ "operation": "query",
488
+ "name": {
489
+ "kind": "Name",
490
+ "value": "WorkflowRunDeterminismStatus"
491
+ },
492
+ "variableDefinitions": [{
493
+ "kind": "VariableDefinition",
494
+ "variable": {
495
+ "kind": "Variable",
496
+ "name": {
497
+ "kind": "Name",
498
+ "value": "runId"
499
+ }
500
+ },
501
+ "type": {
502
+ "kind": "NonNullType",
503
+ "type": {
504
+ "kind": "NamedType",
505
+ "name": {
506
+ "kind": "Name",
507
+ "value": "ID"
508
+ }
509
+ }
510
+ },
511
+ "directives": []
512
+ }],
513
+ "directives": [],
514
+ "selectionSet": {
515
+ "kind": "SelectionSet",
516
+ "selections": [{
517
+ "kind": "Field",
518
+ "name": {
519
+ "kind": "Name",
520
+ "value": "workflowRunDeterminismStatus"
521
+ },
522
+ "arguments": [{
523
+ "kind": "Argument",
524
+ "name": {
525
+ "kind": "Name",
526
+ "value": "runId"
527
+ },
528
+ "value": {
529
+ "kind": "Variable",
530
+ "name": {
531
+ "kind": "Name",
532
+ "value": "runId"
533
+ }
534
+ }
535
+ }],
536
+ "directives": [],
537
+ "selectionSet": {
538
+ "kind": "SelectionSet",
539
+ "selections": [
540
+ {
541
+ "kind": "Field",
542
+ "name": {
543
+ "kind": "Name",
544
+ "value": "failing"
545
+ },
546
+ "arguments": [],
547
+ "directives": []
548
+ },
549
+ {
550
+ "kind": "Field",
551
+ "name": {
552
+ "kind": "Name",
553
+ "value": "cause"
554
+ },
555
+ "arguments": [],
556
+ "directives": []
557
+ },
558
+ {
559
+ "kind": "Field",
560
+ "name": {
561
+ "kind": "Name",
562
+ "value": "attempts"
563
+ },
564
+ "arguments": [],
565
+ "directives": []
566
+ },
567
+ {
568
+ "kind": "Field",
569
+ "name": {
570
+ "kind": "Name",
571
+ "value": "since"
572
+ },
573
+ "arguments": [],
574
+ "directives": []
575
+ },
576
+ {
577
+ "kind": "Field",
578
+ "name": {
579
+ "kind": "Name",
580
+ "value": "lastFailureSeq"
581
+ },
582
+ "arguments": [],
583
+ "directives": []
584
+ },
585
+ {
586
+ "kind": "Field",
587
+ "name": {
588
+ "kind": "Name",
589
+ "value": "message"
590
+ },
591
+ "arguments": [],
592
+ "directives": []
593
+ }
594
+ ]
595
+ }
596
+ }]
597
+ }
598
+ }]
599
+ };
600
+
601
+ // src/generated/documents/wspace/WorkflowRunHistoryDocument.ts
602
+ const WorkflowRunHistoryDocument = {
603
+ "kind": "Document",
604
+ "definitions": [{
605
+ "kind": "OperationDefinition",
606
+ "operation": "query",
607
+ "name": {
608
+ "kind": "Name",
609
+ "value": "WorkflowRunHistory"
610
+ },
611
+ "variableDefinitions": [
612
+ {
613
+ "kind": "VariableDefinition",
614
+ "variable": {
615
+ "kind": "Variable",
616
+ "name": {
617
+ "kind": "Name",
618
+ "value": "runId"
619
+ }
620
+ },
621
+ "type": {
622
+ "kind": "NonNullType",
623
+ "type": {
624
+ "kind": "NamedType",
625
+ "name": {
626
+ "kind": "Name",
627
+ "value": "ID"
628
+ }
629
+ }
630
+ },
631
+ "directives": []
632
+ },
633
+ {
634
+ "kind": "VariableDefinition",
635
+ "variable": {
636
+ "kind": "Variable",
637
+ "name": {
638
+ "kind": "Name",
639
+ "value": "after"
640
+ }
641
+ },
642
+ "type": {
643
+ "kind": "NamedType",
644
+ "name": {
645
+ "kind": "Name",
646
+ "value": "Int"
647
+ }
648
+ },
649
+ "directives": []
650
+ },
651
+ {
652
+ "kind": "VariableDefinition",
653
+ "variable": {
654
+ "kind": "Variable",
655
+ "name": {
656
+ "kind": "Name",
657
+ "value": "limit"
658
+ }
659
+ },
660
+ "type": {
661
+ "kind": "NamedType",
662
+ "name": {
663
+ "kind": "Name",
664
+ "value": "Int"
665
+ }
666
+ },
667
+ "directives": []
668
+ }
669
+ ],
670
+ "directives": [],
671
+ "selectionSet": {
672
+ "kind": "SelectionSet",
673
+ "selections": [{
674
+ "kind": "Field",
675
+ "name": {
676
+ "kind": "Name",
677
+ "value": "workflowRunHistory"
678
+ },
679
+ "arguments": [
680
+ {
681
+ "kind": "Argument",
682
+ "name": {
683
+ "kind": "Name",
684
+ "value": "runId"
685
+ },
686
+ "value": {
687
+ "kind": "Variable",
688
+ "name": {
689
+ "kind": "Name",
690
+ "value": "runId"
691
+ }
692
+ }
693
+ },
694
+ {
695
+ "kind": "Argument",
696
+ "name": {
697
+ "kind": "Name",
698
+ "value": "after"
699
+ },
700
+ "value": {
701
+ "kind": "Variable",
702
+ "name": {
703
+ "kind": "Name",
704
+ "value": "after"
705
+ }
706
+ }
707
+ },
708
+ {
709
+ "kind": "Argument",
710
+ "name": {
711
+ "kind": "Name",
712
+ "value": "limit"
713
+ },
714
+ "value": {
715
+ "kind": "Variable",
716
+ "name": {
717
+ "kind": "Name",
718
+ "value": "limit"
719
+ }
720
+ }
721
+ }
722
+ ],
723
+ "directives": [],
724
+ "selectionSet": {
725
+ "kind": "SelectionSet",
726
+ "selections": [
727
+ {
728
+ "kind": "Field",
729
+ "name": {
730
+ "kind": "Name",
731
+ "value": "events"
732
+ },
733
+ "arguments": [],
734
+ "directives": [],
735
+ "selectionSet": {
736
+ "kind": "SelectionSet",
737
+ "selections": [{
738
+ "kind": "FragmentSpread",
739
+ "name": {
740
+ "kind": "Name",
741
+ "value": "WorkflowRunEventFields"
742
+ },
743
+ "directives": []
744
+ }]
745
+ }
746
+ },
747
+ {
748
+ "kind": "Field",
749
+ "name": {
750
+ "kind": "Name",
751
+ "value": "nextAfter"
752
+ },
753
+ "arguments": [],
754
+ "directives": []
755
+ },
756
+ {
757
+ "kind": "Field",
758
+ "name": {
759
+ "kind": "Name",
760
+ "value": "hasMore"
761
+ },
762
+ "arguments": [],
763
+ "directives": []
764
+ },
765
+ {
766
+ "kind": "Field",
767
+ "name": {
768
+ "kind": "Name",
769
+ "value": "historyLength"
770
+ },
771
+ "arguments": [],
772
+ "directives": []
773
+ },
774
+ {
775
+ "kind": "Field",
776
+ "name": {
777
+ "kind": "Name",
778
+ "value": "historyBytes"
779
+ },
780
+ "arguments": [],
781
+ "directives": []
782
+ }
783
+ ]
784
+ }
785
+ }]
786
+ }
787
+ }, {
788
+ "kind": "FragmentDefinition",
789
+ "name": {
790
+ "kind": "Name",
791
+ "value": "WorkflowRunEventFields"
792
+ },
793
+ "variableDefinitions": [],
794
+ "typeCondition": {
795
+ "kind": "NamedType",
796
+ "name": {
797
+ "kind": "Name",
798
+ "value": "WorkflowRunEvent"
799
+ }
800
+ },
801
+ "directives": [],
802
+ "selectionSet": {
803
+ "kind": "SelectionSet",
804
+ "selections": [
805
+ {
806
+ "kind": "Field",
807
+ "name": {
808
+ "kind": "Name",
809
+ "value": "runId"
810
+ },
811
+ "arguments": [],
812
+ "directives": []
813
+ },
814
+ {
815
+ "kind": "Field",
816
+ "name": {
817
+ "kind": "Name",
818
+ "value": "seq"
819
+ },
820
+ "arguments": [],
821
+ "directives": []
822
+ },
823
+ {
824
+ "kind": "Field",
825
+ "name": {
826
+ "kind": "Name",
827
+ "value": "type"
828
+ },
829
+ "arguments": [],
830
+ "directives": []
831
+ },
832
+ {
833
+ "kind": "Field",
834
+ "name": {
835
+ "kind": "Name",
836
+ "value": "taskId"
837
+ },
838
+ "arguments": [],
839
+ "directives": []
840
+ },
841
+ {
842
+ "kind": "Field",
843
+ "name": {
844
+ "kind": "Name",
845
+ "value": "payload"
846
+ },
847
+ "arguments": [],
848
+ "directives": []
849
+ },
850
+ {
851
+ "kind": "Field",
852
+ "name": {
853
+ "kind": "Name",
854
+ "value": "payloadUrl"
855
+ },
856
+ "arguments": [],
857
+ "directives": []
858
+ },
859
+ {
860
+ "kind": "Field",
861
+ "name": {
862
+ "kind": "Name",
863
+ "value": "createdAt"
864
+ },
865
+ "arguments": [],
866
+ "directives": []
867
+ }
868
+ ]
869
+ }
870
+ }]
871
+ };
872
+
873
+ // src/generated/documents/wspace/WorkflowRunStackTraceDocument.ts
874
+ const WorkflowRunStackTraceDocument = {
875
+ "kind": "Document",
876
+ "definitions": [{
877
+ "kind": "OperationDefinition",
878
+ "operation": "query",
879
+ "name": {
880
+ "kind": "Name",
881
+ "value": "WorkflowRunStackTrace"
882
+ },
883
+ "variableDefinitions": [{
884
+ "kind": "VariableDefinition",
885
+ "variable": {
886
+ "kind": "Variable",
887
+ "name": {
888
+ "kind": "Name",
889
+ "value": "runId"
890
+ }
891
+ },
892
+ "type": {
893
+ "kind": "NonNullType",
894
+ "type": {
895
+ "kind": "NamedType",
896
+ "name": {
897
+ "kind": "Name",
898
+ "value": "ID"
899
+ }
900
+ }
901
+ },
902
+ "directives": []
903
+ }, {
904
+ "kind": "VariableDefinition",
905
+ "variable": {
906
+ "kind": "Variable",
907
+ "name": {
908
+ "kind": "Name",
909
+ "value": "enhanced"
910
+ }
911
+ },
912
+ "type": {
913
+ "kind": "NamedType",
914
+ "name": {
915
+ "kind": "Name",
916
+ "value": "Boolean"
917
+ }
918
+ },
919
+ "directives": []
920
+ }],
921
+ "directives": [],
922
+ "selectionSet": {
923
+ "kind": "SelectionSet",
924
+ "selections": [{
925
+ "kind": "Field",
926
+ "name": {
927
+ "kind": "Name",
928
+ "value": "workflowRunStackTrace"
929
+ },
930
+ "arguments": [{
931
+ "kind": "Argument",
932
+ "name": {
933
+ "kind": "Name",
934
+ "value": "runId"
935
+ },
936
+ "value": {
937
+ "kind": "Variable",
938
+ "name": {
939
+ "kind": "Name",
940
+ "value": "runId"
941
+ }
942
+ }
943
+ }, {
944
+ "kind": "Argument",
945
+ "name": {
946
+ "kind": "Name",
947
+ "value": "enhanced"
948
+ },
949
+ "value": {
950
+ "kind": "Variable",
951
+ "name": {
952
+ "kind": "Name",
953
+ "value": "enhanced"
954
+ }
955
+ }
956
+ }],
957
+ "directives": [],
958
+ "selectionSet": {
959
+ "kind": "SelectionSet",
960
+ "selections": [{
961
+ "kind": "Field",
962
+ "name": {
963
+ "kind": "Name",
964
+ "value": "trace"
965
+ },
966
+ "arguments": [],
967
+ "directives": []
968
+ }, {
969
+ "kind": "Field",
970
+ "name": {
971
+ "kind": "Name",
972
+ "value": "enhanced"
973
+ },
974
+ "arguments": [],
975
+ "directives": []
976
+ }]
977
+ }
978
+ }]
979
+ }
980
+ }]
981
+ };
982
+
983
+ // src/generated/documents/wspace/RunEventAppendedDocument.ts
984
+ const RunEventAppendedDocument = {
985
+ "kind": "Document",
986
+ "definitions": [{
987
+ "kind": "OperationDefinition",
988
+ "operation": "subscription",
989
+ "name": {
990
+ "kind": "Name",
991
+ "value": "RunEventAppended"
992
+ },
993
+ "variableDefinitions": [{
994
+ "kind": "VariableDefinition",
995
+ "variable": {
996
+ "kind": "Variable",
997
+ "name": {
998
+ "kind": "Name",
999
+ "value": "runId"
1000
+ }
1001
+ },
1002
+ "type": {
1003
+ "kind": "NonNullType",
1004
+ "type": {
1005
+ "kind": "NamedType",
1006
+ "name": {
1007
+ "kind": "Name",
1008
+ "value": "ID"
1009
+ }
1010
+ }
1011
+ },
1012
+ "directives": []
1013
+ }],
1014
+ "directives": [],
1015
+ "selectionSet": {
1016
+ "kind": "SelectionSet",
1017
+ "selections": [{
1018
+ "kind": "Field",
1019
+ "name": {
1020
+ "kind": "Name",
1021
+ "value": "runEventAppended"
1022
+ },
1023
+ "arguments": [{
1024
+ "kind": "Argument",
1025
+ "name": {
1026
+ "kind": "Name",
1027
+ "value": "runId"
1028
+ },
1029
+ "value": {
1030
+ "kind": "Variable",
1031
+ "name": {
1032
+ "kind": "Name",
1033
+ "value": "runId"
1034
+ }
1035
+ }
1036
+ }],
1037
+ "directives": [],
1038
+ "selectionSet": {
1039
+ "kind": "SelectionSet",
1040
+ "selections": [{
1041
+ "kind": "FragmentSpread",
1042
+ "name": {
1043
+ "kind": "Name",
1044
+ "value": "WorkflowRunEventFields"
1045
+ },
1046
+ "directives": []
1047
+ }]
1048
+ }
1049
+ }]
1050
+ }
1051
+ }, {
1052
+ "kind": "FragmentDefinition",
1053
+ "name": {
1054
+ "kind": "Name",
1055
+ "value": "WorkflowRunEventFields"
1056
+ },
1057
+ "variableDefinitions": [],
1058
+ "typeCondition": {
1059
+ "kind": "NamedType",
1060
+ "name": {
1061
+ "kind": "Name",
1062
+ "value": "WorkflowRunEvent"
1063
+ }
1064
+ },
1065
+ "directives": [],
1066
+ "selectionSet": {
1067
+ "kind": "SelectionSet",
1068
+ "selections": [
1069
+ {
1070
+ "kind": "Field",
1071
+ "name": {
1072
+ "kind": "Name",
1073
+ "value": "runId"
1074
+ },
1075
+ "arguments": [],
1076
+ "directives": []
1077
+ },
1078
+ {
1079
+ "kind": "Field",
1080
+ "name": {
1081
+ "kind": "Name",
1082
+ "value": "seq"
1083
+ },
1084
+ "arguments": [],
1085
+ "directives": []
1086
+ },
1087
+ {
1088
+ "kind": "Field",
1089
+ "name": {
1090
+ "kind": "Name",
1091
+ "value": "type"
1092
+ },
1093
+ "arguments": [],
1094
+ "directives": []
1095
+ },
1096
+ {
1097
+ "kind": "Field",
1098
+ "name": {
1099
+ "kind": "Name",
1100
+ "value": "taskId"
1101
+ },
1102
+ "arguments": [],
1103
+ "directives": []
1104
+ },
1105
+ {
1106
+ "kind": "Field",
1107
+ "name": {
1108
+ "kind": "Name",
1109
+ "value": "payload"
1110
+ },
1111
+ "arguments": [],
1112
+ "directives": []
1113
+ },
1114
+ {
1115
+ "kind": "Field",
1116
+ "name": {
1117
+ "kind": "Name",
1118
+ "value": "payloadUrl"
1119
+ },
1120
+ "arguments": [],
1121
+ "directives": []
1122
+ },
1123
+ {
1124
+ "kind": "Field",
1125
+ "name": {
1126
+ "kind": "Name",
1127
+ "value": "createdAt"
1128
+ },
1129
+ "arguments": [],
1130
+ "directives": []
1131
+ }
1132
+ ]
1133
+ }
1134
+ }]
1135
+ };
1136
+
1137
+ // src/modules/executions/hooks/useRunLogs.ts
1138
+ /**
1139
+ * useRunLogs — a GitHub-Actions-style live tail for a workflow run.
1140
+ *
1141
+ * Two sources feed one ordered list:
1142
+ *
1143
+ * backfill `workflowRunLogs`, keyset-paginated. The source of truth, and
1144
+ * the only thing that can show a run that finished before the page
1145
+ * was opened.
1146
+ * live `runLogAppended`, which carries ONLY lines appended after the
1147
+ * subscription opens — it is a pub/sub stream with no history.
1148
+ *
1149
+ * So the order matters: query first, then subscribe, then de-duplicate by line
1150
+ * `id`. Line ids are assigned by the executor precisely so the live copy and
1151
+ * the persisted copy of a line can be matched.
1152
+ *
1153
+ * If the subscription never connects (a proxy that blocks SSE, a gateway
1154
+ * hiccup) the hook falls back to polling the cursor while the run is active,
1155
+ * so a live tail degrades to a slower live tail rather than to nothing.
1156
+ */
1157
+ /** How often to re-query when the live subscription is unavailable. */
1158
+ const POLL_INTERVAL_MS = 2e3;
1159
+ /** Page size for backfill. Large enough that a typical run arrives in one round trip. */
1160
+ const PAGE_SIZE = 500;
1161
+ function useRunLogs(runId, options = {}) {
1162
+ const { live = false, minLevel = null, includeChildRuns = false, nodeId, search } = options;
1163
+ const [lines, setLines] = useState([]);
1164
+ const [loading, setLoading] = useState(true);
1165
+ const [error, setError] = useState(null);
1166
+ const [hasMore, setHasMore] = useState(false);
1167
+ const [limitReached, setLimitReached] = useState(false);
1168
+ const [streaming, setStreaming] = useState(false);
1169
+ /**
1170
+ * Ids already rendered. A line can arrive twice — once live and once in a
1171
+ * later backfill page — and the two copies are byte-identical by design, so
1172
+ * the id is all that is needed to collapse them.
1173
+ */
1174
+ const seenIds = useRef(/* @__PURE__ */ new Set());
1175
+ /** Cursor of the newest line we hold; where the next forward read starts. */
1176
+ const cursor = useRef(null);
1177
+ const append = useCallback((incoming) => {
1178
+ if (incoming.length === 0) return;
1179
+ const fresh = incoming.filter((line) => !seenIds.current.has(line.id));
1180
+ if (fresh.length === 0) return;
1181
+ for (const line of fresh) seenIds.current.add(line.id);
1182
+ setLines((prev) => [...prev, ...fresh].sort((a, b) => a.timestamp === b.timestamp ? a.id.localeCompare(b.id) : a.timestamp.localeCompare(b.timestamp)));
1183
+ }, []);
1184
+ /** Read one page forward from `cursor`. */
1185
+ const fetchPage = useCallback(async (after) => {
1186
+ const client = getFluidGridsClientSafe();
1187
+ if (!client || !runId) return;
1188
+ const result = await client.query({
1189
+ query: RunLogsDocument,
1190
+ variables: {
1191
+ runId,
1192
+ after,
1193
+ limit: PAGE_SIZE,
1194
+ minLevel,
1195
+ includeChildRuns,
1196
+ nodeId,
1197
+ search
1198
+ },
1199
+ fetchPolicy: "network-only"
1200
+ });
1201
+ throwIfResultError(result);
1202
+ const page = result.data?.workflowRunLogs;
1203
+ if (!page) return;
1204
+ append(page.lines);
1205
+ setHasMore(page.hasMore);
1206
+ setLimitReached(page.limitReached);
1207
+ if (page.nextCursor) cursor.current = page.nextCursor;
1208
+ }, [
1209
+ runId,
1210
+ minLevel,
1211
+ includeChildRuns,
1212
+ nodeId,
1213
+ search,
1214
+ append
1215
+ ]);
1216
+ const refetch = useCallback(async () => {
1217
+ seenIds.current = /* @__PURE__ */ new Set();
1218
+ cursor.current = null;
1219
+ setLines([]);
1220
+ setLoading(true);
1221
+ setError(null);
1222
+ try {
1223
+ await fetchPage(null);
1224
+ } catch (err) {
1225
+ setError(err);
1226
+ } finally {
1227
+ setLoading(false);
1228
+ }
1229
+ }, [fetchPage]);
1230
+ const loadMore = useCallback(async () => {
1231
+ try {
1232
+ await fetchPage(cursor.current);
1233
+ } catch (err) {
1234
+ setError(err);
1235
+ }
1236
+ }, [fetchPage]);
1237
+ useEffect(() => {
1238
+ if (!runId) {
1239
+ setLoading(false);
1240
+ return;
1241
+ }
1242
+ refetch();
1243
+ }, [runId, refetch]);
1244
+ useEffect(() => {
1245
+ const client = getFluidGridsClientSafe();
1246
+ if (!runId || !live || !client) {
1247
+ setStreaming(false);
1248
+ return;
1249
+ }
1250
+ let cancelled = false;
1251
+ let poll = null;
1252
+ const startPolling = () => {
1253
+ if (poll || cancelled) return;
1254
+ setStreaming(false);
1255
+ poll = setInterval(() => {
1256
+ fetchPage(cursor.current).catch(() => {});
1257
+ }, POLL_INTERVAL_MS);
1258
+ };
1259
+ const subscription = client.subscribe({
1260
+ query: RunLogAppendedDocument,
1261
+ variables: { runId }
1262
+ }).subscribe({
1263
+ next: ({ data }) => {
1264
+ if (cancelled) return;
1265
+ setStreaming(true);
1266
+ append(data?.runLogAppended ?? []);
1267
+ },
1268
+ error: () => {
1269
+ startPolling();
1270
+ },
1271
+ complete: () => {
1272
+ if (!cancelled) startPolling();
1273
+ }
1274
+ });
1275
+ const readinessProbe = setTimeout(startPolling, POLL_INTERVAL_MS * 2);
1276
+ return () => {
1277
+ cancelled = true;
1278
+ clearTimeout(readinessProbe);
1279
+ if (poll) clearInterval(poll);
1280
+ subscription.unsubscribe();
1281
+ setStreaming(false);
1282
+ };
1283
+ }, [
1284
+ runId,
1285
+ live,
1286
+ fetchPage,
1287
+ append
1288
+ ]);
1289
+ const wasLive = useRef(false);
1290
+ useEffect(() => {
1291
+ if (live) {
1292
+ wasLive.current = true;
1293
+ return;
1294
+ }
1295
+ if (!wasLive.current) return;
1296
+ wasLive.current = false;
1297
+ fetchPage(cursor.current).catch(() => {});
1298
+ }, [live, fetchPage]);
1299
+ return {
1300
+ lines: useMemo(() => {
1301
+ if (!minLevel && !nodeId && !search) return lines;
1302
+ const order = [
1303
+ "DEBUG",
1304
+ "INFO",
1305
+ "WARN",
1306
+ "ERROR"
1307
+ ];
1308
+ const floor = minLevel ? order.indexOf(minLevel) : 0;
1309
+ const substring = search?.toLowerCase();
1310
+ return lines.filter((line) => order.indexOf(line.level) >= floor && (!nodeId || line.nodeId === nodeId) && (!substring || line.message.toLowerCase().includes(substring)));
1311
+ }, [
1312
+ lines,
1313
+ minLevel,
1314
+ nodeId,
1315
+ search
1316
+ ]),
1317
+ loading,
1318
+ error,
1319
+ hasMore,
1320
+ limitReached,
1321
+ streaming,
1322
+ loadMore,
1323
+ refetch
1324
+ };
1325
+ }
1326
+
1327
+ // src/modules/executions/components/RunHistoryView.tsx
1328
+ /**
1329
+ * The History tab of a durable-function run (BOFF-9905, spec code-first 04
1330
+ * §9), also rendered inside the code-workflow node's Trace drawer.
1331
+ *
1332
+ * One row per activity (with its attempt count), timer, child run, signal,
1333
+ * workflow task and workflow-level event, labelled by the `summary` the code
1334
+ * gave. A row expands to its raw events and payloads; an offloaded payload
1335
+ * (above 256 KiB) is a download link instead of inline JSON.
1336
+ */
1337
+ const KIND_ICONS = {
1338
+ workflow: "mdi:flag-outline",
1339
+ task: "mdi:cog-sync-outline",
1340
+ activity: "mdi:lightning-bolt-outline",
1341
+ timer: "mdi:timer-sand",
1342
+ child: "mdi:source-branch",
1343
+ signal: "mdi:bell-ring-outline",
1344
+ external: "mdi:send-outline",
1345
+ marker: "mdi:bookmark-outline",
1346
+ sideEffect: "mdi:dice-multiple-outline",
1347
+ context: "mdi:tag-text-outline",
1348
+ update: "mdi:pencil-outline",
1349
+ other: "mdi:circle-small"
1350
+ };
1351
+ /** Status chip colours: semantic status tokens only. */
1352
+ const STATUS_CLASS = {
1353
+ scheduled: "bg-surface-sunken text-text-secondary border-border-default",
1354
+ running: "bg-[var(--color-status-info-bg-subtle)] text-[var(--color-status-info-text)] border-[var(--color-status-info-border)]",
1355
+ completed: "bg-[var(--color-status-success-bg-subtle)] text-[var(--color-status-success-text)] border-[var(--color-status-success-border)]",
1356
+ fired: "bg-[var(--color-status-success-bg-subtle)] text-[var(--color-status-success-text)] border-[var(--color-status-success-border)]",
1357
+ received: "bg-[var(--color-status-success-bg-subtle)] text-[var(--color-status-success-text)] border-[var(--color-status-success-border)]",
1358
+ recorded: "bg-surface-sunken text-text-secondary border-border-default",
1359
+ failed: "bg-[var(--color-status-error-bg-subtle)] text-[var(--color-status-error-text)] border-[var(--color-status-error-border)]",
1360
+ timedOut: "bg-[var(--color-status-error-bg-subtle)] text-[var(--color-status-error-text)] border-[var(--color-status-error-border)]",
1361
+ terminated: "bg-[var(--color-status-error-bg-subtle)] text-[var(--color-status-error-text)] border-[var(--color-status-error-border)]",
1362
+ cancelRequested: "bg-[var(--color-status-warning-bg-subtle)] text-[var(--color-status-warning-text)] border-[var(--color-status-warning-border)]",
1363
+ cancelled: "bg-[var(--color-status-warning-bg-subtle)] text-[var(--color-status-warning-text)] border-[var(--color-status-warning-border)]",
1364
+ continued: "bg-[var(--color-status-info-bg-subtle)] text-[var(--color-status-info-text)] border-[var(--color-status-info-border)]"
1365
+ };
1366
+ /** A BENIGN (expected) failure: neutral grey, never the error colours. */
1367
+ const BENIGN_CLASS = "bg-surface-sunken text-text-secondary border-border-default";
1368
+ const STATUS_LABEL = {
1369
+ scheduled: ["fluidgrids.executions.history.status.scheduled", "Scheduled"],
1370
+ running: ["fluidgrids.executions.history.status.running", "Running"],
1371
+ completed: ["fluidgrids.executions.history.status.completed", "Completed"],
1372
+ failed: ["fluidgrids.executions.history.status.failed", "Failed"],
1373
+ timedOut: ["fluidgrids.executions.history.status.timedOut", "Timed out"],
1374
+ cancelled: ["fluidgrids.executions.history.status.cancelled", "Cancelled"],
1375
+ cancelRequested: ["fluidgrids.executions.history.status.cancelRequested", "Cancel requested"],
1376
+ terminated: ["fluidgrids.executions.history.status.terminated", "Terminated"],
1377
+ continued: ["fluidgrids.executions.history.status.continued", "Continued"],
1378
+ fired: ["fluidgrids.executions.history.status.fired", "Fired"],
1379
+ received: ["fluidgrids.executions.history.status.received", "Received"],
1380
+ recorded: ["fluidgrids.executions.history.status.recorded", "Recorded"]
1381
+ };
1382
+ /** Only an https link is rendered; anything else is never an href. */
1383
+ function isHttpsUrl(value) {
1384
+ if (!value) return false;
1385
+ try {
1386
+ return new URL(value).protocol === "https:";
1387
+ } catch {
1388
+ return false;
1389
+ }
1390
+ }
1391
+ function formatTime(value) {
1392
+ const date = new Date(value);
1393
+ if (Number.isNaN(date.getTime())) return value;
1394
+ return date.toLocaleTimeString("en-US", {
1395
+ hour: "2-digit",
1396
+ minute: "2-digit",
1397
+ second: "2-digit"
1398
+ });
1399
+ }
1400
+ function RunHistoryView({ events, loading, error, active, streaming, truncated = false, historyLength, onRefresh, onViewChildRun, defaultShowTasks = false, compact = false, showBenign = false, standaloneRunId, renderPayload, eventActions, "data-testid": testId = "run-history" }) {
1401
+ const tr = useTr();
1402
+ const [showTasks, setShowTasks] = useState(defaultShowTasks);
1403
+ const [expanded, setExpanded] = useState(() => /* @__PURE__ */ new Set());
1404
+ const groups = useMemo(() => groupRunHistory(events), [events]);
1405
+ const visible = useMemo(() => showTasks ? groups : groups.filter((g) => g.kind !== "task"), [groups, showTasks]);
1406
+ const toggle = (key) => setExpanded((current) => {
1407
+ const next = new Set(current);
1408
+ if (next.has(key)) next.delete(key);
1409
+ else next.add(key);
1410
+ return next;
1411
+ });
1412
+ return /* @__PURE__ */ jsxs("div", {
1413
+ "data-testid": testId,
1414
+ className: "flex flex-col gap-3",
1415
+ children: [
1416
+ /* @__PURE__ */ jsxs("div", {
1417
+ className: "flex flex-wrap items-center gap-3 text-sm text-text-secondary",
1418
+ children: [
1419
+ /* @__PURE__ */ jsx("span", {
1420
+ "data-testid": `${testId}-count`,
1421
+ children: tr("fluidgrids.executions.history.eventCount", "{{count}} events", { count: historyLength ?? events.length })
1422
+ }),
1423
+ active && /* @__PURE__ */ jsxs("span", {
1424
+ className: "flex items-center gap-1",
1425
+ children: [/* @__PURE__ */ jsx(Icon, {
1426
+ icon: streaming ? "mdi:access-point" : "mdi:refresh",
1427
+ width: 14
1428
+ }), streaming ? tr("fluidgrids.executions.history.live", "Live") : tr("fluidgrids.executions.history.polling", "Refreshing")]
1429
+ }),
1430
+ /* @__PURE__ */ jsxs("label", {
1431
+ className: "ml-auto flex items-center gap-2",
1432
+ children: [/* @__PURE__ */ jsx("input", {
1433
+ type: "checkbox",
1434
+ checked: showTasks,
1435
+ onChange: (e) => setShowTasks(e.target.checked),
1436
+ className: "h-4 w-4 rounded",
1437
+ "data-testid": `${testId}-show-tasks`
1438
+ }), tr("fluidgrids.executions.history.showTasks", "Show workflow tasks")]
1439
+ }),
1440
+ onRefresh && /* @__PURE__ */ jsxs(Button$1, {
1441
+ variant: "outline",
1442
+ size: "sm",
1443
+ onClick: onRefresh,
1444
+ children: [/* @__PURE__ */ jsx(Icon, {
1445
+ icon: "mdi:refresh",
1446
+ className: "mr-1",
1447
+ width: 16
1448
+ }), tr("fluidgrids.executions.history.refresh", "Refresh")]
1449
+ })
1450
+ ]
1451
+ }),
1452
+ error && /* @__PURE__ */ jsxs("div", {
1453
+ role: "alert",
1454
+ className: "rounded-md border border-[var(--color-status-error-border)] bg-[var(--color-status-error-bg-subtle)] p-3 text-sm text-[var(--color-status-error-text)]",
1455
+ children: [
1456
+ tr("fluidgrids.executions.history.loadError", "Could not load the run history:"),
1457
+ " ",
1458
+ error.message
1459
+ ]
1460
+ }),
1461
+ truncated && /* @__PURE__ */ jsx("div", {
1462
+ className: "rounded-md border border-[var(--color-status-warning-border)] bg-[var(--color-status-warning-bg-subtle)] p-3 text-sm text-[var(--color-status-warning-text)]",
1463
+ children: tr("fluidgrids.executions.history.truncated", "Only the first events are shown. Use fluidgrids history <runId> for the full history.")
1464
+ }),
1465
+ loading && events.length === 0 ? /* @__PURE__ */ jsx("div", {
1466
+ className: "space-y-2",
1467
+ "aria-busy": "true",
1468
+ children: [
1469
+ 0,
1470
+ 1,
1471
+ 2
1472
+ ].map((i) => /* @__PURE__ */ jsx("div", { className: "h-10 animate-pulse rounded bg-surface-sunken" }, i))
1473
+ }) : visible.length === 0 && !error ? /* @__PURE__ */ jsx(EmptyState, {
1474
+ kind: !showTasks && groups.length > 0 ? "filtered" : "first-use",
1475
+ illustration: "history",
1476
+ size: "panel",
1477
+ icon: null,
1478
+ title: tr("fluidgrids.executions.history.empty", "No events recorded yet.")
1479
+ }) : /* @__PURE__ */ jsx("ol", {
1480
+ className: "flex flex-col divide-y divide-border-default rounded-md border border-border-default",
1481
+ children: visible.map((group) => /* @__PURE__ */ jsx(HistoryRow, {
1482
+ group,
1483
+ attempts: standaloneRunId && group.kind === "activity" ? /* @__PURE__ */ jsx(StandaloneActivityAttempts, {
1484
+ runId: standaloneRunId,
1485
+ activityId: group.id,
1486
+ live: active
1487
+ }) : void 0,
1488
+ expanded: expanded.has(group.key),
1489
+ onToggle: () => toggle(group.key),
1490
+ onViewChildRun,
1491
+ compact,
1492
+ benign: showBenign && group.failure?.benign === true,
1493
+ statusLabel: tr(...STATUS_LABEL[group.status]),
1494
+ renderPayload,
1495
+ eventActions
1496
+ }, group.key))
1497
+ })
1498
+ ]
1499
+ });
1500
+ }
1501
+ function HistoryRow({ group, attempts, expanded, onToggle, onViewChildRun, compact, benign, statusLabel, renderPayload, eventActions }) {
1502
+ const tr = useTr();
1503
+ return /* @__PURE__ */ jsxs("li", {
1504
+ "data-testid": `history-group-${group.key}`,
1505
+ "data-status": group.status,
1506
+ "data-benign": benign ? "true" : void 0,
1507
+ children: [
1508
+ /* @__PURE__ */ jsxs("button", {
1509
+ type: "button",
1510
+ onClick: onToggle,
1511
+ "aria-expanded": expanded,
1512
+ className: cn("flex w-full items-center gap-3 text-left hover:bg-surface-sunken", compact ? "px-2 py-1.5" : "px-3 py-2"),
1513
+ children: [
1514
+ /* @__PURE__ */ jsx(Icon, {
1515
+ icon: expanded ? "mdi:chevron-down" : "mdi:chevron-right",
1516
+ width: 16,
1517
+ className: "shrink-0 text-text-secondary"
1518
+ }),
1519
+ /* @__PURE__ */ jsx(Icon, {
1520
+ icon: KIND_ICONS[group.kind],
1521
+ width: 16,
1522
+ className: "shrink-0 text-text-secondary"
1523
+ }),
1524
+ /* @__PURE__ */ jsxs("span", {
1525
+ className: "min-w-0 flex-1",
1526
+ children: [/* @__PURE__ */ jsx("span", {
1527
+ className: "block truncate text-sm font-medium text-text-primary",
1528
+ children: group.label
1529
+ }), group.detail && /* @__PURE__ */ jsx("span", {
1530
+ className: "block truncate font-mono text-xs text-text-secondary",
1531
+ children: group.detail
1532
+ })]
1533
+ }),
1534
+ group.attempt !== void 0 && group.attempt > 1 && /* @__PURE__ */ jsx("span", {
1535
+ className: "shrink-0 text-xs text-text-secondary",
1536
+ children: tr("fluidgrids.executions.history.attempt", "attempt {{attempt}}", { attempt: group.attempt })
1537
+ }),
1538
+ /* @__PURE__ */ jsx("span", {
1539
+ className: cn("shrink-0 rounded border px-1.5 py-0.5 text-xs", benign ? BENIGN_CLASS : STATUS_CLASS[group.status]),
1540
+ children: benign ? tr("fluidgrids.executions.history.status.benign", "Expected") : statusLabel
1541
+ }),
1542
+ !compact && /* @__PURE__ */ jsx("span", {
1543
+ className: "w-20 shrink-0 text-right font-mono text-xs text-text-secondary",
1544
+ children: formatTime(group.startedAt)
1545
+ })
1546
+ ]
1547
+ }),
1548
+ group.failure && /* @__PURE__ */ jsx("p", {
1549
+ className: cn("px-10 pb-2 text-xs", benign ? "text-text-secondary" : "text-[var(--color-status-error-text)]"),
1550
+ children: isSandboxRuntimeExhausted(group.failure.errorType) ? errorAdvice(tr, group.failure.errorType) : /* @__PURE__ */ jsxs(Fragment$1, { children: [group.failure.errorType ? `${group.failure.errorType}: ` : "", group.failure.message] })
1551
+ }),
1552
+ expanded && /* @__PURE__ */ jsxs("div", {
1553
+ className: "space-y-2 bg-surface-canvas px-10 py-2",
1554
+ children: [
1555
+ attempts,
1556
+ group.childRunId && onViewChildRun && /* @__PURE__ */ jsxs(Button$1, {
1557
+ variant: "outline",
1558
+ size: "sm",
1559
+ onClick: () => onViewChildRun(group.childRunId),
1560
+ children: [/* @__PURE__ */ jsx(Icon, {
1561
+ icon: "mdi:open-in-new",
1562
+ className: "mr-1",
1563
+ width: 14
1564
+ }), tr("fluidgrids.executions.history.openChild", "Open child run")]
1565
+ }),
1566
+ group.events.map((event) => /* @__PURE__ */ jsxs("div", {
1567
+ className: "text-xs",
1568
+ children: [/* @__PURE__ */ jsxs("div", {
1569
+ className: "flex gap-3 font-mono text-text-secondary",
1570
+ children: [
1571
+ /* @__PURE__ */ jsxs("span", { children: ["#", event.seq] }),
1572
+ /* @__PURE__ */ jsx("span", {
1573
+ className: "text-text-primary",
1574
+ children: event.type
1575
+ }),
1576
+ /* @__PURE__ */ jsx("span", {
1577
+ className: "ml-auto",
1578
+ children: formatTime(event.createdAt)
1579
+ }),
1580
+ eventActions?.(event)
1581
+ ]
1582
+ }), isHttpsUrl(event.payloadUrl) ? /* @__PURE__ */ jsx("a", {
1583
+ href: event.payloadUrl ?? void 0,
1584
+ target: "_blank",
1585
+ rel: "noreferrer noopener",
1586
+ className: "text-text-link hover:text-text-linkHover hover:underline",
1587
+ children: tr("fluidgrids.executions.history.offloadedPayload", "Download payload")
1588
+ }) : event.payload && Object.keys(event.payload).length > 0 && renderPayload ? renderPayload(event) : event.payload && Object.keys(event.payload).length > 0 ? /* @__PURE__ */ jsx("pre", {
1589
+ className: "mt-1 max-h-48 overflow-auto whitespace-pre-wrap break-words rounded bg-surface p-2 font-mono text-text-primary",
1590
+ children: JSON.stringify(event.payload, null, 2)
1591
+ }) : null]
1592
+ }, event.seq))
1593
+ ]
1594
+ })
1595
+ ]
1596
+ });
1597
+ }
1598
+ function StandaloneActivityAttempts({ runId, activityId, live }) {
1599
+ const tr = useTr();
1600
+ const logs = useRunLogs(runId, {
1601
+ nodeId: `act:${activityId}`,
1602
+ search: "Activity attempt ",
1603
+ live
1604
+ });
1605
+ const attempts = logs.lines.filter((line) => line.runId === runId && line.phase === "activity-attempt" && line.stream === "SYSTEM");
1606
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1607
+ logs.error && /* @__PURE__ */ jsx("p", {
1608
+ role: "alert",
1609
+ className: "text-xs text-text-secondary",
1610
+ children: logs.error.message
1611
+ }),
1612
+ attempts.length > 0 && /* @__PURE__ */ jsx("ol", {
1613
+ className: "space-y-1",
1614
+ children: attempts.map((line) => /* @__PURE__ */ jsxs("li", {
1615
+ "data-testid": "activity-attempt",
1616
+ className: "rounded border border-border-default p-2 text-xs",
1617
+ children: [
1618
+ /* @__PURE__ */ jsxs("strong", { children: [
1619
+ tr("fluidgrids.executions.runLogViewer.attemptTooltip", "Attempt"),
1620
+ " ",
1621
+ line.attempt
1622
+ ] }),
1623
+ /* @__PURE__ */ jsx("span", {
1624
+ className: "mx-2",
1625
+ children: line.message
1626
+ }),
1627
+ /* @__PURE__ */ jsx("time", {
1628
+ dateTime: line.timestamp,
1629
+ children: line.timestamp
1630
+ }),
1631
+ line.data != null && /* @__PURE__ */ jsx("pre", {
1632
+ className: "mt-1 whitespace-pre-wrap break-words text-text-secondary",
1633
+ children: JSON.stringify(line.data, null, 2)
1634
+ })
1635
+ ]
1636
+ }, line.id))
1637
+ }),
1638
+ logs.hasMore && /* @__PURE__ */ jsx(Button$1, {
1639
+ size: "sm",
1640
+ variant: "outline",
1641
+ onClick: () => void logs.loadMore(),
1642
+ children: tr("fluidgrids.executions.runLogViewer.loadMoreLines", "Load more lines")
1643
+ }),
1644
+ logs.limitReached && /* @__PURE__ */ jsx("p", {
1645
+ className: "text-xs text-text-secondary",
1646
+ children: tr("fluidgrids.executions.runLogViewer.limitReachedNotice", "This run hit its log limit — later lines were dropped. Reduce logging inside loops, or split the workflow into sub-workflows.")
1647
+ })
1648
+ ] });
1649
+ }
1650
+
1651
+ // src/modules/adaptive-cards/components/coerce.ts
1652
+ function optionalDeclaration(value) {
1653
+ const declaration = typeof value === "string" ? { type: value } : value;
1654
+ if (!declaration || typeof declaration !== "object" || Array.isArray(declaration)) return null;
1655
+ const fields = Object.fromEntries(Object.entries(declaration));
1656
+ if (typeof fields.type !== "string" || !/^(string|boolean|number|integer|array(?:<.+>)?|object|json)$/i.test(fields.type.trim())) return null;
1657
+ if (Object.hasOwn(fields, "required") && fields.required !== false) return null;
1658
+ return fields;
1659
+ }
1660
+ /**
1661
+ * Coerces submitted data from the card based on input types.
1662
+ * Handles Input.Number (converts to number) and Input.Toggle (converts to
1663
+ * boolean). The type map is built by walking the card body, containers,
1664
+ * column sets, and the nested cards of Action.ShowCard actions — inputs in
1665
+ * show cards are collected by getAllInputs() and must coerce identically.
1666
+ */
1667
+ function coerceSubmittedDataFromCard(submittedData, cardData, context) {
1668
+ const fieldTypeMap = {};
1669
+ const literalDefaults = /* @__PURE__ */ new Set();
1670
+ /** Fields whose numeric value must be a whole number */
1671
+ const integerFields = /* @__PURE__ */ new Set();
1672
+ function extractInputTypes(elements) {
1673
+ for (const element of elements) {
1674
+ if (element.type?.startsWith("Input") && element.id) {
1675
+ fieldTypeMap[element.id] = element.type;
1676
+ if (element.value !== void 0 && (typeof element.value !== "string" || !element.value.includes("${"))) literalDefaults.add(element.id);
1677
+ if (element.type === "Input.Number" && element.isInteger === true) integerFields.add(element.id);
1678
+ }
1679
+ if (Array.isArray(element.items)) extractInputTypes(element.items);
1680
+ if (Array.isArray(element.columns)) {
1681
+ for (const column of element.columns) if (column.items) extractInputTypes(column.items);
1682
+ }
1683
+ if (Array.isArray(element.actions)) extractFromActions(element.actions);
1684
+ }
1685
+ }
1686
+ function extractFromActions(actions) {
1687
+ for (const action of actions) {
1688
+ const nested = action?.card;
1689
+ if (nested && typeof nested === "object") {
1690
+ if (Array.isArray(nested.body)) extractInputTypes(nested.body);
1691
+ if (Array.isArray(nested.actions)) extractFromActions(nested.actions);
1692
+ }
1693
+ }
1694
+ }
1695
+ if (Array.isArray(cardData.body)) extractInputTypes(cardData.body);
1696
+ if (Array.isArray(cardData.actions)) extractFromActions(cardData.actions);
1697
+ const coercedData = {};
1698
+ for (const key in submittedData) {
1699
+ const value = submittedData[key];
1700
+ const type = fieldTypeMap[key];
1701
+ const field = key.replace(/^(?:args\.)?state\./, "");
1702
+ const declaration = optionalDeclaration(context?.inputFields?.[field]);
1703
+ if (context && declaration && !context.changedInputs.has(key)) {
1704
+ const initialKey = [
1705
+ key,
1706
+ field,
1707
+ `args.state.${field}`,
1708
+ `state.${field}`
1709
+ ].find((candidate) => Object.hasOwn(context.initialValues, candidate));
1710
+ if (initialKey !== void 0) {
1711
+ coercedData[key] = context.initialValues[initialKey];
1712
+ continue;
1713
+ }
1714
+ if (Object.hasOwn(declaration, "default")) {
1715
+ coercedData[key] = declaration.default;
1716
+ continue;
1717
+ }
1718
+ if (!literalDefaults.has(key)) continue;
1719
+ }
1720
+ switch (type) {
1721
+ case "Input.Number":
1722
+ if (value === void 0 || value === "") coercedData[key] = void 0;
1723
+ else if (integerFields.has(key)) coercedData[key] = Math.trunc(Number(value));
1724
+ else coercedData[key] = Number(value);
1725
+ break;
1726
+ case "Input.Toggle":
1727
+ coercedData[key] = value === "true" || value === true;
1728
+ break;
1729
+ default: coercedData[key] = value;
1730
+ }
1731
+ }
1732
+ return coercedData;
1733
+ }
1734
+
1735
+ // src/modules/adaptive-cards/components/index.tsx
1736
+ /** Type guard to check if card data has the expected Adaptive Card type field */
1737
+ function isAdaptiveCard(data) {
1738
+ return data.type === "AdaptiveCard";
1739
+ }
1740
+ /** Checks if card data is using a custom (non-Adaptive Card) format with inputs */
1741
+ function isCustomFormat(data) {
1742
+ const record = data;
1743
+ return record.type !== "AdaptiveCard" && "inputs" in record;
1744
+ }
1745
+ /**
1746
+ * Simple template expansion - replaces ${variable} with values from data
1747
+ * This is a lightweight alternative to adaptivecards-templating
1748
+ */
1749
+ function expandTemplate(obj, data) {
1750
+ if (typeof obj === "string") {
1751
+ const singleVarMatch = obj.match(/^\$\{([^}]+)\}$/);
1752
+ if (singleVarMatch) {
1753
+ const value = data[singleVarMatch[1].trim()];
1754
+ if (value !== void 0 && value !== null) {
1755
+ if (typeof value === "boolean") return value ? "true" : "false";
1756
+ return value;
1757
+ }
1758
+ return "";
1759
+ }
1760
+ return obj.replace(/\$\{([^}]+)\}/g, (_match, key) => {
1761
+ const value = data[key.trim()];
1762
+ if (value !== void 0 && value !== null) return String(value);
1763
+ return "";
1764
+ });
1765
+ }
1766
+ if (Array.isArray(obj)) return obj.map((item) => expandTemplate(item, data));
1767
+ if (obj !== null && typeof obj === "object") {
1768
+ const result = {};
1769
+ for (const [key, value] of Object.entries(obj)) {
1770
+ if (key === "defaultValue") continue;
1771
+ result[key] = expandTemplate(value, data);
1772
+ }
1773
+ return result;
1774
+ }
1775
+ return obj;
1776
+ }
1777
+ /**
1778
+ * Apply custom styles to override Adaptive Cards SDK inline styles
1779
+ */
1780
+ function applyCustomStyles(container) {
1781
+ const inputStyles = {
1782
+ width: "100%",
1783
+ padding: "0.5rem 0.75rem",
1784
+ fontSize: "0.875rem",
1785
+ lineHeight: "1.5",
1786
+ borderRadius: "0.375rem",
1787
+ border: "1px solid hsl(var(--input))",
1788
+ backgroundColor: "hsl(var(--background))",
1789
+ color: "hsl(var(--foreground))",
1790
+ outline: "none",
1791
+ transition: "border-color 0.2s ease, box-shadow 0.2s ease"
1792
+ };
1793
+ const addInputInteractivity = (input) => {
1794
+ const originalBorder = "1px solid hsl(var(--input))";
1795
+ input.addEventListener("mouseenter", () => {
1796
+ if (document.activeElement !== input) input.style.borderColor = "hsl(var(--foreground) / 0.3)";
1797
+ });
1798
+ input.addEventListener("mouseleave", () => {
1799
+ if (document.activeElement !== input) input.style.border = originalBorder;
1800
+ });
1801
+ input.addEventListener("focus", () => {
1802
+ input.style.borderColor = "hsl(var(--ring))";
1803
+ input.style.boxShadow = "0 0 0 2px hsl(var(--ring) / 0.2)";
1804
+ });
1805
+ input.addEventListener("blur", () => {
1806
+ input.style.border = originalBorder;
1807
+ input.style.boxShadow = "none";
1808
+ });
1809
+ };
1810
+ container.querySelectorAll(".ac-textInput, .ac-numberInput, .ac-dateInput, .ac-timeInput").forEach((input) => {
1811
+ Object.assign(input.style, inputStyles);
1812
+ addInputInteractivity(input);
1813
+ });
1814
+ container.querySelectorAll(".ac-multiline").forEach((textarea) => {
1815
+ Object.assign(textarea.style, {
1816
+ ...inputStyles,
1817
+ minHeight: "80px",
1818
+ resize: "vertical"
1819
+ });
1820
+ addInputInteractivity(textarea);
1821
+ });
1822
+ container.querySelectorAll(".ac-choiceSetInput-compact, select").forEach((select) => {
1823
+ Object.assign(select.style, {
1824
+ ...inputStyles,
1825
+ cursor: "pointer",
1826
+ appearance: "none",
1827
+ backgroundImage: `url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e")`,
1828
+ backgroundPosition: "right 0.5rem center",
1829
+ backgroundRepeat: "no-repeat",
1830
+ backgroundSize: "1.5em 1.5em",
1831
+ paddingRight: "2.5rem"
1832
+ });
1833
+ addInputInteractivity(select);
1834
+ });
1835
+ container.querySelectorAll(".ac-choiceSetInput-expanded").forEach((group) => {
1836
+ Object.assign(group.style, {
1837
+ display: "flex",
1838
+ flexDirection: "column",
1839
+ gap: "0.5rem"
1840
+ });
1841
+ });
1842
+ container.querySelectorAll("input[type=\"radio\"]").forEach((radio) => {
1843
+ Object.assign(radio.style, {
1844
+ width: "1rem",
1845
+ height: "1rem",
1846
+ accentColor: "hsl(var(--primary))",
1847
+ cursor: "pointer",
1848
+ transition: "transform 0.1s ease"
1849
+ });
1850
+ radio.addEventListener("mouseenter", () => {
1851
+ radio.style.transform = "scale(1.1)";
1852
+ });
1853
+ radio.addEventListener("mouseleave", () => {
1854
+ radio.style.transform = "scale(1)";
1855
+ });
1856
+ radio.addEventListener("focus", () => {
1857
+ radio.style.outline = "2px solid hsl(var(--ring) / 0.3)";
1858
+ radio.style.outlineOffset = "2px";
1859
+ });
1860
+ radio.addEventListener("blur", () => {
1861
+ radio.style.outline = "none";
1862
+ });
1863
+ });
1864
+ container.querySelectorAll("input[type=\"checkbox\"]").forEach((checkbox) => {
1865
+ Object.assign(checkbox.style, {
1866
+ width: "1rem",
1867
+ height: "1rem",
1868
+ accentColor: "hsl(var(--primary))",
1869
+ cursor: "pointer",
1870
+ transition: "transform 0.1s ease"
1871
+ });
1872
+ checkbox.addEventListener("mouseenter", () => {
1873
+ checkbox.style.transform = "scale(1.1)";
1874
+ });
1875
+ checkbox.addEventListener("mouseleave", () => {
1876
+ checkbox.style.transform = "scale(1)";
1877
+ });
1878
+ checkbox.addEventListener("focus", () => {
1879
+ checkbox.style.outline = "2px solid hsl(var(--ring) / 0.3)";
1880
+ checkbox.style.outlineOffset = "2px";
1881
+ });
1882
+ checkbox.addEventListener("blur", () => {
1883
+ checkbox.style.outline = "none";
1884
+ });
1885
+ });
1886
+ container.querySelectorAll(".ac-pushButton").forEach((button) => {
1887
+ Object.assign(button.style, {
1888
+ padding: "0.5rem 1rem",
1889
+ fontSize: "0.875rem",
1890
+ fontWeight: "500",
1891
+ borderRadius: "0.375rem",
1892
+ border: "none",
1893
+ backgroundColor: "hsl(var(--primary))",
1894
+ color: "hsl(var(--primary-foreground))",
1895
+ cursor: "pointer",
1896
+ transition: "background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease"
1897
+ });
1898
+ button.addEventListener("mouseenter", () => {
1899
+ button.style.backgroundColor = "hsl(var(--primary) / 0.9)";
1900
+ button.style.boxShadow = "0 2px 4px hsl(var(--primary) / 0.3)";
1901
+ });
1902
+ button.addEventListener("mouseleave", () => {
1903
+ button.style.backgroundColor = "hsl(var(--primary))";
1904
+ button.style.boxShadow = "none";
1905
+ });
1906
+ button.addEventListener("focus", () => {
1907
+ button.style.boxShadow = "0 0 0 2px hsl(var(--ring) / 0.3)";
1908
+ });
1909
+ button.addEventListener("blur", () => {
1910
+ button.style.boxShadow = "none";
1911
+ });
1912
+ button.addEventListener("mousedown", () => {
1913
+ button.style.transform = "scale(0.98)";
1914
+ });
1915
+ button.addEventListener("mouseup", () => {
1916
+ button.style.transform = "scale(1)";
1917
+ });
1918
+ });
1919
+ container.querySelectorAll(".ac-textBlock").forEach((textBlock) => {
1920
+ if (textBlock.closest(".ac-toggleInput") || textBlock.closest(".ac-choiceSetInput-expanded")) Object.assign(textBlock.style, {
1921
+ fontSize: "0.875rem",
1922
+ fontWeight: "400",
1923
+ color: "hsl(var(--foreground) / 0.8)"
1924
+ });
1925
+ else Object.assign(textBlock.style, {
1926
+ fontSize: "0.8125rem",
1927
+ fontWeight: "500",
1928
+ color: "hsl(var(--foreground) / 0.8)",
1929
+ marginBottom: "0.25rem"
1930
+ });
1931
+ });
1932
+ container.querySelectorAll(".ac-actionSet").forEach((actionSet) => {
1933
+ Object.assign(actionSet.style, {
1934
+ marginTop: "0.75rem",
1935
+ paddingTop: "0.75rem",
1936
+ borderTop: "1px solid hsl(var(--border))",
1937
+ gap: "0.5rem"
1938
+ });
1939
+ });
1940
+ container.querySelectorAll(".ac-horizontal-separator").forEach((separator) => {
1941
+ Object.assign(separator.style, { height: "0.5rem" });
1942
+ });
1943
+ container.querySelectorAll(".ac-image img").forEach((img) => {
1944
+ Object.assign(img.style, { borderRadius: "0.375rem" });
1945
+ });
1946
+ }
1947
+ /**
1948
+ * AdaptiveCardRenderer - Renders Adaptive Cards with template support
1949
+ *
1950
+ * Features:
1951
+ * - Parses Adaptive Card JSON definitions
1952
+ * - Expands templates using sample/context data
1953
+ * - Handles form submissions with automatic type coercion
1954
+ * - Manages input value changes
1955
+ */
1956
+ const AdaptiveCardRenderer = forwardRef(function AdaptiveCardRenderer({ cardData, sampleData, inputFields, onSubmit, onAction, className }, ref) {
1957
+ const cardContainerRef = useRef(null);
1958
+ const adaptiveCardInstanceRef = useRef(null);
1959
+ const initialSampleDataRef = useRef(sampleData);
1960
+ const hasRenderedRef = useRef(false);
1961
+ const submissionContextRef = useRef({
1962
+ initialValues: {},
1963
+ changedInputs: /* @__PURE__ */ new Set()
1964
+ });
1965
+ const onSubmitRef = useRef(onSubmit);
1966
+ const onActionRef = useRef(onAction);
1967
+ useEffect(() => {
1968
+ onSubmitRef.current = onSubmit;
1969
+ }, [onSubmit]);
1970
+ useEffect(() => {
1971
+ onActionRef.current = onAction;
1972
+ }, [onAction]);
1973
+ useEffect(() => {
1974
+ initialSampleDataRef.current = sampleData;
1975
+ }, [sampleData]);
1976
+ useEffect(() => {
1977
+ if (!cardData || !cardContainerRef.current) {
1978
+ adaptiveCardInstanceRef.current = null;
1979
+ return;
1980
+ }
1981
+ if (!isAdaptiveCard(cardData)) {
1982
+ console.warn("AdaptiveCardRenderer: Invalid format. Expected type \"AdaptiveCard\"");
1983
+ cardContainerRef.current.innerHTML = "";
1984
+ adaptiveCardInstanceRef.current = null;
1985
+ return;
1986
+ }
1987
+ const adaptiveCard = new AdaptiveCards.AdaptiveCard();
1988
+ adaptiveCard.hostConfig = new AdaptiveCards.HostConfig({
1989
+ fontFamily: "inherit",
1990
+ spacing: {
1991
+ small: 6,
1992
+ default: 10,
1993
+ medium: 14,
1994
+ large: 18,
1995
+ extraLarge: 22,
1996
+ padding: 12
1997
+ },
1998
+ separator: {
1999
+ lineThickness: 1,
2000
+ lineColor: "var(--color-border-default)"
2001
+ },
2002
+ containerStyles: { default: {
2003
+ backgroundColor: "transparent",
2004
+ foregroundColors: {
2005
+ default: {
2006
+ default: "var(--color-text-primary)",
2007
+ subtle: "var(--color-text-muted)"
2008
+ },
2009
+ accent: {
2010
+ default: "var(--color-text-link)",
2011
+ subtle: "var(--color-text-linkHover)"
2012
+ }
2013
+ }
2014
+ } }
2015
+ });
2016
+ let cardToRender = cardData;
2017
+ const defaultValues = cardData.defaultValue;
2018
+ const dataToUse = initialSampleDataRef.current;
2019
+ const mergedData = {
2020
+ ...defaultValues,
2021
+ ...dataToUse
2022
+ };
2023
+ const submissionContext = {
2024
+ inputFields,
2025
+ initialValues: mergedData,
2026
+ changedInputs: /* @__PURE__ */ new Set()
2027
+ };
2028
+ submissionContextRef.current = submissionContext;
2029
+ hasRenderedRef.current = true;
2030
+ cardToRender = expandTemplate(cardData, mergedData);
2031
+ adaptiveCard.parse(cardToRender);
2032
+ adaptiveCardInstanceRef.current = adaptiveCard;
2033
+ if (Object.keys(mergedData).length > 0) {
2034
+ const allInputs = adaptiveCard.getAllInputs();
2035
+ for (const input of allInputs) if (input.id && mergedData[input.id] !== void 0) {
2036
+ if (!input.value || input.value === "") input.defaultValue = String(mergedData[input.id]);
2037
+ }
2038
+ }
2039
+ adaptiveCard.onExecuteAction = (action) => {
2040
+ if (action instanceof AdaptiveCards.SubmitAction) {
2041
+ const allInputs = adaptiveCard.getAllInputs();
2042
+ const submittedData = {};
2043
+ for (const input of allInputs) if (input.id) submittedData[input.id] = input.value;
2044
+ const serializedAction = action.toJSON();
2045
+ const actionDefinition = serializedAction && typeof serializedAction === "object" ? Object.fromEntries(Object.entries(serializedAction)) : {};
2046
+ const rawActionData = inputFields ? actionDefinition.data : action.data;
2047
+ const actionData = rawActionData && typeof rawActionData === "object" ? Object.fromEntries(Object.entries(rawActionData)) : {};
2048
+ const parsedData = inputFields ? {
2049
+ ...coerceSubmittedDataFromCard(actionData, cardData),
2050
+ ...coerceSubmittedDataFromCard(submittedData, cardData, submissionContext)
2051
+ } : coerceSubmittedDataFromCard({
2052
+ ...submittedData,
2053
+ ...actionData
2054
+ }, cardData);
2055
+ onSubmitRef.current?.(parsedData);
2056
+ }
2057
+ onActionRef.current?.(action);
2058
+ };
2059
+ const renderedCard = adaptiveCard.render();
2060
+ cardContainerRef.current.innerHTML = "";
2061
+ if (renderedCard) {
2062
+ cardContainerRef.current.appendChild(renderedCard);
2063
+ applyCustomStyles(cardContainerRef.current);
2064
+ }
2065
+ const container = cardContainerRef.current;
2066
+ const markEdited = (event) => {
2067
+ if (!(event.target instanceof Node)) return;
2068
+ for (const input of adaptiveCard.getAllInputs()) if (input.id && input.renderedElement?.contains(event.target)) submissionContext.changedInputs.add(input.id);
2069
+ };
2070
+ container.addEventListener("input", markEdited, true);
2071
+ container.addEventListener("change", markEdited, true);
2072
+ return () => {
2073
+ container.removeEventListener("input", markEdited, true);
2074
+ container.removeEventListener("change", markEdited, true);
2075
+ };
2076
+ }, [cardData, inputFields]);
2077
+ useImperativeHandle(ref, () => ({
2078
+ validateInputs() {
2079
+ const adaptiveCard = adaptiveCardInstanceRef.current;
2080
+ if (!adaptiveCard) return true;
2081
+ const invalidInputs = adaptiveCard.getAllInputs().filter((input) => !input.validateValue());
2082
+ invalidInputs[0]?.focus();
2083
+ return invalidInputs.length === 0;
2084
+ },
2085
+ collectValues() {
2086
+ const adaptiveCard = adaptiveCardInstanceRef.current;
2087
+ if (!adaptiveCard || !cardData) return {};
2088
+ const collected = {};
2089
+ for (const input of adaptiveCard.getAllInputs()) if (input.id) collected[input.id] = input.value;
2090
+ return coerceSubmittedDataFromCard(collected, cardData, submissionContextRef.current);
2091
+ }
2092
+ }), [cardData]);
2093
+ if (!cardData) return null;
2094
+ if (isCustomFormat(cardData)) return /* @__PURE__ */ jsxs("div", {
2095
+ className: "p-4 border border-[var(--color-status-warning-border)] rounded bg-[var(--color-status-warning-bg-subtle)] text-sm",
2096
+ children: [
2097
+ /* @__PURE__ */ jsx("p", {
2098
+ className: "font-semibold text-[var(--color-status-warning-text)]",
2099
+ children: "Invalid Adaptive Card Format"
2100
+ }),
2101
+ /* @__PURE__ */ jsx("p", {
2102
+ className: "text-[var(--color-status-warning-text)] mt-1",
2103
+ children: "The adaptive_card is using a custom format. Please update it to use the Microsoft Adaptive Card schema."
2104
+ }),
2105
+ /* @__PURE__ */ jsxs("details", {
2106
+ className: "mt-2",
2107
+ children: [/* @__PURE__ */ jsx("summary", {
2108
+ className: "cursor-pointer text-[var(--color-status-warning-text)]",
2109
+ children: "View current data"
2110
+ }), /* @__PURE__ */ jsx("pre", {
2111
+ className: "mt-2 text-xs overflow-auto max-h-40",
2112
+ children: JSON.stringify(cardData, null, 2)
2113
+ })]
2114
+ })
2115
+ ]
2116
+ });
2117
+ return /* @__PURE__ */ jsx("div", {
2118
+ ref: cardContainerRef,
2119
+ className: cn("adaptive-card-container", className)
2120
+ });
2121
+ });
2122
+
2123
+ // src/modules/executions/hooks/useDurableRun.ts
2124
+ /**
2125
+ * Durable-function run controls for the run page (BOFF-9905): the
2126
+ * determinism status behind the banner, the built-in `__stack_trace` behind
2127
+ * the "Waiting at" panel, signals and terminate.
2128
+ *
2129
+ * Every read here is a plain network read (never the Apollo cache) because
2130
+ * all of it changes while the run executes. The hooks read nothing while
2131
+ * `enabled` is false, which the run page ties to the durable-functions flag.
2132
+ */
2133
+ async function fetchDurableRunFields(runId) {
2134
+ const result = await getFluidGridsClient().query({
2135
+ query: DurableRunFieldsDocument,
2136
+ variables: { id: runId },
2137
+ fetchPolicy: "network-only"
2138
+ });
2139
+ throwIfResultError(result);
2140
+ return result.data?.workflowRun ?? null;
2141
+ }
2142
+ /**
2143
+ * The durable-function fields of a run, read with their own query so that
2144
+ * ExecutionDetail (the run page of every canvas run) never selects fields a
2145
+ * gateway or service without durable functions does not know. Nothing is
2146
+ * read while `enabled` is false. A failed read leaves `fields` null, which
2147
+ * the page treats as a graph run: the durable views fail closed.
2148
+ *
2149
+ * The kind of a run never changes, so after a read finds a GRAPH run the
2150
+ * page's periodic refetch does not send this query again.
2151
+ */
2152
+ function useDurableRunFields(runId, enabled) {
2153
+ const [fields, setFields] = useState(null);
2154
+ const request = useRef(0);
2155
+ const isGraphRun = useRef(false);
2156
+ const read = useCallback(async () => {
2157
+ if (!runId || !enabled) return true;
2158
+ const id = ++request.current;
2159
+ try {
2160
+ const next = await fetchDurableRunFields(runId);
2161
+ if (id !== request.current) return true;
2162
+ isGraphRun.current = next?.executionKind === "GRAPH";
2163
+ setFields(next);
2164
+ return true;
2165
+ } catch {
2166
+ if (id !== request.current) return true;
2167
+ return false;
2168
+ }
2169
+ }, [runId, enabled]);
2170
+ useEffect(() => {
2171
+ request.current += 1;
2172
+ isGraphRun.current = false;
2173
+ setFields(null);
2174
+ read();
2175
+ }, [read]);
2176
+ const refetch = useCallback(async () => {
2177
+ if (isGraphRun.current) return true;
2178
+ return read();
2179
+ }, [read]);
2180
+ return {
2181
+ fields: enabled ? fields : null,
2182
+ refetch
2183
+ };
2184
+ }
2185
+ /** Re-read cadence of the determinism status while the run can change. */
2186
+ const DETERMINISM_POLL_INTERVAL_MS = 1e4;
2187
+ async function fetchDeterminismStatus(runId) {
2188
+ const result = await getFluidGridsClient().query({
2189
+ query: WorkflowRunDeterminismStatusDocument,
2190
+ variables: { runId },
2191
+ fetchPolicy: "network-only"
2192
+ });
2193
+ throwIfResultError(result);
2194
+ return result.data?.workflowRunDeterminismStatus ?? null;
2195
+ }
2196
+ async function fetchRunStackTrace(runId) {
2197
+ const result = await getFluidGridsClient().query({
2198
+ query: WorkflowRunStackTraceDocument,
2199
+ variables: {
2200
+ runId,
2201
+ enhanced: false
2202
+ },
2203
+ fetchPolicy: "network-only"
2204
+ });
2205
+ throwIfResultError(result);
2206
+ return result.data?.workflowRunStackTrace.trace ?? null;
2207
+ }
2208
+ /** A fresh key per send, so a retried click is recorded once by the service. */
2209
+ function newSignalIdempotencyKey() {
2210
+ return crypto.randomUUID();
2211
+ }
2212
+ async function sendRunSignal(input) {
2213
+ const result = await getFluidGridsClient().mutate({
2214
+ mutation: SignalWorkflowRunDocument,
2215
+ variables: {
2216
+ runId: input.runId,
2217
+ name: input.name,
2218
+ payload: input.payload,
2219
+ idempotencyKey: input.idempotencyKey
2220
+ }
2221
+ });
2222
+ throwIfResultError(result);
2223
+ const data = result.data?.signalWorkflowRun;
2224
+ if (!data) throw new Error("The signal returned no result");
2225
+ return data;
2226
+ }
2227
+ async function terminateDurableRun(runId, reason) {
2228
+ const result = await getFluidGridsClient().mutate({
2229
+ mutation: TerminateWorkflowRunDocument,
2230
+ variables: {
2231
+ runId,
2232
+ reason
2233
+ }
2234
+ });
2235
+ throwIfResultError(result);
2236
+ }
2237
+ /** The determinism status, re-read every 10 s while `live`. */
2238
+ function useDeterminismStatus(runId, { enabled, live }) {
2239
+ const [status, setStatus] = useState(null);
2240
+ const [error, setError] = useState(null);
2241
+ const request = useRef(0);
2242
+ const refetch = useCallback(async () => {
2243
+ if (!runId || !enabled) return;
2244
+ const id = ++request.current;
2245
+ try {
2246
+ const next = await fetchDeterminismStatus(runId);
2247
+ if (id !== request.current) return;
2248
+ setStatus(next);
2249
+ setError(null);
2250
+ } catch (err) {
2251
+ if (id !== request.current) return;
2252
+ setError(describeOperationError(err));
2253
+ }
2254
+ }, [runId, enabled]);
2255
+ useEffect(() => {
2256
+ request.current += 1;
2257
+ setStatus(null);
2258
+ setError(null);
2259
+ refetch();
2260
+ }, [refetch]);
2261
+ useEffect(() => {
2262
+ if (!live || !enabled || !runId) return;
2263
+ const timer = setInterval(() => {
2264
+ refetch();
2265
+ }, DETERMINISM_POLL_INTERVAL_MS);
2266
+ return () => clearInterval(timer);
2267
+ }, [
2268
+ live,
2269
+ enabled,
2270
+ runId,
2271
+ refetch
2272
+ ]);
2273
+ return {
2274
+ status,
2275
+ error,
2276
+ refetch
2277
+ };
2278
+ }
2279
+ /**
2280
+ * `__stack_trace` of an open durable run. It costs a replay in the service
2281
+ * (10 s budget, one at a time per pod), so it is read once when shown and
2282
+ * again only on request, never polled.
2283
+ */
2284
+ function useRunStackTrace(runId, enabled) {
2285
+ const [trace, setTrace] = useState(null);
2286
+ const [loading, setLoading] = useState(false);
2287
+ const [error, setError] = useState(null);
2288
+ const request = useRef(0);
2289
+ const refetch = useCallback(async () => {
2290
+ if (!runId || !enabled) return;
2291
+ const id = ++request.current;
2292
+ setLoading(true);
2293
+ try {
2294
+ const next = await fetchRunStackTrace(runId);
2295
+ if (id !== request.current) return;
2296
+ setTrace(next);
2297
+ setError(null);
2298
+ } catch (err) {
2299
+ if (id !== request.current) return;
2300
+ setError(describeOperationError(err));
2301
+ } finally {
2302
+ if (id === request.current) setLoading(false);
2303
+ }
2304
+ }, [runId, enabled]);
2305
+ useEffect(() => {
2306
+ request.current += 1;
2307
+ setTrace(null);
2308
+ setError(null);
2309
+ setLoading(false);
2310
+ refetch();
2311
+ }, [refetch]);
2312
+ return {
2313
+ trace,
2314
+ loading,
2315
+ error,
2316
+ refetch
2317
+ };
2318
+ }
2319
+
2320
+ // src/modules/executions/hooks/useOpenSnapshot.ts
2321
+ /**
2322
+ * The value a dialog was opened with (BOFF-9905).
2323
+ *
2324
+ * The run page refetches the run after a signal is sent, and the refetch can
2325
+ * change what the dialog was built from (a graph run's wait-for-signal node
2326
+ * resumes, so it is no longer a signal target). The dialog keeps showing what
2327
+ * it was opened with, including the send result, until it is closed; the next
2328
+ * opening takes the current value.
2329
+ */
2330
+ function useOpenSnapshot(open, value) {
2331
+ const [snapshot, setSnapshot] = useState(() => open ? { value } : null);
2332
+ if (open && snapshot === null) {
2333
+ setSnapshot({ value });
2334
+ return value;
2335
+ }
2336
+ if (!open && snapshot !== null) setSnapshot(null);
2337
+ return snapshot === null ? value : snapshot.value;
2338
+ }
2339
+
2340
+ // src/modules/executions/components/SignalRunDialog.tsx
2341
+ /**
2342
+ * Send a signal to a run (BOFF-9905, spec code-first 05 §9).
2343
+ *
2344
+ * The person picks one of the run's signal targets (or types a name when the
2345
+ * function accepts undeclared ones), fills the payload in an Adaptive Card
2346
+ * generated from the payload schema, or as raw JSON, and sends it with a fresh
2347
+ * idempotency key. The key is kept while the dialog stays open, so pressing
2348
+ * Send again after a network error is recorded once (`duplicate: true`).
2349
+ */
2350
+ const CUSTOM = "__custom__";
2351
+ /** The name of a signal the function did not declare. */
2352
+ function CustomSignalNameInput({ value, onChange }) {
2353
+ const tr = useTr();
2354
+ return /* @__PURE__ */ jsx(Input, {
2355
+ value,
2356
+ onChange: (e) => onChange(e.target.value),
2357
+ placeholder: tr("fluidgrids.executions.signal.namePlaceholder", "signal-name"),
2358
+ "aria-label": tr("fluidgrids.executions.signal.customNameLabel", "Signal name"),
2359
+ "data-testid": "signal-custom-name"
2360
+ });
2361
+ }
2362
+ /** Form or raw JSON payload; the active mode is announced as pressed. */
2363
+ function PayloadModeToggle({ mode, onChange }) {
2364
+ const tr = useTr();
2365
+ return /* @__PURE__ */ jsxs("div", {
2366
+ className: "flex gap-2 text-xs",
2367
+ role: "group",
2368
+ "aria-label": tr("fluidgrids.executions.signal.payloadMode", "Payload editor"),
2369
+ children: [/* @__PURE__ */ jsx(Button$1, {
2370
+ variant: mode === "form" ? "default" : "outline",
2371
+ size: "sm",
2372
+ "aria-pressed": mode === "form",
2373
+ onClick: () => onChange("form"),
2374
+ children: tr("fluidgrids.executions.signal.formMode", "Form")
2375
+ }), /* @__PURE__ */ jsx(Button$1, {
2376
+ variant: mode === "json" ? "default" : "outline",
2377
+ size: "sm",
2378
+ "aria-pressed": mode === "json",
2379
+ onClick: () => onChange("json"),
2380
+ children: tr("fluidgrids.executions.signal.jsonMode", "JSON")
2381
+ })]
2382
+ });
2383
+ }
2384
+ function SignalRunDialog({ runId, targets: currentTargets, open, onOpenChange, onSent, initialName: currentInitialName }) {
2385
+ const tr = useTr();
2386
+ const { targets, initialName } = useOpenSnapshot(open, {
2387
+ targets: currentTargets,
2388
+ initialName: currentInitialName
2389
+ });
2390
+ const firstName = initialName ?? targets.targets[0]?.name ?? CUSTOM;
2391
+ const [selected, setSelected] = useState(firstName);
2392
+ const [customName, setCustomName] = useState("");
2393
+ const [mode, setMode] = useState("form");
2394
+ const [rawPayload, setRawPayload] = useState("");
2395
+ const [error, setError] = useState(null);
2396
+ const [sending, setSending] = useState(false);
2397
+ const [result, setResult] = useState(null);
2398
+ const idempotencyKey = useRef(newSignalIdempotencyKey());
2399
+ const cardRef = useRef(null);
2400
+ useEffect(() => {
2401
+ if (!open) return;
2402
+ idempotencyKey.current = newSignalIdempotencyKey();
2403
+ setSelected(firstName);
2404
+ setCustomName("");
2405
+ setRawPayload("");
2406
+ setError(null);
2407
+ setResult(null);
2408
+ setSending(false);
2409
+ }, [open, firstName]);
2410
+ const target = targets.targets.find((t) => t.name === selected);
2411
+ const name = selected === CUSTOM ? customName.trim() : selected;
2412
+ const card = useMemo(() => signalPayloadCard(target?.payloadSchema), [target?.payloadSchema]);
2413
+ const effectiveMode = card ? mode : "json";
2414
+ useEffect(() => {
2415
+ idempotencyKey.current = newSignalIdempotencyKey();
2416
+ setResult(null);
2417
+ setError(null);
2418
+ }, [selected]);
2419
+ const send = async () => {
2420
+ setError(null);
2421
+ if (!name) {
2422
+ setError(tr("fluidgrids.executions.signal.nameRequired", "Enter a signal name."));
2423
+ return;
2424
+ }
2425
+ let payload;
2426
+ if (effectiveMode === "form" && card) {
2427
+ if (cardRef.current && !cardRef.current.validateInputs()) {
2428
+ setError(tr("fluidgrids.executions.signal.formInvalid", "Fill in the required fields."));
2429
+ return;
2430
+ }
2431
+ const parsed = payloadFromCardValues(target?.payloadSchema, cardRef.current?.collectValues() ?? {});
2432
+ if ("error" in parsed) {
2433
+ setError(parsed.error);
2434
+ return;
2435
+ }
2436
+ payload = parsed.payload;
2437
+ } else {
2438
+ const parsed = parseRawSignalPayload(rawPayload);
2439
+ if ("error" in parsed) {
2440
+ setError(tr("fluidgrids.executions.signal.jsonInvalid", "The payload is not valid JSON: {{message}}", { message: parsed.error }));
2441
+ return;
2442
+ }
2443
+ payload = parsed.payload;
2444
+ }
2445
+ setSending(true);
2446
+ try {
2447
+ const sent = await sendRunSignal({
2448
+ runId,
2449
+ name,
2450
+ payload,
2451
+ idempotencyKey: idempotencyKey.current
2452
+ });
2453
+ setResult(sent);
2454
+ onSent?.(sent);
2455
+ } catch (err) {
2456
+ setError(describeOperationError(err));
2457
+ } finally {
2458
+ setSending(false);
2459
+ }
2460
+ };
2461
+ return /* @__PURE__ */ jsx(Dialog, {
2462
+ open,
2463
+ onOpenChange,
2464
+ children: /* @__PURE__ */ jsxs(DialogContent, {
2465
+ "data-testid": "signal-run-dialog",
2466
+ className: "max-w-lg",
2467
+ children: [
2468
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: tr("fluidgrids.executions.signal.title", "Send a signal") }), /* @__PURE__ */ jsx(DialogDescription, { children: tr("fluidgrids.executions.signal.description", "The run receives the signal by name. A payload that does not match the signal's schema is refused.") })] }),
2469
+ /* @__PURE__ */ jsxs("div", {
2470
+ className: "space-y-4",
2471
+ children: [
2472
+ /* @__PURE__ */ jsxs("div", {
2473
+ className: "space-y-1",
2474
+ children: [
2475
+ /* @__PURE__ */ jsx(Label, {
2476
+ htmlFor: "signal-name",
2477
+ children: tr("fluidgrids.executions.signal.nameLabel", "Signal")
2478
+ }),
2479
+ /* @__PURE__ */ jsxs(ThemedSelect, {
2480
+ id: "signal-name",
2481
+ value: selected,
2482
+ onChange: (e) => setSelected(e.target.value),
2483
+ className: "w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground",
2484
+ "data-testid": "signal-name-select",
2485
+ children: [targets.targets.map((t) => /* @__PURE__ */ jsx("option", {
2486
+ value: t.name,
2487
+ children: t.name
2488
+ }, `${t.nodeId ?? ""}:${t.name}`)), targets.openNames && /* @__PURE__ */ jsx("option", {
2489
+ value: CUSTOM,
2490
+ children: tr("fluidgrids.executions.signal.otherName", "Another name…")
2491
+ })]
2492
+ }),
2493
+ selected === CUSTOM && /* @__PURE__ */ jsx(CustomSignalNameInput, {
2494
+ value: customName,
2495
+ onChange: setCustomName
2496
+ })
2497
+ ]
2498
+ }),
2499
+ card && /* @__PURE__ */ jsx(PayloadModeToggle, {
2500
+ mode: effectiveMode,
2501
+ onChange: setMode
2502
+ }),
2503
+ effectiveMode === "form" && card ? /* @__PURE__ */ jsx(AdaptiveCardRenderer, {
2504
+ ref: cardRef,
2505
+ cardData: card
2506
+ }) : /* @__PURE__ */ jsxs("div", {
2507
+ className: "space-y-1",
2508
+ children: [/* @__PURE__ */ jsx(Label, {
2509
+ htmlFor: "signal-payload",
2510
+ children: tr("fluidgrids.executions.signal.payloadLabel", "Payload (JSON)")
2511
+ }), /* @__PURE__ */ jsx(Textarea, {
2512
+ id: "signal-payload",
2513
+ value: rawPayload,
2514
+ onChange: (e) => setRawPayload(e.target.value),
2515
+ rows: 6,
2516
+ className: "font-mono text-sm",
2517
+ placeholder: "{ \"approved\": true }",
2518
+ "data-testid": "signal-payload-json"
2519
+ })]
2520
+ }),
2521
+ error && /* @__PURE__ */ jsx("p", {
2522
+ role: "alert",
2523
+ className: "text-sm text-[var(--color-status-error-text)]",
2524
+ children: error
2525
+ }),
2526
+ result && /* @__PURE__ */ jsxs("p", {
2527
+ "data-testid": "signal-result",
2528
+ className: "flex items-center gap-2 text-sm text-[var(--color-status-success-text)]",
2529
+ children: [/* @__PURE__ */ jsx(Icon, {
2530
+ icon: "mdi:check-circle-outline",
2531
+ width: 16
2532
+ }), result.duplicate ? tr("fluidgrids.executions.signal.duplicate", "Already sent; the run recorded it once.") : result.buffered ? tr("fluidgrids.executions.signal.buffered", "Sent. The run will receive it when it reaches its wait.") : result.forwardedToRunId ? tr("fluidgrids.executions.signal.forwarded", "Sent to the child run that is waiting for it.") : tr("fluidgrids.executions.signal.delivered", "Sent and delivered.")]
2533
+ })
2534
+ ]
2535
+ }),
2536
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button$1, {
2537
+ variant: "outline",
2538
+ onClick: () => onOpenChange(false),
2539
+ children: result ? tr("fluidgrids.executions.signal.close", "Close") : tr("fluidgrids.executions.signal.cancel", "Cancel")
2540
+ }), !result && /* @__PURE__ */ jsx(Button$1, {
2541
+ onClick: () => void send(),
2542
+ disabled: sending,
2543
+ "data-testid": "signal-send",
2544
+ children: sending ? tr("fluidgrids.executions.signal.sending", "Sending...") : tr("fluidgrids.executions.signal.send", "Send")
2545
+ })] })
2546
+ ]
2547
+ })
2548
+ });
2549
+ }
2550
+
2551
+ // src/modules/executions/hooks/useRunHistory.ts
2552
+ /**
2553
+ * useRunHistory — the event history of a durable-function run, kept live
2554
+ * (BOFF-9905, spec code-first 04 §9). Modelled on useRunLogs.
2555
+ *
2556
+ * Two sources feed one seq-ordered list:
2557
+ *
2558
+ * backfill `workflowRunHistory`, paged by seq (`after`). The source of
2559
+ * truth, and the only way to see events appended before the page
2560
+ * was opened. The whole history is read (at most 10,000 events
2561
+ * by default, 20 pages).
2562
+ * live `runEventAppended`, which carries only events appended after the
2563
+ * subscription opens.
2564
+ *
2565
+ * Events are de-duplicated by `seq`, which the service assigns gaplessly under
2566
+ * the run-row lock, so a live copy and a backfilled copy are the same event.
2567
+ * When the subscription errors or completes while the run is live, the hook
2568
+ * polls from the last seq held every 2 s. An open subscription that has not
2569
+ * delivered yet (a run parked on a signal or a timer can be quiet for hours)
2570
+ * is not treated as broken: it gets a sparse safety read with backoff
2571
+ * (15 s, doubling to 2 min), which stops at the first live event.
2572
+ */
2573
+ /** How often to re-read when the live subscription is unavailable. */
2574
+ const RUN_HISTORY_POLL_INTERVAL_MS = 2e3;
2575
+ /** First safety read while an open subscription has not delivered yet. */
2576
+ const RUN_HISTORY_SAFETY_READ_INITIAL_MS = 15e3;
2577
+ /** Longest gap between safety reads. */
2578
+ const RUN_HISTORY_SAFETY_READ_MAX_MS = 12e4;
2579
+ /** The service's page size cap. */
2580
+ const RUN_HISTORY_PAGE_SIZE = 500;
2581
+ /** Pages read in one backfill (the default history cap is 10,000 events). */
2582
+ const RUN_HISTORY_MAX_PAGES = 20;
2583
+ function toEvents(events) {
2584
+ return events.map((event) => ({
2585
+ runId: event.runId,
2586
+ seq: event.seq,
2587
+ type: event.type,
2588
+ taskId: event.taskId ?? null,
2589
+ payload: event.payload ?? null,
2590
+ payloadUrl: event.payloadUrl ?? null,
2591
+ createdAt: event.createdAt
2592
+ }));
2593
+ }
2594
+ function useRunHistory(runId, options = {}) {
2595
+ const { live = false, enabled = true } = options;
2596
+ const [events, setEvents] = useState([]);
2597
+ const [loading, setLoading] = useState(enabled && !!runId);
2598
+ const [error, setError] = useState(null);
2599
+ const [truncated, setTruncated] = useState(false);
2600
+ const [historyLength, setHistoryLength] = useState(null);
2601
+ const [streaming, setStreaming] = useState(false);
2602
+ /** The newest seq held; where the next forward read starts. */
2603
+ const cursor = useRef(0);
2604
+ /** Bumped on every reset so a read for an older run is dropped. */
2605
+ const generation = useRef(0);
2606
+ const append = useCallback((incoming) => {
2607
+ if (!incoming.length) return;
2608
+ setEvents((current) => {
2609
+ const next = mergeHistoryEvents(current, incoming);
2610
+ cursor.current = Math.max(cursor.current, lastSeqOf(next));
2611
+ return next;
2612
+ });
2613
+ }, []);
2614
+ /** Reads forward from `cursor` until the service reports no more (or the cap). */
2615
+ const readForward = useCallback(async (maxPages) => {
2616
+ const client = getFluidGridsClientSafe();
2617
+ if (!client || !runId) return;
2618
+ const started = generation.current;
2619
+ for (let page = 0; page < maxPages; page += 1) {
2620
+ const result = await client.query({
2621
+ query: WorkflowRunHistoryDocument,
2622
+ variables: {
2623
+ runId,
2624
+ after: cursor.current,
2625
+ limit: 500
2626
+ },
2627
+ fetchPolicy: "network-only"
2628
+ });
2629
+ throwIfResultError(result);
2630
+ if (generation.current !== started) return;
2631
+ const pageData = result.data?.workflowRunHistory;
2632
+ if (!pageData) return;
2633
+ const fresh = toEvents(pageData.events);
2634
+ append(fresh);
2635
+ cursor.current = Math.max(cursor.current, lastSeqOf(fresh), pageData.nextAfter ?? 0);
2636
+ setHistoryLength(pageData.historyLength);
2637
+ if (!pageData.hasMore || fresh.length === 0) {
2638
+ setTruncated(false);
2639
+ return;
2640
+ }
2641
+ if (page === maxPages - 1) setTruncated(true);
2642
+ }
2643
+ }, [runId, append]);
2644
+ const refetch = useCallback(async () => {
2645
+ generation.current += 1;
2646
+ cursor.current = 0;
2647
+ setEvents([]);
2648
+ setTruncated(false);
2649
+ setError(null);
2650
+ setLoading(true);
2651
+ try {
2652
+ await readForward(20);
2653
+ } catch (err) {
2654
+ setError(err instanceof Error ? err : new Error(String(err)));
2655
+ } finally {
2656
+ setLoading(false);
2657
+ }
2658
+ }, [readForward]);
2659
+ useEffect(() => {
2660
+ if (!runId || !enabled) {
2661
+ generation.current += 1;
2662
+ cursor.current = 0;
2663
+ setEvents([]);
2664
+ setLoading(false);
2665
+ return;
2666
+ }
2667
+ refetch();
2668
+ }, [
2669
+ runId,
2670
+ enabled,
2671
+ refetch
2672
+ ]);
2673
+ useEffect(() => {
2674
+ const client = getFluidGridsClientSafe();
2675
+ if (!runId || !enabled || !live || !client) {
2676
+ setStreaming(false);
2677
+ return;
2678
+ }
2679
+ let cancelled = false;
2680
+ let poll = null;
2681
+ let safetyRead = null;
2682
+ let delivered = false;
2683
+ const stopSafetyReads = () => {
2684
+ if (safetyRead) clearTimeout(safetyRead);
2685
+ safetyRead = null;
2686
+ };
2687
+ const startPolling = () => {
2688
+ stopSafetyReads();
2689
+ if (poll || cancelled) return;
2690
+ setStreaming(false);
2691
+ poll = setInterval(() => {
2692
+ readForward(1).catch(() => {});
2693
+ }, RUN_HISTORY_POLL_INTERVAL_MS);
2694
+ };
2695
+ const scheduleSafetyRead = (delay) => {
2696
+ safetyRead = setTimeout(() => {
2697
+ safetyRead = null;
2698
+ if (cancelled || delivered || poll) return;
2699
+ readForward(1).catch(() => {});
2700
+ scheduleSafetyRead(Math.min(delay * 2, RUN_HISTORY_SAFETY_READ_MAX_MS));
2701
+ }, delay);
2702
+ };
2703
+ const subscription = client.subscribe({
2704
+ query: RunEventAppendedDocument,
2705
+ variables: { runId }
2706
+ }).subscribe({
2707
+ next: ({ data }) => {
2708
+ if (cancelled || !data?.runEventAppended) return;
2709
+ delivered = true;
2710
+ stopSafetyReads();
2711
+ if (poll) {
2712
+ clearInterval(poll);
2713
+ poll = null;
2714
+ }
2715
+ setStreaming(true);
2716
+ append(toEvents([data.runEventAppended]));
2717
+ },
2718
+ error: () => startPolling(),
2719
+ complete: () => {
2720
+ if (!cancelled) startPolling();
2721
+ }
2722
+ });
2723
+ scheduleSafetyRead(RUN_HISTORY_SAFETY_READ_INITIAL_MS);
2724
+ return () => {
2725
+ cancelled = true;
2726
+ stopSafetyReads();
2727
+ if (poll) clearInterval(poll);
2728
+ subscription.unsubscribe();
2729
+ setStreaming(false);
2730
+ };
2731
+ }, [
2732
+ runId,
2733
+ enabled,
2734
+ live,
2735
+ readForward,
2736
+ append
2737
+ ]);
2738
+ const wasLive = useRef(false);
2739
+ useEffect(() => {
2740
+ if (live) {
2741
+ wasLive.current = true;
2742
+ return;
2743
+ }
2744
+ if (!wasLive.current) return;
2745
+ wasLive.current = false;
2746
+ readForward(20).catch(() => {});
2747
+ }, [live, readForward]);
2748
+ return {
2749
+ events,
2750
+ loading,
2751
+ error,
2752
+ truncated,
2753
+ historyLength,
2754
+ streaming,
2755
+ refetch
2756
+ };
2757
+ }
2758
+
2759
+ export { useDurableRunFields as a, useRunLogs as c, WorkflowRunHistoryDocument as d, WorkflowRunDeterminismStatusDocument as f, SignalWorkflowRunDocument as h, useDeterminismStatus as i, RunEventAppendedDocument as l, TerminateWorkflowRunDocument as m, SignalRunDialog as n, useRunStackTrace as o, DurableRunFieldsDocument as p, terminateDurableRun as r, RunHistoryView as s, useRunHistory as t, WorkflowRunStackTraceDocument as u };