@powerhousedao/workflow 6.2.3-dev.83 → 6.2.3-dev.85

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 (142) hide show
  1. package/README.md +3 -1
  2. package/dist/browser/{BlockSelector-DHVzUGjW.js → BlockSelector-BKAJwJ4Y.js} +77 -8
  3. package/dist/browser/BlockSelector-BKAJwJ4Y.js.map +1 -0
  4. package/dist/browser/{PieceMarkdown-U6OUTwRi.js → PieceMarkdown-DSdZd-Jc.js} +34 -8
  5. package/dist/browser/PieceMarkdown-DSdZd-Jc.js.map +1 -0
  6. package/dist/browser/{connection-form-D2qAEHsl.js → connection-form-DltdMa8F.js} +3 -3
  7. package/dist/browser/{connection-form-D2qAEHsl.js.map → connection-form-DltdMa8F.js.map} +1 -1
  8. package/dist/browser/{data-tree-BOuPR-2J.js → data-tree-DAw8e0j8.js} +25 -12
  9. package/dist/browser/data-tree-DAw8e0j8.js.map +1 -0
  10. package/dist/browser/document-models/index.js +2 -2
  11. package/dist/browser/document-models/workflow/index.js +2 -2
  12. package/dist/browser/{document-models-DSK5cn8B.js → document-models-C2SAP1SX.js} +2 -2
  13. package/dist/browser/{document-models-DSK5cn8B.js.map → document-models-C2SAP1SX.js.map} +1 -1
  14. package/dist/{node/editor-C_eWGGi8.mjs → browser/editor--J61vLSC.js} +630 -72
  15. package/dist/browser/editor--J61vLSC.js.map +1 -0
  16. package/dist/browser/{editor-0XPrGeLT.js → editor-CZLe6CAF.js} +5 -5
  17. package/dist/browser/{editor-0XPrGeLT.js.map → editor-CZLe6CAF.js.map} +1 -1
  18. package/dist/browser/{editor--59WtNaj.js → editor-Dl6lzxkM.js} +158 -2676
  19. package/dist/browser/editor-Dl6lzxkM.js.map +1 -0
  20. package/dist/browser/editors/connection-editor/module.js +1 -1
  21. package/dist/browser/editors/runtime/index.js +1 -1
  22. package/dist/browser/editors/workflow-editor/module.js +1 -1
  23. package/dist/browser/editors/workflow-studio/module.js +1 -1
  24. package/dist/browser/index.js +3 -3
  25. package/dist/browser/{module-eOpxJVIl.js → module-mFCt9WHJ.js} +2 -2
  26. package/dist/browser/module-mFCt9WHJ.js.map +1 -0
  27. package/dist/browser/reactor/index.js +2 -2
  28. package/dist/browser/{runtime-queries-LAcyniYz.js → runtime-queries-D81Ghpok.js} +105 -4
  29. package/dist/browser/runtime-queries-D81Ghpok.js.map +1 -0
  30. package/dist/browser/trigger-text-BSVi5oGZ.js +3045 -0
  31. package/dist/browser/trigger-text-BSVi5oGZ.js.map +1 -0
  32. package/dist/browser/{upgrade-manifests-CLYUPqBs.js → upgrade-manifests-C2Qa6myy.js} +2 -2
  33. package/dist/browser/{upgrade-manifests-CLYUPqBs.js.map → upgrade-manifests-C2Qa6myy.js.map} +1 -1
  34. package/dist/browser/{workflow-Cn1UP-eJ.js → workflow-BFdnSGRD.js} +2 -2
  35. package/dist/browser/{workflow-Cn1UP-eJ.js.map → workflow-BFdnSGRD.js.map} +1 -1
  36. package/dist/node/{BlockSelector-D2UAnFpN.mjs → BlockSelector-Bcb5NJ_X.mjs} +77 -8
  37. package/dist/node/BlockSelector-Bcb5NJ_X.mjs.map +1 -0
  38. package/dist/node/{PieceMarkdown-DwpCBISY.mjs → PieceMarkdown-CUSdTMH4.mjs} +34 -8
  39. package/dist/node/{PieceMarkdown-DwpCBISY.mjs.map → PieceMarkdown-CUSdTMH4.mjs.map} +1 -1
  40. package/dist/node/{connection-form-Btmejfyn.mjs → connection-form-DF5418sz.mjs} +3 -3
  41. package/dist/node/{connection-form-Btmejfyn.mjs.map → connection-form-DF5418sz.mjs.map} +1 -1
  42. package/dist/node/{data-tree-rZiK2Ev-.mjs → data-tree-CebWVI_P.mjs} +25 -12
  43. package/dist/node/{data-tree-rZiK2Ev-.mjs.map → data-tree-CebWVI_P.mjs.map} +1 -1
  44. package/dist/node/document-models/index.mjs +2 -2
  45. package/dist/node/document-models/workflow/index.mjs +2 -2
  46. package/dist/{browser/editor-BD-5ClkW.js → node/editor-BmRWQvRs.mjs} +629 -72
  47. package/dist/node/editor-BmRWQvRs.mjs.map +1 -0
  48. package/dist/node/{editor-ChJMxbeM.mjs → editor-J0op3mM7.mjs} +5 -5
  49. package/dist/node/{editor-ChJMxbeM.mjs.map → editor-J0op3mM7.mjs.map} +1 -1
  50. package/dist/node/{editor-U6trS0QO.mjs → editor-UzRtZp-A.mjs} +276 -2793
  51. package/dist/node/editor-UzRtZp-A.mjs.map +1 -0
  52. package/dist/node/editors/connection-editor/module.mjs +1 -1
  53. package/dist/node/editors/runtime/index.mjs +1 -1
  54. package/dist/node/editors/workflow-editor/module.mjs +1 -1
  55. package/dist/node/editors/workflow-studio/module.mjs +1 -1
  56. package/dist/node/index.mjs +3 -3
  57. package/dist/node/{module-D9Zx5Zow.mjs → module-CuTg45ct.mjs} +2 -2
  58. package/dist/{browser/module-eOpxJVIl.js.map → node/module-CuTg45ct.mjs.map} +1 -1
  59. package/dist/node/pieces/ai/descriptor.json +1 -1
  60. package/dist/node/pieces/ai/package.json +1 -1
  61. package/dist/node/pieces/reactor/descriptor.json +1 -1
  62. package/dist/node/pieces/reactor/package.json +1 -1
  63. package/dist/node/{runtime-queries-CmrHBPRw.mjs → runtime-queries-VXJsWno5.mjs} +263 -7
  64. package/dist/node/runtime-queries-VXJsWno5.mjs.map +1 -0
  65. package/dist/node/trigger-text-BvEzEani.mjs +3045 -0
  66. package/dist/node/trigger-text-BvEzEani.mjs.map +1 -0
  67. package/dist/node/{upgrade-manifests-C4akaA_X.mjs → upgrade-manifests-BA5OaR4H.mjs} +2 -2
  68. package/dist/node/{upgrade-manifests-C4akaA_X.mjs.map → upgrade-manifests-BA5OaR4H.mjs.map} +1 -1
  69. package/dist/node/{workflow-DqF9VsBQ.mjs → workflow-BgURVzdc.mjs} +2 -2
  70. package/dist/node/{workflow-DqF9VsBQ.mjs.map → workflow-BgURVzdc.mjs.map} +1 -1
  71. package/dist/powerhouse.manifest.json +2 -2
  72. package/dist/style.css +1 -1
  73. package/dist/types/document-models/workflow/v1/gen/schema/types.d.ts +1 -1
  74. package/dist/types/document-models/workflow/v1/gen/schema/types.d.ts.map +1 -1
  75. package/dist/types/editors/shared/controls.d.ts.map +1 -1
  76. package/dist/types/editors/shared/data-tree.d.ts.map +1 -1
  77. package/dist/types/editors/shared/icons.d.ts +1 -0
  78. package/dist/types/editors/shared/icons.d.ts.map +1 -1
  79. package/dist/types/editors/workflow-editor/editor.d.ts.map +1 -1
  80. package/dist/types/editors/workflow-editor/runtime-client.d.ts +39 -0
  81. package/dist/types/editors/workflow-editor/runtime-client.d.ts.map +1 -1
  82. package/dist/types/editors/workflow-editor/runtime-context.d.ts +10 -1
  83. package/dist/types/editors/workflow-editor/runtime-context.d.ts.map +1 -1
  84. package/dist/types/editors/workflow-editor/runtime-queries.d.ts +21 -1
  85. package/dist/types/editors/workflow-editor/runtime-queries.d.ts.map +1 -1
  86. package/dist/types/editors/workflow-editor/ui/BlockSelector.d.ts.map +1 -1
  87. package/dist/types/editors/workflow-editor/ui/PieceMarkdown.d.ts +2 -1
  88. package/dist/types/editors/workflow-editor/ui/PieceMarkdown.d.ts.map +1 -1
  89. package/dist/types/editors/workflow-editor/ui/PropertyForm.d.ts +4 -0
  90. package/dist/types/editors/workflow-editor/ui/PropertyForm.d.ts.map +1 -1
  91. package/dist/types/editors/workflow-editor/ui/block-meta.d.ts.map +1 -1
  92. package/dist/types/editors/workflow-editor/ui/blocks.d.ts +4 -0
  93. package/dist/types/editors/workflow-editor/ui/blocks.d.ts.map +1 -1
  94. package/dist/types/editors/workflow-editor/ui/manual-inputs.d.ts +7 -0
  95. package/dist/types/editors/workflow-editor/ui/manual-inputs.d.ts.map +1 -0
  96. package/dist/types/editors/workflow-editor/ui/manual-inputs.test.d.ts +2 -0
  97. package/dist/types/editors/workflow-editor/ui/manual-inputs.test.d.ts.map +1 -0
  98. package/dist/types/editors/workflow-editor/ui/query-keys.d.ts +9 -0
  99. package/dist/types/editors/workflow-editor/ui/query-keys.d.ts.map +1 -1
  100. package/dist/types/editors/workflow-studio/components/RunDialog.d.ts +7 -0
  101. package/dist/types/editors/workflow-studio/components/RunDialog.d.ts.map +1 -0
  102. package/dist/types/editors/workflow-studio/components/RunsTable.d.ts.map +1 -1
  103. package/dist/types/editors/workflow-studio/components/RunsView.d.ts +3 -1
  104. package/dist/types/editors/workflow-studio/components/RunsView.d.ts.map +1 -1
  105. package/dist/types/editors/workflow-studio/components/Sidebar.d.ts +3 -0
  106. package/dist/types/editors/workflow-studio/components/Sidebar.d.ts.map +1 -1
  107. package/dist/types/editors/workflow-studio/components/Waitpoints.d.ts +49 -0
  108. package/dist/types/editors/workflow-studio/components/Waitpoints.d.ts.map +1 -0
  109. package/dist/types/editors/workflow-studio/components/WorkflowBoard.d.ts +3 -0
  110. package/dist/types/editors/workflow-studio/components/WorkflowBoard.d.ts.map +1 -1
  111. package/dist/types/editors/workflow-studio/components/WorkflowStudio.d.ts.map +1 -1
  112. package/dist/types/editors/workflow-studio/components/run-dialog.test.d.ts +2 -0
  113. package/dist/types/editors/workflow-studio/components/run-dialog.test.d.ts.map +1 -0
  114. package/dist/types/editors/workflow-studio/components/run-format.d.ts +2 -1
  115. package/dist/types/editors/workflow-studio/components/run-format.d.ts.map +1 -1
  116. package/dist/types/editors/workflow-studio/components/waitpoints-view.test.d.ts +2 -0
  117. package/dist/types/editors/workflow-studio/components/waitpoints-view.test.d.ts.map +1 -0
  118. package/dist/types/editors/workflow-studio/components/waitpoints.test.d.ts +2 -0
  119. package/dist/types/editors/workflow-studio/components/waitpoints.test.d.ts.map +1 -0
  120. package/dist/types/test/graphql-server.d.ts +9 -0
  121. package/dist/types/test/graphql-server.d.ts.map +1 -0
  122. package/dist/types/test/ui/manual-inputs.spec.d.ts +2 -0
  123. package/dist/types/test/ui/manual-inputs.spec.d.ts.map +1 -0
  124. package/dist/types/test/waitpoint-record.d.ts +3 -0
  125. package/dist/types/test/waitpoint-record.d.ts.map +1 -0
  126. package/dist/workflow.css +2 -0
  127. package/package.json +9 -9
  128. package/dist/browser/BlockSelector-DHVzUGjW.js.map +0 -1
  129. package/dist/browser/PieceMarkdown-U6OUTwRi.js.map +0 -1
  130. package/dist/browser/data-tree-BOuPR-2J.js.map +0 -1
  131. package/dist/browser/editor--59WtNaj.js.map +0 -1
  132. package/dist/browser/editor-BD-5ClkW.js.map +0 -1
  133. package/dist/browser/runtime-queries-LAcyniYz.js.map +0 -1
  134. package/dist/browser/trigger-text-Co-dn9x-.js +0 -513
  135. package/dist/browser/trigger-text-Co-dn9x-.js.map +0 -1
  136. package/dist/node/BlockSelector-D2UAnFpN.mjs.map +0 -1
  137. package/dist/node/editor-C_eWGGi8.mjs.map +0 -1
  138. package/dist/node/editor-U6trS0QO.mjs.map +0 -1
  139. package/dist/node/module-D9Zx5Zow.mjs.map +0 -1
  140. package/dist/node/runtime-queries-CmrHBPRw.mjs.map +0 -1
  141. package/dist/node/trigger-text-CAiRCG2X.mjs +0 -512
  142. package/dist/node/trigger-text-CAiRCG2X.mjs.map +0 -1
@@ -1,14 +1,201 @@
1
- import { X as CORE_PIECE, Z as MANUAL_TRIGGER, at as sameBlock, ct as triggerBlock, l as runsOfPages, ot as stepBlock } from "./runtime-queries-CmrHBPRw.mjs";
2
- import { A as runStats, Bt as Icon, C as canRerun, Ct as ITEM_PARAM, D as formatMs, E as formatDuration, Et as Button, F as toneOf, Ht as DocumentErrorBoundary, I as workflowHealth, M as runTimeline, Mt as Select, N as runTone, O as formatTrigger, P as statusLabel, S as TONE_TEXT, T as formatAbsolute, Tt as useSearchParamDraft, Ut as DocumentLoadError, Wt as errorMessage, _ as CONNECTION_TONE, _t as useRunPagesQuery, b as STEP_TONE, f as blockMeta, g as usePieceLogos, j as runStatusLabel, k as formatWhen, pt as WorkflowRuntimeProvider, t as BlockLogo, v as RUN_STATUSES, vt as useRunQuery, w as durationMs, wt as useSearchParam, x as TONE_DOT, xt as useRuntimeActions, y as RUN_TONE, zt as textInputClass } from "./BlockSelector-D2UAnFpN.mjs";
3
- import { y as actions } from "./module-D9Zx5Zow.mjs";
4
- import { r as useWorkflowDocumentsInSelectedDrive } from "./workflow-DqF9VsBQ.mjs";
5
- import { a as StepError, f as StatusToggle, i as DataViewer, l as PublishState, r as describeTrigger } from "./trigger-text-CAiRCG2X.mjs";
1
+ import { K as triggerBlock, N as MANUAL_TRIGGER, U as sameBlock, W as stepBlock, j as CORE_PIECE, l as runsOfPages } from "./runtime-queries-D81Ghpok.js";
2
+ import { y as actions } from "./module-mFCt9WHJ.js";
3
+ import { r as useWorkflowDocumentsInSelectedDrive } from "./workflow-BFdnSGRD.js";
4
+ import { A as formatWhen, Bt as textAreaClass, C as canRerun, D as formatMs, Dt as useSearchParamDraft, E as formatDuration, Et as useSearchParam, F as statusLabel, Ft as Switch, Gt as DocumentLoadError, Ht as Icon, I as toneOf, Kt as errorMessage, L as workflowHealth, M as runStatusLabel, N as runTimeline, O as formatTrigger, Ot as Button, P as runTone, Pt as Select, S as TONE_TEXT, St as useRuntimeActions, T as formatAbsolute, Tt as ITEM_PARAM, Vt as textInputClass, Wt as DocumentErrorBoundary, _ as CONNECTION_TONE, b as STEP_TONE, f as blockMeta, g as usePieceLogos, j as runStats, k as formatUntil, mt as WorkflowRuntimeProvider, t as BlockLogo, v as RUN_STATUSES, vt as useRunPagesQuery, w as durationMs, wt as useWaitingRunsQuery, x as TONE_DOT, y as RUN_TONE, yt as useRunQuery } from "./BlockSelector-BKAJwJ4Y.js";
5
+ import { a as StepError, b as PropertyForm, f as StatusToggle, i as DataViewer, l as PublishState, r as describeTrigger } from "./trigger-text-BSVi5oGZ.js";
6
6
  import { addDocument, addFolder, deleteNode, getPHStore, showDeleteNodeModal, useDispatch, useDocumentSafe, useFileNodesInSelectedDrive, useNodesInSelectedDrive, usePHToast, useSearchParams, useSelectedDrive, useSelectedNode, useSetPHAppConfig, useSetSearchParams, useSetSelectedNode } from "@powerhousedao/reactor-browser";
7
7
  import { generateId } from "document-model";
8
- import { Fragment, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
8
+ import { ManualPayloadError, coerceManualPayload, manualDefault, parseManualInputs } from "@powerhousedao/pieces-framework/workflow";
9
+ import { Fragment, Suspense, lazy, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
9
10
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
10
- import { addFolder as addFolder$1, moveNode, updateNode } from "@powerhousedao/shared/document-drive";
11
11
  import { ConnectTooltip, ConnectTooltipProvider, Modal } from "@powerhousedao/design-system/connect";
12
+ import { addFolder as addFolder$1, moveNode, updateNode } from "@powerhousedao/shared/document-drive";
13
+ //#region editors/workflow-editor/ui/manual-inputs.ts
14
+ const PROPERTY_TYPES = {
15
+ text: "SHORT_TEXT",
16
+ text_area: "LONG_TEXT",
17
+ number: "NUMBER",
18
+ toggle: "CHECKBOX",
19
+ date: "DATE_TIME",
20
+ dropdown: "STATIC_DROPDOWN",
21
+ json: "JSON"
22
+ };
23
+ function manualInputProp(input) {
24
+ const defaultValue = manualDefault(input);
25
+ return {
26
+ name: input.name,
27
+ displayName: input.displayName,
28
+ type: PROPERTY_TYPES[input.type],
29
+ required: input.type === "toggle" ? false : input.required,
30
+ ...input.description ? { description: input.description } : {},
31
+ ...defaultValue !== void 0 ? { defaultValue } : {},
32
+ ...input.type === "dropdown" ? { staticOptions: (input.options ?? []).map(({ value, label }) => ({
33
+ value,
34
+ label
35
+ })) } : {}
36
+ };
37
+ }
38
+ function manualRunPayload(inputs, values) {
39
+ try {
40
+ return coerceManualPayload(inputs, values);
41
+ } catch (error) {
42
+ if (!(error instanceof ManualPayloadError)) throw error;
43
+ const label = (name) => inputs.find((input) => input.name === name)?.displayName ?? name;
44
+ throw new Error(error.fields.map((entry) => `${label(entry.field)} ${entry.message}`).join("; "), { cause: error });
45
+ }
46
+ }
47
+ function manualInputValues(inputs) {
48
+ const values = {};
49
+ for (const input of inputs) {
50
+ const value = manualDefault(input);
51
+ if (value !== void 0) values[input.name] = value;
52
+ else if (input.type === "toggle") values[input.name] = false;
53
+ }
54
+ return values;
55
+ }
56
+ //#endregion
57
+ //#region editors/workflow-studio/components/ui.tsx
58
+ function StatusDot(props) {
59
+ const hollow = props.hollow ?? props.tone === "idle";
60
+ return /* @__PURE__ */ jsx("span", {
61
+ "aria-hidden": true,
62
+ className: `inline-block h-2 w-2 shrink-0 rounded-full ${hollow ? "border border-solid border-muted-foreground/60" : TONE_DOT[props.tone]} ${props.className ?? ""}`
63
+ });
64
+ }
65
+ function StatusText(props) {
66
+ return /* @__PURE__ */ jsxs("span", {
67
+ className: `inline-flex items-center gap-1.5 font-medium ${TONE_TEXT[props.tone]} ${props.className ?? ""}`,
68
+ children: [/* @__PURE__ */ jsx(StatusDot, { tone: props.tone }), props.label ?? statusLabel(props.status)]
69
+ });
70
+ }
71
+ /** A label/value pair for a header's facts line. */
72
+ function Fact(props) {
73
+ return /* @__PURE__ */ jsxs("div", {
74
+ className: "flex min-w-0 flex-col gap-0.5",
75
+ title: props.title,
76
+ children: [/* @__PURE__ */ jsx("dt", {
77
+ className: "text-xs text-muted-foreground",
78
+ children: props.label
79
+ }), /* @__PURE__ */ jsx("dd", {
80
+ className: "truncate text-[13px] tabular-nums text-foreground",
81
+ children: props.children
82
+ })]
83
+ });
84
+ }
85
+ //#endregion
86
+ //#region editors/workflow-studio/components/RunDialog.tsx
87
+ function RunDialog(props) {
88
+ const fields = useMemo(() => props.inputs.map(manualInputProp), [props.inputs]);
89
+ const [values, setValues] = useState(() => manualInputValues(props.inputs));
90
+ const latest = useRef(values);
91
+ const [raw, setRaw] = useState(null);
92
+ const [error, setError] = useState(null);
93
+ const [firing, setFiring] = useState(false);
94
+ const rawId = useId();
95
+ const payload = () => {
96
+ if (raw === null) return manualRunPayload(props.inputs, latest.current);
97
+ try {
98
+ return JSON.parse(raw === "" ? "{}" : raw);
99
+ } catch {
100
+ throw new Error("The payload is not valid JSON.");
101
+ }
102
+ };
103
+ return /* @__PURE__ */ jsx(Modal, {
104
+ open: true,
105
+ title: "Run workflow",
106
+ onOpenChange: (open) => {
107
+ if (!open) props.onCancel();
108
+ },
109
+ contentProps: {
110
+ className: "max-h-[85vh] w-[32rem] max-w-[92vw] overflow-y-auto rounded-xl border border-solid border-foreground/10",
111
+ "aria-label": "Run workflow"
112
+ },
113
+ children: /* @__PURE__ */ jsxs("form", {
114
+ className: "flex flex-col gap-4 p-6",
115
+ noValidate: true,
116
+ onSubmit: (event) => {
117
+ event.preventDefault();
118
+ if (firing) return;
119
+ document.activeElement?.blur();
120
+ let body;
121
+ try {
122
+ body = payload();
123
+ } catch (cause) {
124
+ setError(cause instanceof Error ? cause.message : String(cause));
125
+ return;
126
+ }
127
+ setFiring(true);
128
+ setError(null);
129
+ props.onFire(body).then((fireError) => fireError, (cause) => cause instanceof Error ? cause.message : String(cause)).then((fireError) => {
130
+ setFiring(false);
131
+ if (fireError) setError(fireError);
132
+ else props.onCancel();
133
+ });
134
+ },
135
+ children: [
136
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h2", {
137
+ className: "text-[15px] font-semibold text-foreground",
138
+ children: "Run workflow"
139
+ }), /* @__PURE__ */ jsxs("p", {
140
+ className: "mt-1 text-[13px] text-muted-foreground",
141
+ children: [
142
+ "The run reads these as ",
143
+ "{{trigger.payload.<key>}}",
144
+ "."
145
+ ]
146
+ })] }),
147
+ /* @__PURE__ */ jsx(Switch, {
148
+ label: "Raw JSON",
149
+ checked: raw !== null,
150
+ onChange: (on) => {
151
+ setError(null);
152
+ if (!on) return setRaw(null);
153
+ setRaw(JSON.stringify(latest.current, null, 2));
154
+ }
155
+ }),
156
+ raw === null ? /* @__PURE__ */ jsx(PropertyForm, {
157
+ props: fields,
158
+ value: values,
159
+ onChange: (next) => {
160
+ latest.current = next;
161
+ setValues(next);
162
+ }
163
+ }) : /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
164
+ htmlFor: rawId,
165
+ className: "mb-1.5 block text-[13px] font-medium text-foreground",
166
+ children: "Payload"
167
+ }), /* @__PURE__ */ jsx("textarea", {
168
+ id: rawId,
169
+ className: `${textAreaClass} min-h-40 font-mono text-xs`,
170
+ value: raw,
171
+ spellCheck: false,
172
+ onChange: (event) => setRaw(event.target.value)
173
+ })] }),
174
+ error ? /* @__PURE__ */ jsx("p", {
175
+ role: "alert",
176
+ className: "rounded-md bg-wf-fail/10 px-3 py-2 text-[13px] text-wf-fail",
177
+ children: error
178
+ }) : null,
179
+ /* @__PURE__ */ jsxs("div", {
180
+ className: "flex justify-end gap-2",
181
+ children: [/* @__PURE__ */ jsx(Button, {
182
+ onClick: props.onCancel,
183
+ children: "Cancel"
184
+ }), /* @__PURE__ */ jsxs(Button, {
185
+ type: "submit",
186
+ variant: "primary",
187
+ disabled: firing,
188
+ children: [/* @__PURE__ */ jsx(Icon, {
189
+ name: "play",
190
+ className: "h-3.5 w-3.5"
191
+ }), firing ? "Running…" : "Run"]
192
+ })]
193
+ })
194
+ ]
195
+ })
196
+ });
197
+ }
198
+ //#endregion
12
199
  //#region editors/workflow-studio/components/step-outline.ts
13
200
  function stepOutline(args) {
14
201
  const inbound = /* @__PURE__ */ new Map();
@@ -340,31 +527,314 @@ function RunStrip(props) {
340
527
  }) });
341
528
  }
342
529
  //#endregion
343
- //#region editors/workflow-studio/components/ui.tsx
344
- function StatusDot(props) {
345
- const hollow = props.hollow ?? props.tone === "idle";
346
- return /* @__PURE__ */ jsx("span", {
347
- "aria-hidden": true,
348
- className: `inline-block h-2 w-2 shrink-0 rounded-full ${hollow ? "border border-solid border-muted-foreground/60" : TONE_DOT[props.tone]} ${props.className ?? ""}`
530
+ //#region editors/workflow-studio/components/Waitpoints.tsx
531
+ const PieceMarkdown = lazy(() => import("./PieceMarkdown-DSdZd-Jc.js"));
532
+ const WAITING_POLL_MS = 3e4;
533
+ function isOpenApproval(waitpoint) {
534
+ return waitpoint.status === "PENDING" && waitpoint.kind === "approval";
535
+ }
536
+ function waitDescription(waitpoint, stepName) {
537
+ if (waitpoint.kind === "delay") return waitpoint.resumeAt ? `${stepName} is waiting until ${formatAbsolute(waitpoint.resumeAt)}` : `${stepName} is waiting for its delay`;
538
+ return `${stepName} is waiting for a webhook callback${waitpoint.expiresAt ? `, until ${formatAbsolute(waitpoint.expiresAt)}` : ""}`;
539
+ }
540
+ function cancelFailure(result) {
541
+ if (!result) return "The run was not found";
542
+ if (result.status === "CANCELLED") return null;
543
+ return result.error ?? `The run is ${result.status}`;
544
+ }
545
+ function countPendingApprovals(runs, limit) {
546
+ const byWorkflow = /* @__PURE__ */ new Map();
547
+ let total = 0;
548
+ for (const run of runs ?? []) {
549
+ const open = (run.waitpoints ?? []).filter(isOpenApproval).length;
550
+ if (open === 0) continue;
551
+ total += open;
552
+ byWorkflow.set(run.workflowId, (byWorkflow.get(run.workflowId) ?? 0) + open);
553
+ }
554
+ return {
555
+ total,
556
+ byWorkflow,
557
+ capped: (runs?.length ?? 0) >= limit
558
+ };
559
+ }
560
+ function approvalCountText(count, capped) {
561
+ return capped ? `${count}+` : String(count);
562
+ }
563
+ function approvalCountLabel(count, capped) {
564
+ const noun = count === 1 && !capped ? "approval" : "approvals";
565
+ return `${approvalCountText(count, capped)} ${noun} waiting`;
566
+ }
567
+ function usePendingApprovals(driveId) {
568
+ return countPendingApprovals(useWaitingRunsQuery({
569
+ driveId,
570
+ first: 100
571
+ }, { pollMs: WAITING_POLL_MS }).data, 100);
572
+ }
573
+ function ApprovalBadge(props) {
574
+ if (props.count === 0) return null;
575
+ const label = approvalCountLabel(props.count, props.capped);
576
+ const className = `inline-flex h-5 shrink-0 items-center gap-1 rounded-full bg-wf-warn/12 px-1.5 text-[11px] font-medium tabular-nums text-wf-warn ${props.className ?? ""}`;
577
+ const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Icon, {
578
+ name: "clock",
579
+ className: "h-3 w-3"
580
+ }), approvalCountText(props.count, props.capped)] });
581
+ return props.onClick ? /* @__PURE__ */ jsx("button", {
582
+ type: "button",
583
+ title: label,
584
+ "aria-label": label,
585
+ className: `${className} hover:bg-wf-warn/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,
586
+ onClick: (event) => {
587
+ event.stopPropagation();
588
+ props.onClick();
589
+ },
590
+ children: content
591
+ }) : /* @__PURE__ */ jsx("span", {
592
+ role: "img",
593
+ title: label,
594
+ "aria-label": label,
595
+ className,
596
+ children: content
349
597
  });
350
598
  }
351
- function StatusText(props) {
352
- return /* @__PURE__ */ jsxs("span", {
353
- className: `inline-flex items-center gap-1.5 font-medium ${TONE_TEXT[props.tone]} ${props.className ?? ""}`,
354
- children: [/* @__PURE__ */ jsx(StatusDot, { tone: props.tone }), props.label ?? statusLabel(props.status)]
599
+ function reasonRequired(waitpoint, approved) {
600
+ const policy = waitpoint.approval?.reasonRequiredOn ?? "none";
601
+ return policy === "both" || policy === "reject" && !approved;
602
+ }
603
+ function errorText(error) {
604
+ return error instanceof Error ? error.message : String(error);
605
+ }
606
+ function ApprovalCard(props) {
607
+ const { waitpoint } = props;
608
+ const { resolveWaitpoint } = useRuntimeActions();
609
+ const reasonId = useId();
610
+ const [reason, setReason] = useState("");
611
+ const [busy, setBusy] = useState(null);
612
+ const [error, setError] = useState(null);
613
+ const approval = waitpoint.approval;
614
+ const stepName = props.stepName ?? waitpoint.stepKey;
615
+ const policy = approval?.reasonRequiredOn ?? "none";
616
+ const expiresIn = waitpoint.expiresAt ? formatUntil(waitpoint.expiresAt) : null;
617
+ const decide = (approved) => {
618
+ const trimmed = reason.trim();
619
+ if (reasonRequired(waitpoint, approved) && !trimmed) {
620
+ setError(`Give a reason to ${approved ? "approve" : "disapprove"} this request.`);
621
+ return;
622
+ }
623
+ setBusy(approved);
624
+ setError(null);
625
+ resolveWaitpoint(waitpoint, approved, trimmed || void 0).then(() => props.onResolved?.()).catch((resolveError) => setError(errorText(resolveError))).finally(() => setBusy(null));
626
+ };
627
+ return /* @__PURE__ */ jsxs("section", {
628
+ "aria-label": `Approval for ${stepName}`,
629
+ className: "overflow-hidden rounded-xl border border-solid border-foreground/10 bg-card",
630
+ children: [/* @__PURE__ */ jsxs("div", {
631
+ className: "flex items-start gap-3 px-4 py-3.5",
632
+ children: [/* @__PURE__ */ jsx("span", {
633
+ "aria-hidden": true,
634
+ className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-wf-warn/12 text-wf-warn",
635
+ children: /* @__PURE__ */ jsx(Icon, {
636
+ name: "clock",
637
+ className: "h-3.5 w-3.5"
638
+ })
639
+ }), /* @__PURE__ */ jsxs("div", {
640
+ className: "min-w-0 grow space-y-3",
641
+ children: [
642
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
643
+ className: "text-[13px] font-semibold text-foreground",
644
+ children: approval?.title || `Waiting at ${stepName}`
645
+ }), /* @__PURE__ */ jsxs("p", {
646
+ className: "mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-xs text-muted-foreground",
647
+ children: [
648
+ props.meta,
649
+ /* @__PURE__ */ jsxs("span", {
650
+ title: formatAbsolute(waitpoint.createdAt),
651
+ children: ["Asked ", formatWhen(waitpoint.createdAt)]
652
+ }),
653
+ waitpoint.expiresAt ? /* @__PURE__ */ jsx("span", {
654
+ title: formatAbsolute(waitpoint.expiresAt),
655
+ className: expiresIn ? void 0 : "text-wf-warn",
656
+ children: expiresIn ? `Expires ${expiresIn}` : "Expired"
657
+ }) : null
658
+ ]
659
+ })] }),
660
+ approval?.body ? /* @__PURE__ */ jsx(Suspense, {
661
+ fallback: /* @__PURE__ */ jsx("p", {
662
+ className: "whitespace-pre-wrap text-[13px] text-foreground",
663
+ children: approval.body
664
+ }),
665
+ children: /* @__PURE__ */ jsx(PieceMarkdown, {
666
+ text: approval.body,
667
+ className: "max-w-prose text-[13px] text-foreground"
668
+ })
669
+ }) : null,
670
+ approval && approval.approvers.length > 0 ? /* @__PURE__ */ jsxs("p", {
671
+ className: "text-xs text-muted-foreground",
672
+ title: approval.approvers.join("\n"),
673
+ children: [
674
+ "Only ",
675
+ approval.approvers.length,
676
+ " listed",
677
+ " ",
678
+ approval.approvers.length === 1 ? "approver" : "approvers",
679
+ " can decide."
680
+ ]
681
+ }) : null
682
+ ]
683
+ })]
684
+ }), /* @__PURE__ */ jsxs("div", {
685
+ className: "border-t border-solid border-border bg-muted/40 px-4 py-3",
686
+ children: [
687
+ /* @__PURE__ */ jsxs("label", {
688
+ htmlFor: reasonId,
689
+ className: "mb-1.5 flex items-baseline gap-1.5 text-[13px] font-medium text-foreground",
690
+ children: ["Reason", /* @__PURE__ */ jsx("span", {
691
+ className: "text-xs font-normal text-muted-foreground",
692
+ children: policy === "none" ? "Optional" : policy === "reject" ? "Required to disapprove" : "Required"
693
+ })]
694
+ }),
695
+ /* @__PURE__ */ jsx("textarea", {
696
+ id: reasonId,
697
+ className: `${textAreaClass} min-h-16 resize-y`,
698
+ rows: 2,
699
+ value: reason,
700
+ onChange: (event) => setReason(event.target.value)
701
+ }),
702
+ /* @__PURE__ */ jsxs("div", {
703
+ className: "mt-3 flex flex-wrap items-center justify-end gap-2",
704
+ children: [
705
+ error ? /* @__PURE__ */ jsx("span", {
706
+ role: "alert",
707
+ className: "mr-auto text-xs text-wf-fail",
708
+ children: error
709
+ }) : null,
710
+ /* @__PURE__ */ jsxs(Button, {
711
+ variant: "destructive",
712
+ disabled: busy !== null,
713
+ onClick: () => decide(false),
714
+ children: [/* @__PURE__ */ jsx(Icon, {
715
+ name: "close",
716
+ className: "h-3.5 w-3.5"
717
+ }), busy === false ? "Disapproving…" : approval?.rejectLabel || "Disapprove"]
718
+ }),
719
+ /* @__PURE__ */ jsxs(Button, {
720
+ variant: "primary",
721
+ disabled: busy !== null,
722
+ onClick: () => decide(true),
723
+ children: [/* @__PURE__ */ jsx(Icon, {
724
+ name: "check",
725
+ className: "h-3.5 w-3.5"
726
+ }), busy === true ? "Approving…" : approval?.approveLabel || "Approve"]
727
+ })
728
+ ]
729
+ })
730
+ ]
731
+ })]
355
732
  });
356
733
  }
357
- /** A label/value pair for a header's facts line. */
358
- function Fact(props) {
359
- return /* @__PURE__ */ jsxs("div", {
360
- className: "flex min-w-0 flex-col gap-0.5",
361
- title: props.title,
362
- children: [/* @__PURE__ */ jsx("dt", {
363
- className: "text-xs text-muted-foreground",
364
- children: props.label
365
- }), /* @__PURE__ */ jsx("dd", {
366
- className: "truncate text-[13px] tabular-nums text-foreground",
367
- children: props.children
734
+ function RunWaitpoints(props) {
735
+ const open = props.waitpoints.filter((waitpoint) => waitpoint.status === "PENDING");
736
+ if (open.length === 0) return null;
737
+ return /* @__PURE__ */ jsx("div", {
738
+ className: "space-y-2",
739
+ children: open.map((waitpoint) => waitpoint.kind === "approval" ? /* @__PURE__ */ jsx(ApprovalCard, {
740
+ waitpoint,
741
+ stepName: props.names.get(waitpoint.stepKey),
742
+ onResolved: props.onChanged
743
+ }, waitpoint.id) : /* @__PURE__ */ jsxs("p", {
744
+ className: "flex items-center gap-2 rounded-md bg-wf-warn/10 px-3 py-2 text-[13px] text-wf-warn",
745
+ children: [/* @__PURE__ */ jsx(Icon, {
746
+ name: "clock",
747
+ className: "h-3.5 w-3.5"
748
+ }), waitDescription(waitpoint, props.names.get(waitpoint.stepKey) ?? waitpoint.stepKey)]
749
+ }, waitpoint.id))
750
+ });
751
+ }
752
+ function CancelRunButton(props) {
753
+ const { cancelRun } = useRuntimeActions();
754
+ const [cancelling, setCancelling] = useState(false);
755
+ const [error, setError] = useState(null);
756
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Button, {
757
+ variant: "danger",
758
+ disabled: cancelling,
759
+ onClick: () => {
760
+ setCancelling(true);
761
+ setError(null);
762
+ cancelRun(props.run.id).then((result) => setError(cancelFailure(result))).catch((cancelError) => setError(errorText(cancelError))).finally(() => {
763
+ setCancelling(false);
764
+ props.onChanged();
765
+ });
766
+ },
767
+ children: [/* @__PURE__ */ jsx(Icon, {
768
+ name: "close",
769
+ className: "h-3.5 w-3.5"
770
+ }), cancelling ? "Cancelling…" : "Cancel run"]
771
+ }), error ? /* @__PURE__ */ jsx("span", {
772
+ className: "text-wf-fail",
773
+ children: error
774
+ }) : null] });
775
+ }
776
+ function WaitingApprovals(props) {
777
+ const query = useWaitingRunsQuery({
778
+ driveId: props.driveId,
779
+ workflowId: props.workflowId,
780
+ first: 100
781
+ }, { pollMs: WAITING_POLL_MS });
782
+ const entries = (query.data ?? []).flatMap((run) => (run.waitpoints ?? []).filter(isOpenApproval).map((waitpoint) => ({
783
+ run,
784
+ waitpoint
785
+ })));
786
+ const capped = (query.data?.length ?? 0) >= 100;
787
+ const sectionRef = useRef(null);
788
+ const handled = useRef(0);
789
+ const shown = entries.length > 0;
790
+ useEffect(() => {
791
+ const request = props.focusRequest ?? 0;
792
+ if (!shown || request === handled.current) return;
793
+ handled.current = request;
794
+ sectionRef.current?.scrollIntoView({
795
+ behavior: "smooth",
796
+ block: "start"
797
+ });
798
+ sectionRef.current?.focus({ preventScroll: true });
799
+ }, [props.focusRequest, shown]);
800
+ if (!shown) return null;
801
+ return /* @__PURE__ */ jsxs("section", {
802
+ ref: sectionRef,
803
+ tabIndex: -1,
804
+ "aria-label": "Waiting for approval",
805
+ className: "mb-8 scroll-mt-4 focus:outline-none",
806
+ children: [/* @__PURE__ */ jsxs("h2", {
807
+ className: "mb-4 flex items-center gap-2 text-[15px] font-semibold text-foreground",
808
+ children: ["Waiting for approval", /* @__PURE__ */ jsx(ApprovalBadge, {
809
+ count: entries.length,
810
+ capped
811
+ })]
812
+ }), /* @__PURE__ */ jsx("div", {
813
+ className: "space-y-3",
814
+ children: entries.map(({ run, waitpoint }) => {
815
+ const names = props.stepNames.get(run.workflowId);
816
+ return /* @__PURE__ */ jsx(ApprovalCard, {
817
+ waitpoint,
818
+ stepName: names?.get(waitpoint.stepKey),
819
+ onResolved: props.onChanged,
820
+ meta: /* @__PURE__ */ jsxs(Fragment$1, { children: [props.showWorkflow ? /* @__PURE__ */ jsx("span", {
821
+ className: "font-medium text-foreground",
822
+ children: run.workflowName
823
+ }) : null, /* @__PURE__ */ jsxs("span", {
824
+ title: formatAbsolute(run.startedAt),
825
+ children: [
826
+ "Run ",
827
+ /* @__PURE__ */ jsx("span", {
828
+ className: "font-mono",
829
+ children: run.id.slice(0, 8)
830
+ }),
831
+ " ",
832
+ "started ",
833
+ formatWhen(run.startedAt)
834
+ ]
835
+ })] })
836
+ }, waitpoint.id);
837
+ })
368
838
  })]
369
839
  });
370
840
  }
@@ -592,6 +1062,11 @@ function RunDetail(props) {
592
1062
  className: "rounded-md bg-wf-fail/10 px-3 py-2 text-[13px] text-wf-fail",
593
1063
  children: describeRunError(run.error, names)
594
1064
  }) : null,
1065
+ run.waitpoints ? /* @__PURE__ */ jsx(RunWaitpoints, {
1066
+ waitpoints: run.waitpoints,
1067
+ names,
1068
+ onChanged: props.onChanged
1069
+ }) : null,
595
1070
  run.warningNotes.length > 0 ? /* @__PURE__ */ jsx("ul", {
596
1071
  "aria-label": "Run warnings",
597
1072
  className: "space-y-1 rounded-md bg-wf-warn/10 px-3 py-2 text-[13px] text-wf-warn",
@@ -628,6 +1103,13 @@ function RunDetail(props) {
628
1103
  rerunError ? /* @__PURE__ */ jsx("span", {
629
1104
  className: "text-wf-fail",
630
1105
  children: rerunError
1106
+ }) : null,
1107
+ run.status === "WAITING" ? /* @__PURE__ */ jsx("span", {
1108
+ className: "ml-auto flex items-center gap-2",
1109
+ children: /* @__PURE__ */ jsx(CancelRunButton, {
1110
+ run,
1111
+ onChanged: props.onChanged
1112
+ })
631
1113
  }) : null
632
1114
  ]
633
1115
  }),
@@ -710,6 +1192,7 @@ function RunsTable(props) {
710
1192
  const counts = useMemo(() => ({
711
1193
  ALL: scoped.length,
712
1194
  RUNNING: scoped.filter((run) => run.status === "RUNNING").length,
1195
+ WAITING: scoped.filter((run) => run.status === "WAITING").length,
713
1196
  SUCCEEDED: scoped.filter((run) => run.status === "SUCCEEDED").length,
714
1197
  FAILED: scoped.filter((run) => run.status === "FAILED").length
715
1198
  }), [scoped]);
@@ -936,7 +1419,9 @@ function RunsTable(props) {
936
1419
  function RunsView(props) {
937
1420
  const [firing, setFiring] = useState(false);
938
1421
  const [fireError, setFireError] = useState(null);
1422
+ const [asking, setAsking] = useState(false);
939
1423
  const { runs } = props;
1424
+ const inputs = props.fireInputs ?? [];
940
1425
  return /* @__PURE__ */ jsxs("div", {
941
1426
  className: "w-full",
942
1427
  children: [
@@ -952,6 +1437,11 @@ function RunsView(props) {
952
1437
  variant: "primary",
953
1438
  disabled: firing,
954
1439
  onClick: () => {
1440
+ if (inputs.length > 0) {
1441
+ setFireError(null);
1442
+ setAsking(true);
1443
+ return;
1444
+ }
955
1445
  setFiring(true);
956
1446
  setFireError(null);
957
1447
  props.onFire().then((fireResultError) => setFireError(fireResultError)).catch((fireCallError) => setFireError(fireCallError instanceof Error ? fireCallError.message : String(fireCallError))).finally(() => {
@@ -966,6 +1456,11 @@ function RunsView(props) {
966
1456
  }) : null
967
1457
  ]
968
1458
  }),
1459
+ asking && props.onFire && inputs.length > 0 ? /* @__PURE__ */ jsx(RunDialog, {
1460
+ inputs,
1461
+ onCancel: () => setAsking(false),
1462
+ onFire: (payload) => props.onFire(payload).finally(() => props.reload())
1463
+ }) : null,
969
1464
  fireError ? /* @__PURE__ */ jsx("p", {
970
1465
  className: "mb-3 rounded-md bg-wf-fail/10 px-3 py-2 text-[13px] text-wf-fail",
971
1466
  children: fireError
@@ -1387,24 +1882,33 @@ function NodeRow(props) {
1387
1882
  keyShortcuts: props.keyShortcuts,
1388
1883
  trailing: /* @__PURE__ */ jsxs("span", {
1389
1884
  className: "mr-1.5 flex shrink-0 items-center",
1390
- children: [props.onEdit ? /* @__PURE__ */ jsx("button", {
1391
- type: "button",
1392
- title: "Open in editor",
1393
- "aria-label": `Open ${documentName(document, node.name)} in the editor`,
1394
- className: ROW_ACTION,
1395
- onClick: props.onEdit,
1396
- children: /* @__PURE__ */ jsx(Icon, {
1397
- name: "pencil",
1398
- className: "h-3.5 w-3.5"
1885
+ children: [
1886
+ /* @__PURE__ */ jsx(ApprovalBadge, {
1887
+ count: props.approvals ?? 0,
1888
+ capped: props.approvalsCapped ?? false,
1889
+ onClick: props.onShowApprovals,
1890
+ className: "mr-0.5"
1891
+ }),
1892
+ props.onEdit ? /* @__PURE__ */ jsx("button", {
1893
+ type: "button",
1894
+ title: "Open in editor",
1895
+ "aria-label": `Open ${documentName(document, node.name)} in the editor`,
1896
+ className: ROW_ACTION,
1897
+ onClick: props.onEdit,
1898
+ children: /* @__PURE__ */ jsx(Icon, {
1899
+ name: "pencil",
1900
+ className: "h-3.5 w-3.5"
1901
+ })
1902
+ }) : null,
1903
+ isWorkflow && document ? /* @__PURE__ */ jsx(WorkflowMenu, {
1904
+ subtle: true,
1905
+ document,
1906
+ nodeName: node.name
1907
+ }) : /* @__PURE__ */ jsx(DeleteButton, {
1908
+ node,
1909
+ label: documentName(document, node.name)
1399
1910
  })
1400
- }) : null, isWorkflow && document ? /* @__PURE__ */ jsx(WorkflowMenu, {
1401
- subtle: true,
1402
- document,
1403
- nodeName: node.name
1404
- }) : /* @__PURE__ */ jsx(DeleteButton, {
1405
- node,
1406
- label: documentName(document, node.name)
1407
- })]
1911
+ ]
1408
1912
  }),
1409
1913
  children: [/* @__PURE__ */ jsx("span", {
1410
1914
  title: label,
@@ -1495,6 +1999,9 @@ function Section(props) {
1495
1999
  /* @__PURE__ */ jsx(NodeRow, {
1496
2000
  node,
1497
2001
  lastRunStatus: props.lastRuns?.get(node.id),
2002
+ approvals: props.approvals?.byWorkflow.get(node.id),
2003
+ approvalsCapped: props.approvals?.capped,
2004
+ onShowApprovals: props.onShowApprovals ? () => props.onShowApprovals(node) : void 0,
1498
2005
  active: props.activeId === node.id,
1499
2006
  onOpen: () => props.onOpen(node),
1500
2007
  onEdit: props.onEdit ? () => props.onEdit(node) : void 0,
@@ -1523,6 +2030,12 @@ function Sidebar(props) {
1523
2030
  /* @__PURE__ */ jsxs(Row, {
1524
2031
  active: props.allRunsActive,
1525
2032
  onClick: props.onShowAllRuns,
2033
+ trailing: /* @__PURE__ */ jsx(ApprovalBadge, {
2034
+ count: props.approvals.total,
2035
+ capped: props.approvals.capped,
2036
+ onClick: () => props.onShowApprovals(),
2037
+ className: "mr-2"
2038
+ }),
1526
2039
  children: [/* @__PURE__ */ jsx(Icon, {
1527
2040
  name: "list",
1528
2041
  className: "text-muted-foreground"
@@ -1534,6 +2047,8 @@ function Sidebar(props) {
1534
2047
  empty: "No workflows yet.",
1535
2048
  nodes: props.workflows,
1536
2049
  lastRuns: props.lastRuns,
2050
+ approvals: props.approvals,
2051
+ onShowApprovals: (node) => props.onShowApprovals(node.id),
1537
2052
  activeId: props.activeId,
1538
2053
  onOpen: props.onOpenWorkflow,
1539
2054
  onEdit: props.onEditWorkflow,
@@ -2143,6 +2658,7 @@ function summary(rows) {
2143
2658
  return parts.join(", ");
2144
2659
  }
2145
2660
  function WorkflowBoard(props) {
2661
+ const { approvals, onShowApprovals } = props;
2146
2662
  usePieceLogos();
2147
2663
  const { isCollapsed, toggle } = useCollapsed();
2148
2664
  const documents = useWorkflowDocumentsInSelectedDrive() ?? [];
@@ -2169,9 +2685,17 @@ function WorkflowBoard(props) {
2169
2685
  children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h2", {
2170
2686
  className: "text-2xl font-semibold tracking-tight text-foreground",
2171
2687
  children: "Workflows"
2172
- }), /* @__PURE__ */ jsx("p", {
2173
- className: "mt-1 text-[13px] text-muted-foreground",
2174
- children: rows.length === 0 ? "Automations in this drive" : summary(rows)
2688
+ }), /* @__PURE__ */ jsxs("p", {
2689
+ className: "mt-1 flex flex-wrap items-center gap-2 text-[13px] text-muted-foreground",
2690
+ children: [rows.length === 0 ? "Automations in this drive" : summary(rows), approvals && approvals.total > 0 ? /* @__PURE__ */ jsxs("button", {
2691
+ type: "button",
2692
+ className: "inline-flex items-center gap-1 rounded-full bg-wf-warn/12 px-2 py-0.5 text-xs font-medium text-wf-warn hover:bg-wf-warn/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
2693
+ onClick: () => onShowApprovals?.(),
2694
+ children: [/* @__PURE__ */ jsx(Icon, {
2695
+ name: "clock",
2696
+ className: "h-3 w-3"
2697
+ }), approvalCountLabel(approvals.total, approvals.capped)]
2698
+ }) : null]
2175
2699
  })] }), /* @__PURE__ */ jsxs(Button, {
2176
2700
  variant: "primary",
2177
2701
  disabled: props.creating,
@@ -2277,7 +2801,15 @@ function WorkflowBoard(props) {
2277
2801
  })]
2278
2802
  }), /* @__PURE__ */ jsxs("span", {
2279
2803
  className: "mt-4 flex h-6 shrink-0 items-center gap-1 pr-3",
2280
- children: [/* @__PURE__ */ jsx(RowToggle, { document: row.document }), /* @__PURE__ */ jsx(WorkflowMenu, { document: row.document })]
2804
+ children: [
2805
+ /* @__PURE__ */ jsx(ApprovalBadge, {
2806
+ count: approvals?.byWorkflow.get(row.id) ?? 0,
2807
+ capped: approvals?.capped ?? false,
2808
+ onClick: onShowApprovals ? () => onShowApprovals(row.id) : void 0
2809
+ }),
2810
+ /* @__PURE__ */ jsx(RowToggle, { document: row.document }),
2811
+ /* @__PURE__ */ jsx(WorkflowMenu, { document: row.document })
2812
+ ]
2281
2813
  })]
2282
2814
  }), collapsed ? null : /* @__PURE__ */ jsxs("button", {
2283
2815
  type: "button",
@@ -2638,20 +3170,32 @@ function Studio(props) {
2638
3170
  ]);
2639
3171
  const focusedWorkflow = liveTarget;
2640
3172
  const driveFeed = useRuns({ driveId });
3173
+ const approvals = usePendingApprovals(driveId);
3174
+ const [waitingFocus, setWaitingFocus] = useState(0);
3175
+ const showApprovals = (workflowId) => {
3176
+ go(workflowId);
3177
+ setWaitingFocus((request) => request + 1);
3178
+ };
2641
3179
  const workflowFeed = useRuns({ workflowId: focusedWorkflow?.id }, Boolean(focusedWorkflow));
2642
3180
  const feed = focusedWorkflow ? workflowFeed : driveFeed;
2643
3181
  const { runs, error: runsError, reload: reloadRuns } = feed;
2644
3182
  const lastRuns = /* @__PURE__ */ new Map();
2645
3183
  for (const run of driveFeed.runs ?? []) if (!lastRuns.has(run.workflowId)) lastRuns.set(run.workflowId, run.status);
3184
+ const stepNames = new Map(workflowDocuments.map((document) => [document.header.id, new Map(document.state.global.steps.map((step) => [step.key, step.name || step.key]))]));
2646
3185
  const { data: targetDocument } = useDocumentSafe(liveTarget?.id ?? null);
2647
3186
  const targetTrigger = targetDocument?.header.documentType === WORKFLOW_TYPE ? targetDocument.state.global.trigger : null;
2648
3187
  const manualTrigger = Boolean(targetTrigger && sameBlock(triggerBlock(targetTrigger), MANUAL_TRIGGER));
3188
+ const published = targetDocument?.header.documentType === WORKFLOW_TYPE ? targetDocument.state.global.published : null;
3189
+ const firedTrigger = published ? published.trigger : targetTrigger;
3190
+ const fireInputs = useMemo(() => firedTrigger && sameBlock(triggerBlock(firedTrigger), MANUAL_TRIGGER) ? parseManualInputs(firedTrigger.config) : [], [firedTrigger]);
2649
3191
  return /* @__PURE__ */ jsxs("div", {
2650
3192
  className: "flex h-full min-h-0 flex-col md:flex-row",
2651
3193
  children: [/* @__PURE__ */ jsx(Sidebar, {
2652
3194
  workflows,
2653
3195
  connections,
2654
3196
  lastRuns,
3197
+ approvals,
3198
+ onShowApprovals: showApprovals,
2655
3199
  activeId: selectedId,
2656
3200
  allRunsActive: !selectedId,
2657
3201
  creating,
@@ -2677,28 +3221,42 @@ function Studio(props) {
2677
3221
  })
2678
3222
  }) : /* @__PURE__ */ jsxs("div", {
2679
3223
  className: "mx-auto w-full max-w-6xl px-4 py-6 md:px-8 md:py-10",
2680
- children: [liveTarget ? /* @__PURE__ */ jsx(WorkflowHeader, {
2681
- node: liveTarget,
2682
- runs,
2683
- onEdit: () => go(liveTarget.id, liveTarget.id),
2684
- onDeleted: () => select(void 0, { replace: true })
2685
- }, liveTarget.id) : /* @__PURE__ */ jsx(WorkflowBoard, {
2686
- runs,
2687
- order: workflows.map((node) => node.id),
2688
- creating,
2689
- onOpen: (workflowId) => go(workflowId),
2690
- onCreate: () => create(WORKFLOW_TYPE, "Workflow", workflows.length)
2691
- }), /* @__PURE__ */ jsx(RunsView, {
2692
- title: liveTarget ? "Runs" : "Recent runs",
2693
- runs,
2694
- error: runsError,
2695
- reload: reloadRuns,
2696
- showWorkflow: liveTarget === null,
2697
- hasMore: feed.hasMore,
2698
- loadingMore: feed.loadingMore,
2699
- onLoadMore: feed.loadMore,
2700
- onFire: liveTarget && manualTrigger ? () => fireWorkflow(liveTarget.id).then((result) => result.error) : void 0
2701
- })]
3224
+ children: [
3225
+ liveTarget ? /* @__PURE__ */ jsx(WorkflowHeader, {
3226
+ node: liveTarget,
3227
+ runs,
3228
+ onEdit: () => go(liveTarget.id, liveTarget.id),
3229
+ onDeleted: () => select(void 0, { replace: true })
3230
+ }, liveTarget.id) : /* @__PURE__ */ jsx(WorkflowBoard, {
3231
+ runs,
3232
+ order: workflows.map((node) => node.id),
3233
+ creating,
3234
+ onOpen: (workflowId) => go(workflowId),
3235
+ approvals,
3236
+ onShowApprovals: showApprovals,
3237
+ onCreate: () => create(WORKFLOW_TYPE, "Workflow", workflows.length)
3238
+ }),
3239
+ /* @__PURE__ */ jsx(WaitingApprovals, {
3240
+ driveId: liveTarget ? void 0 : driveId,
3241
+ workflowId: liveTarget?.id,
3242
+ showWorkflow: liveTarget === null,
3243
+ stepNames,
3244
+ onChanged: reloadRuns,
3245
+ focusRequest: waitingFocus
3246
+ }),
3247
+ /* @__PURE__ */ jsx(RunsView, {
3248
+ title: liveTarget ? "Runs" : "Recent runs",
3249
+ runs,
3250
+ error: runsError,
3251
+ reload: reloadRuns,
3252
+ showWorkflow: liveTarget === null,
3253
+ hasMore: feed.hasMore,
3254
+ loadingMore: feed.loadingMore,
3255
+ onLoadMore: feed.loadMore,
3256
+ onFire: liveTarget && manualTrigger ? (payload) => fireWorkflow(liveTarget.id, payload).then((result) => result.error) : void 0,
3257
+ fireInputs
3258
+ })
3259
+ ]
2702
3260
  })
2703
3261
  })]
2704
3262
  });
@@ -2726,4 +3284,4 @@ function Editor(props) {
2726
3284
  //#endregion
2727
3285
  export { Editor as default };
2728
3286
 
2729
- //# sourceMappingURL=editor-C_eWGGi8.mjs.map
3287
+ //# sourceMappingURL=editor--J61vLSC.js.map