@w6w/embed 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +231 -4
- package/dist/ConfirmModal-RLbZT5_k.js +181 -0
- package/dist/ConfirmModal-RLbZT5_k.js.map +1 -0
- package/dist/CreateFunctionModal-DRsFx-FB.js +221 -0
- package/dist/CreateFunctionModal-DRsFx-FB.js.map +1 -0
- package/dist/DocumentFormModal-BExK1V-B.js +89 -0
- package/dist/DocumentFormModal-BExK1V-B.js.map +1 -0
- package/dist/ImportSpecModal-BDQIf6rg.js +136 -0
- package/dist/ImportSpecModal-BDQIf6rg.js.map +1 -0
- package/dist/W6WEmbedProvider.d.ts +22 -4
- package/dist/WorkflowEditor-DlbVv6Fs.js +854 -0
- package/dist/WorkflowEditor-DlbVv6Fs.js.map +1 -0
- package/dist/api-calls--JHyif6a.js +107 -0
- package/dist/api-calls--JHyif6a.js.map +1 -0
- package/dist/apps-1FNUwbGv.js +77 -0
- package/dist/apps-1FNUwbGv.js.map +1 -0
- package/dist/callables-3mFrMVG_.js +151 -0
- package/dist/callables-3mFrMVG_.js.map +1 -0
- package/dist/chrome/index.d.ts +6 -0
- package/dist/chrome/workspace.d.ts +29 -1
- package/dist/coerce-input-BicYr7nc.js +139 -0
- package/dist/coerce-input-BicYr7nc.js.map +1 -0
- package/dist/connections-CjjYeRqb.js +78 -0
- package/dist/connections-CjjYeRqb.js.map +1 -0
- package/dist/document-sources-C0grrtdq.js +86 -0
- package/dist/document-sources-C0grrtdq.js.map +1 -0
- package/dist/draft/index.d.ts +3 -1
- package/dist/draft/use-callable-draft.d.ts +65 -0
- package/dist/draft/workflow-save.d.ts +3 -0
- package/dist/draft.mjs +9 -5
- package/dist/draft.mjs.map +1 -1
- package/dist/editor/CallableEditorFrame.d.ts +33 -0
- package/dist/editor/EditorShell.d.ts +16 -0
- package/dist/editor/EndpointCards.d.ts +56 -0
- package/dist/editor/EndpointEditor.d.ts +26 -0
- package/dist/editor/FunctionEditor.d.ts +21 -0
- package/dist/editor/InputListEditor.d.ts +29 -0
- package/dist/editor/TargetSelector.d.ts +30 -0
- package/dist/editor/TargetSelector.types.d.ts +62 -0
- package/dist/editor/editor-apps.d.ts +8 -2
- package/dist/editor/types.d.ts +57 -0
- package/dist/editor-apps-BdenSV1o.js +95 -0
- package/dist/editor-apps-BdenSV1o.js.map +1 -0
- package/dist/editor-tools-RxmY5iyi.js +1279 -0
- package/dist/editor-tools-RxmY5iyi.js.map +1 -0
- package/dist/editor.mjs +2 -2166
- package/dist/editor.mjs.map +1 -1
- package/dist/editors/DocumentEditor.d.ts +20 -0
- package/dist/editors/doc-format.d.ts +3 -0
- package/dist/editors.d.ts +12 -0
- package/dist/editors.mjs +1313 -0
- package/dist/editors.mjs.map +1 -0
- package/dist/embed-status.d.ts +20 -0
- package/dist/endpoints-B2ynbZo-.js +227 -0
- package/dist/endpoints-B2ynbZo-.js.map +1 -0
- package/dist/forms/CreateEndpointModal.d.ts +54 -0
- package/dist/forms/CreateFunctionModal.d.ts +55 -0
- package/dist/forms/DocumentFormModal.d.ts +8 -0
- package/dist/forms/SecretsManager.d.ts +12 -0
- package/dist/forms/VarsManager.d.ts +29 -0
- package/dist/forms.d.ts +6 -0
- package/dist/forms.mjs +407 -0
- package/dist/forms.mjs.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.mjs +153 -50
- package/dist/index.mjs.map +1 -1
- package/dist/lib/callable-record.d.ts +21 -0
- package/dist/lib/coerce-input.d.ts +6 -0
- package/dist/lib/endpoint-editor.d.ts +23 -0
- package/dist/lib/index.d.ts +7 -0
- package/dist/lib/input-coverage.d.ts +28 -0
- package/dist/lib/input-seeding.d.ts +67 -0
- package/dist/lib/rail-settings.d.ts +3 -3
- package/dist/lib/recent-activity.d.ts +128 -0
- package/dist/lib/target-fields.d.ts +168 -0
- package/dist/lib/workflow-blank.d.ts +2 -0
- package/dist/lib.mjs +70 -48
- package/dist/lib.mjs.map +1 -1
- package/dist/lists/ActivitySummary.d.ts +29 -0
- package/dist/lists/CallableKindList.d.ts +34 -0
- package/dist/lists/ConnectionDetail.d.ts +17 -0
- package/dist/lists/ConnectionList.d.ts +16 -0
- package/dist/lists/DocumentList.d.ts +29 -0
- package/dist/lists/EndpointList.d.ts +19 -0
- package/dist/lists/FunctionList.d.ts +18 -0
- package/dist/lists/ReliabilityBoard.d.ts +23 -0
- package/dist/lists/RunHistory.d.ts +11 -0
- package/dist/lists/ServiceDetail.d.ts +20 -0
- package/dist/lists/WorkflowList.d.ts +19 -0
- package/dist/lists/vendor-history.d.ts +40 -0
- package/dist/lists.d.ts +20 -0
- package/dist/lists.mjs +1185 -0
- package/dist/lists.mjs.map +1 -0
- package/dist/project-context-BiCjv_E3.js +25 -0
- package/dist/project-context-BiCjv_E3.js.map +1 -0
- package/dist/project-context.d.ts +15 -1
- package/dist/rail/CallableRail.d.ts +12 -0
- package/dist/rail/CallableWorkspace.d.ts +16 -0
- package/dist/rail/SettingsTool.d.ts +7 -1
- package/dist/rail/settings-sections.d.ts +2 -2
- package/dist/rail-settings-XYGToh00.js +111 -0
- package/dist/rail-settings-XYGToh00.js.map +1 -0
- package/dist/rail.d.ts +11 -0
- package/dist/rail.mjs +35 -0
- package/dist/rail.mjs.map +1 -0
- package/dist/repos/api-calls.d.ts +4 -0
- package/dist/repos/apps.d.ts +14 -0
- package/dist/repos/callables.d.ts +91 -0
- package/dist/repos/connections.d.ts +33 -0
- package/dist/repos/dashboard.d.ts +4 -0
- package/dist/repos/endpoints.d.ts +125 -0
- package/dist/repos/functions.d.ts +79 -0
- package/dist/repos/index.d.ts +10 -0
- package/dist/repos/reliability.d.ts +42 -0
- package/dist/repos/saved-tests.d.ts +46 -0
- package/dist/repos/spec-export.d.ts +23 -0
- package/dist/repos/workflows.d.ts +138 -0
- package/dist/repos.mjs +174 -88
- package/dist/repos.mjs.map +1 -1
- package/dist/settings-rail--GdRMusb.js +33 -0
- package/dist/settings-rail--GdRMusb.js.map +1 -0
- package/dist/slug-C4ktDPdy.js +315 -0
- package/dist/slug-C4ktDPdy.js.map +1 -0
- package/dist/spec-export-Cf3VQSQS.js +176 -0
- package/dist/spec-export-Cf3VQSQS.js.map +1 -0
- package/dist/spec-import-CjmxyZDR.js +465 -0
- package/dist/spec-import-CjmxyZDR.js.map +1 -0
- package/dist/step-tests-CivICmTq.js +18 -0
- package/dist/step-tests-CivICmTq.js.map +1 -0
- package/dist/trigger-preview-VPkrryDl.js +120 -0
- package/dist/trigger-preview-VPkrryDl.js.map +1 -0
- package/dist/use-callable-draft-zHLpcr-b.js +271 -0
- package/dist/use-callable-draft-zHLpcr-b.js.map +1 -0
- package/dist/{use-workflow-draft-oI02dsP-.js → use-workflow-draft-DzAyUeA6.js} +48 -46
- package/dist/use-workflow-draft-DzAyUeA6.js.map +1 -0
- package/dist/vault-BSEWhMYC.js +117 -0
- package/dist/vault-BSEWhMYC.js.map +1 -0
- package/dist/workflow-blank-DyL3_RUA.js +14 -0
- package/dist/workflow-blank-DyL3_RUA.js.map +1 -0
- package/package.json +21 -5
- package/src/styles.css +408 -1
- package/dist/project-context-Dbk0Gr1K.js +0 -16
- package/dist/project-context-Dbk0Gr1K.js.map +0 -1
- package/dist/slug-ByKQgxrf.js +0 -642
- package/dist/slug-ByKQgxrf.js.map +0 -1
- package/dist/spec-import-HgO7ZkLZ.js +0 -898
- package/dist/spec-import-HgO7ZkLZ.js.map +0 -1
- package/dist/use-workflow-draft-oI02dsP-.js.map +0 -1
package/dist/editor.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.mjs","sources":["../src/chrome/ExecutionProfileHeader.tsx","../src/chrome/HistoryView.tsx","../src/chrome/history-open-run.ts","../src/chrome/HistoryModal.tsx","../src/chrome/HistoryButton.tsx","../src/chrome/Modal.tsx","../src/chrome/JsonToggle.tsx","../src/chrome/workspace.tsx","../src/chrome/RightRail.tsx","../src/rail/ExpressionScope.tsx","../src/chrome/CallFromCodeButton.tsx","../src/rail/CodeTool.tsx","../src/rail/rail-env.tsx","../src/rail/ErrorHandlingTool.tsx","../src/lib/tag-editor.ts","../src/chrome/TagEditor.tsx","../src/chrome/CallableSettingsModal.tsx","../src/chrome/ImportSpecModal.tsx","../src/chrome/ConfirmModal.tsx","../src/chrome/VersionHistoryModal.tsx","../src/chrome/DangerZone.tsx","../src/rail/settings-sections.tsx","../src/rail/SettingsTool.tsx","../src/rail/editor-tools.ts","../src/editor/WorkflowSettingsModal.tsx","../src/editor/definition.ts","../src/editor/editor-apps.ts","../src/editor/WorkflowEditor.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\n\n/**\n * `ExecutionProfileHeader` — the ONE editor header every execution profile's\n * editor mounts (T3.1.1, `building-blocks.md` §Profile building blocks\n * §Mirror).\n *\n * Extracted verbatim from `WorkflowsPage.tsx`'s full-bleed editor head, which\n * is the presentation of record: back control, title, actions. Two hosts use\n * it with two title CONFIGURATIONS, never two headers:\n * - `WorkflowsPage.tsx` — an inline-editable, controlled name input\n * (`editable: true`); back clears the `?edit=` search param; the action row\n * (run / stop / publish / JSON / settings) stays host-owned and arrives as\n * `actions`.\n * - `CallablePage.tsx`'s `CallableEditorChrome` — a Function/Endpoint\n * read-only heading (`editable: false`) with the `incomplete` badge passed\n * as `titleAdornment`, and the host's own JSON toggle then Save button as\n * `actions`.\n *\n * Presentation only: no query, mutation or navigation logic lives here — every\n * callback (`onBack`, `onChange`, `onBlur`) and every node in the action row is\n * the host's, mirroring the `ConnectionHeader.tsx` action-slot precedent.\n *\n * The rendered DOM of the Workflow editor's header is byte-for-byte what it\n * was before the extraction (`wf-fullbleed-head` / `wf-back-btn` /\n * `wf-title-input` / `wf-head-actions`, every `data-testid`, the `aria-label`\n * and the attribute order), which is what `styles.css`'s\n * `.wf-fullbleed-head input.wf-title-input` ancestor specificity and the\n * workflow header screenshot guard both depend on.\n */\n\n/** The editable title variant: the Workflow editor's inline-editable name. */\nexport interface EditableProfileTitle {\n /** The controlled value. */\n value: string;\n /** Called with the new text on every keystroke. */\n onChange: (next: string) => void;\n /** Called when the field loses focus — the Workflow host saves here. */\n onBlur: () => void;\n /** Shown while the value is empty; also the field's minimum sizing basis. */\n placeholder: string;\n /** The `maxLength` the input carries. */\n maxLength: number;\n /** The input's accessible name. */\n ariaLabel: string;\n}\n\n/** The read-only title variant: a Function/Endpoint editor's heading text. */\nexport interface ReadOnlyProfileTitle {\n value: string;\n}\n\n/** Which title the host mounts. The discriminant is `editable`. */\nexport type ExecutionProfileTitle =\n | ({ editable: true } & EditableProfileTitle)\n | ({ editable: false } & ReadOnlyProfileTitle);\n\n/**\n * The editable title field itself. Extracted so the input's own JSX — and the\n * `size` expression `src/lib/__tests__/workflow-title-size.test.ts` extracts\n * and RUNS — lives in one readable place. `size` is capped at the literal 80\n * (the same cap `maxLength` carries on the workflow host), independently of\n * `maxLength`: a name longer than 80 characters can only ever come from the\n * server, so `maxLength` alone would leave a pre-existing long name overflowing\n * its header.\n */\nfunction EditableTitle({ title }: { title: EditableProfileTitle }) {\n const { value, placeholder, maxLength, ariaLabel, onChange, onBlur } = title;\n return (\n <input\n className=\"wf-title-input\"\n value={value}\n placeholder={placeholder}\n maxLength={maxLength}\n size={Math.min(Math.max(value.length, placeholder.length), 80)}\n aria-label={ariaLabel}\n onChange={(e) => onChange(e.target.value)}\n onBlur={onBlur}\n />\n );\n}\n\nexport interface ExecutionProfileHeaderProps {\n /** The back control's click handler — host-owned (the Workflow host clears\n * `?edit=`; `CallableEditorChrome` navigates to the kind's listing). */\n onBack: () => void;\n /** The back control's visible text — host-owned copy (`\"← Workflows\"`,\n * `descriptor.editor.backLabel`). */\n backLabel: string;\n /** Editable (Workflow) or read-only (Function/Endpoint) title. */\n title: ExecutionProfileTitle;\n /** Rendered immediately after a read-only title — the `incomplete` badge. */\n titleAdornment?: ReactNode;\n /** The host's action row (buttons only; this component owns the wrapper). */\n actions: ReactNode;\n}\n\nexport function ExecutionProfileHeader({\n onBack,\n backLabel,\n title,\n titleAdornment,\n actions,\n}: ExecutionProfileHeaderProps) {\n return (\n <div className=\"wf-fullbleed-head\">\n <button\n type=\"button\"\n className=\"muted wf-back-btn\"\n data-testid=\"wf-editor-back\"\n onClick={onBack}\n >\n {backLabel}\n </button>\n {title.editable ? (\n <EditableTitle title={title} />\n ) : (\n <h2 className=\"exec-profile-title\">\n {title.value} {titleAdornment}\n </h2>\n )}\n <div className=\"wf-head-actions\" style={{ marginLeft: \"auto\" }}>\n {actions}\n </div>\n </div>\n );\n}\n","/**\n * `HistoryView` — the execution-history view body (T3.2.1, extracted from\n * `HistoryPage.tsx`'s T2.4.1 shape): stats + filters + paged list + the\n * selected execution's detail. Two hosts mount it — `HistoryPage` (the\n * project-wide and per-callable routes, filters URL-backed) and\n * `HistoryModal` (R-2's in-place modal, filters kept in local state) — so\n * this component owns every judgment call about HOW the view behaves, and\n * takes no position on WHERE its filters live: the host hands down\n * `filters` and gets every change back through `onFiltersChange`, exactly\n * the controlled-value shape `filtersToSearch`/`filtersFromSearch` already\n * assume on the URL-backed side.\n *\n * What stays here, same as it was in `HistoryPage` before the extraction:\n * - the search box's text, debounced, so a keystroke does not re-key and\n * re-issue both queries on every character (`onFiltersChange` — and so\n * the host's own write, URL or local state — fires only once typing\n * settles);\n * - which list row is selected, which is not shareable state and resets on\n * every mount;\n * - every filter change but paging snapping the page back to the first\n * (`offset` 0), because a narrowed result set has no meaningful \"page 3\".\n *\n * `onOpenInEditor`, when given, is called with the selected execution ONLY\n * while it is a workflow run (a function/endpoint invocation has no visual\n * editor to open) — the same gate `HistoryPage.tsx` applied inline before\n * this extraction. A host that never passes it (none of today's two do)\n * simply never sees the call.\n */\nimport {\n type ExecutionSummary,\n HISTORY_PAGE_SIZE,\n type HistoryFilters,\n type HistoryScope,\n useExecutionDetailQuery,\n useHistoryQuery,\n useHistoryStatsQuery,\n} from \"@w6w/embed/repos\";\nimport {\n ExecutionDetail,\n type ExecutionFilterValue,\n ExecutionFilters,\n ExecutionList,\n ExecutionStats,\n} from \"@w6w/ui\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\n/** How long to wait after the last keystroke before `onFiltersChange` fires\n * with the new `q` (and so before either query re-issues with it). */\nconst SEARCH_DEBOUNCE_MS = 300;\n\nexport interface HistoryViewProps {\n /** `null` ⇒ no scope known yet (the project-wide host, before its project\n * resolves) — both queries stay disabled, mirroring `repos/history.ts`'s\n * own `enabled: scope !== null`. */\n scope: HistoryScope | null;\n /** Project-wide chrome: the Kind filter, and the Callable column on every\n * row. A per-callable host (every callable already knows its own kind)\n * passes `false`. */\n showKind: boolean;\n filters: HistoryFilters;\n onFiltersChange: (next: HistoryFilters) => void;\n onOpenInEditor?: (execution: ExecutionSummary) => void;\n}\n\nexport function HistoryView(props: HistoryViewProps) {\n const { scope, showKind, filters, onFiltersChange, onOpenInEditor } = props;\n\n // The debounce below fires outside any render, so it needs the LATEST\n // filters (a status picked while a `q` write was still pending must\n // survive it) rather than the ones captured when typing started.\n const filtersRef = useRef(filters);\n filtersRef.current = filters;\n\n const [q, setQ] = useState(filters.q);\n const searchTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const [selected, setSelected] = useState<ExecutionSummary | null>(null);\n\n // Keep the search box in step with `filters.q` when IT moves from outside\n // (Back/Forward or a shared link on the URL-backed host). This never\n // fights a keystroke: an outside `q` only changes once typing has\n // settled, by which point `q` already equals it.\n useEffect(() => {\n setQ(filters.q);\n }, [filters.q]);\n\n // Drop a pending debounce on unmount.\n useEffect(\n () => () => {\n if (searchTimer.current) clearTimeout(searchTimer.current);\n },\n [],\n );\n\n const listQuery = useHistoryQuery(scope, filters);\n const statsQuery = useHistoryStatsQuery(scope, filters);\n const detailQuery = useExecutionDetailQuery(selected);\n\n const executions = listQuery.data?.executions ?? [];\n const offset = filters.offset;\n const hasMore = listQuery.data?.hasMore ?? false;\n\n /** Every filter change but paging reports a fresh filter set and resets\n * the page to the first. */\n const applyFilters = (next: ExecutionFilterValue) => {\n onFiltersChange({ ...next, offset: 0 });\n };\n\n const onChange = (next: ExecutionFilterValue) => {\n if (next.q === q) {\n applyFilters(next);\n return;\n }\n setQ(next.q);\n if (searchTimer.current) clearTimeout(searchTimer.current);\n searchTimer.current = setTimeout(() => {\n searchTimer.current = null;\n onFiltersChange({ ...filtersRef.current, q: next.q, offset: 0 });\n }, SEARCH_DEBOUNCE_MS);\n };\n\n const onPrev = () =>\n onFiltersChange({ ...filters, q, offset: Math.max(0, offset - HISTORY_PAGE_SIZE) });\n const onNext = () => onFiltersChange({ ...filters, q, offset: offset + HISTORY_PAGE_SIZE });\n\n const onSelect = useCallback(\n (executionId: string) => {\n setSelected(executions.find((row) => row.id === executionId) ?? null);\n },\n [executions],\n );\n\n const filterValue: ExecutionFilterValue = {\n status: filters.status,\n kind: filters.kind,\n from: filters.from,\n to: filters.to,\n q,\n };\n\n // A workflow run is the only execution with a visual editor to jump into\n // — a function/endpoint invocation has no such surface.\n const openInEditor =\n selected?.kind === \"workflow\" && onOpenInEditor ? () => onOpenInEditor(selected) : undefined;\n\n return (\n <>\n <ExecutionStats stats={statsQuery.data ?? null} />\n\n <ExecutionFilters showKind={showKind} value={filterValue} onChange={onChange} />\n\n {listQuery.isError && (\n <p className=\"error\" data-testid=\"history-error\">\n Couldn't load execution history.\n </p>\n )}\n\n <ExecutionList\n items={executions}\n showCallable={showKind}\n loading={listQuery.isLoading}\n selectedId={selected?.id ?? null}\n hasPrev={offset > 0}\n hasNext={hasMore}\n onPrev={onPrev}\n onNext={onNext}\n onSelect={onSelect}\n />\n\n {selected && (\n <ExecutionDetail\n execution={detailQuery.data ?? null}\n loading={detailQuery.isLoading}\n errorMessage={detailQuery.isError ? \"This execution is no longer available.\" : undefined}\n onClose={() => setSelected(null)}\n onOpenInEditor={openInEditor}\n />\n )}\n </>\n );\n}\n","import type { CallableKind, ExecutionSummary } from \"../repos/index.ts\";\n\n/**\n * The open-in-editor decision for a History view: only a workflow run has an editor to open, and\n * only when the host supplied `onOpenRun`. The handler closes the modal BEFORE handing the run id\n * to the host (the host's navigation then lands on an unobscured page).\n */\nexport function historyOpenRun(\n kind: CallableKind,\n onOpenRun: ((runId: string) => void) | undefined,\n onClose: () => void,\n): ((execution: ExecutionSummary) => void) | undefined {\n if (kind !== \"workflow\" || onOpenRun === undefined) return undefined;\n return (execution) => {\n onClose();\n onOpenRun(execution.id);\n };\n}\n","/**\n * `HistoryModal` (R-2 / T3.2.1) — the callable's own execution history,\n * opened as a full-page modal OVER the profile instead of away from it: the\n * route and the URL never change, so the editor underneath (unsaved edits,\n * canvas position, selected node) stays exactly as the author left it.\n * Mounted by `HistoryButton` in place of the navigation it used to do.\n *\n * `@w6w/ui`'s `Modal` at `size=\"full\"` (a near-fullscreen work surface,\n * `ui/src/components/Modal.tsx:12`) wraps `HistoryView`, scoped to this one\n * callable (`{ callable: id }`) with `showKind={false}` — a per-callable\n * view already knows its own kind. Filters are LOCAL state, starting empty\n * every time the modal opens, and are never written to the URL (HB10):\n * bookmarking a filtered view only makes sense for the standalone History\n * page, which still owns the URL-backed form.\n *\n * Closeable by ✕ (the `headerRight` button below), Esc (the real `Modal`'s\n * own `cancel` handling) or its backdrop click — all three funnel through\n * the same `onClose`, so the caller's \"focus returns to the History button\"\n * behaviour (`HistoryButton.tsx`) covers every dismissal path.\n *\n * \"Open in visual editor\" only ever applies to a workflow run, and every\n * execution this modal lists already belongs to THIS callable — its scope\n * is `{ callable: id }`, never project-wide — so there is no \"other\n * workflow\" branch to handle here (that one only exists on the project-wide\n * History page, which `HistoryPage.tsx` still owns). Closes the modal and\n * seeds `?run=` on the SAME route; `WorkflowsPage`'s own `[editId, runParam]`\n * effect (T2.4.2 HB7) is what opens the run overlay in place.\n */\nimport { type CallableKind, EMPTY_HISTORY_FILTERS, type HistoryFilters } from \"@w6w/embed/repos\";\nimport { IconButton, Modal } from \"@w6w/ui\";\nimport { useState } from \"react\";\nimport { HistoryView } from \"./HistoryView.tsx\";\nimport { historyOpenRun } from \"./history-open-run.ts\";\n\nexport interface HistoryModalProps {\n kind: CallableKind;\n id: string;\n onClose: () => void;\n /** Open a workflow run in the host's editor; absent ⇒ no open-in-editor affordance. */\n onOpenRun?: (runId: string) => void;\n}\n\nexport function HistoryModal(props: HistoryModalProps) {\n const { kind, id, onClose, onOpenRun } = props;\n const [filters, setFilters] = useState<HistoryFilters>(EMPTY_HISTORY_FILTERS);\n\n const onOpenInEditor = historyOpenRun(kind, onOpenRun, onClose);\n\n return (\n <Modal\n size=\"full\"\n title=\"History\"\n subtitle={id}\n onClose={onClose}\n headerRight={<IconButton icon=\"close\" label=\"Close\" onClick={onClose} />}\n >\n <div className=\"w6w-modal-body\">\n <HistoryView\n scope={{ callable: id }}\n showKind={false}\n filters={filters}\n onFiltersChange={setFilters}\n onOpenInEditor={onOpenInEditor}\n />\n </div>\n </Modal>\n );\n}\n","/**\n * The History affordance in the Function/Endpoint/Workflow editor headers\n * (T2.4.2, reworked by T3.2.1/R-2) — one icon button that opens the\n * callable's own execution history as a full-page modal OVER the profile\n * (`HistoryModal.tsx`) instead of navigating away from it, and refuses to\n * open while that callable has never executed.\n *\n * \"Has it ever executed?\" is `repos/history.ts`'s `useHasExecutedQuery` — the\n * cheap one-row `GET /history?callable=<id>&limit=1` existence probe (D1:\n * caller-scoped, exactly the rows its own History page lists). `hasExecuted`\n * reads `false` while that probe is in flight or has failed, so the button's\n * disabled state can never claim history that isn't there — the same \"no\n * false yes\" rule the hook's own docblock states.\n *\n * FAIL CLOSED WHEN THE ANSWER IS UNREADABLE. The hook assumes the envelope\n * (`{executions, hasMore}`) and dereferences `executions` directly, so a\n * response that is JSON but not that envelope — a bare `[]`, which several\n * older page-guard harnesses return from their catch-all for any unmodelled\n * `GET` — throws DURING RENDER. An uncaught render throw unmounts the whole\n * editor, so a header icon would be able to take the page down. The boundary\n * below keeps that failure inside this component and renders the same button\n * in its disabled state: no history is claimed, no modal is opened, and the\n * editor survives. The envelope-vs-array mismatch itself belongs to T2.3.1's\n * file (`src/repos/history.ts`), which this node must not edit.\n *\n * Chrome is `@w6w/ui`'s `IconButton` — the same borderless glyph-only control\n * `JsonToggle.tsx`'s `JsonToggleButton` renders, so the two header icon buttons\n * read as one family. The glyph is that component's `icon=\"history\"` (T2; the\n * local `HistoryIcon` hand-drawn SVG is gone), named `history` in the shared\n * set because it is the same drawing the left rail's History entry uses.\n *\n * Focus handling (R-2's \"closing it puts the user back exactly where they\n * were\"): the button keeps a ref to its own DOM node and refocuses it the\n * moment the modal reports `onClose`, regardless of which of the modal's own\n * three dismiss paths (✕, Esc, backdrop) fired it.\n */\nimport { type CallableKind, useHasExecutedQuery } from \"@w6w/embed/repos\";\nimport { IconButton } from \"@w6w/ui\";\nimport { Component, type ReactNode, type Ref, useEffect, useRef, useState } from \"react\";\nimport { HistoryModal } from \"./HistoryModal.tsx\";\n\nexport interface HistoryButtonProps {\n kind: CallableKind;\n id: string;\n /** Forwarded to the modal; see `HistoryModalProps.onOpenRun`. */\n onOpenRun?: (runId: string) => void;\n}\n\n/** The chrome itself, shared by the live button and the fail-closed fallback —\n * the fallback must be the SAME control (same test id, same name, same\n * glyph), only disabled, or a caller could tell the two apart by shape. */\nfunction HistoryButtonChrome({\n hasExecuted,\n onClick,\n buttonRef,\n}: {\n hasExecuted: boolean;\n onClick: () => void;\n buttonRef?: Ref<HTMLButtonElement>;\n}) {\n return (\n <IconButton\n ref={buttonRef}\n icon=\"history\"\n data-testid=\"history-button\"\n label=\"Execution history\"\n title={hasExecuted ? \"Execution history\" : \"No executions yet\"}\n disabled={!hasExecuted}\n onClick={onClick}\n />\n );\n}\n\n/** The probe's own render — the only thing that reads the query. Kept separate\n * so a throw from the hook lands on the boundary, not on the page. */\nfunction HistoryButtonProbe({ kind, id, onOpenRun }: HistoryButtonProps) {\n const { hasExecuted } = useHasExecutedQuery(id);\n const [open, setOpen] = useState(false);\n const buttonRef = useRef<HTMLButtonElement>(null);\n // Tracks the PREVIOUS `open` so the effect below only fires the moment the\n // modal actually goes from open to closed — never on first mount.\n const wasOpen = useRef(false);\n\n // Deferred to an effect (runs after the modal's `<dialog>` is gone from the\n // DOM) rather than called straight from `onClose`: while the native dialog\n // is still the top-layer modal, it traps focus, so a `.focus()` call fired\n // DURING its own `cancel`/dismiss handling can be silently ignored. Waiting\n // for the post-commit effect sidesteps that race for all three dismiss\n // paths (✕, Esc, backdrop) alike.\n useEffect(() => {\n if (wasOpen.current && !open) buttonRef.current?.focus();\n wasOpen.current = open;\n }, [open]);\n\n return (\n <>\n <HistoryButtonChrome\n hasExecuted={hasExecuted}\n buttonRef={buttonRef}\n onClick={() => setOpen(true)}\n />\n {open && (\n <HistoryModal kind={kind} id={id} onClose={() => setOpen(false)} onOpenRun={onOpenRun} />\n )}\n </>\n );\n}\n\n/** Last-resort boundary: an unreadable history answer disables the button\n * instead of unmounting the editor that hosts it. The fallback's `onClick` can\n * never fire (the button is disabled), so it does not need the router. */\nclass HistoryProbeBoundary extends Component<{ children: ReactNode }, { failed: boolean }> {\n state = { failed: false };\n\n static getDerivedStateFromError(): { failed: boolean } {\n return { failed: true };\n }\n\n componentDidCatch(error: unknown): void {\n console.error(\"history probe answer was unreadable; disabling the button\", error);\n }\n\n render(): ReactNode {\n if (this.state.failed) return <HistoryButtonChrome hasExecuted={false} onClick={() => {}} />;\n return this.props.children;\n }\n}\n\nexport function HistoryButton(props: HistoryButtonProps) {\n return (\n <HistoryProbeBoundary>\n <HistoryButtonProbe {...props} />\n </HistoryProbeBoundary>\n );\n}\n","import { useEffect, useRef } from \"react\";\n\ninterface ModalProps {\n title: string;\n onClose: () => void;\n children: React.ReactNode;\n /** Widen the dialog (e.g. for a JSON editor that needs room). */\n wide?: boolean;\n /** Widen further still (e.g. for the plan comparison grid). */\n xl?: boolean;\n /** Trailing control on the title row (e.g. a close `IconButton`). Given,\n * the title and this node share one `.modal-head` row; absent, the title\n * renders as a direct child exactly as before. */\n headerRight?: React.ReactNode;\n}\n\n/**\n * Small dialog modal. Built on the native <dialog> element so it gets focus\n * trapping, Esc-dismiss, and accessibility semantics for free. A button\n * positioned over the backdrop catches outside-clicks to close.\n */\nexport function Modal({\n title,\n onClose,\n children,\n wide = false,\n xl = false,\n headerRight,\n}: ModalProps) {\n const ref = useRef<HTMLDialogElement>(null);\n\n useEffect(() => {\n const el = ref.current;\n if (!el) return;\n if (!el.open) el.showModal();\n const onCancel = (e: Event) => {\n e.preventDefault();\n onClose();\n };\n // A `showModal()` dialog + its ::backdrop sit in the top layer, above any\n // sibling overlay — so catch outside clicks on the dialog itself: backdrop\n // clicks target the dialog, and land outside its box.\n const onClick = (e: MouseEvent) => {\n if (e.target !== el) return;\n const r = el.getBoundingClientRect();\n const outside =\n e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom;\n if (outside) onClose();\n };\n el.addEventListener(\"cancel\", onCancel);\n el.addEventListener(\"click\", onClick);\n return () => {\n el.removeEventListener(\"cancel\", onCancel);\n el.removeEventListener(\"click\", onClick);\n };\n }, [onClose]);\n\n return (\n <div className=\"modal-backdrop\">\n <dialog\n ref={ref}\n className={`modal${wide ? \" modal-wide\" : \"\"}${xl ? \" modal-xl\" : \"\"}`}\n aria-label={title}\n >\n {headerRight ? (\n <div className=\"modal-head\">\n <h3>{title}</h3>\n {headerRight}\n </div>\n ) : (\n <h3>{title}</h3>\n )}\n {children}\n </dialog>\n </div>\n );\n}\n","import { IconButton, JsonEditor } from \"@w6w/ui\";\nimport { Modal } from \"./Modal.tsx\";\n\nexport type JsonToggleMode = \"synced\" | \"disconnected\";\n\n/** The header icon button: `IconButton` with the set's `json` glyph — the\n * curly-brace icon, distinct from the `code` `</>` \"Call from code\" icon\n * beside it, so the two stop reading as the same button. The local\n * `JsonIcon` SVG this file used to carry is now `icon=\"json\"` in the shared\n * set. */\nexport function JsonToggleButton(props: { onClick: () => void }) {\n return <IconButton icon=\"json\" onClick={props.onClick} label=\"Edit raw JSON definition\" />;\n}\n\nexport interface JsonToggleProps {\n /** Parent-owned; render nothing when false. */\n open: boolean;\n onClose: () => void;\n /** Modal title. */\n title: string;\n mode: JsonToggleMode;\n /** Parent-owned text; the component keeps NO copy of it. */\n value: string;\n /** Every JsonEditor change, both modes. */\n onChange: (text: string) => void;\n /** JsonEditor's, error ?? null. */\n onValidityChange?: (v: { valid: boolean; error: string | null }) => void;\n /** When non-null: \"Invalid JSON — {invalidReason}\" (Workflow's existing line). */\n invalidReason?: string | null;\n /** Evaluated on `value` every render; non-null → shown in\n * <p className=\"muted small\" data-testid=\"json-toggle-reason\">. */\n guard?: (text: string) => string | null;\n /** disconnected only. */\n onSave?: () => void;\n /** disconnected only. */\n saving?: boolean;\n /** disconnected only; rendered as <div className=\"error\"> inside the dialog. */\n error?: string | null;\n /** JsonEditor aria-label. */\n editorLabel: string;\n}\n\n/**\n * The JSON⇄editor toggle's chrome — the header icon button's dialog, extracted\n * verbatim from `WorkflowsPage.tsx`'s raw-JSON modal (T2.1.1 D-2) so a second\n * host can reuse it in `mode=\"disconnected\"` (T2.1.2). Wraps `@w6w/ui`'s\n * `JsonEditor` and studio's own `Modal` (not `@w6w/ui`'s) — both existing\n * JSON-toggle-shaped precedents in this repo use studio's `Modal`.\n *\n * The component holds NO copy of `value`: every render shows exactly what the\n * parent hands it, which is what keeps a reopened dialog free of a stale\n * snapshot from the previous time it was open.\n */\nexport function JsonToggle(props: JsonToggleProps): JSX.Element | null {\n const {\n open,\n onClose,\n title,\n mode,\n value,\n onChange,\n onValidityChange,\n invalidReason,\n guard,\n onSave,\n saving,\n error,\n editorLabel,\n } = props;\n if (!open) return null;\n\n const guardReason = guard?.(value) ?? null;\n\n return (\n <Modal title={title} onClose={onClose} wide>\n <div className=\"modal-body\">\n <p className=\"muted small\">\n {mode === \"synced\" ? (\n <>\n Edit the raw definition (<code>manifestVersion: \"2\"</code>). Changes sync live to the\n visual editor.\n </>\n ) : (\n \"Save replaces the stored definition.\"\n )}\n </p>\n <JsonEditor\n value={value}\n onChange={onChange}\n onValidityChange={({ valid, error: err }) =>\n onValidityChange?.({ valid, error: err ?? null })\n }\n minHeight=\"420px\"\n aria-label={editorLabel}\n />\n {guardReason && (\n <p className=\"muted small\" data-testid=\"json-toggle-reason\">\n {guardReason}\n </p>\n )}\n {invalidReason && <div className=\"muted small\">Invalid JSON — {invalidReason}</div>}\n {error && <div className=\"error\">{error}</div>}\n </div>\n <div className=\"modal-actions\">\n {mode === \"synced\" ? (\n <button type=\"button\" className=\"btn ghost\" onClick={onClose}>\n Done\n </button>\n ) : (\n <>\n <button type=\"button\" className=\"btn ghost\" onClick={onClose}>\n Cancel\n </button>\n <button\n type=\"button\"\n className=\"btn\"\n data-testid=\"json-toggle-save\"\n disabled={guardReason != null || Boolean(saving)}\n onClick={onSave}\n >\n {saving ? \"Saving…\" : \"Save\"}\n </button>\n </>\n )}\n </div>\n </Modal>\n );\n}\n","import type { CallablePolicy, SnippetInput, TriggerPreview } from \"@w6w/embed/lib\";\n/**\n * `WorkspaceContext` — what resource (if any) the currently-viewed page has\n * open. The right rail (`chrome/RightRail.tsx`) and every registered\n * `RailTool`'s `Panel` read this via `useWorkspaceCallable`; a page publishes\n * into it via `useWorkspace`.\n *\n * Route-scoped, not root-scoped — mirrors `ProjectContext.tsx`'s precedent\n * (the only other context in this codebase deliberately scoped below the app\n * root): mounted around `Layout()`'s own returned tree (`components/Layout.tsx`),\n * next to its only reader, the rail.\n *\n * The publish idiom (compute a value during render, `useEffect` keyed on a\n * stable serialization of it, clear on unmount) mirrors the shape of the\n * human's uncommitted `src/ui/useDocumentTitle.ts` — copied here as a\n * PATTERN, never imported: that file is one of this project's 23 uncommitted\n * human files and a merged branch cannot depend on it.\n */\nimport { type ReactNode, createContext, useContext, useEffect, useState } from \"react\";\n\n/**\n * T2.1.2: widened to a discriminated union, one arm per kind — every new\n * field OPTIONAL, no new required member, so every existing producer keeps\n * compiling and behaving identically (`{kind, id}` alone still satisfies any\n * arm). The extra fields are what `CodeTool`'s snippet panel needs per kind\n * (mirrors `lib/sdk-snippets.ts`'s `SnippetCallable`, field-for-field where\n * the names match — see `lib/code-rail.ts`'s `toSnippetCallable` for the one\n * field that doesn't, `label` -> `displayName`).\n */\nexport type WorkspaceCallable =\n | {\n kind: \"function\";\n id: string;\n label?: string;\n key?: string;\n inputs?: readonly SnippetInput[];\n alias?: string;\n }\n | {\n kind: \"endpoint\";\n id: string;\n label?: string;\n key?: string;\n invokeUrl?: string;\n invokeUrlByKey?: string;\n urlForm?: \"id\" | \"key\";\n alias?: string;\n inputs?: readonly SnippetInput[];\n }\n | {\n kind: \"workflow\";\n id: string;\n label?: string;\n key?: string;\n triggers?: TriggerPreview[];\n /**\n * The workflow's run-level error policy, and the writer that applies it\n * (core Workflow RFC — *Amendment — 2026-08-21: the run-level error\n * handler*). Published ONLY by the page that owns the definition buffer\n * — the canvas editor — so the rail's Error handling tool edits the same\n * text the editor is about to save instead of racing it over the wire.\n * `ErrorHandlingTool` is the only reader; see `lib/settings-rail.ts`'s\n * `isAvailable` for why the tool hides itself when they are absent.\n *\n * ⚠️ `onPolicyChange` MUST be referentially stable across renders (a\n * `useCallback` reading through a ref). `useWorkspace` keys its publish\n * effect on `JSON.stringify(resource)`, which drops functions — so the\n * stored callback is whichever one was current when some OTHER field\n * last changed, and a closure that captured stale editor state would\n * write stale bytes.\n */\n policy?: CallablePolicy;\n onPolicyChange?: (policy: CallablePolicy) => void;\n }\n | { kind: \"connection\"; id: string; label?: string }\n | null;\n\n/** Derived from {@link WorkspaceCallable}, never redeclared — the arm a\n * `RailTool.isAvailable`/route wrapper narrows on. */\nexport type WorkspaceKind = Exclude<WorkspaceCallable, null>[\"kind\"];\n\ninterface WorkspaceContextValue {\n resource: WorkspaceCallable;\n setCallable: (resource: WorkspaceCallable) => void;\n}\n\nconst WorkspaceContext = createContext<WorkspaceContextValue | null>(null);\n\nexport function WorkspaceProvider({ children }: { children: ReactNode }) {\n const [resource, setCallable] = useState<WorkspaceCallable>(null);\n return (\n <WorkspaceContext.Provider value={{ resource, setCallable }}>\n {children}\n </WorkspaceContext.Provider>\n );\n}\n\n/** Publisher. Compute during render, effect-write, clear on unmount. */\nexport function useWorkspace(resource: WorkspaceCallable): void {\n const ctx = useContext(WorkspaceContext);\n if (!ctx) throw new Error(\"useWorkspace must be used within <WorkspaceProvider>\");\n const { setCallable } = ctx;\n // A stable serialization, not `resource` itself: a fresh object literal on\n // every render of the calling page (e.g. `{kind:\"workflow\", id}` rebuilt\n // each render) must not re-fire this effect every render — only a genuine\n // change to some field's VALUE should. T2.1.2: widened from a bespoke\n // `kind:id:label` template to a full `JSON.stringify` once the union grew\n // per-kind fields (`key`/`invokeUrl`/`invokeUrlByKey`/`urlForm`/`inputs`/\n // `triggers`) a caller can update after its first publish — e.g. the\n // Endpoint editor's id/key URL-form toggle or a picked tenant domain, both\n // of which change nothing about kind/id/label. A template keyed on\n // kind/id/label alone would miss those and leave `CodeTool`'s panel showing\n // the value from the FIRST render forever (same content -> same string ->\n // no re-fire, so this preserves the original's intent exactly, just over\n // every field instead of three of them).\n const key = resource ? JSON.stringify(resource) : \"\";\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed on the stable serialized `key`, not `resource`'s object identity — see the comment above.\n useEffect(() => {\n setCallable(resource);\n return () => setCallable(null);\n }, [key, setCallable]);\n}\n\n/** Reader — used by the rail and by every tool `Panel`. Throws outside the provider. */\nexport function useWorkspaceCallable(): WorkspaceCallable {\n const ctx = useContext(WorkspaceContext);\n if (!ctx) throw new Error(\"useWorkspaceCallable must be used within <WorkspaceProvider>\");\n return ctx.resource;\n}\n","import { restoreRailState } from \"@w6w/embed/lib\";\n/**\n * Third `.workspace` grid column: a 48px strip of the tools it is handed plus, when one is open,\n * its panel. Iterates `tools` with a single `.map` — never a per-tool JSX branch — so adding a\n * tool is a registry append in the host (Studio: `StudioRightRail`), nothing here changes.\n */\nimport { type ComponentType, useEffect, useState } from \"react\";\nimport { type WorkspaceCallable, useWorkspaceCallable } from \"./workspace.tsx\";\n\nexport interface RailTool {\n /** Stable; used as the persisted `activeTool`. */\n id: string;\n /** Strip tooltip + panel heading. */\n title: string;\n /** The strip glyph, as a component — built-in tools render a 16×16 `<Icon name=\"…\" />`\n * from `@w6w/ui`'s shared set; a tool may bring its own glyph instead. A component,\n * not an `IconName`, so this seam never narrows to the shared set. */\n Icon: ComponentType;\n isAvailable(ctx: WorkspaceCallable): boolean;\n /** Panel renders its own heading when it includes section actions. */\n rendersHeading?: boolean;\n Panel: ComponentType<{ ctx: WorkspaceCallable }>;\n}\n\ninterface RailState {\n open: boolean;\n activeTool: string | null;\n}\n\nconst CLOSED: RailState = { open: false, activeTool: null };\n\n/**\n * T4.1.1/A2: every mount starts CLOSED, unconditionally — `open` is no\n * longer read out of storage at all (D-I0-2). `restoreRailState`\n * (`../lib/rail-settings.ts`) only ever returns `activeTool`; its return\n * type has no `open` member, so a pre-existing `{\"open\":true,…}` value\n * written before this task has nothing here to reopen the rail with.\n */\nfunction readStoredState(key: string): RailState {\n if (typeof localStorage === \"undefined\") return CLOSED;\n const raw = localStorage.getItem(key);\n const { activeTool } = restoreRailState(raw);\n return { open: false, activeTool };\n}\n\n/** Presentational: the strip + (when open) the active tool's panel. Shared by\n * the persisted and not-yet-persistable (pin 12) render paths below. */\nfunction RailShell({\n tools,\n ctx,\n state,\n onToggle,\n}: {\n tools: readonly RailTool[];\n ctx: WorkspaceCallable;\n state: RailState;\n onToggle: (id: string) => void;\n}) {\n const activeTool = state.open ? (tools.find((t) => t.id === state.activeTool) ?? null) : null;\n return (\n <aside className=\"right-rail\">\n <div className=\"right-rail-strip\">\n {tools.map((tool) => (\n <button\n key={tool.id}\n type=\"button\"\n data-testid={`rail-tool-${tool.id}`}\n className={`right-rail-tool-btn${activeTool?.id === tool.id ? \" active\" : \"\"}`}\n title={tool.title}\n aria-label={tool.title}\n aria-pressed={activeTool?.id === tool.id}\n onClick={() => onToggle(tool.id)}\n >\n <tool.Icon />\n </button>\n ))}\n </div>\n {activeTool && (\n <div className=\"right-rail-panel\" data-testid={`rail-panel-${activeTool.id}`}>\n {!activeTool.rendersHeading && (\n <div className=\"right-rail-panel-head\">\n <h3>{activeTool.title}</h3>\n </div>\n )}\n <activeTool.Panel ctx={ctx} />\n </div>\n )}\n </aside>\n );\n}\n\n/** Owns the persisted open/activeTool state. Split out from `RightRail` and\n * `key`ed on `storageKey` (pin 11/12): `currentProject` resolves from a\n * query, so a `useState` initializer that ran before it resolved would read\n * `w6w.rail.undefined.undefined`. `RightRail` renders this component only\n * once `storageKey` is non-null, and `key={storageKey}` forces a fresh\n * mount — and so a fresh synchronous read of the RESOLVED key — whenever the\n * account/project changes. */\nfunction PersistedRail({\n storageKey,\n tools,\n ctx,\n}: {\n storageKey: string;\n tools: readonly RailTool[];\n ctx: WorkspaceCallable;\n}) {\n const [state, setState] = useState<RailState>(() => readStoredState(storageKey));\n\n // A2: only `activeTool` is ever persisted — `open` is never written to\n // storage (D-I0-2), so a fresh mount always starts closed regardless of\n // whether the rail happened to be open when the tab last closed.\n useEffect(() => {\n if (typeof localStorage === \"undefined\") return;\n localStorage.setItem(storageKey, JSON.stringify({ activeTool: state.activeTool }));\n }, [storageKey, state.activeTool]);\n\n function onToggle(id: string) {\n setState((prev) =>\n prev.open && prev.activeTool === id\n ? { open: false, activeTool: id }\n : { open: true, activeTool: id },\n );\n }\n\n return <RailShell tools={tools} ctx={ctx} state={state} onToggle={onToggle} />;\n}\n\n/** `storageKey === null`: no key to persist under yet (pin 12) — the strip renders closed and\n * nothing is written to localStorage. No available tool ⇒ no rail element at all (C/D-C3). */\nexport function RightRail({\n tools,\n storageKey,\n}: {\n tools: readonly RailTool[];\n storageKey: string | null;\n}) {\n const ctx = useWorkspaceCallable();\n const available = tools.filter((t) => t.isAvailable(ctx));\n if (available.length === 0) return null;\n if (storageKey === null) {\n return <RailShell tools={available} ctx={ctx} state={CLOSED} onToggle={() => {}} />;\n }\n return <PersistedRail key={storageKey} storageKey={storageKey} tools={available} ctx={ctx} />;\n}\n","import { type ExpressionOptions, ExpressionOptionsProvider } from \"@w6w/ui\";\nimport type { ReactNode } from \"react\";\nimport { useMemo } from \"react\";\nimport { documentSampleValues, projectDocumentSources } from \"../lib/document-sources.ts\";\n/**\n * The APP-LEVEL contribution to the ƒx expression scope — the rail every\n * expression editor starts from (Studio binds `project` to its `ProjectContext`; an embedder\n * passes its own, `null` disabling the project-scoped queries), wherever it is opened.\n *\n * ## Why this is a provider and not a hook each page calls\n *\n * The scope used to travel as an `exprOptions` PROP: each page built the same\n * ~40-line object and handed it to the one or two components it happened to\n * think of. Two things went wrong with that, and both are user-visible:\n *\n * 1. **A field the prop had not reached opened an empty editor.** On a\n * Function's Implementation card, the `ƒx` toggle on a mapping row offered\n * no variables, no secrets and no inputs — while the very same editor,\n * reached through that card's \"Change\" button, offered all of them,\n * because only the modal had been wrapped in a provider.\n * 2. **Five pages carried a copy of the same object.** `FunctionsPage`,\n * `EndpointsPage`, `AliasesPage`, `WorkflowsPage` and the connection\n * tester each restated vars, secrets, documents, `sampleValues`,\n * `sealSecret`, `createVar` and `createSecret` — because the only way to\n * add one page-specific key (`inputs`) was to restate the rest alongside\n * it.\n *\n * Mounted ONCE, inside `ProjectProvider` and around `Layout`, this fixes both:\n * every route inherits it, and a page contributes only what is genuinely its\n * own by nesting a second `ExpressionOptionsProvider` (which LAYERS — see that\n * component's own doc). A page's `inputs` therefore cannot reach a sibling\n * route or a region above it; navigating away drops it with the subtree.\n *\n * ## What belongs here, and what does not\n *\n * Here: anything true for the whole **project** — its variables, its secret\n * NAMES, its document keys, the sample values the Result pane previews against,\n * and the three host callbacks the picker's \"+ Add\"/seal affordances need.\n *\n * Not here: anything that is only true inside one editor. A Function's declared\n * `inputs`, an Endpoint's declared `input`, the upstream `steps` leading to one\n * workflow node — those are contributed by the page or the region that knows\n * about them, and must not be visible anywhere else.\n *\n * `ui` components stay pure (they never fetch): this is the host side, and only\n * names/refs cross the boundary — secret plaintext never reaches the client.\n */\nimport {\n useCreateSecretMutation,\n useCreateVarMutation,\n useDocumentsQuery,\n useSealSecret,\n useSecretsQuery,\n useVarsQuery,\n} from \"../repos/index.ts\";\n\n/**\n * The current project's expression sources, as an `ExpressionOptions`.\n *\n * Exported because a surface that renders OUTSIDE `ProjectExpressionScope` —\n * or one that needs the values themselves rather than the context — can still\n * build the same object. Inside the scope, prefer inheriting it.\n */\nexport function useProjectExpressionOptions(project: string | null): ExpressionOptions {\n const projectId = project;\n\n // Vars/secrets are subject-scoped (no project param on the secret list); the\n // vault list is masked name-only summaries, so nothing secret reaches the\n // client. Documents are project-scoped.\n const varsQuery = useVarsQuery(projectId ?? undefined, projectId != null);\n const secretsQuery = useSecretsQuery();\n const documentsQuery = useDocumentsQuery(projectId ?? undefined, projectId != null);\n const sealSecretFn = useSealSecret();\n // \"+ Add\" (T1.2.4): both mutations already invalidate the exact key their\n // `useQuery` reads (repos/vars.ts, repos/vault.ts), so a create's success\n // alone refreshes the rail — no refetch(), no local list state.\n const createVarMut = useCreateVarMutation();\n const createSecretMut = useCreateSecretMutation();\n\n return useMemo(\n () => ({\n vars: (varsQuery.data ?? []).map((v) => v.name),\n secrets: (secretsQuery.data ?? []).map((s) => s.name),\n // `document-sources.ts` owns the `format === \"json\"` gate and the raw\n // field enumeration — no parsing, no gate logic, and no filtering here\n // (A5c); `isRefSafeKey` filtering happens once, downstream, at the\n // modal's render site.\n documents: projectDocumentSources(documentsQuery.data ?? []),\n // Real project values so the ƒx Result preview substitutes them for\n // `vars.<name>` / `documents.<key>` / `documents.<key>.<field>` refs\n // instead of the raw template.\n sampleValues: {\n ...Object.fromEntries((varsQuery.data ?? []).map((v) => [`vars.${v.name}`, v.value])),\n ...documentSampleValues(documentsQuery.data ?? []),\n },\n sealSecret: sealSecretFn,\n // A created var carries the SAME project the read above carried (B3) —\n // it must land in the project whose rail asked for it. `type: \"string\"`\n // is pinned (a string type's `raw` passes through untouched) — the modal\n // has no type field.\n createVar: (input: { name: string; value: string; description?: string }) =>\n createVarMut\n .mutateAsync({\n input: {\n name: input.name,\n type: \"string\",\n value: input.value,\n description: input.description,\n },\n project: projectId ?? undefined,\n })\n .then(() => undefined),\n // Secrets carry NO project (B4) — `vault_secrets` has no `project`\n // column and the routes read no `?project=`. Plaintext in, the server\n // encrypts; the resolved value is referenced nowhere (B5).\n createSecret: (input: { name: string; value: string; description?: string }) =>\n createSecretMut\n .mutateAsync({ name: input.name, value: input.value, description: input.description })\n .then(() => undefined),\n }),\n [\n varsQuery.data,\n secretsQuery.data,\n documentsQuery.data,\n sealSecretFn,\n createVarMut.mutateAsync,\n createSecretMut.mutateAsync,\n projectId,\n ],\n );\n}\n\n/**\n * Provide the current project's expression sources to every route below.\n *\n * Mount once, inside `ProjectProvider` (it reads the active project) and around\n * `Layout` (so every page inherits). It contributes no `inputs` and no `steps`\n * on purpose — see the module doc.\n */\nexport function ProjectExpressionScope({\n project,\n children,\n}: {\n project: string | null;\n children: ReactNode;\n}) {\n const options = useProjectExpressionOptions(project);\n return <ExpressionOptionsProvider value={options}>{children}</ExpressionOptionsProvider>;\n}\n","import {\n type SnippetCallable,\n type TriggerPreview,\n buildSnippet,\n unavailableReason,\n} from \"@w6w/embed/lib\";\nimport { CodeBlock, type CodeLanguage, IconButton, type IconName, Modal } from \"@w6w/ui\";\nimport { useState } from \"react\";\n\n/**\n * \"Call from code\" — the button that shows how to reach the thing you are\n * looking at from the Node SDK (`@w6w/sdk`), the CLI (`w6w`), or the Python\n * SDK (`w6w`, PyPI).\n *\n * Mounted on the pages whose resource the wrapper contract actually covers.\n * Everything shown comes from `../lib/sdk-snippets.ts`, which builds against\n * `packages/wrappers/endpoints.json` — this component owns presentation only\n * and never composes an API call of its own.\n *\n * A modal rather than an inline block: the snippet is reference material a\n * reader wants once and then dismisses, and inlining it would push the page's\n * real content (a function's inputs, a workflow's steps) below the fold for\n * everyone who is not currently writing a client.\n */\n\n/**\n * Tabs, in the order the contract lists the wrappers — then `curl`, which is\n * not a wrapper at all and therefore comes last.\n *\n * The strip renders only the tabs the BUILT snippet actually carries\n * (`Snippet.curl` is optional): a Function, Endpoint or Workflow shows all\n * four tabs, while a Connection, Var or Document — which have no fixed\n * single-resource route to curl against — still show exactly the three\n * Node/CLI/Python tabs they show today.\n */\nconst TABS = [\n { id: \"node\", label: \"Node\", language: \"TypeScript\", grammar: \"typescript\", icon: \"lang-node\" },\n { id: \"cli\", label: \"CLI\", language: \"Shell\", grammar: \"bash\", icon: \"terminal\" },\n { id: \"python\", label: \"Python\", language: \"Python\", grammar: \"python\", icon: \"lang-python\" },\n { id: \"curl\", label: \"curl\", language: \"Shell\", grammar: \"bash\", icon: \"lang-curl\" },\n] as const satisfies readonly {\n id: string;\n label: string;\n language: string;\n grammar: CodeLanguage;\n /** The tab's glyph, by name from `@w6w/ui`'s icon set (`icons.tsx`). Every\n * language mark this file used to draw — its own `NodeGlyph`/`CliGlyph`/\n * `PythonGlyph`/`CurlGlyph` — is one of those entries, copied verbatim, so\n * the tab strip and the rail's language picker draw the same four shapes\n * from one place. */\n icon: IconName;\n}[];\n\n/**\n * The tab table, exported so a caller can render its OWN affordance per\n * language without re-deriving the set. `CodeTool`'s rail panel uses it to draw\n * one icon per language and open this component's modal on that language.\n *\n * Exported as the table rather than as a list of ids on purpose: label, grammar\n * and glyph belong to the same row, and a second place that decided \"which\n * languages exist\" would be a second place to forget `curl`.\n */\nexport const SNIPPET_TABS = TABS;\n\ntype TabId = (typeof TABS)[number][\"id\"];\nexport type SnippetTabId = TabId;\n\n/**\n * Which language tabs a resource actually has — the same filter the strip\n * below applies, hoisted so a caller can ask BEFORE rendering.\n *\n * `curl` is emitted only where a public URL exists and was handed in (today: a\n * Function, a Workflow, or an Endpoint that knows its own server-rendered URL),\n * so a var, document or connection yields exactly Node/CLI/Python. Trigger\n * fields are deliberately not a parameter: they change what the snippet SAYS,\n * never which languages it is available in.\n *\n * Empty when the resource has no snippet at all — the caller should then show\n * {@link unavailableReason} rather than an empty row of icons.\n */\nexport function snippetTabsFor(resource: SnippetCallable): readonly (typeof TABS)[number][] {\n const snippet = buildSnippet(resource);\n return snippet ? TABS.filter((t) => typeof snippet[t.id] === \"string\") : [];\n}\n\n/**\n * The headless body — everything that renders the snippet itself: the\n * trigger-tab strip, the language-tab strip, the `CodeBlock`, and the per-tab\n * install-hint paragraph. No button, no `Modal`. Split out (T2.1.2) so\n * `CodeTool.Panel` (`../ui/rail/CodeTool.tsx`) can render this INSIDE the\n * right rail's own already-open panel, without a second trigger button or a\n * Modal-on-top-of-a-panel double-wrap — the rail's strip + panel disclosure\n * IS the trigger; this component only needs to draw what's inside it.\n * `CallFromCodeButton` below is unchanged in outward shape: the same button +\n * `Modal`, now rendering this body inside.\n */\nexport function CallFromCodeBody({\n resource,\n triggers,\n wrap = false,\n maxHeight = \"420px\",\n initialTab,\n}: {\n resource: SnippetCallable;\n /**\n * The workflow's declared manual (`@w6w/trigger`) triggers, one entry per\n * step, in declared order — optional so every other `CallFromCodeBody`\n * caller (function, endpoint, connection, var, document) is unaffected.\n * Both call sites derive this from a workflow definition already in scope\n * (T2.2.1, HITL-2/HITL-4 pinned); nothing here fetches it. The selected\n * trigger's declared fields are passed straight into `buildSnippet` and\n * rendered INSIDE the generated code — required fields as active code with\n * a type-derived placeholder, optional fields commented out (D-3/D-4) — so\n * there is nothing left to duplicate in a panel above it.\n */\n triggers?: TriggerPreview[];\n /**\n * Soft-wrap the code box instead of scrolling it horizontally. Default OFF\n * — see the `CodeBlock` call below for why off is right wherever there is\n * room, and why the right rail is the place where it is not.\n */\n wrap?: boolean;\n /** The code box's max height. Default `\"420px\"`, the modal's size. */\n maxHeight?: string;\n /**\n * Which language to open on. Seeds the selection ONCE, at mount — this is a\n * starting point, not a controlled value, so the strip stays clickable\n * afterwards.\n *\n * That \"once\" is load-bearing for the rail: `CodeTool` mounts this inside a\n * modal that is conditionally rendered, so picking Python, closing, and\n * picking Node re-mounts and re-seeds. A tab this resource does not carry\n * falls back to the first one it does, via `activeTab` below.\n */\n initialTab?: TabId;\n}) {\n const [tab, setTab] = useState<TabId>(initialTab ?? \"node\");\n const [triggerIndex, setTriggerIndex] = useState(0);\n const hasTriggers = !!triggers && triggers.length > 0;\n const selectedTrigger = hasTriggers\n ? (triggers[Math.min(triggerIndex, triggers.length - 1)] ?? triggers[0])\n : null;\n const snippet = buildSnippet(resource, selectedTrigger?.fields);\n // Only the tabs this snippet carries. `curl` is emitted for a Function,\n // Workflow, or an Endpoint that knows its own server-rendered URL — a var,\n // document or connection still renders exactly Node/CLI/Python.\n const tabs = snippet ? TABS.filter((t) => typeof snippet[t.id] === \"string\") : [];\n // Never leave the selection pointing at a tab that is not on the strip — the\n // component is mounted once per page and `tab` outlives a resource change.\n const activeTab: TabId = tabs.some((t) => t.id === tab) ? tab : (tabs[0]?.id ?? \"node\");\n const code = snippet?.[activeTab] ?? \"\";\n\n if (snippet === null) return <p className=\"muted\">{unavailableReason(resource)}</p>;\n\n return (\n <>\n {hasTriggers && selectedTrigger && (\n <div className=\"subpanel\" style={{ marginTop: 0, paddingTop: 0, borderTop: \"none\" }}>\n {/* Reuses `.code-tabs`/`.code-tab` — the modal's own existing\n Node/CLI/Python strip pattern (HITL-2: \"mirroring the\n modal's existing Node/CLI/Python strip\"). Nested INSIDE\n the trigger panel so the language tab-strip assertion\n below (which filters out anything under\n `[data-testid='trigger-panel']`) still sees exactly\n Node/CLI/Python. The selected trigger's fields are no\n longer listed HERE — they are rendered inside the code\n below (required active, optional commented; D-3/D-4),\n so a list here would only duplicate it. */}\n <div data-testid=\"trigger-panel\">\n <div className=\"code-tabs\">\n {triggers.map((t, i) => (\n <button\n key={t.id}\n type=\"button\"\n className={`code-tab${i === triggerIndex ? \" active\" : \"\"}`}\n data-testid=\"trigger-tab\"\n onClick={() => setTriggerIndex(i)}\n >\n {t.label}\n </button>\n ))}\n </div>\n {selectedTrigger.fields.length === 0 && (\n <p className=\"muted small\">This trigger declares no fields.</p>\n )}\n </div>\n {triggers.length > 1 && (\n <p className=\"muted small\" data-testid=\"trigger-multi-note\">\n This workflow has {triggers.length} manual triggers — the same input reaches every one\n of them identically; there is no per-trigger routing.\n </p>\n )}\n </div>\n )}\n\n <div className=\"code-tabs\">\n {tabs.map((t) => (\n <button\n key={t.id}\n type=\"button\"\n className={`code-tab${activeTab === t.id ? \" active\" : \"\"}`}\n onClick={() => setTab(t.id)}\n >\n {t.label}\n </button>\n ))}\n </div>\n\n {/* `wrap` is a CALLER decision, defaulting OFF. Off is right wherever\n there is room: the CLI snippet's `\\`-continued lines are chosen line\n breaks, and soft-wrapping blurs them into the accidental ones, so a\n long Node line scrolls instead.\n It is wrong in the right RAIL, whose panel is ~395px wide — there\n every snippet scrolls horizontally, every time, and a snippet you\n have to drag sideways to read is not a snippet you can read. The\n rail passes `wrap`; the modal (which has the room) does not. The\n copy affordance lives inside the code box itself (`copyable`) — no\n local `CopyButton`, no `.code-tabs-spacer`. */}\n <CodeBlock\n code={code}\n language={TABS.find((t) => t.id === activeTab)?.grammar ?? \"plaintext\"}\n maxHeight={maxHeight}\n wrap={wrap}\n aria-label={`${TABS.find((t) => t.id === activeTab)?.label ?? activeTab} snippet`}\n copyable\n />\n\n {/* One arm per tab, and `python` is now EXPLICIT: it used to be\n the trailing `else`, so a fourth tab would silently have\n inherited \"pip install w6w\". The `curl` arm names no\n `operation` — raw HTTP maps to no wrapper-contract operation,\n and claiming one would be a promise the contract does not\n make. */}\n <p className=\"muted small\" style={{ marginBottom: 0 }}>\n {activeTab === \"node\" ? (\n <>\n <code>npm i @w6w/sdk</code> · set <code>W6W_BASE_URL</code> and <code>W6W_TOKEN</code> ·\n operation <code>{snippet.operation}</code>\n </>\n ) : activeTab === \"cli\" ? (\n <>\n <code>npm i -g @w6w/cli</code> · set <code>W6W_BASE_URL</code> and{\" \"}\n <code>W6W_TOKEN</code> (or pass <code>--base-url</code> / <code>--token</code>) ·\n operation <code>{snippet.operation}</code>\n </>\n ) : activeTab === \"python\" ? (\n <>\n <code>pip install w6w</code> · set <code>W6W_BASE_URL</code> and <code>W6W_TOKEN</code>{\" \"}\n · operation <code>{snippet.operation}</code>\n </>\n ) : (\n <>\n No client library — any HTTP client will do. Set <code>W6W_BASE_URL</code> to your w6w\n base URL (for an Endpoint, the URL above is the one this page is showing); substitute a\n w6w token for <code>$W6W_TOKEN</code> and send the declared input as the JSON body.\n </>\n )}\n </p>\n </>\n );\n}\n\nexport function CallFromCodeButton({\n resource,\n label = \"Call from code\",\n triggers,\n initialTab,\n}: {\n resource: SnippetCallable;\n label?: string;\n /** See {@link CallFromCodeBody}'s own doc — passed straight through. */\n triggers?: TriggerPreview[];\n /** See {@link CallFromCodeBody}'s own doc — passed straight through. */\n initialTab?: TabId;\n}) {\n const [open, setOpen] = useState(false);\n\n return (\n <>\n <IconButton icon=\"code\" label={label} onClick={() => setOpen(true)} />\n\n {open && (\n <Modal title=\"Call from code\" size=\"wide\" onClose={() => setOpen(false)}>\n <CallFromCodeBody resource={resource} triggers={triggers} initialTab={initialTab} />\n </Modal>\n )}\n </>\n );\n}\n","import { Icon } from \"@w6w/ui\";\nimport { useState } from \"react\";\nimport {\n CallFromCodeBody,\n type SnippetTabId,\n snippetTabsFor,\n} from \"../chrome/CallFromCodeButton.tsx\";\nimport { Modal } from \"../chrome/Modal.tsx\";\nimport type { RailTool } from \"../chrome/RightRail.tsx\";\nimport type { WorkspaceCallable } from \"../chrome/workspace.tsx\";\nimport { isAvailable, toSnippetCallable } from \"../lib/code-rail.ts\";\nimport { unavailableReason } from \"../lib/sdk-snippets.ts\";\n/**\n * The Code tool — the right rail's second registered client of T3.1.1's\n * registry seam (`src/ui/railTools.ts`), and T2.1.2's \"use code\" move: the\n * page-header \"Call from code\" button on Functions/Endpoints/Workflow-detail/\n * the flow-editor canvas becomes this strip icon + panel instead.\n *\n * The two pure decisions — is a snippet meaningful for this context, and\n * what `SnippetCallable` it converts to — live in `./../lib/code-rail.ts` so\n * `node --test` can gate them. This module owns presentation only.\n *\n * The panel is a LANGUAGE PICKER, not a snippet. It used to render\n * `CallFromCodeBody` inline, and a snippet is not readable in a ~395px\n * column: it scrolled sideways, and wrapping it (the first fix) turned the\n * CLI snippet's deliberate `\\`-continuations into what reads as separate\n * commands. Both are symptoms of the same thing — the snippet needs width the\n * rail does not have.\n *\n * So the rail shows one icon per language the resource can be called in, and\n * each opens the full-width modal ALREADY ON THAT LANGUAGE: one click to the\n * thing you came for, rather than open-then-hunt-for-the-tab. The set of\n * languages comes from `snippetTabsFor`, the same filter the modal's own tab\n * strip applies, so the rail can never offer a language the modal would not.\n */\n\nfunction CodePanel({ ctx }: { ctx: WorkspaceCallable }) {\n // Which language the modal opens on, or `null` for closed. ONE piece of\n // state, not an `open` flag beside a `tab`: the two can never disagree, and\n // \"closed\" cannot carry a stale language into the next open.\n const [openTab, setOpenTab] = useState<SnippetTabId | null>(null);\n const snippetCallable = toSnippetCallable(ctx);\n // Defensive: `isAvailable` already keeps this tool off the strip for a\n // `ctx` this can't build a snippet for — mirrors `SettingsTool.tsx`'s own\n // note about `Panel` still needing to handle a ctx `isAvailable` would\n // have excluded (a persisted `activeTool` plus an in-app transition to a\n // non-publishing route can still render this Panel).\n if (!snippetCallable) return null;\n const triggers = ctx?.kind === \"workflow\" ? ctx.triggers : undefined;\n const tabs = snippetTabsFor(snippetCallable);\n\n // No languages means no snippet at all — say why, rather than draw an empty\n // row of icons. Same sentence the body itself would have shown.\n if (tabs.length === 0) return <p className=\"muted\">{unavailableReason(snippetCallable)}</p>;\n\n return (\n <div>\n {/* A LANGUAGE PICKER, not a snippet.\n\n The rail's panel is ~395px wide, and a snippet rendered into it was\n unreadable at that width — first because it scrolled sideways, then,\n once wrapped, because a wrapped shell command reads as two commands.\n Neither is fixable in 395px: the snippet needs the room.\n\n So the panel stops trying to show one. It shows the languages this\n resource can be called in, and each opens the full-width modal\n ALREADY ON THAT LANGUAGE — one click to the thing you came for,\n instead of open-then-hunt-for-the-tab. The languages come from\n `snippetTabsFor`, so a resource with no public URL simply has no curl\n icon rather than an icon that opens an empty tab.\n\n Still not the double-chrome `CallFromCodeButton.tsx`'s header warns\n about: that trap was wrapping the rail's own panel in a modal by\n DEFAULT. The panel is its own content here; the modal is opt-in. */}\n <p className=\"muted small\" style={{ marginTop: 0 }}>\n Call this from:\n </p>\n <div className=\"rail-code-langs\">\n {tabs.map(({ id, label, icon }) => (\n <button\n key={id}\n type=\"button\"\n className=\"rail-code-lang\"\n data-testid={`rail-code-lang-${id}`}\n title={`Show the ${label} snippet`}\n aria-label={`Show the ${label} snippet`}\n onClick={() => setOpenTab(id)}\n >\n <Icon name={icon} size={20} />\n <span>{label}</span>\n </button>\n ))}\n </div>\n\n {/* Conditionally rendered, so each open MOUNTS the body afresh and\n `initialTab` seeds it again — picking Python, closing, then picking\n Node lands on Node. A body kept mounted would keep the first pick. */}\n {openTab !== null && (\n <Modal title=\"Call from code\" wide onClose={() => setOpenTab(null)}>\n <div style={{ height: 450 }}>\n <CallFromCodeBody resource={snippetCallable} triggers={triggers} initialTab={openTab} />\n </div>\n </Modal>\n )}\n </div>\n );\n}\n\nfunction CodeToolIcon() {\n return <Icon name=\"code\" />;\n}\n\nexport const codeTool: RailTool = {\n id: \"code\",\n title: \"Code\",\n Icon: CodeToolIcon,\n isAvailable: (ctx) => isAvailable(ctx),\n Panel: CodePanel,\n};\n","/**\n * The rail's host environment — the two things a rail tool needs from the host that it cannot\n * own: which project the surface is looking at, and how to move the host somewhere after a\n * rail action (archive / delete land on the list; an import opens the imported row).\n *\n * Studio binds both to its router and `ProjectContext`; an embedder binds them to its own. A\n * rail tool never imports a router: it calls `onNavigate` with a target and the host decides what\n * that means. The default (no provider mounted) is inert — no project, navigation ignored — so a\n * tool rendered outside a provider cannot save into the wrong project or throw.\n *\n * `project` is passed through to every write VERBATIM; `null` means \"no project\", on which the\n * package hooks refuse to save (never a fallback to the account default, C/D-C2).\n */\nimport { type ReactNode, createContext, useContext } from \"react\";\nimport type { SpecImportKind } from \"../lib/spec-import-invalidation.ts\";\n\n/** Where the host should go after a rail action. */\nexport type RailNavigation =\n | { type: \"list\" }\n | { type: \"imported\"; kind: SpecImportKind; id: string };\n\nexport interface RailEnv {\n project: string | null;\n onNavigate(to: RailNavigation): void;\n}\n\nconst DEFAULT_ENV: RailEnv = { project: null, onNavigate: () => {} };\n\nconst RailEnvContext = createContext<RailEnv>(DEFAULT_ENV);\n\nexport function RailEnvProvider({\n project,\n onNavigate,\n children,\n}: RailEnv & { children: ReactNode }) {\n return (\n <RailEnvContext.Provider value={{ project, onNavigate }}>{children}</RailEnvContext.Provider>\n );\n}\n\nexport function useRailEnv(): RailEnv {\n return useContext(RailEnvContext);\n}\n","/**\n * The Error handling tool — the right rail's tool for choosing **what runs when a call fails**.\n *\n * It is a BUTTON, not a form. Clicking it opens the F-2.0 picker modal (`StepBuilderModal`) with\n * its Functions and Workflows tabs, and the pick becomes the resource's `reroute.target`. All\n * three handler shapes are offered: an app Action, a Function, or a Workflow.\n *\n * This module owns two things:\n * - `ErrorHandlerSection` — the shared body (picker, handler label lookup, self-decision,\n * retry / reroute fields and the inline error). It calls no definition query and no save\n * mutation: the caller hands in the `policy` it read and an `onPersist` that writes. Studio's\n * function/endpoint arms render it over their own repos; the workflow arm below renders it\n * over the host's buffer.\n * - `errorHandlingTool` — the workflow-only registry entry. A Workflow hands the policy back to\n * the surface that owns the definition buffer (`ctx.onPolicyChange`), which folds it into the\n * JSON the canvas is already saving. The rail never writes a workflow over the wire itself —\n * see `lib/settings-rail.ts`'s `isAvailable` for why racing the canvas's auto-save is not an\n * option.\n *\n * For a Workflow this is the handler for the RUN AS A WHOLE (core Workflow RFC — *Amendment —\n * 2026-08-21: the run-level error handler*), which is a different question from a step's own\n * `onError` on the canvas and from an `Edge.when: \"error\"`. `retry` IS authored here, through\n * `@w6w/ui`'s `RetryPolicyFields` (core Workflow RFC R-2, \"one retry shape everywhere\").\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { type BuiltStep, Icon, RetryPolicyFields, StepBuilderModal } from \"@w6w/ui\";\nimport { useEffect, useState } from \"react\";\nimport type { RailTool } from \"../chrome/RightRail.tsx\";\nimport type { WorkspaceCallable } from \"../chrome/workspace.tsx\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport { errorHandlerSelfDecision } from \"../lib/error-handler-self.ts\";\nimport {\n type CallablePolicy,\n isAvailable as isSettingsRailAvailable,\n policyFromDefinition,\n} from \"../lib/settings-rail.ts\";\nimport { useWorkflowsQuery } from \"../repos/workflows.ts\";\nimport { useRailEnv } from \"./rail-env.tsx\";\n\n/**\n * `@w6w/ui/flow`'s `CALL_APP`, restated: a VALUE import from the flow subpath would put the whole\n * canvas on the editor's eager path (the editor loads it with a dynamic `import()` only). A test\n * (`workflow-editor.test.ts`) pins the two spellings equal.\n */\nexport const CALL_APP = \"@w6w/call\";\n\ntype ErrorHandlerTarget = NonNullable<NonNullable<CallablePolicy[\"reroute\"]>[\"target\"]>;\n\nexport type ErrorHandlerKind = \"function\" | \"endpoint\" | \"workflow\";\n\n/** The id a handler target names, whichever of the three arms it is. */\nfunction refOf(target: ErrorHandlerTarget | undefined): string {\n if (!target) return \"\";\n if (target.kind === \"workflow\") return target.workflow;\n if (target.kind === \"function\") return target.function;\n return `${target.uses.app}/${target.uses.action}`;\n}\n\n/** The noun shown under a bound handler. */\nfunction nounOf(target: ErrorHandlerTarget | undefined): string {\n if (target?.kind === \"workflow\") return \"Workflow (asynchronous)\";\n if (target?.kind === \"function\") return \"Function (synchronous)\";\n return \"App action (synchronous)\";\n}\n\n/** The Functions list, for naming a bound handler. Same key and payload as Studio's\n * `useFunctionsQuery` (`GET /functions`, unwrapped), so the two share one cache entry. */\nfunction useFunctionsLabels(enabled: boolean) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: [\"functions\"],\n queryFn: () => client.functions.list(),\n enabled,\n });\n}\n\nexport interface ErrorHandlerSectionProps {\n kind: ErrorHandlerKind;\n id: string;\n /** The policy as currently stored (already read off the definition or buffer). */\n policy: CallablePolicy;\n /** The definition (or buffer) the policy was read from is present. */\n ready: boolean;\n saving: boolean;\n /** Write a whole new policy. `onError` shows a refusal inline. */\n onPersist(next: CallablePolicy, onError: (message: string) => void): void;\n}\n\nexport function ErrorHandlerSection({\n kind,\n id,\n policy,\n ready,\n saving,\n onPersist,\n}: ErrorHandlerSectionProps) {\n // Name the bound handler rather than showing a bare id. Both lists are already cached by the\n // picker itself, so this costs no extra round-trip in the common case.\n const functionsQuery = useFunctionsLabels(true);\n // The editor's project (RailEnv, as the Settings tool reads it), never the provider's default:\n // a project-less list would go out as the provider's project, not the one being edited.\n const { project } = useRailEnv();\n const workflowsQuery = useWorkflowsQuery(project ?? undefined, true);\n\n const [pickerOpen, setPickerOpen] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const target = policy.reroute?.target;\n const ref = refOf(target);\n const selfDecision = target\n ? errorHandlerSelfDecision({\n resource: { kind, id },\n target: { kind: target.kind, id: ref },\n hasAdapter: policy.reroute?.with !== undefined,\n })\n : \"allow\";\n const label =\n target?.kind === \"workflow\"\n ? (workflowsQuery.data?.find((w) => w.id === ref)?.displayName ?? undefined)\n : (() => {\n const fn = functionsQuery.data?.find((f) => f.id === ref);\n return fn ? fn.displayName || fn.key : undefined;\n })();\n\n // The rail remains mounted while its resource changes. A refusal belonging to the previous\n // resource must not obscure the current policy.\n useEffect(() => {\n if (id && kind) setError(null);\n }, [id, kind]);\n\n /** Persist a whole new policy — the one write path, shared by pick and clear. */\n function persist(next: CallablePolicy) {\n setError(null);\n onPersist(next, setError);\n }\n\n /**\n * The picker's `onAdd`. Two shapes reach here, because all three handler arms are offered:\n * - a callable → `{ uses: {app: \"@w6w/call\", …}, with: {targetKind, targetId} }`\n * - an action → `{ uses: {app, action, connection}, with }`\n * A graph-only internal node (`@w6w/script`, `@w6w/control`, …) is refused — `appsOnly` means no\n * such tab is rendered, but a `BuiltStep` is a wide type and a silent mis-write would be\n * invisible.\n */\n function pickHandler(built: BuiltStep) {\n let nextTarget: ErrorHandlerTarget;\n if (built.uses.app === CALL_APP) {\n const w = (built.with ?? {}) as { targetKind?: unknown; targetId?: unknown };\n const nextId = typeof w.targetId === \"string\" ? w.targetId : \"\";\n if (!nextId) return;\n nextTarget =\n w.targetKind === \"workflow\"\n ? { kind: \"workflow\", workflow: nextId }\n : { kind: \"function\", function: nextId };\n } else if (!built.uses.app.startsWith(\"@w6w/\")) {\n // The app arm. `with` is the action's own param map, straight from the picker's Configure\n // stage — it is `ActionTarget.with`, which `error-handler.ts` reads in preference to the\n // general `reroute.with`.\n nextTarget = {\n kind: \"action\",\n uses: {\n app: built.uses.app,\n action: built.uses.action,\n connection: built.uses.connection ?? undefined,\n },\n ...(built.with ? { with: built.with } : {}),\n };\n } else {\n return;\n }\n const nextDecision = errorHandlerSelfDecision({\n resource: { kind, id },\n target: { kind: nextTarget.kind, id: refOf(nextTarget) },\n hasAdapter: policy.reroute?.with !== undefined,\n });\n if (nextDecision === \"block\") {\n setError(\n \"This handler would call itself with the same inputs and can loop forever. Choose another handler or keep a differing imported adapter.\",\n );\n setPickerOpen(false);\n return;\n }\n // Preserve `reroute.with` if one was already authored elsewhere — this tool changes WHICH\n // handler runs, never the mapping onto it.\n persist({ ...policy, reroute: { ...policy.reroute, target: nextTarget } });\n setPickerOpen(false);\n }\n\n if (!ready && !saving) {\n return <p className=\"muted small\">Loading…</p>;\n }\n\n return (\n <div className=\"w6w-stack\" data-testid=\"rail-errorhandling-body\">\n {/* Retries run BEFORE the handler below, so the section renders first. */}\n <section data-testid=\"rail-retry-section\">\n <RetryPolicyFields\n value={policy.retry}\n onChange={(next) => persist({ ...policy, retry: next })}\n readOnly={saving}\n target={kind}\n />\n {kind === \"workflow\" && (\n <p className=\"muted small\" data-testid=\"rail-retry-run-warning\">\n Retrying re-runs the whole workflow from its first step, so steps that already succeeded\n run again. For a step that must not repeat (a send or a charge), set retry on that step\n instead.\n </p>\n )}\n </section>\n\n <p className=\"muted small\">\n {kind === \"workflow\"\n ? \"What runs when this workflow's run fails, after every step's own retry is spent.\"\n : \"What runs when this call fails, after retry (if any) is exhausted.\"}\n </p>\n\n {ref ? (\n <div className=\"row\" style={{ alignItems: \"center\", gap: 8 }}>\n <span className=\"list-main\">\n <strong>{label ?? ref}</strong> <code className=\"muted\">{ref}</code>\n <span className=\"muted small block\">{nounOf(target)}</span>\n </span>\n <button\n type=\"button\"\n className=\"btn ghost\"\n data-testid=\"rail-errorhandling-change\"\n disabled={saving}\n onClick={() => setPickerOpen(true)}\n >\n Change\n </button>\n </div>\n ) : (\n <button\n type=\"button\"\n className=\"btn\"\n data-testid=\"rail-errorhandling-choose\"\n disabled={saving}\n onClick={() => setPickerOpen(true)}\n >\n + Choose what runs on failure\n </button>\n )}\n\n {ref && (\n <button\n type=\"button\"\n className=\"btn ghost\"\n data-testid=\"rail-errorhandling-clear\"\n disabled={saving}\n onClick={() => persist({ ...policy, reroute: undefined })}\n >\n Remove handler\n </button>\n )}\n\n {selfDecision === \"warn\" && (\n <div className=\"result error\" data-testid=\"rail-errorhandling-self-caution\">\n This handler targets itself. Its imported input adapter is preserved; the server will\n refuse it if it resolves to the failed call's same inputs.\n </div>\n )}\n\n {error && (\n <div className=\"error\" data-testid=\"rail-errorhandling-error\">\n {error}\n </div>\n )}\n\n {pickerOpen && (\n <StepBuilderModal\n appsOnly\n callables={[\"function\", \"workflow\"] as const}\n title=\"Choose what runs on failure\"\n onClose={() => setPickerOpen(false)}\n onAdd={pickHandler}\n />\n )}\n </div>\n );\n}\n\n/** The workflow arm: policy read off the host's buffer, written back through `onPolicyChange`. */\nfunction WorkflowErrorHandlingPanel({ ctx }: { ctx: WorkspaceCallable }) {\n // Absent on a surface that does not own the definition buffer — in which case `isAvailable`\n // already kept this tool off the strip.\n const wfPolicy = ctx?.kind === \"workflow\" ? ctx.policy : undefined;\n const onPolicyChange = ctx?.kind === \"workflow\" ? ctx.onPolicyChange : undefined;\n // Defensive: a persisted `activeTool` can render this Panel with a ctx this tool has no handler\n // for.\n if (ctx?.kind !== \"workflow\") return null;\n return (\n <ErrorHandlerSection\n kind=\"workflow\"\n id={ctx.id}\n policy={wfPolicy ? policyFromDefinition(wfPolicy) : {}}\n ready={Boolean(onPolicyChange)}\n saving={false}\n onPersist={(next) => onPolicyChange?.(next)}\n />\n );\n}\n\nfunction ErrorHandlingToolIcon() {\n return <Icon name=\"warning\" />;\n}\n\nexport const errorHandlingTool: RailTool = {\n id: \"error-handling\",\n title: \"Error handling\",\n Icon: ErrorHandlingToolIcon,\n isAvailable: (ctx) => isSettingsRailAvailable(ctx) && ctx?.kind === \"workflow\",\n Panel: WorkflowErrorHandlingPanel,\n};\n","/**\n * Pure decision logic behind `../components/TagEditor.tsx` — kept out of the\n * component so `node --test` can exercise it directly\n * (`__tests__/tag-editor.test.ts`) without touching React, mirroring\n * `alias-rail.ts`/`rail-settings.ts`'s own split. Carries over the retiring\n * `WorkflowsPage.tsx`'s retired tags-editing modal's data contract verbatim:\n * `string[]`, trim, dedupe-on-add, drop empties.\n */\n\n/**\n * Applies a chip input's freeform text to the committed tag list. Called on\n * every change to the trailing, not-yet-committed input — `typed` is always\n * the FULL current value of just that one input, which resets to `\"\"` after\n * a commit, so a single keystroke never carries more than the one character\n * just typed.\n *\n * A comma anywhere in `typed` is the commit signal: every comma-delimited\n * segment is trimmed and, if non-empty and not already present, appended as\n * a chip — in order, regardless of whether it sits before or after the last\n * comma. That is what makes both shapes work from the one rule: typing\n * `\"alpha,\"` one character at a time commits `\"alpha\"` the moment the comma\n * lands, and pasting `\"a,b,c\"` in one go (no trailing comma at all) still\n * commits all three, because nothing here treats \"the last segment\" as\n * special. The returned `typed` is always `\"\"` once a comma triggered a\n * commit. With no comma present at all, nothing commits and `typed` passes\n * through unchanged, so the caller can just store it as the next draft.\n */\nexport function commitTag(tags: string[], typed: string): { tags: string[]; typed: string } {\n if (!typed.includes(\",\")) return { tags, typed };\n let next = tags;\n for (const raw of typed.split(\",\")) {\n const t = raw.trim();\n if (t && !next.includes(t)) next = [...next, t];\n }\n return { tags: next, typed: \"\" };\n}\n\n/**\n * Removes exactly one tag by VALUE, never by position — a list carrying both\n * a tag and a second tag that merely contains it as a prefix (`[\"ab\", \"b\"]`)\n * only ever loses the exact match.\n */\nexport function removeTag(tags: string[], tag: string): string[] {\n return tags.filter((t) => t !== tag);\n}\n","import { IconButton } from \"@w6w/ui\";\nimport { useState } from \"react\";\nimport { commitTag, removeTag } from \"../lib/tag-editor.ts\";\n\n/**\n * A chip input for a workflow's free-form tags: type text, `,` commits the\n * typed value as a chip (or paste a whole comma-separated list to commit\n * several at once — `../lib/tag-editor.ts`'s `commitTag`), each chip carries\n * an `×` to remove it, and a still-typable tail follows the chips — one\n * control, not a stacked input-above-list.\n *\n * Built fresh (T2.2.1) rather than extended from the retiring\n * `WorkflowsPage.tsx` tags-editing modal: that component was a submit-button\n * \"Add\" form with its own inline add/remove branching, a different\n * interaction shape from a comma-commits chip editor. The shared data\n * contract (trim, dedupe-on-add, drop empties) now lives in\n * `../lib/tag-editor.ts`'s\n * `commitTag`/`removeTag`, so this component holds no branching of its own —\n * it only calls them and renders the result. Controlled, mirroring\n * `InputListEditor.tsx`'s shape: the caller owns `tags`, this component owns\n * only the not-yet-committed typed tail.\n */\nexport interface TagEditorProps {\n tags: string[];\n onChange: (next: string[]) => void;\n}\n\nexport function TagEditor({ tags, onChange }: TagEditorProps) {\n const [typed, setTyped] = useState(\"\");\n\n function handleTypedChange(value: string) {\n const result = commitTag(tags, value);\n setTyped(result.typed);\n if (result.tags !== tags) onChange(result.tags);\n }\n\n return (\n <div className=\"tag-list\" data-testid=\"tag-editor\">\n {tags.map((t) => (\n <span key={t} className=\"tag removable\">\n {t}\n <IconButton\n danger\n icon=\"close\"\n label={`Remove tag ${t}`}\n title={`Remove ${t}`}\n onClick={() => onChange(removeTag(tags, t))}\n />\n </span>\n ))}\n <input\n type=\"text\"\n value={typed}\n placeholder=\"Add a tag…\"\n aria-label=\"New tag\"\n onChange={(e) => handleTypedChange(e.target.value)}\n />\n </div>\n );\n}\n","import { filterKeyInput, isEndpointKey } from \"@w6w/embed/lib\";\n/**\n * Unified settings modal for editing name, key, and tags (workflow only)\n * in a single dialog. Replaces separate Edit Key and Edit Tags modals.\n * Supports Function, Endpoint, and Workflow kinds.\n *\n * T4.2.1: every kind-shaped decision this component used to make inline — may\n * the key be typed at all, does this kind store tags, which placeholder goes in\n * which field — now comes from `CALLABLE_DESCRIPTORS[kind].settings`\n * (`lib/callable-descriptors.ts`). There is deliberately **no `kind ===` left in\n * this file**: a fourth kind, or a copy change, is an edit to the descriptor\n * table and to nothing else. The rendered output is byte-identical to before —\n * same labels, same placeholders, same hint sentence, same conditional Tags\n * section.\n */\nimport { descriptorFor } from \"@w6w/embed/repos\";\nimport { ApiError } from \"@w6w/sdk\";\nimport { useEnterSubmit } from \"@w6w/ui\";\nimport { useState } from \"react\";\nimport { Modal } from \"./Modal.tsx\";\nimport { TagEditor } from \"./TagEditor.tsx\";\n\ninterface CallableSettingsModalProps {\n kind: \"function\" | \"endpoint\" | \"workflow\";\n id: string;\n initial: {\n displayName: string;\n key: string | null;\n tags?: string[]; // workflow only\n };\n onSave: (data: {\n displayName: string;\n key: string | null;\n tags?: string[];\n }) => Promise<void>;\n onClose: () => void;\n}\n\nexport function CallableSettingsModal(props: CallableSettingsModalProps) {\n // The one kind lookup this component makes. `settings` then answers every\n // per-kind question below, including which of the three `initial` fields this\n // kind even has.\n const settings = descriptorFor(props.kind).settings;\n const { initial } = props;\n const [displayName, setDisplayName] = useState(initial.displayName);\n const [key, setKey] = useState(initial.key ?? \"\");\n const [tags, setTags] = useState<string[]>(initial.tags ?? []);\n const [isSaving, setIsSaving] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const displayNameChanged = displayName !== initial.displayName;\n const keyChanged = key !== (initial.key ?? \"\");\n const tagsChanged =\n settings.hasTags && JSON.stringify(tags) !== JSON.stringify(initial.tags ?? []);\n const isDirty = displayNameChanged || keyChanged || tagsChanged;\n\n // Key can be edited for function/workflow only (not endpoint)\n const canEditKey = settings.canEditKey;\n const keyGrammarOk = key === \"\" || isEndpointKey(key);\n const canSubmit = isDirty && keyGrammarOk && !isSaving;\n\n async function handleSave() {\n if (!canSubmit) return;\n setError(null);\n setIsSaving(true);\n try {\n await props.onSave({\n displayName: displayName.trim(),\n key: canEditKey && keyChanged ? key : initial.key,\n tags: settings.hasTags ? tags : undefined,\n });\n props.onClose();\n } catch (e) {\n setError(e instanceof ApiError ? e.message : String(e));\n } finally {\n setIsSaving(false);\n }\n }\n\n const enterSubmit = useEnterSubmit(handleSave, { enabled: canSubmit });\n\n return (\n <Modal title=\"Edit settings\" onClose={props.onClose}>\n <div className=\"modal-body\">\n <label className=\"field\">\n <span>Name</span>\n <input\n type=\"text\"\n value={displayName}\n onChange={(e) => setDisplayName(e.target.value)}\n placeholder={settings.namePlaceholder}\n autoFocus\n {...enterSubmit}\n />\n </label>\n\n {canEditKey && (\n <label className=\"field\">\n <span>Key</span>\n <input\n type=\"text\"\n value={key}\n onChange={(e) => setKey(filterKeyInput(e.target.value))}\n placeholder={settings.keyPlaceholder}\n {...enterSubmit}\n />\n <span className=\"muted small\">\n Lowercase, kebab-case, 3–39 characters.\n {settings.keyHintSuffix}\n </span>\n </label>\n )}\n\n {settings.hasTags && (\n <div>\n <p className=\"muted small\" style={{ marginBottom: \"8px\" }}>\n Tags\n </p>\n <TagEditor tags={tags} onChange={setTags} />\n </div>\n )}\n\n {error && <div className=\"error\">{error}</div>}\n </div>\n\n <div className=\"modal-actions\">\n <button type=\"button\" className=\"btn ghost\" onClick={props.onClose}>\n Cancel\n </button>\n <button type=\"button\" className=\"btn\" disabled={!canSubmit} onClick={handleSave}>\n {isSaving ? \"Saving…\" : \"Save\"}\n </button>\n </div>\n </Modal>\n );\n}\n","import { type SpecImportKind, type SpecImportListKeys, parseImportPaste } from \"@w6w/embed/lib\";\nimport { ApiError } from \"@w6w/sdk\";\nimport { JsonEditor } from \"@w6w/ui\";\nimport { useState } from \"react\";\nimport { type SpecImportReferenceReport, useImportSpecMutation } from \"../repos/spec-import.ts\";\nimport { Modal } from \"./Modal.tsx\";\n\n/** The list route segment for each kind — `goto()`'s `<collection>/<id>` nav target. */\nconst COLLECTION: Record<SpecImportKind, \"functions\" | \"endpoints\" | \"workflows\"> = {\n function: \"functions\",\n endpoint: \"endpoints\",\n workflow: \"workflows\",\n};\n\n/**\n * P2's `<collection>-import-*` testid scheme, spelled out literally per kind rather than built by\n * string interpolation — so the Functions arm's four testids stay the exact byte strings\n * `functions-page-guards.test.cjs` (IM1–IM3) already asserts against, verifiable by a plain\n * substring search over this file rather than only by running the browser suite.\n */\nconst TESTIDS: Record<\n SpecImportKind,\n { json: string; submit: string; unresolved: string; goto: string }\n> = {\n function: {\n json: \"functions-import-json\",\n submit: \"functions-import-submit\",\n unresolved: \"functions-import-unresolved\",\n goto: \"functions-import-goto\",\n },\n endpoint: {\n json: \"endpoints-import-json\",\n submit: \"endpoints-import-submit\",\n unresolved: \"endpoints-import-unresolved\",\n goto: \"endpoints-import-goto\",\n },\n workflow: {\n json: \"workflows-import-json\",\n submit: \"workflows-import-submit\",\n unresolved: \"workflows-import-unresolved\",\n goto: \"workflows-import-goto\",\n },\n};\n\n/**\n * Import modal for the Functions, Endpoints and Workflows lists (T1.2.1, generalizing T3.2.1's\n * Functions-only `ImportFunctionModal`): paste a portable spec document (rfcs/function.md), POST\n * it to `/spec/import` and either land in the created resource's editor (every reference resolved)\n * or stay open with the unresolved-reference report (A5).\n *\n * **P1 — one parameterized component, not three.** The Function-specific surface was four strings,\n * one nav target and a testid prefix — forking it into three siblings would duplicate the state\n * machine below for no gain. The `kind` prop drives all of it: `parseImportPaste`'s expected kind,\n * the title/copy, the `goto()` navigation target (`<collection>/<id>`), and every testid (P2 — the\n * four `functions-import-*` ones this file used to hardcode keep matching byte-for-byte; see\n * `TESTIDS` above for why they are spelled out literally per kind rather than interpolated).\n *\n * Mirrors `FunctionIdentityModal.tsx` (note 3 — same studio-local `Modal`,\n * same `ApiError.message` handling, same \"the row was created, hand the\n * operator the id\" shape as `onCreated`) but is a structurally PARALLEL,\n * distinct trigger — not a second \"create a resource and land in its editor\"\n * flow built on top of it. It owns its own navigation (unlike the identity\n * modal, which reports back to the list) because A5's \"created but\n * partially resolved\" outcome has nowhere else to render the report: the\n * modal has to stay mounted to show it, so it is also the one place that can\n * decide whether and when to leave the list route.\n *\n * **A `201` whose `references` carry any `resolved: false` entry is NOT\n * \"done\" (A5)** — the near-miss this exists to kill is \"201 ⇒ close and\n * navigate\", which would hide exactly the unresolved-reference report the\n * intake asks for.\n */\nexport interface ImportSpecModalProps {\n kind: SpecImportKind;\n /** The host's current project (only the workflow list key reads it). */\n project: string | undefined;\n /** The three list query keys, injected by the host. */\n listKeys: SpecImportListKeys;\n /** Navigate to the imported row; the modal closes itself first. */\n onOpenImported: (kind: SpecImportKind, id: string) => void;\n onClose: () => void;\n}\n\nexport function ImportSpecModal(props: ImportSpecModalProps) {\n const { kind } = props;\n const collection = COLLECTION[kind];\n const testids = TESTIDS[kind];\n const [text, setText] = useState(\"\");\n const [error, setError] = useState<string | null>(null);\n const [unresolved, setUnresolved] = useState<{\n callableId: string;\n references: SpecImportReferenceReport[];\n } | null>(null);\n const importMut = useImportSpecMutation(props.project, props.listKeys);\n\n const { parsed, blockedReason } = parseImportPaste(text, kind);\n const disabled = blockedReason !== null || importMut.isPending;\n\n function goto(id: string) {\n props.onClose();\n props.onOpenImported(kind, id);\n }\n\n function submit() {\n // Defensive, not decorative: a forced click (e.g. `dispatchEvent`) on a\n // disabled button must still issue zero requests (A3, IM1(a)/(b)).\n if (blockedReason !== null || parsed === null || importMut.isPending) return;\n setError(null);\n setUnresolved(null);\n // The parsed paste, forwarded VERBATIM — note 1's mechanism pin (A4).\n importMut.mutate(parsed, {\n onSuccess: (result) => {\n const allResolved = result.references.every((r) => r.resolved);\n if (allResolved) {\n goto(result.callable.id);\n return;\n }\n // Kept open (A5): the resource WAS created, but at least one\n // reference did not bind — report every unresolved entry, and give\n // the operator an explicit way to still reach the row.\n setUnresolved({\n callableId: result.callable.id,\n references: result.references.filter((r) => !r.resolved),\n });\n },\n onError: (e) => setError(e instanceof ApiError ? e.message : String(e)),\n });\n }\n\n return (\n <Modal title={`Import ${kind}`} onClose={props.onClose} wide>\n <div className=\"modal-body\">\n <p className=\"muted small\">\n Paste a portable {kind} spec document (exported via{\" \"}\n <code>GET /{collection}/:id/spec</code>\n ). A fresh id is minted here; connection references are re-bound to whatever this account\n already has connected, and anything that couldn't be re-bound is reported below.\n </p>\n\n <div data-testid={testids.json}>\n <JsonEditor\n value={text}\n onChange={(v) => {\n setText(v);\n setUnresolved(null);\n setError(null);\n }}\n minHeight=\"320px\"\n aria-label={`${kind} spec document JSON`}\n />\n </div>\n\n {blockedReason && text !== \"\" && <p className=\"muted small\">{blockedReason}</p>}\n {error && <div className=\"result error\">{error}</div>}\n\n {unresolved && (\n <div className=\"result\" data-testid={testids.unresolved}>\n <p>\n The {kind} was created, but {unresolved.references.length} reference\n {unresolved.references.length === 1 ? \"\" : \"s\"} could not be resolved:\n </p>\n <ul className=\"list\">\n {unresolved.references.map((r) => (\n <li key={r.path}>\n <code>{r.path}</code> <span className=\"muted\">({r.kind})</span>\n {r.reason && <span className=\"muted\"> — {r.reason}</span>}\n </li>\n ))}\n </ul>\n <button\n type=\"button\"\n className=\"btn\"\n data-testid={testids.goto}\n onClick={() => goto(unresolved.callableId)}\n >\n Open the created {kind}\n </button>\n </div>\n )}\n </div>\n\n <div className=\"modal-actions\">\n <button type=\"button\" className=\"btn ghost\" onClick={props.onClose}>\n Cancel\n </button>\n <button\n type=\"button\"\n className=\"btn\"\n data-testid={testids.submit}\n disabled={disabled}\n onClick={submit}\n >\n {importMut.isPending ? \"Importing…\" : \"Import\"}\n </button>\n </div>\n </Modal>\n );\n}\n","import { Modal } from \"./Modal.tsx\";\n\ninterface ConfirmModalProps {\n title: string;\n message: string;\n /** Fired when the user confirms. The caller clears its pending state via onClose. */\n onConfirm: () => void;\n /** Fired on Cancel, Esc, or outside-click — dismisses without confirming. */\n onClose: () => void;\n confirmLabel?: string;\n cancelLabel?: string;\n /** Style the confirm button as destructive (default true — this dialog gates dangerous actions). */\n destructive?: boolean;\n}\n\n/**\n * A reusable confirmation dialog built on our <dialog>-based Modal, so it inherits\n * focus-trap, Esc-dismiss, and outside-click close. Replaces the browser's native\n * confirmation prompt for destructive actions: Confirm fires `onConfirm`;\n * Cancel/Esc/outside-click fires `onClose` only (no confirmation).\n */\nexport function ConfirmModal({\n title,\n message,\n onConfirm,\n onClose,\n confirmLabel = \"Confirm\",\n cancelLabel = \"Cancel\",\n destructive = true,\n}: ConfirmModalProps) {\n return (\n <Modal title={title} onClose={onClose}>\n <div className=\"modal-body\">\n <p className=\"muted small\">{message}</p>\n </div>\n <div className=\"modal-actions\">\n <button type=\"button\" className=\"btn ghost\" onClick={onClose}>\n {cancelLabel}\n </button>\n <button type=\"button\" className={destructive ? \"btn danger\" : \"btn\"} onClick={onConfirm}>\n {confirmLabel}\n </button>\n </div>\n </Modal>\n );\n}\n","import {\n type VersionsKind,\n useInvokeVersionMutation,\n useRevertMutation,\n useVersionQuery,\n} from \"@w6w/embed/repos\";\nimport { ApiError } from \"@w6w/sdk\";\nimport { CodeBlock } from \"@w6w/ui\";\nimport { useState } from \"react\";\nimport { ConfirmModal } from \"./ConfirmModal.tsx\";\nimport { Modal } from \"./Modal.tsx\";\n\n/**\n * P2's `<collection>-version-*` testid scheme, spelled out literally per kind rather than built\n * by string interpolation — mirrors `ImportSpecModal.tsx`'s own `TESTIDS` reasoning: this file's\n * own kind arms stay the exact byte strings a page-guard suite would assert against, verifiable\n * by a plain substring search rather than only by running the browser suite.\n */\nconst TESTIDS: Record<\n VersionsKind,\n {\n json: string;\n error: string;\n revertButton: string;\n invokeButton: string;\n invokeJson: string;\n invokeError: string;\n }\n> = {\n function: {\n json: \"functions-version-json\",\n error: \"functions-version-error\",\n revertButton: \"functions-version-revert\",\n invokeButton: \"functions-version-invoke\",\n invokeJson: \"functions-version-invoke-json\",\n invokeError: \"functions-version-invoke-error\",\n },\n workflow: {\n json: \"workflows-version-json\",\n error: \"workflows-version-error\",\n revertButton: \"workflows-version-revert\",\n invokeButton: \"workflows-version-invoke\",\n invokeJson: \"workflows-version-invoke-json\",\n invokeError: \"workflows-version-invoke-error\",\n },\n endpoint: {\n json: \"endpoints-version-json\",\n error: \"endpoints-version-error\",\n revertButton: \"endpoints-version-revert\",\n invokeButton: \"endpoints-version-invoke\",\n invokeJson: \"endpoints-version-invoke-json\",\n invokeError: \"endpoints-version-invoke-error\",\n },\n};\n\n/**\n * Version viewer for Function/Workflow/Endpoint (T3.1.1, extended by T5.3.1): one\n * kind-parametrized component, mirroring `ImportSpecModal.tsx:12-46`'s established shape (a\n * `kind` prop plus per-kind `TESTIDS`, one component mounted from more than one place rather than\n * three near-copies). This project mounts it from `SettingsTool.tsx` only — the component\n * boundary exists so a second mount point later costs one line.\n *\n * Renders the version's own read-only definition through the same two primitives\n * `SettingsTool.tsx`'s existing Export modal already uses — the studio-local `Modal` and\n * `@w6w/ui`'s `CodeBlock` — plus, since T5.3.1, two live actions:\n *\n * - **\"Revert to this version\"** — confirmed via the studio-local `ConfirmModal` (P2-D4:\n * `./ConfirmModal.tsx`, never `@w6w/ui`'s), rendered as a SIBLING of `<Modal>` in\n * the returned fragment, never nested inside it. Overwrites the LIVE resource's `definition`\n * with this version's content, preserving its `key`/address (HITL-4's pinned default).\n * - **\"Invoke this version\"** — one click, NO confirm (ruling #12: an invoke is a call, not a\n * write to the resource, and the LIVE invoke action it mirrors carries no confirm either). Runs\n * this version's own archived definition, never the live one, and renders the response body\n * inline via `CodeBlock`, or a failure inline via the `ApiError` idiom (never a thrown error, a\n * blank modal, or a browser dialog).\n *\n * Both actions read `kind`/`id`/`versionNumber` from props, and both mutations are fresh\n * `useMutation` instances scoped to this component instance — since `SettingsTool.tsx`'s\n * `openVersion` gate fully unmounts/remounts this component per version rather than swapping\n * props on a surviving instance, any prior invoke result or error is gone the moment a different\n * version is opened.\n *\n * Amendments #5/#6 (project.md, Phase 2) supersede the earlier pin that made both of the above\n * out of scope (HITL-2's \"invocation always runs the live definition\"; Amendment #5's \"restore is\n * out of scope, not even a disabled button\").\n */\nexport function VersionHistoryModal(props: {\n kind: VersionsKind;\n id: string;\n versionNumber: number;\n onClose: () => void;\n}) {\n const { kind, id, versionNumber } = props;\n const testids = TESTIDS[kind];\n // Always enabled: this component only ever mounts once a specific version has been picked\n // (the caller renders it conditionally), mirroring the Export modal's own \"mounted while open\"\n // gate rather than re-deriving a second `enabled` flag here.\n const versionQuery = useVersionQuery(kind, id, versionNumber, true);\n const revertMut = useRevertMutation(kind);\n const invokeMut = useInvokeVersionMutation(kind);\n const [confirmingRevert, setConfirmingRevert] = useState(false);\n\n return (\n <>\n <Modal title={`Version ${versionNumber}`} onClose={props.onClose} wide>\n <div className=\"modal-body\">\n {versionQuery.isLoading ? (\n <p className=\"muted small\">Loading…</p>\n ) : versionQuery.isError ? (\n <div className=\"error\" data-testid={testids.error}>\n {versionQuery.error instanceof Error\n ? versionQuery.error.message\n : String(versionQuery.error)}\n </div>\n ) : versionQuery.data ? (\n <div data-testid={testids.json}>\n <CodeBlock\n code={JSON.stringify(versionQuery.data.definition, null, 2)}\n language=\"json\"\n maxHeight=\"420px\"\n copyable\n />\n </div>\n ) : null}\n\n {invokeMut.data !== undefined && (\n <div data-testid={testids.invokeJson}>\n <CodeBlock\n code={JSON.stringify(invokeMut.data, null, 2)}\n language=\"json\"\n maxHeight=\"240px\"\n copyable\n />\n </div>\n )}\n {invokeMut.isError && (\n <div className=\"error\" data-testid={testids.invokeError}>\n {invokeMut.error instanceof ApiError\n ? invokeMut.error.message\n : String(invokeMut.error)}\n </div>\n )}\n </div>\n\n <div className=\"modal-actions\">\n <button\n type=\"button\"\n className=\"btn ghost\"\n data-testid={testids.invokeButton}\n disabled={invokeMut.isPending}\n onClick={() => invokeMut.mutate({ id, versionNumber })}\n >\n {invokeMut.isPending ? \"Invoking…\" : \"Invoke this version\"}\n </button>\n <button\n type=\"button\"\n className=\"btn danger\"\n data-testid={testids.revertButton}\n disabled={revertMut.isPending}\n onClick={() => setConfirmingRevert(true)}\n >\n {revertMut.isPending ? \"Reverting…\" : \"Revert to this version\"}\n </button>\n <button type=\"button\" className=\"btn ghost\" onClick={props.onClose}>\n Close\n </button>\n </div>\n </Modal>\n {confirmingRevert && (\n <ConfirmModal\n title=\"Revert to this version\"\n message={`Revert to version ${versionNumber}? This restores its content onto the resource's current draft; the resource's key and address stay unchanged.`}\n confirmLabel=\"Revert\"\n destructive\n onConfirm={() => {\n setConfirmingRevert(false);\n revertMut.mutate({ id, versionNumber });\n }}\n onClose={() => setConfirmingRevert(false)}\n />\n )}\n </>\n );\n}\n","/**\n * T4.1.1/A3: the rail Settings panel's bottom \"danger zone\" — Archive (until\n * archived) then Delete, behind a visibly red confirmation panel — extracted\n * out of `src/ui/rail/SettingsTool.tsx` so Function, Endpoint and Workflow\n * render the EXACT same markup instead of three near-identical branches.\n * T1.3.1 had already moved all three kinds' Archive/Delete into one file, but\n * left them as three separate JSX arms that had drifted out of sync — only\n * Workflow's delete copy said the deletion was permanent (A5). This\n * extraction is what stops a fourth kind (or a future edit to one arm) from\n * silently reintroducing that gap: per-kind variance arrives entirely as\n * props, and there is exactly one archive-vs-delete branch to read.\n *\n * Presentational only, mirroring `@w6w/ui`'s own `DeleteButton` (HITL-1,\n * binding there): takes plain `onClick` callbacks, never an `onConfirm` and\n * never renders a confirm dialog itself — the caller (`SettingsTool.tsx`)\n * owns the `ConfirmModal`s and the archive/delete mutations, exactly as it\n * did before this extraction.\n *\n * A4: `DeleteButton`'s own `label` prop renders as `title`/`aria-label`\n * ONLY, never visible text (`packages/ui/src/components/IconButton.tsx`) —\n * so the visible word \"Delete\" here is this component's OWN sibling\n * `<span>`, not something passed through to `DeleteButton`.\n */\nimport { DeleteButton } from \"@w6w/ui\";\n\nexport interface DangerZoneProps {\n /** Whether the resource is archived yet. `true` renders Delete; `false`\n * renders Archive. Every kind has an archive-before-delete step as of\n * T4.1.1 (Function/Endpoint newly, Workflow already did). */\n archived: boolean;\n /** Accessible name for the Delete icon button — `title`/`aria-label` only\n * (`IconButton.tsx`), e.g. \"Delete this function\". */\n deleteLabel: string;\n /** `data-testid` for the Delete control. Kind-specific — page guards key\n * on these directly (e.g. `delete-function`, `wf-settings-delete`). */\n deleteTestId: string;\n /** `data-testid` for the Archive control. Kind-specific. */\n archiveTestId: string;\n onRequestDelete: () => void;\n onRequestArchive: () => void;\n deleteError: string | null;\n archiveError: string | null;\n}\n\nexport function DangerZone(props: DangerZoneProps) {\n const {\n archived,\n deleteLabel,\n deleteTestId,\n archiveTestId,\n onRequestDelete,\n onRequestArchive,\n deleteError,\n archiveError,\n } = props;\n return (\n <div className=\"rail-danger-zone rail-danger-zone--panel\" data-testid=\"rail-danger-zone-panel\">\n {/* A2/M4's kill: mutually exclusive, never both rendered — Delete only\n once archived, Archive otherwise. */}\n {archived ? (\n <span className=\"rail-danger-zone-delete\">\n <DeleteButton label={deleteLabel} data-testid={deleteTestId} onClick={onRequestDelete} />\n <span>Delete</span>\n </span>\n ) : (\n <button\n type=\"button\"\n className=\"btn danger\"\n data-testid={archiveTestId}\n onClick={onRequestArchive}\n >\n Archive\n </button>\n )}\n {deleteError && (\n <div className=\"error\" data-testid=\"rail-delete-error\">\n {deleteError}\n </div>\n )}\n {archiveError && (\n <div className=\"error\" data-testid=\"rail-archive-error\">\n {archiveError}\n </div>\n )}\n </div>\n );\n}\n","/**\n * The presentational sections of the rail Settings panel, rendered by BOTH arms — the package's\n * workflow arm (`./SettingsTool.tsx`) and Studio's function/endpoint arm\n * (`src/ui/rail/SettingsTool.tsx`) — so the markup, test ids and copy exist exactly once.\n *\n * Every section takes data and callbacks as props. There is no query or mutation hook in this\n * file: the arms own their data access (the workflow arm on `useEmbedClient()`, Studio's arm on\n * its own function/endpoint repos). `useState`-free too — open/close state lives in the arm, so a\n * section is a pure function of its props.\n *\n * Moved verbatim from the pre-split `SettingsPanel`: the `rail-meta` definition-list grid, the\n * version-history link + Publish/Enable block and its \"All versions\" list modal (kept as two\n * separate open states in the arm — see `SettingsTool.tsx`), the Export/Edit JSON/Import chooser\n * shell, and the Delete/Archive danger zone with its per-kind confirm copy.\n */\nimport { ConfirmModal, EditButton, Icon, IconButton } from \"@w6w/ui\";\nimport type { ReactNode } from \"react\";\nimport { DangerZone } from \"../chrome/DangerZone.tsx\";\nimport { Modal } from \"../chrome/Modal.tsx\";\nimport type { RailSettingsKind } from \"../lib/rail-settings.ts\";\nimport type { VersionSummary, VersionsEnvelope } from \"../repos/versions.ts\";\n\n/** The three kinds the Settings panel renders for. */\nexport type SettingsKind = Extract<RailSettingsKind, \"function\" | \"endpoint\" | \"workflow\">;\n\n/** Heading row: the title and the \"Edit settings\" trigger for the unified settings modal. */\nexport function SettingsHeading(props: { onEdit: () => void }) {\n return (\n <div className=\"right-rail-panel-head rail-settings-head\">\n <h3>Settings</h3>\n <EditButton label=\"Edit settings\" data-testid=\"rail-settings-edit\" onClick={props.onEdit} />\n </div>\n );\n}\n\n/**\n * id + key + updated (+ tags, workflow only) — and nothing else. No createdAt, ever. A two-column\n * label/value GRID (`dl`/`dt`/`dd`); `.rail-meta-list` is the rail-scoped grid and there is\n * deliberately no global `dl`/`dt`/`dd` rule.\n */\nexport function MetadataSection(props: {\n id: string;\n displayName: string;\n /** `metadataFieldsForKind(kind)`. */\n fields: ReadonlyArray<\"id\" | \"key\" | \"updatedAt\">;\n /** The already-cached list row (carries key/updatedAt); `undefined` until the list loads. */\n row: { key?: string | null; updatedAt: string } | undefined;\n /** Workflow only: the tag chips. `undefined` hides the row (function/endpoint). */\n tags?: readonly string[];\n}) {\n const { id, displayName, fields, row, tags } = props;\n return (\n <div className=\"rail-meta\">\n <div\n style={{\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"flex-start\",\n gap: \"8px\",\n }}\n >\n <dl className=\"rail-meta-list\">\n {displayName && (\n <>\n <dt>Name</dt>\n <dd data-testid=\"rail-meta-name\">\n <code>{displayName}</code>\n </dd>\n </>\n )}\n <dt>ID</dt>\n <dd data-testid=\"rail-meta-id\">\n <code>{id}</code>\n </dd>\n {fields.includes(\"key\") && row && (\n <>\n <dt>Key</dt>\n <dd data-testid=\"rail-meta-key\">\n <code>{row.key || \"unset\"}</code>\n </dd>\n </>\n )}\n {fields.includes(\"updatedAt\") && row && (\n <>\n <dt>Updated</dt>\n <dd data-testid=\"rail-meta-updated\" data-value={row.updatedAt}>\n {new Date(row.updatedAt).toLocaleString()}\n </dd>\n </>\n )}\n {tags !== undefined && row && (\n <>\n <dt>Tags</dt>\n <dd data-testid=\"rail-meta-tags\">\n {tags.length > 0\n ? tags.map((t) => (\n <span key={t} className=\"tag\">\n {t}\n </span>\n ))\n : \"No tags\"}\n </dd>\n </>\n )}\n </dl>\n </div>\n </div>\n );\n}\n\n/**\n * A5: one icon opens the combined Export/Edit JSON/Import chooser. Nothing here grows with the\n * size of the resource's definition — the definition renders in neither vessel here, only inside\n * a modal.\n */\nexport function SpecActionsTrigger(props: { onOpen: () => void }) {\n return (\n <div className=\"rail-spec-actions\">\n <IconButton\n icon=\"file-text\"\n label=\"Export, edit, or import\"\n data-testid=\"rail-spec-actions-open\"\n onClick={props.onOpen}\n />\n </div>\n );\n}\n\n/**\n * The chooser shell: Import always (it creates a NEW resource and navigates to it, never an\n * in-place replacement), plus a slot the host fills with extra definition actions (Studio adds\n * Export + Edit JSON for function/endpoint). Picking an item closes THIS modal and opens that\n * item's own — nothing is ever nested inside this one's body.\n */\nexport function SpecChooserModal(props: {\n kind: SettingsKind;\n /** Extra definition actions, rendered above the Import row. */\n children?: ReactNode;\n onImport: () => void;\n onClose: () => void;\n}) {\n const { kind, children, onImport, onClose } = props;\n return (\n <Modal title=\"Definition\" onClose={onClose}>\n <div className=\"modal-body\">\n {children}\n <p className=\"muted small\">\n Import a spec document to create a NEW {kind} and navigate to it — this does not replace\n the {kind} you have open.\n </p>\n <div className=\"rail-spec-menu-row\">\n <button\n type=\"button\"\n className=\"btn ghost\"\n data-testid=\"rail-spec-import\"\n onClick={onImport}\n >\n Import\n </button>\n </div>\n </div>\n <div className=\"modal-actions\">\n <button type=\"button\" className=\"btn ghost\" onClick={onClose}>\n Close\n </button>\n </div>\n </Modal>\n );\n}\n\n/**\n * Version history (A4): a link-styled icon, ALWAYS enabled (\"no earlier versions\" is an empty\n * state INSIDE the list modal, never a disabled control). Once opened (`open`), the un-carded\n * \"Published: vN\" line and Publish / Enable-Disable stay in the main panel.\n */\nexport function VersionSection(props: {\n open: boolean;\n versions: VersionsEnvelope | undefined;\n publishing: boolean;\n togglingEnabled: boolean;\n publishError: string | null;\n enableError: string | null;\n onShow: () => void;\n onPublish: () => void;\n onToggleEnabled: () => void;\n}) {\n const { open, versions } = props;\n return (\n <div className=\"rail-version-section\">\n <button\n type=\"button\"\n className=\"rail-link-icon\"\n data-testid=\"rail-history-show\"\n aria-label=\"Version history\"\n title=\"Version history\"\n onClick={props.onShow}\n >\n <Icon name=\"clock\" size={14} />\n <span>Version history</span>\n </button>\n {open && (\n <>\n <p className=\"muted small\" data-testid=\"rail-version-published\">\n {versions?.currentPublishedVersion != null\n ? `Published: v${versions.currentPublishedVersion}`\n : \"Never published\"}\n </p>\n <div className=\"rail-version-actions\">\n <button\n type=\"button\"\n className=\"btn ghost\"\n data-testid=\"rail-publish\"\n disabled={props.publishing}\n onClick={props.onPublish}\n >\n {props.publishing ? \"Publishing…\" : \"Publish\"}\n </button>{\" \"}\n <button\n type=\"button\"\n className=\"btn ghost\"\n data-testid=\"rail-enable-toggle\"\n disabled={props.togglingEnabled || versions === undefined}\n onClick={props.onToggleEnabled}\n >\n {props.togglingEnabled ? \"Saving…\" : versions?.enabled ? \"Disable\" : \"Enable\"}\n </button>\n </div>\n {props.publishError && (\n <div className=\"error\" data-testid=\"rail-publish-error\">\n {props.publishError}\n </div>\n )}\n {props.enableError && (\n <div className=\"error\" data-testid=\"rail-enable-error\">\n {props.enableError}\n </div>\n )}\n </>\n )}\n </div>\n );\n}\n\n/**\n * The \"All versions\" list modal — deliberately NOT titled \"Version history\" (which would share\n * the `Version …` aria-label prefix the per-version detail viewer's own dialogs use).\n */\nexport function VersionListModal(props: {\n loading: boolean;\n versions: readonly VersionSummary[] | undefined;\n onSelect: (versionNumber: number) => void;\n onClose: () => void;\n}) {\n const { loading, versions } = props;\n return (\n <Modal title=\"All versions\" onClose={props.onClose} wide>\n <div className=\"modal-body\">\n {loading && <p className=\"muted small\">Loading…</p>}\n {versions?.length === 0 && <p className=\"muted small\">No versions yet.</p>}\n {versions && versions.length > 0 && (\n <ul className=\"list\">\n {versions.map((v) => (\n <li key={v.versionNumber} className=\"selectable\">\n <button\n type=\"button\"\n className=\"row-select\"\n data-testid=\"rail-version-row\"\n onClick={() => props.onSelect(v.versionNumber)}\n >\n <div className=\"list-main\">\n <code>v{v.versionNumber}</code>{\" \"}\n {v.isCurrentPublished && (\n <span className=\"badge\" data-testid=\"rail-version-current\">\n Published\n </span>\n )}\n <div className=\"muted small\">{new Date(v.createdAt).toLocaleString()}</div>\n </div>\n </button>\n </li>\n ))}\n </ul>\n )}\n </div>\n <div className=\"modal-actions\">\n <button type=\"button\" className=\"btn ghost\" onClick={props.onClose}>\n Done\n </button>\n </div>\n </Modal>\n );\n}\n\nconst DANGER_COPY: Record<\n SettingsKind,\n {\n deleteTitle: string;\n deleteMessage: string;\n archiveTitle: string;\n archiveMessage: string;\n deleteLabel: string;\n deleteTestId: string;\n archiveTestId: string;\n }\n> = {\n function: {\n deleteTitle: \"Delete function\",\n deleteMessage:\n \"Delete this function permanently? Any endpoint, workflow, or call pointing to it will start failing with a not-found error the next time it runs, and this cannot be undone.\",\n archiveTitle: \"Archive function\",\n archiveMessage:\n \"Archive this function? It stops being invocable and can no longer be edited. Archiving is one-way — there is no unarchive — and only an archived function can be deleted.\",\n deleteLabel: \"Delete this function\",\n deleteTestId: \"delete-function\",\n archiveTestId: \"archive-function\",\n },\n endpoint: {\n deleteTitle: \"Delete endpoint\",\n deleteMessage:\n \"Delete this endpoint permanently? Any alias, workflow, or call pointing to it will start failing with a not-found error the next time it runs, and this cannot be undone.\",\n archiveTitle: \"Archive endpoint\",\n archiveMessage:\n \"Archive this endpoint? It stops being invocable and can no longer be edited. Archiving is one-way — there is no unarchive — and only an archived endpoint can be deleted.\",\n deleteLabel: \"Delete this endpoint\",\n deleteTestId: \"delete-endpoint\",\n archiveTestId: \"archive-endpoint\",\n },\n workflow: {\n deleteTitle: \"Delete workflow\",\n deleteMessage:\n \"Delete this workflow permanently? Its run history is discarded immediately via cascading deletes and cannot be recovered.\",\n archiveTitle: \"Archive workflow\",\n archiveMessage:\n \"Archive this workflow? It stops running and can no longer be published. Archiving is one-way — there is no unarchive — and only an archived workflow can be deleted.\",\n deleteLabel: \"Delete this workflow\",\n deleteTestId: \"wf-settings-delete\",\n archiveTestId: \"wf-settings-archive\",\n },\n};\n\n/**\n * The bottom \"danger zone\": Archive (until archived) then Delete, with the two confirm modals.\n * Per-kind variance (copy, test ids) is the table above; the caller owns the mutations and the\n * confirm/error state, and renders this only when `hasDelete(kind)`.\n */\nexport function SettingsDangerZone(props: {\n kind: SettingsKind;\n archived: boolean;\n deleteConfirming: boolean;\n archiveConfirming: boolean;\n deleteError: string | null;\n archiveError: string | null;\n onRequestDelete: () => void;\n onRequestArchive: () => void;\n onConfirmDelete: () => void;\n onConfirmArchive: () => void;\n onCloseDelete: () => void;\n onCloseArchive: () => void;\n}) {\n const copy = DANGER_COPY[props.kind];\n return (\n <>\n <DangerZone\n archived={props.archived}\n deleteLabel={copy.deleteLabel}\n deleteTestId={copy.deleteTestId}\n archiveTestId={copy.archiveTestId}\n onRequestDelete={props.onRequestDelete}\n onRequestArchive={props.onRequestArchive}\n deleteError={props.deleteError}\n archiveError={props.archiveError}\n />\n {props.deleteConfirming && (\n <ConfirmModal\n title={copy.deleteTitle}\n message={copy.deleteMessage}\n confirmLabel=\"Delete\"\n onConfirm={props.onConfirmDelete}\n onClose={props.onCloseDelete}\n />\n )}\n {props.archiveConfirming && (\n <ConfirmModal\n title={copy.archiveTitle}\n message={copy.archiveMessage}\n confirmLabel=\"Archive\"\n onConfirm={props.onConfirmArchive}\n onClose={props.onCloseArchive}\n />\n )}\n </>\n );\n}\n","/**\n * The Settings rail tool, workflow arm — what a Workflow's right-rail Settings panel does, owned\n * by the package so `<WorkflowEditor>` can render it without Studio. The function/endpoint arms\n * stay in Studio (`src/ui/rail/SettingsTool.tsx`), rendering the same presentational sections\n * (`./settings-sections.tsx`) over Studio's own repos.\n *\n * Behaviour is the pre-split workflow arm, unchanged:\n * - metadata (name / id / key / tags) read off the cached workflow list row;\n * - the unified settings modal saves the WHOLE stored definition (`useWorkflowQuery`'s\n * `workflow`, `displayName` / `key` / `tags` replaced) with `ifUnmodifiedSince` from that\n * query's `updatedAt`, and `project` passed VERBATIM — `useSaveWorkflowMutation` refuses\n * without one, because an unscoped write would silently relocate the workflow into the\n * account's default project (C/D-C2). A 409/400 renders inline, never a thrown error;\n * - the Import chooser → `ImportSpecModal` (creates a NEW workflow and opens it);\n * - version history / Publish / Enable are gated on the section's OWN open state, so opening\n * the panel issues zero `/versions` requests;\n * - Archive → Delete. Both land on the list via `onNavigate({ type: \"list\" })`.\n *\n * Host seams: `project` and `onNavigate` arrive as props on `WorkflowSettingsPanel`, and the\n * `settingsTool` Panel reads them from `useRailEnv()` (`./rail-env.tsx`). No router, no\n * function/endpoint data access, no `client.console`, no module-scope browser globals.\n */\nimport { ApiError } from \"@w6w/sdk\";\nimport { Icon } from \"@w6w/ui\";\nimport { useState } from \"react\";\nimport { CallableSettingsModal } from \"../chrome/CallableSettingsModal.tsx\";\nimport { ImportSpecModal } from \"../chrome/ImportSpecModal.tsx\";\nimport type { RailTool } from \"../chrome/RightRail.tsx\";\nimport { VersionHistoryModal } from \"../chrome/VersionHistoryModal.tsx\";\nimport type { WorkspaceCallable } from \"../chrome/workspace.tsx\";\nimport { metadataFieldsForKind } from \"../lib/rail-settings.ts\";\nimport { usePublishMutation, useSetEnabledMutation, useVersionsQuery } from \"../repos/versions.ts\";\nimport {\n useArchiveWorkflowMutation,\n useDeleteWorkflowMutation,\n useSaveWorkflowMutation,\n useWorkflowQuery,\n useWorkflowsQuery,\n workflowsKey,\n} from \"../repos/workflows.ts\";\nimport { type RailNavigation, useRailEnv } from \"./rail-env.tsx\";\nimport {\n MetadataSection,\n SettingsDangerZone,\n SettingsHeading,\n SpecActionsTrigger,\n SpecChooserModal,\n VersionListModal,\n VersionSection,\n} from \"./settings-sections.tsx\";\n\n/** The Import modal's three list keys; for a workflow import only `workflowsKey` is read. */\nconst IMPORT_LIST_KEYS = {\n functionsKey: [\"functions\"] as const,\n endpointsKey: [\"endpoints\"] as const,\n workflowsKey,\n};\n\n/**\n * The three open flags a Settings panel shows: the Name/Key/Tags modal, the history section, and\n * the version list modal. They are OWNED BY THE CALLER (a stateful shell above every kind's arm),\n * not by the arm: a rail that stays mounted across a kind change (function -> workflow ->\n * endpoint) swaps arm component types, and state held in the arm would be remounted away,\n * closing an open modal. Lifting them keeps the modal open exactly as the pre-split single\n * component did.\n */\nexport type SettingsOpenState = {\n editingSettings: boolean;\n setEditingSettings: (v: boolean) => void;\n historyOpen: boolean;\n setHistoryOpen: (v: boolean) => void;\n versionListOpen: boolean;\n setVersionListOpen: (v: boolean) => void;\n};\n\nexport function WorkflowSettingsPanel({\n ctx,\n project,\n onNavigate,\n open,\n}: {\n ctx: WorkspaceCallable;\n project: string | null;\n onNavigate: (to: RailNavigation) => void;\n open: SettingsOpenState;\n}) {\n const {\n editingSettings,\n setEditingSettings,\n historyOpen,\n setHistoryOpen,\n versionListOpen,\n setVersionListOpen,\n } = open;\n const workflowsQuery = useWorkflowsQuery(project ?? undefined);\n const isWorkflow = ctx?.kind === \"workflow\";\n const id = ctx?.id ?? \"\";\n\n // The Key / Tags / Name save needs the WHOLE stored definition (never a `{id,key}` stub) plus\n // the `updatedAt` precondition — both come from this query.\n const wfDefQuery = useWorkflowQuery(id, isWorkflow);\n // MUST carry the current project, verbatim: the hook refuses a missing one (no default).\n const saveWfMut = useSaveWorkflowMutation(project ?? undefined);\n const archiveWfMut = useArchiveWorkflowMutation();\n const deleteWfMut = useDeleteWorkflowMutation();\n\n const [specMenuOpen, setSpecMenuOpen] = useState(false);\n const [importing, setImporting] = useState(false);\n const [deleteConfirming, setDeleteConfirming] = useState(false);\n const [archiveConfirming, setArchiveConfirming] = useState(false);\n const [deleteError, setDeleteError] = useState<string | null>(null);\n const [archiveError, setArchiveError] = useState<string | null>(null);\n\n // `versionListOpen` is DELIBERATELY separate from `historyOpen` (both arrive via `open`): a\n // native `<dialog>` opened via `showModal()` makes the rest of the page inert, so sharing one\n // boolean would hide Publish/Enable-Disable the moment the list modal closes. The entry icon\n // sets both true; only the list modal's own close clears `versionListOpen`.\n // Gated on the section's OWN open state: opening this panel issues zero `/versions` requests.\n const versionsQuery = useVersionsQuery(\"workflow\", id, historyOpen && isWorkflow);\n const publishMut = usePublishMutation(\"workflow\");\n const setEnabledMut = useSetEnabledMutation(\"workflow\");\n const [publishError, setPublishError] = useState<string | null>(null);\n const [enableError, setEnableError] = useState<string | null>(null);\n // Keyed by resource id: falls back to closed the instant `ctx.id` no longer matches, so a\n // transition never carries a stale version from a DIFFERENT resource.\n const [openVersion, setOpenVersion] = useState<{ id: string; versionNumber: number } | null>(\n null,\n );\n\n if (!ctx || ctx.kind !== \"workflow\") {\n return <p className=\"muted small\">Open a workflow to see its settings.</p>;\n }\n\n const listRow = workflowsQuery.data?.find((w) => w.id === ctx.id);\n const displayName =\n listRow && typeof (listRow as { displayName?: unknown }).displayName === \"string\"\n ? (listRow as { displayName: string }).displayName\n : \"\";\n const tags = (listRow as { tags?: string[] } | undefined)?.tags ?? [];\n const archived = (listRow as { status?: string } | undefined)?.status === \"archived\";\n\n function onDelete() {\n setDeleteError(null);\n deleteWfMut.mutate(id, {\n onSuccess: () => {\n setDeleteConfirming(false);\n onNavigate({ type: \"list\" });\n },\n onError: (e: unknown) => {\n setDeleteConfirming(false);\n setDeleteError(e instanceof ApiError ? e.message : String(e));\n },\n });\n }\n\n function onArchive() {\n setArchiveError(null);\n archiveWfMut.mutate(id, {\n onSuccess: () => {\n setArchiveConfirming(false);\n onNavigate({ type: \"list\" });\n },\n onError: (e: unknown) => {\n setArchiveConfirming(false);\n setArchiveError(e instanceof ApiError ? e.message : String(e));\n },\n });\n }\n\n return (\n <div className=\"rail-settings-panel\">\n <SettingsHeading onEdit={() => setEditingSettings(true)} />\n <MetadataSection\n id={ctx.id}\n displayName={displayName}\n fields={metadataFieldsForKind(\"workflow\")}\n row={listRow}\n tags={tags}\n />\n\n <SpecActionsTrigger onOpen={() => setSpecMenuOpen(true)} />\n\n <VersionSection\n open={historyOpen}\n versions={versionsQuery.data}\n publishing={publishMut.isPending}\n togglingEnabled={setEnabledMut.isPending}\n publishError={publishError}\n enableError={enableError}\n onShow={() => {\n setHistoryOpen(true);\n setVersionListOpen(true);\n }}\n onPublish={() => {\n setPublishError(null);\n publishMut.mutate(id, {\n onError: (e) => setPublishError(e instanceof ApiError ? e.message : String(e)),\n });\n }}\n onToggleEnabled={() => {\n setEnableError(null);\n setEnabledMut.mutate(\n { id, enabled: !versionsQuery.data?.enabled },\n { onError: (e) => setEnableError(e instanceof ApiError ? e.message : String(e)) },\n );\n }}\n />\n\n {versionListOpen && (\n <VersionListModal\n loading={versionsQuery.isLoading}\n versions={versionsQuery.data?.versions}\n onSelect={(versionNumber) => setOpenVersion({ id, versionNumber })}\n onClose={() => setVersionListOpen(false)}\n />\n )}\n\n {openVersion && openVersion.id === id && (\n <VersionHistoryModal\n kind=\"workflow\"\n id={id}\n versionNumber={openVersion.versionNumber}\n onClose={() => setOpenVersion(null)}\n />\n )}\n\n {specMenuOpen && (\n <SpecChooserModal\n kind=\"workflow\"\n onClose={() => setSpecMenuOpen(false)}\n onImport={() => {\n setSpecMenuOpen(false);\n setImporting(true);\n }}\n />\n )}\n\n {/* Unified settings modal for name, key, and tags. */}\n {editingSettings && listRow && (\n <CallableSettingsModal\n // `key={id}` remounts (not merely re-renders) when an in-app navigation swaps the rail\n // to a different resource while this modal is open — the modal's `useState`\n // initializers never re-run on a prop change, so without it a save would mix the first\n // resource's stale fields with the new `id`.\n key={id}\n kind=\"workflow\"\n id={id}\n initial={{\n displayName,\n key: (listRow as { key?: string | null }).key ?? null,\n tags,\n }}\n onSave={async (data) => {\n if (!wfDefQuery.data) throw new Error(\"Unable to save settings\");\n const stored = wfDefQuery.data;\n return new Promise((resolve, reject) => {\n const updated: Record<string, unknown> = {\n ...stored.workflow,\n displayName: data.displayName,\n };\n if (data.key !== undefined) {\n updated.key = data.key;\n }\n if (data.tags !== undefined) {\n updated.tags = data.tags;\n }\n saveWfMut.mutate(\n { definition: updated, ifUnmodifiedSince: stored.updatedAt },\n { onSuccess: () => resolve(), onError: reject },\n );\n });\n }}\n onClose={() => setEditingSettings(false)}\n />\n )}\n\n <SettingsDangerZone\n kind=\"workflow\"\n archived={archived}\n deleteConfirming={deleteConfirming}\n archiveConfirming={archiveConfirming}\n deleteError={deleteError}\n archiveError={archiveError}\n onRequestDelete={() => setDeleteConfirming(true)}\n onRequestArchive={() => setArchiveConfirming(true)}\n onConfirmDelete={onDelete}\n onConfirmArchive={onArchive}\n onCloseDelete={() => setDeleteConfirming(false)}\n onCloseArchive={() => setArchiveConfirming(false)}\n />\n\n {importing && (\n <ImportSpecModal\n kind=\"workflow\"\n project={project ?? undefined}\n listKeys={IMPORT_LIST_KEYS}\n onOpenImported={(kind, newId) => onNavigate({ type: \"imported\", kind, id: newId })}\n onClose={() => setImporting(false)}\n />\n )}\n </div>\n );\n}\n\nfunction SettingsToolPanel({ ctx }: { ctx: WorkspaceCallable }) {\n const { project, onNavigate } = useRailEnv();\n const [editingSettings, setEditingSettings] = useState(false);\n const [historyOpen, setHistoryOpen] = useState(false);\n const [versionListOpen, setVersionListOpen] = useState(false);\n return (\n <WorkflowSettingsPanel\n ctx={ctx}\n project={project}\n onNavigate={onNavigate}\n open={{\n editingSettings,\n setEditingSettings,\n historyOpen,\n setHistoryOpen,\n versionListOpen,\n setVersionListOpen,\n }}\n />\n );\n}\n\nfunction SettingsToolIcon() {\n return <Icon name=\"settings\" />;\n}\n\n/** The package's Settings tool — workflow context only (Studio keeps its own for the other arms). */\nexport const settingsTool: RailTool = {\n id: \"settings\",\n title: \"Settings\",\n rendersHeading: true,\n Icon: SettingsToolIcon,\n isAvailable: (ctx) => ctx?.kind === \"workflow\",\n Panel: SettingsToolPanel,\n};\n","/**\n * The rail tools `<WorkflowEditor>` mounts, in display order. Workflow-only arms of the three\n * tools Studio's rail shares; the Aliases tool is deliberately absent (alias management is\n * Studio-only). Reachable from the `chrome` subpath, never from the package root barrel — the\n * Error handling tool pulls in `@w6w/ui/flow`.\n */\nimport type { RailTool } from \"../chrome/RightRail.tsx\";\nimport { codeTool } from \"./CodeTool.tsx\";\nimport { errorHandlingTool } from \"./ErrorHandlingTool.tsx\";\nimport { settingsTool } from \"./SettingsTool.tsx\";\n\nexport const editorRailTools: readonly RailTool[] = [settingsTool, codeTool, errorHandlingTool];\n","import {\n type ExprValue,\n ExpressionInput,\n ExpressionOptionsProvider,\n IconButton,\n type SecretValue,\n useExpressionOptions,\n} from \"@w6w/ui\";\nimport { useState } from \"react\";\nimport { Modal } from \"../chrome/Modal.tsx\";\nimport { type WorkflowVariableRow, duplicateKeyIndexes, varsRailFor } from \"../lib/index.ts\";\n\n/** The settings modal's two tabs — General is always the one it opens on. */\nconst SETTINGS_TABS = [\"general\", \"variables\"] as const;\ntype SettingsTab = (typeof SETTINGS_TABS)[number];\n\n/** The `WorkflowVariable.type` union a row's type `<select>` offers. */\nconst VARIABLE_TYPES = [\"string\", \"number\", \"boolean\", \"object\", \"array\"] as const;\n\n/**\n * Per-workflow authoring settings (General) plus the Variables tab (T1.1.5) —\n * the workflow's declared `variables` list, its public input schema (HITL-5).\n * Both General flags are on unless the workflow says otherwise and persist\n * immediately (`saveMeta`, via `onChange`); every Variables edit instead goes\n * through the auto-saver (`onVariablesChange` → `patchMeta`, never an\n * immediate save — see the module docstring's Save path decision).\n */\nexport function WorkflowSettingsModal(props: {\n autoSave: boolean;\n savePosition: boolean;\n variables: WorkflowVariableRow[];\n onClose: () => void;\n onChange: (key: \"autoSave\" | \"savePosition\", value: boolean) => void;\n onVariablesChange: (next: WorkflowVariableRow[]) => void;\n}) {\n const { autoSave, savePosition, variables, onClose, onChange, onVariablesChange } = props;\n // The project's variable names, inherited from the app shell — the base list\n // `varsRailFor` narrows per row below.\n const inheritedVars = useExpressionOptions().vars ?? [];\n const [tab, setTab] = useState<SettingsTab>(\"general\");\n\n function addVariable() {\n onVariablesChange([...variables, { key: \"\" }]);\n }\n function updateVariable(i: number, next: Partial<WorkflowVariableRow>) {\n onVariablesChange(variables.map((v, idx) => (idx === i ? { ...v, ...next } : v)));\n }\n function removeVariable(i: number) {\n onVariablesChange(variables.filter((_, idx) => idx !== i));\n }\n const dupIndexes = duplicateKeyIndexes(variables);\n\n return (\n <Modal title=\"Workflow settings\" onClose={onClose} wide>\n <div className=\"w6w-subtabs\">\n <button\n type=\"button\"\n className={`w6w-subtab${tab === \"general\" ? \" active\" : \"\"}`}\n onClick={() => setTab(\"general\")}\n >\n General\n </button>\n <button\n type=\"button\"\n className={`w6w-subtab${tab === \"variables\" ? \" active\" : \"\"}`}\n onClick={() => setTab(\"variables\")}\n >\n Variables\n </button>\n </div>\n\n {tab === \"general\" ? (\n <>\n <div className=\"modal-body\">\n <p className=\"muted small\">\n These settings belong to the workflow, so everyone who opens it gets the same\n behaviour. Both are on unless you turn them off; each change saves straight away.\n </p>\n <label\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: \"var(--w6w-sp-2)\",\n cursor: \"pointer\",\n }}\n title=\"Save edits as you make them, without pressing Save.\"\n >\n <input\n type=\"checkbox\"\n checked={autoSave}\n onChange={(e) => onChange(\"autoSave\", e.target.checked)}\n />\n <span className=\"muted small\">Auto-save edits</span>\n </label>\n <label\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: \"var(--w6w-sp-2)\",\n cursor: \"pointer\",\n }}\n title=\"Keep the arrangement of the canvas — where each step sits, and the view you left it at.\"\n >\n <input\n type=\"checkbox\"\n checked={savePosition}\n onChange={(e) => onChange(\"savePosition\", e.target.checked)}\n />\n <span className=\"muted small\">Save step positions and canvas view</span>\n </label>\n </div>\n <div className=\"modal-actions\">\n {/* T1.3.1: Archive/Delete moved to the right rail's Settings tool\n — one consistent Settings surface, same archive-before-delete\n lifecycle, only relocated (D-I0.1-1). See\n `SettingsTool.tsx`'s own module docstring. */}\n <button type=\"button\" className=\"btn ghost\" onClick={onClose}>\n Done\n </button>\n </div>\n </>\n ) : (\n <>\n <div className=\"modal-body\">\n {/* HITL-5: declaring a variable flips this workflow's generated MCP\n tool from a pass-through schema to a declared one — say so. */}\n <p className=\"muted small\">\n Declaring variables here defines this workflow's <strong>public input schema</strong>:\n API and AI (MCP) callers then see exactly these inputs. With none declared, they may\n send anything.\n </p>\n <div className=\"row\" style={{ justifyContent: \"space-between\", alignItems: \"center\" }}>\n <span className=\"muted small\">\n {variables.length === 0\n ? \"No variables declared.\"\n : `${variables.length} variable${variables.length === 1 ? \"\" : \"s\"} declared.`}\n </span>\n <button type=\"button\" className=\"btn ghost\" onClick={addVariable}>\n + Add variable\n </button>\n </div>\n {variables.length > 0 && (\n <ul className=\"list\" data-testid=\"workflow-variables-list\">\n {variables.map((v, i) => (\n <li\n // biome-ignore lint/suspicious/noArrayIndexKey: rows are positional and reorderable\n key={i}\n style={{\n flexDirection: \"column\",\n alignItems: \"stretch\",\n gap: \"var(--w6w-sp-1)\",\n }}\n >\n <div className=\"row\" style={{ alignItems: \"center\", gap: \"var(--w6w-sp-2)\" }}>\n <input\n type=\"text\"\n value={v.key}\n placeholder=\"key\"\n aria-label=\"Variable key\"\n onChange={(e) => updateVariable(i, { key: e.target.value })}\n />\n <select\n value={v.type ?? \"\"}\n aria-label=\"Variable type\"\n onChange={(e) =>\n updateVariable(i, {\n type: (e.target.value || undefined) as WorkflowVariableRow[\"type\"],\n })\n }\n >\n <option value=\"\">(unset)</option>\n {VARIABLE_TYPES.map((t) => (\n <option key={t} value={t}>\n {t}\n </option>\n ))}\n </select>\n <label\n className=\"row\"\n style={{ gap: \"var(--w6w-sp-1)\", alignItems: \"center\" }}\n >\n <input\n type=\"checkbox\"\n checked={v.required ?? false}\n onChange={(e) => updateVariable(i, { required: e.target.checked })}\n />\n <span className=\"muted small\">required</span>\n </label>\n {/* Narrow `vars` for THIS row only: a variable's default\n may reference the variables declared above it, never\n itself or the ones below. Only that one key is\n contributed — secrets, documents, sample values and the\n callbacks come through from the app shell untouched,\n because the provider layers rather than replaces. */}\n <ExpressionOptionsProvider\n value={{ vars: varsRailFor(variables, i, inheritedVars) }}\n >\n <ExpressionInput\n // Re-key on the list's shape (not just `i`): ExpressionInput\n // seeds its parts once on mount and never again, so when a\n // row is removed and later rows shift up an index, React\n // must remount the widget rather than reuse the instance —\n // otherwise the surviving cell keeps showing the previous\n // occupant's default (see ExpressionInput.tsx:56-57).\n key={`${variables.length}:${i}`}\n value={v.default as ExprValue | string | SecretValue | undefined}\n onChange={(next) => updateVariable(i, { default: next })}\n placeholder=\"default\"\n aria-label=\"Variable default\"\n />\n </ExpressionOptionsProvider>\n <IconButton\n danger\n icon=\"close\"\n label={`Remove variable ${v.key || i + 1}`}\n onClick={() => removeVariable(i)}\n />\n </div>\n {dupIndexes.includes(i) && (\n <span className=\"muted small\" data-testid=\"variable-duplicate\">\n Duplicate key — a later row with the same name wins.\n </span>\n )}\n </li>\n ))}\n </ul>\n )}\n </div>\n <div className=\"modal-actions\">\n <button type=\"button\" className=\"btn ghost\" onClick={onClose}>\n Done\n </button>\n </div>\n </>\n )}\n </Modal>\n );\n}\n","import type { WorkflowStatus } from \"@w6w/sdk\";\nimport type { CallablePolicy, WorkflowSettings, WorkflowVariableRow } from \"../lib/index.ts\";\n\nexport type Parsed = Record<string, unknown> & {\n id?: string;\n name?: string;\n /** D-1: nullable, no backfill; `undefined` when the field is absent from\n * the text entirely — both mean \"no key\" to {@link workflowKeyEditAllowed}\n * (D-3). The rail's Key control (`SettingsTool.tsx`) is the only place\n * this is ever ASSIGNED; this page only ever reads it back. */\n key?: string | null;\n steps?: unknown[];\n status?: WorkflowStatus;\n tags?: string[];\n /** Authoring presentation — rides in the definition, no column of its own. */\n settings?: WorkflowSettings;\n /** Declared public input schema (T1.1.5) — see `workflow-variables.ts`. */\n variables?: WorkflowVariableRow[];\n /**\n * The RUN-level error policy (core Workflow RFC — *Amendment — 2026-08-21:\n * the run-level error handler*). Authored from the right rail's Error\n * handling tool, which this page hands a writer to rather than letting it\n * save independently — see the `useWorkspace` call below.\n */\n retry?: CallablePolicy[\"retry\"];\n onError?: CallablePolicy[\"onError\"];\n reroute?: CallablePolicy[\"reroute\"];\n};\n\n/** Workflow ids: start alphanumeric, then word chars / dots / dashes. */\nexport const ID_RE = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;\n\n/** Placeholder + minimum sizing basis for the inline title field. */\nexport const TITLE_PLACEHOLDER = \"Untitled workflow\";\n","/**\n * The canvas's app lookups, through the host-provided `W6WApi` (`useW6WApi()` — in an embed that\n * is `createW6WUiAdapter`'s, in Studio the facade, which delegates to the same store/repo).\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { type AppSummary, useW6WApi } from \"@w6w/ui\";\nimport { useMemo } from \"react\";\n\n/** The per-app actions query key — byte-identical to Studio's `repos/apps.ts#appActionsKey`. */\nexport const appActionsKey = (id: string) => [\"app-actions\", id] as const;\n\nconst NO_APPS: ReadonlyMap<string, AppSummary> = new Map();\n\n/** A bounded set of app records by id. Empty when the host's API has no `listAppsByIds`. */\nexport function useEditorApps(ids: readonly string[]): { byId: ReadonlyMap<string, AppSummary> } {\n const api = useW6WApi();\n const list = api.listAppsByIds?.bind(api);\n const key = [...ids].sort().join(\",\");\n const q = useQuery({\n queryKey: [\"editor-apps\", key],\n queryFn: ({ signal }) => (list ? list(ids, { signal }) : Promise.resolve([] as AppSummary[])),\n enabled: ids.length > 0 && typeof list === \"function\",\n });\n const data = q.data;\n const byId = useMemo(\n () => (data ? new Map(data.map((a) => [a.id, a] as const)) : NO_APPS),\n [data],\n );\n return { byId };\n}\n","import { useQueries } from \"@tanstack/react-query\";\nimport { ApiError } from \"@w6w/sdk\";\nimport {\n ExecutionLogPanel,\n IconButton,\n isTestRequired,\n requiredParamsFilled,\n useW6WApi,\n} from \"@w6w/ui\";\nimport type { InternalNodeDef } from \"@w6w/ui/flow\";\nimport {\n type ReactNode,\n Suspense,\n lazy,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { ExecutionProfileHeader } from \"../chrome/ExecutionProfileHeader.tsx\";\nimport { HistoryButton } from \"../chrome/HistoryButton.tsx\";\nimport { JsonToggle, JsonToggleButton } from \"../chrome/JsonToggle.tsx\";\nimport { Modal } from \"../chrome/Modal.tsx\";\nimport { RightRail } from \"../chrome/RightRail.tsx\";\nimport { WorkspaceProvider, useWorkspace } from \"../chrome/workspace.tsx\";\nimport { useEmbedClient, useWorkflowDraft } from \"../draft/index.ts\";\nimport {\n type ActionParamLike,\n type CallablePolicy,\n type TriggerPreview,\n type TriggerPreviewFieldDef,\n type ValidityContext,\n type WorkflowLike,\n type WorkflowStepLike,\n definitionWithPolicy,\n invalidReason,\n policyFromDefinition,\n readSettings,\n readVariables,\n triggerPreviews,\n variablesForSave,\n workflowKeyEditAllowed,\n workflowValid,\n writeSetting,\n} from \"../lib/index.ts\";\nimport { useEditorProject } from \"../project-context.ts\";\nimport { ProjectExpressionScope } from \"../rail/ExpressionScope.tsx\";\nimport { editorRailTools } from \"../rail/editor-tools.ts\";\nimport { RailEnvProvider, type RailNavigation } from \"../rail/rail-env.tsx\";\nimport {\n classifyCancelError,\n isRunInFlight,\n listStepTests,\n mapRunStateToLogSteps,\n resolveHeaderRunInput,\n runButtonLabel,\n runLevelErrors,\n stepTestsKey,\n useCancelRunMutation,\n useLiveRunQuery,\n usePublishMutation,\n useStartRunMutation,\n useVersionsQuery,\n} from \"../repos/index.ts\";\nimport { WorkflowSettingsModal } from \"./WorkflowSettingsModal.tsx\";\nimport { ID_RE, type Parsed, TITLE_PLACEHOLDER } from \"./definition.ts\";\nimport { appActionsKey, useEditorApps } from \"./editor-apps.ts\";\nimport type {\n WorkflowEditorNavigation,\n WorkflowEditorProps,\n WorkflowEditorSlots,\n} from \"./types.ts\";\n\n// The visual editor is code-split — its @xyflow/react payload only loads when\n// the editor is actually open.\nconst WorkflowFlowEditor = lazy(() =>\n import(\"@w6w/ui/flow\").then((m) => ({ default: m.WorkflowFlowEditor })),\n);\n\nfunction EditorBody(props: {\n workflowId: string;\n project: string | null;\n initialRunId?: string;\n onNavigate: (to: WorkflowEditorNavigation) => void;\n slots?: WorkflowEditorSlots;\n}) {\n const { workflowId, project, initialRunId, onNavigate, slots } = props;\n const apiClient = useEmbedClient();\n const api = useW6WApi();\n const [valid, setValid] = useState(true);\n const [validityError, setValidityError] = useState<string | null>(null);\n // Page-level errors only (run, publish, create); the draft's own load/save errors come from\n // `useWorkflowDraft` (`draftError` below).\n const [error, setError] = useState<string | null>(null);\n const [showJson, setShowJson] = useState(false);\n const [showSettings, setShowSettings] = useState(false);\n const [reloading, setReloading] = useState(false);\n\n // D-3/P4: the key the SERVER most recently sent for the row the buffer is showing — what\n // `workflowKeyEditAllowed` compares the parsed text's own `key` against. `undefined` = nothing\n // loaded yet (refuses unconditionally). Captured whenever the buffer equals the server's copy\n // (load, 409 reload, and after a save), never while it holds unsaved edits. State, not a ref:\n // the guard below must change identity for the draft to re-evaluate it.\n const [loadedKey, setLoadedKey] = useState<string | null | undefined>(undefined);\n // Injected into the draft (the hook is headless — these are Studio's own rules).\n // `autoSave` and the publish-validity reason both depend on the parsed text, which the hook\n // itself produces, so they ride refs assigned after the call (one render of lag at most).\n const autoSaveRef = useRef(true);\n const publishReasonRef = useRef<(def: unknown) => string | null>(() => null);\n const saveGuard = useCallback(\n (def: unknown): string | null => {\n const d = def as Parsed;\n if (!ID_RE.test(typeof d.id === \"string\" ? d.id : \"\")) return \"Invalid workflow id.\";\n // D-3/P4: the rail's Key control is the only place a key is ever assigned — this JSON\n // editor must refuse to save a definition whose `key` differs from what was loaded. Folded\n // into the draft's save gate (never a separate `disabled` on the Save button): auto-save\n // reads the same gate, so a guard on the button alone would be bypassed by typing.\n return workflowKeyEditAllowed(loadedKey, d.key).reason;\n },\n [loadedKey],\n );\n // Load, buffer, save, auto-save, flush-on-hide/unmount and the 409 all live in the hook\n // (`../draft`). The project is `useEditorProject`'s answer (prop, else the provider's): with\n // none, the hook refuses to save (`saveBlockedReason`) rather than let the server pick the\n // account default.\n const draft = useWorkflowDraft({\n workflowId,\n project,\n autoSave: autoSaveRef.current,\n // The expression editor holds uncommitted parts in its own local state until its Save\n // button, so saving from under it would persist a workflow without the expression the user\n // is looking at. Read at fire time (opening it changes neither the buffer nor `canSave`).\n canAutoSave: () => !document.querySelector(\".w6w-exprmodal\"),\n saveGuard,\n publishBlockedReason: (def) => publishReasonRef.current(def),\n });\n const json = draft.json;\n const parsed = draft.parsed as Parsed | null;\n const canSave = draft.canSave;\n const dirty = draft.dirty;\n\n // Capture the server's key whenever the buffer equals the server's copy (never while it holds\n // unsaved edits), and forget it while a workflow is loading or failed to load.\n useEffect(() => {\n if (draft.loading || draft.loadError !== null) {\n setLoadedKey(undefined);\n return;\n }\n if (!draft.dirty && parsed) setLoadedKey((parsed.key as string | null | undefined) ?? null);\n }, [draft.loading, draft.loadError, draft.dirty, parsed]);\n\n // \"Keep editing\" dismisses the 409 modal; the draft stays stale (it refuses to save into the\n // conflict) until the author reloads.\n const [staleDismissed, setStaleDismissed] = useState(false);\n useEffect(() => {\n if (!draft.stale) setStaleDismissed(false);\n }, [draft.stale]);\n\n // The \"Saved.\" marker: a save finished without error since the last one began.\n const [saved, setSaved] = useState(false);\n const wasSaving = useRef(false);\n useEffect(() => {\n if (draft.saving) setSaved(false);\n else if (wasSaving.current && draft.error === null) setSaved(true);\n wasSaving.current = draft.saving;\n }, [draft.saving, draft.error]);\n\n // T2.1.1: the run this canvas is currently showing, if any. Reset inside\n // the `workflowId` load effect below, so a run from a previously open\n // workflow never bleeds into a different one's canvas.\n const [activeRunId, setActiveRunId] = useState<string | null>(null);\n\n // Names offered by each step field's expression picker (task 3.2). The vault\n // No project-scope memo here any more. The ƒx rail's vars, secrets,\n // documents, sample values and \"+ Add\"/seal callbacks are INHERITED from\n // `ProjectExpressionScope` (`App.tsx`); `WorkflowFlowEditor` and the settings\n // modal below both read them from context. What this page's editor\n // contributes on top — the upstream `steps` for one node, and the narrowed\n // `vars` rail for a variable's own default row — is added where it is known,\n // not restated here. See `ui/ExpressionScope.tsx`.\n\n // ── T2.1.1: Run/Stop in the visual editor — live poll, canvas feedback, ──\n // ── log panel, read-only lock. See building-blocks.md §G3/§G4/§G6/§5. ────\n const startRunMut = useStartRunMutation();\n const cancelRunMut = useCancelRunMutation();\n const runQuery = useLiveRunQuery(activeRunId);\n const runStatus = runQuery.data?.status;\n const runPollFailed = runQuery.isError;\n const runInFlight = isRunInFlight(runStatus, runPollFailed);\n // 26-10-04-01-fixes I-1: the run log's rows (each carrying its step's error)\n // and the run-level `error`/`stepErrors` the rows don't already show —\n // mapped once per render, shared by the panel's three props.\n const runLogSteps = mapRunStateToLogSteps(\n runQuery.data?.steps as unknown as Parameters<typeof mapRunStateToLogSteps>[0],\n );\n const runLogErrors = runLevelErrors(runQuery.data, runLogSteps);\n // Header Run fetches the trigger's saved fixture before starting the run;\n // the ref guards re-entry synchronously (a second click can land before the\n // re-render that disables the button), the state disables the button.\n const runStartingRef = useRef(false);\n const [runStarting, setRunStarting] = useState(false);\n\n // ── T2.4.2: `?run=<runId>` — the History page's \"Open in visual editor\" ──\n // A workflow run's History row links to `workflows/<id>?run=<runId>`, and\n // THIS editor is what that link opens. The run plumbing above already\n // renders a terminal run exactly like a live one (`useLiveRunQuery` stops\n // polling on a terminal status by itself), so seeding `activeRunId` from the\n // URL is the whole feature — nothing about the poll, the canvas, the\n // read-only lock or the log panel moves.\n //\n // Declared AFTER the `workflowId` load effect on purpose: that effect resets\n // `activeRunId` for the row it is opening, and effects run in declaration\n // order, so on a mount the URL's run wins. Keyed on `[workflowId, initialRunId]`\n // rather than on mount alone, so an in-app transition to `?run=…` while the\n // editor stays mounted (`history.pushState` + `popstate`) still opens the\n // panel.\n // T2.1.1: a run belongs to the row that started it — the draft's load (formerly this page's\n // `workflowId` effect) reset it; declared BEFORE the `?run=` seed below so the URL's run still wins.\n // biome-ignore lint/correctness/useExhaustiveDependencies: `workflowId` is the trigger, not a value read\n useEffect(() => {\n setActiveRunId(null);\n }, [workflowId]);\n // biome-ignore lint/correctness/useExhaustiveDependencies: `workflowId`'s own value is never read below — it exists solely to re-seed the URL's run when the OPEN WORKFLOW changes, not as a value this closure needs (same retrigger-dependency shape as `api/w6wApiFacade.tsx`).\n useEffect(() => {\n if (initialRunId) setActiveRunId(initialRunId);\n }, [workflowId, initialRunId]);\n\n // The run id alone is not enough: a stale or hand-edited `?run=` can name a\n // run belonging to a DIFFERENT workflow, and painting that run's steps on\n // this canvas would be a lie. `RunState` carries its own `workflowId`, so the\n // first answer that names another workflow drops the run instead of\n // rendering it.\n useEffect(() => {\n if (runQuery.data && runQuery.data.workflowId !== workflowId) setActiveRunId(null);\n }, [runQuery.data, workflowId]);\n\n /**\n * T2.1.5: run `action` only once the buffer is saved. `blocked` shows its reason in the banner;\n * `failed` is already surfaced by the draft itself (banner, or the 409 modal via `draft.stale`).\n */\n async function runAfterFlush(action: () => Promise<unknown>) {\n try {\n const r = await draft.flushThen(action);\n if (!r.ok && r.outcome.status === \"blocked\") setError(r.outcome.reason);\n } catch (e) {\n setError(e instanceof ApiError ? e.message : String(e));\n }\n }\n\n async function onRunClick() {\n if (!workflowId || runInFlight || runStartingRef.current) return;\n setError(null);\n runStartingRef.current = true;\n setRunStarting(true);\n try {\n // 26-10-04-01-fixes I-1 (pinned): the manual trigger's latest saved Test-tab\n // values become the run's `input`, verbatim; no fixture (or no trigger,\n // or a failed fetch) sends no `input` key, exactly as before.\n const input = await resolveHeaderRunInput(triggerPreviewList?.[0]?.id, (stepId) =>\n listStepTests(apiClient, workflowId, stepId),\n );\n // T2.1.5 (R-27): the stored row is what runs, so an unsaved edit is saved FIRST. A refused\n // flush (`blocked` reason / `failed` save) never starts the run.\n await runAfterFlush(() =>\n startRunMut\n .mutateAsync({ id: workflowId, variables: {}, ...(input ? { input } : {}) })\n .then((res) => setActiveRunId(res.runId)),\n );\n } finally {\n runStartingRef.current = false;\n setRunStarting(false);\n }\n }\n\n function onStopClick() {\n if (!activeRunId) return;\n cancelRunMut.mutate(activeRunId, {\n onError: (e) => {\n const code = e instanceof ApiError ? e.code : \"\";\n // A `409 run_not_cancelable` means the run already finished before the\n // cancel request landed — reconcile via the next poll, no error banner.\n if (classifyCancelError(code) === \"surface\") {\n setError(e instanceof ApiError ? e.message : String(e));\n }\n },\n });\n // T1.1.1 A1: ask the server to cancel, but reset the LOCAL run state now —\n // the cancel is cooperative (heartbeat-driven) and may land long after the\n // click, so waiting for a poll to observe a terminal status would leave the\n // canvas greyed out in front of the user who just pressed Stop. The request\n // above still goes out, and `onError` still classifies the 409.\n setActiveRunId(null);\n }\n\n /** Replace the editor's contents with the server's copy and re-arm the token. */\n async function reloadFromServer() {\n setReloading(true);\n try {\n await draft.reload();\n setValid(true);\n setValidityError(null);\n setError(null);\n } finally {\n setReloading(false);\n }\n }\n\n // Page-level errors win; the draft's own load/save failure shows otherwise. A 409 is the\n // modal's business, not the banner's.\n const draftFailure = draft.stale ? null : (draft.error ?? draft.loadError);\n const bannerError =\n error ??\n (draftFailure === null\n ? null\n : draftFailure instanceof Error\n ? draftFailure.message\n : String(draftFailure));\n\n // Parse for the visual view + meta fields — the draft already parses (memoized) per edit.\n const flowUsable = parsed !== null && Array.isArray(parsed.steps);\n\n const displayName = (parsed?.displayName as string) ?? \"\";\n // Both flags are ON for a workflow that declares no `settings` — see readSettings.\n const settings = readSettings(parsed?.settings);\n // The Variables tab's rows (T1.1.5) — declaring the workflow's public input\n // schema (HITL-5). `useMemo` because `varsRailFor` runs once per row on\n // every render otherwise.\n const variables = useMemo(() => readVariables(parsed?.variables), [parsed?.variables]);\n // Visible only once something has actually loaded AND the parsed text is\n // real JSON — never flashes \"Workflow not loaded yet\" on a fresh mount\n // before the initial fetch resolves.\n const keyEdit = workflowKeyEditAllowed(loadedKey, parsed?.key);\n const keyGuardReason =\n parsed !== null && loadedKey !== undefined && !keyEdit.allowed ? keyEdit.reason : null;\n\n // ── Publish-time validity gate (T4.2.1) ──────────────────────────────────\n const steps = useMemo<WorkflowStepLike[]>(\n () => (Array.isArray(parsed?.steps) ? (parsed.steps as WorkflowStepLike[]) : []),\n [parsed],\n );\n\n // `INTERNAL_NODES`/`isInternalApp`/`internalNodeParams` resolve from the SAME\n // `import(\"@w6w/ui/flow\")` the canvas's `lazy()` above already triggers (a\n // module-cache hit, not a second bundle) — only needed while the editor is\n // open, same as the canvas itself. Defaults to \"nothing resolved yet\", which\n // fails `hasTrigger`/`actionParamsByKey` closed (invalid) until it lands.\n const [flowHelpers, setFlowHelpers] = useState<{\n internalNodes: InternalNodeDef[];\n isInternalApp: (app: string) => boolean;\n internalNodeParams: (app: string, action: string) => ActionParamLike[];\n // \"Call from code\" trigger preview (T2.2.1) — `TRIGGER_APP`/`asFieldDefs`\n // resolve from the SAME import, no second dynamic import.\n isManualTrigger: (app: string) => boolean;\n asFieldDefs: (fields: unknown) => TriggerPreviewFieldDef[];\n } | null>(null);\n useEffect(() => {\n let canceled = false;\n import(\"@w6w/ui/flow\").then((m) => {\n if (canceled) return;\n setFlowHelpers({\n internalNodes: m.INTERNAL_NODES,\n isInternalApp: m.isInternalApp,\n internalNodeParams: m.internalNodeParams,\n isManualTrigger: (app) => app === m.TRIGGER_APP,\n asFieldDefs: m.asFieldDefs,\n });\n });\n return () => {\n canceled = true;\n };\n }, []);\n\n // \"Call from code\" trigger preview (T2.2.1, HITL-2/HITL-4 pinned): the\n // modal's per-trigger field picker, derived from the SAME `steps` above —\n // no new fetch, no new query key.\n const triggerPreviewList = useMemo<TriggerPreview[] | undefined>(() => {\n if (!flowHelpers) return undefined;\n return triggerPreviews(\n { steps },\n { isManualTrigger: flowHelpers.isManualTrigger, asFieldDefs: flowHelpers.asFieldDefs },\n );\n }, [flowHelpers, steps]);\n\n // \"A trigger exists\" means a graph STEP whose (app, action) is a trigger\n // node (an `INTERNAL_NODES` entry with `group: \"trigger\"`) — not the\n // workflow's top-level `trigger` field, which `blankDefinition` always\n // seeds and so is truthy unconditionally (rfcs/workflow.md:114).\n const hasTrigger = useMemo(() => {\n if (!flowHelpers) return false;\n const triggerKeys = new Set(\n flowHelpers.internalNodes\n .filter((n) => n.group === \"trigger\")\n .map((n) => `${n.app}::${n.action}`),\n );\n return steps.some((s) => {\n const { app, action } = s.uses ?? {};\n return !!app && !!action && triggerKeys.has(`${app}::${action}`);\n });\n }, [flowHelpers, steps]);\n\n // Unique third-party (non-internal) app ids across the graph, batch-fetched\n // once each — mirrors the per-step fetch WorkflowFlowEditor already does\n // (WorkflowFlowEditor.tsx:~1432), hoisted to page level and de-duplicated.\n const thirdPartyAppIds = useMemo(() => {\n if (!flowHelpers) return [];\n const ids = new Set<string>();\n for (const s of steps) {\n const { app, action } = s.uses ?? {};\n if (app && action && !flowHelpers.isInternalApp(app)) ids.add(app);\n }\n return [...ids];\n }, [flowHelpers, steps]);\n // Registered apps, so the visual editor can render each action node with its\n // owning app's icon, display name, and version — bounded to the ids this\n // graph actually references (src/apps provider, T3.1.2).\n const { byId: fetchedAppsById } = useEditorApps(thirdPartyAppIds);\n const appsList = useMemo(() => [...fetchedAppsById.values()], [fetchedAppsById]);\n const appActionsQueries = useQueries({\n queries: thirdPartyAppIds.map((appId) => ({\n queryKey: appActionsKey(appId),\n queryFn: () => api.getAppActions(appId),\n })),\n });\n\n // Declared params for every step's target, internal (sync) or third-party\n // (fetched above) — keyed `${app}::${action}`, one entry per unique target.\n const actionParamsByKey = useMemo(() => {\n const out: Record<string, ActionParamLike[]> = {};\n if (!flowHelpers) return out;\n for (const s of steps) {\n const { app, action } = s.uses ?? {};\n if (!app || !action) continue;\n const key = `${app}::${action}`;\n if (key in out) continue;\n if (flowHelpers.isInternalApp(app)) {\n out[key] = flowHelpers.internalNodeParams(app, action);\n } else {\n const idx = thirdPartyAppIds.indexOf(app);\n const fetched = idx >= 0 ? appActionsQueries[idx]?.data : undefined;\n out[key] = fetched?.find((a) => a.key === action)?.params ?? [];\n }\n }\n return out;\n }, [flowHelpers, steps, thirdPartyAppIds, appActionsQueries]);\n\n const appsById = useMemo(() => {\n const out: Record<string, unknown> = {};\n for (const [id, a] of fetchedAppsById) out[id] = a;\n return out;\n }, [fetchedAppsById]);\n\n // Only a step whose app is BOTH a real fetched app AND opts into\n // testRequired needs a `listStepTests` fetch — an internal/trigger/control\n // step's app is never a key in `appsById`, so it is never gated.\n const testGatedSteps = useMemo(\n () =>\n steps.filter((s) => {\n const app = s.uses?.app;\n return !!app && app in appsById && isTestRequired(appsById[app]);\n }),\n [steps, appsById],\n );\n const stepTestsQueries = useQueries({\n queries: testGatedSteps.map((s) => ({\n queryKey: stepTestsKey(workflowId, s.id),\n queryFn: () => listStepTests(apiClient, workflowId, s.id),\n enabled: !!workflowId,\n })),\n });\n const testStatus = useMemo(() => {\n const out: Record<string, boolean> = {};\n testGatedSteps.forEach((s, i) => {\n out[s.id] = !!stepTestsQueries[i]?.data?.some((t) => t.lastRunStatus === \"succeeded\");\n });\n return out;\n }, [testGatedSteps, stepTestsQueries]);\n\n // T3.1.1: the Publish button's own published-state, gated the same shape\n // as `stepTestsQueries` above (`!!workflowId`) — never on mount\n // alone. Shares its cache entry with the Settings rail's own History\n // section (same `[\"versions\", \"workflow\", id]` key), so either surface's\n // Publish click refreshes both without a reload.\n const versionsQuery = useVersionsQuery(\"workflow\", workflowId, !!workflowId);\n const publishMut = usePublishMutation(\"workflow\");\n\n const validityCtx = useMemo<ValidityContext>(\n () => ({\n hasTrigger,\n actionParamsByKey,\n appsById,\n testStatus,\n requiredParamsFilled,\n isTestRequired,\n }),\n [hasTrigger, actionParamsByKey, appsById, testStatus],\n );\n const workflowIsValid =\n parsed !== null && workflowValid(parsed as unknown as WorkflowLike, validityCtx);\n const publishInvalidReason =\n parsed !== null ? invalidReason(parsed as unknown as WorkflowLike, validityCtx) : null;\n\n publishReasonRef.current = (def) =>\n def !== null && typeof def === \"object\"\n ? invalidReason(def as unknown as WorkflowLike, validityCtx)\n : null;\n autoSaveRef.current = settings.autoSave;\n\n /** Patch top-level workflow fields, keeping the JSON text as source of truth. */\n function patchMeta(patch: Partial<Parsed>) {\n if (!parsed) return;\n const next: Parsed = { ...parsed, ...patch };\n draft.setJson(JSON.stringify(next, null, 2));\n }\n\n /** Patch top-level fields and persist immediately (for publish/tags edits). */\n function saveMeta(patch: Partial<Parsed>) {\n if (!parsed) return;\n const next: Parsed = { ...parsed, ...patch };\n setError(null);\n void draft.commit(JSON.stringify(next, null, 2));\n }\n\n // The rail's `onPolicyChange` must be referentially stable (see the `useWorkspace` call\n // below) and therefore cannot close over `parsed`/`draft` directly: it reads the live\n // definition and the draft's `commit` through refs.\n const parsedRef = useRef(parsed);\n parsedRef.current = parsed;\n const commitRef = useRef(draft.commit);\n commitRef.current = draft.commit;\n const saveNowRef = useRef(draft.saveNow);\n saveNowRef.current = draft.saveNow;\n\n // Cmd/Ctrl+S saves while the visual editor is open (mirrors the project\n // switcher's keydown effect in components/Layout.tsx: one guarded document\n // listener, symmetric cleanup).\n useEffect(() => {\n const onKey = (e: KeyboardEvent) => {\n if (e.altKey || !(e.metaKey || e.ctrlKey) || e.key.toLowerCase() !== \"s\") return;\n // Suppress the browser's Save Page dialog on every match, including the\n // paths below that decline to save.\n e.preventDefault();\n // The expression editor holds uncommitted parts in its own local state\n // until its Save button, so saving from under it would persist a workflow\n // without the expression the user is looking at.\n if (document.querySelector(\".w6w-exprmodal\")) return;\n if (!canSave) return;\n saveNowRef.current();\n };\n document.addEventListener(\"keydown\", onKey);\n return () => {\n document.removeEventListener(\"keydown\", onKey);\n };\n }, [canSave]);\n\n // T2.1.2: publishes into the right rail's Code/Aliases tools — called on\n // EVERY render, into the `WorkspaceProvider` the outer `WorkflowEditor` mounts.\n //\n // The `policy`/`onPolicyChange` pair is the right rail's Error handling tool\n // (core Workflow RFC — *Amendment — 2026-08-21: the run-level error\n // handler*). The rail does NOT save a workflow itself: this page owns the\n // definition buffer and the draft saves it, so a second writer over the wire\n // would race the canvas and one side's edit would vanish. Handing the rail a\n // writer instead makes its Save fold into the very same JSON text.\n const wfPolicy = useMemo<CallablePolicy>(\n () => (parsed ? policyFromDefinition(parsed) : {}),\n [parsed],\n );\n // Referentially STABLE, as `workspace.tsx` requires: `useWorkspace` keys its\n // publish effect on `JSON.stringify(resource)`, which drops functions, so a\n // callback rebuilt per render would be stored once and then go stale. It\n // reads the current definition through `parsedRef` — always the live value,\n // never a captured one. Persists immediately, exactly like `saveMeta`'s\n // publish/tags edits.\n const onPolicyChange = useCallback((policy: CallablePolicy) => {\n const current = parsedRef.current;\n if (!current) return;\n const next = definitionWithPolicy(current, policy);\n setError(null);\n void commitRef.current(JSON.stringify(next, null, 2));\n }, []);\n\n useWorkspace({\n kind: \"workflow\",\n id: workflowId,\n label: displayName,\n key: parsed?.key ?? undefined,\n triggers: triggerPreviewList,\n policy: wfPolicy,\n onPolicyChange,\n });\n\n return (\n <div className=\"wf-fullbleed\" style={{ height: \"100%\", minWidth: 0, flex: 1 }}>\n {/* T3.1.1: the header itself is `ExecutionProfileHeader` — the SAME\n component a Function/Endpoint editor mounts through\n `CallableEditorChrome`. Everything below is host business: the\n back control (A8, updated by T4.1.1: the editor is its own route\n now, so \"back\" navigates to the LISTING — the sibling params it was\n opened with are kept, since they are the author's), the controlled\n name field that persists on blur, and the action row. */}\n {slots?.header ?? (\n <ExecutionProfileHeader\n onBack={() => onNavigate({ type: \"list\" })}\n backLabel={slots?.backLabel ?? \"← Workflows\"}\n title={{\n editable: true,\n value: displayName,\n placeholder: TITLE_PLACEHOLDER,\n maxLength: 80,\n ariaLabel: \"Workflow name\",\n onChange: (next) => patchMeta({ displayName: next }),\n onBlur: () => {\n if (canSave) draft.saveNow();\n },\n }}\n actions={\n <>\n <IconButton\n icon=\"play\"\n label={runButtonLabel(runStatus, runPollFailed)}\n data-testid=\"wf-run-start\"\n onClick={onRunClick}\n disabled={!workflowId || runInFlight || runStarting || startRunMut.isPending}\n />\n {runInFlight && (\n <IconButton\n icon=\"stop\"\n label=\"Stop this run\"\n data-testid=\"wf-run-stop\"\n onClick={onStopClick}\n disabled={cancelRunMut.isPending}\n />\n )}\n <button\n type=\"button\"\n className={`btn ghost wf-publish${versionsQuery.data?.currentPublishedVersion != null ? \" active\" : \"\"}`}\n data-testid=\"wf-publish\"\n onClick={() => {\n if (!workflowId) return;\n setError(null);\n void runAfterFlush(() => publishMut.mutateAsync(workflowId));\n }}\n disabled={project === null || !canSave || !workflowIsValid || publishMut.isPending}\n title={\n canSave && !workflowIsValid\n ? (publishInvalidReason ?? \"Workflow is not valid\")\n : versionsQuery.data?.currentPublishedVersion != null\n ? \"Published — click to publish a new version\"\n : \"Never published — click to publish\"\n }\n >\n {publishMut.isPending\n ? \"Publishing…\"\n : versionsQuery.data?.currentPublishedVersion != null\n ? \"● Published\"\n : \"Publish\"}\n </button>\n <HistoryButton\n kind=\"workflow\"\n id={workflowId}\n onOpenRun={(runId) => {\n setActiveRunId(runId);\n onNavigate({ type: \"run\", id: workflowId, runId });\n }}\n />\n <JsonToggleButton onClick={() => setShowJson(true)} />\n {/* T2.1.2: \"Call from code\" moved to the right rail's Code tool —\n see the `useWorkspace` call above (this closes the prior\n project's HITL-1: the flow editor now publishes, since the\n gate is the editor's own mount, not the route wrapper that could\n never see this component's route param). */}\n <IconButton\n icon=\"settings\"\n label=\"Workflow settings\"\n onClick={() => setShowSettings(true)}\n />\n {slots?.headerActions}\n </>\n }\n />\n )}\n <div className=\"wf-fullbleed-canvas\">\n <div className=\"wf-run-area\">\n <div className=\"wf-run-canvas\">\n <Suspense fallback={<p className=\"muted\">Loading visual editor…</p>}>\n {flowUsable && parsed ? (\n <WorkflowFlowEditor\n // The parsed cast is safe: onChange only receives shapes we produced.\n value={parsed as unknown as Parameters<typeof WorkflowFlowEditor>[0][\"value\"]}\n onChange={(next) => {\n draft.setJson(JSON.stringify(next, null, 2));\n setValid(true);\n setValidityError(null);\n // T1.1.1 A2.1: an edit to the graph — a canvas edit or a\n // step-config commit from `StepEditModal`, both of which\n // arrive here — means the run this canvas was showing is\n // no longer the thing the author is looking at.\n setActiveRunId(null);\n }}\n apps={appsList}\n project={project ?? undefined}\n height=\"100%\"\n // A4: locked while the run this canvas is showing is still\n // in flight, unlocked again on every terminal status AND\n // when the poll itself gives up or errors.\n readOnly={runInFlight}\n // L-3b: re-frame the graph when the run-log panel docks\n // beside it and again when it leaves — keyed on the panel\n // being MOUNTED (`activeRunId`, same condition as the\n // `wf-run-log` block below), not on `runInFlight` (the\n // panel stays after a terminal status) nor on the run's\n // data (changes every poll tick).\n fitViewKey={activeRunId !== null}\n // A3: each intermediate RunState reaches the canvas as it\n // arrives — the cast crosses the same opaque-`steps`\n // boundary `getRunState`'s own callers already cross (the\n // SDK's console `RunState.steps` is `Record<string,\n // unknown>` on purpose; the server's real per-step shape\n // structurally satisfies `ui`'s narrower `RunState`).\n runState={\n runQuery.data as unknown as Parameters<typeof WorkflowFlowEditor>[0][\"runState\"]\n }\n // T1.1.1 A3: a step test starts → the run this canvas was\n // showing is no longer the thing under test, so drop it on\n // the click rather than waiting for the test's result.\n onTestRun={() => setActiveRunId(null)}\n />\n ) : json === \"\" ? (\n <p className=\"muted\">Loading…</p>\n ) : (\n <p className=\"muted\">Fix the JSON to render the visual editor.</p>\n )}\n </Suspense>\n </div>\n {activeRunId && (\n <div className=\"wf-run-log\" data-testid=\"wf-run-log\">\n <ExecutionLogPanel\n steps={runLogSteps}\n runError={runLogErrors.runError}\n stepErrors={runLogErrors.stepErrors}\n // T1.1.1 A4: the one explicit \"I'm done looking at this run\"\n // control — same lever as Stop, so it must work in the empty\n // branch too (the panel renders its head there as well).\n onDismiss={() => setActiveRunId(null)}\n />\n </div>\n )}\n </div>\n </div>\n {project === null && (\n <div role=\"alert\" className=\"error\" data-testid=\"wf-project-required\">\n No project selected — pass a <code>project</code> prop (or set the provider's project) to\n edit and save this workflow.\n </div>\n )}\n <div className=\"wf-fullbleed-foot\">\n <div className=\"row\" style={{ flexWrap: \"wrap\", alignItems: \"center\" }}>\n {/* Auto-save does not remove this button (it is the escape hatch when\n `autoSave` is off, and the only legible signal of save state when it\n is on): it flushes the pending window now, and greys out once the\n canvas matches the server. */}\n <button\n type=\"button\"\n className=\"btn\"\n disabled={project === null || !canSave || !dirty}\n onClick={draft.saveNow}\n >\n {draft.saving ? \"Saving…\" : \"Save\"}\n </button>\n {saved && <span className=\"ok\">Saved.</span>}\n </div>\n {bannerError && <div className=\"error\">{bannerError}</div>}\n {keyGuardReason && (\n <div className=\"error\" data-testid=\"wf-key-guard\">\n {keyGuardReason}\n </div>\n )}\n </div>\n\n <JsonToggle\n open={showJson}\n onClose={() => setShowJson(false)}\n title={`JSON — ${(parsed?.displayName as string) || \"workflow\"}`}\n mode=\"synced\"\n value={json}\n onChange={(next) => {\n draft.setJson(next);\n // T1.1.1 A2.2 (D-2): the raw-JSON surface is an edit surface\n // too, so it clears the shown run the same way the canvas does.\n setActiveRunId(null);\n }}\n onValidityChange={({ valid: v, error: err }) => {\n setValid(v);\n setValidityError(err);\n }}\n invalidReason={!valid ? validityError : null}\n editorLabel=\"Workflow definition JSON\"\n />\n\n {draft.stale && !staleDismissed && (\n <Modal title=\"This workflow changed on the server\" onClose={() => setStaleDismissed(true)}>\n <div className=\"modal-body\">\n <p className=\"muted small\">\n Someone else — another tab, another session — saved this workflow after you opened it.\n Your save was refused rather than applied, so their work is still intact.\n </p>\n <p className=\"muted small\">\n <strong>Reload from server</strong> replaces what is on this canvas with the saved\n copy; anything you changed here and have not saved is lost.{\" \"}\n <strong>Keep editing</strong> leaves your version exactly as it is — but every save\n will be refused the same way until you reload, so copy out anything you need first.\n </p>\n </div>\n <div className=\"modal-actions\">\n <button type=\"button\" className=\"btn ghost\" onClick={() => setStaleDismissed(true)}>\n Keep editing\n </button>\n <button type=\"button\" className=\"btn\" disabled={reloading} onClick={reloadFromServer}>\n {reloading ? \"Reloading…\" : \"Reload from server\"}\n </button>\n </div>\n </Modal>\n )}\n\n {showSettings && (\n <WorkflowSettingsModal\n autoSave={settings.autoSave}\n savePosition={settings.savePosition}\n variables={variables}\n onClose={() => setShowSettings(false)}\n onChange={(key, value) =>\n saveMeta({ settings: writeSetting(parsed?.settings, key, value) })\n }\n onVariablesChange={(next) => patchMeta({ variables: variablesForSave(next) })}\n />\n )}\n </div>\n );\n}\n\nconst NOOP = (): void => {};\n\n/**\n * The managed workflow editor. The outermost element is `.w6w-embed-root` (pinned for the embed\n * stylesheet); everything the editor renders — header, canvas, modals, rail — stays a descendant of\n * it, and nothing goes through a portal. It fills its host container (`height: 100%`), so the host\n * decides how tall the editor is.\n *\n * `useEditorProject(props.project)` is the ONLY project source: it feeds the draft, the expression\n * scope, the rail environment and the canvas. `null` (no project) refuses — see `EditorBody`.\n */\nexport function WorkflowEditor(props: WorkflowEditorProps): ReactNode {\n const { workflowId, initialRunId, onNavigate = NOOP, slots } = props;\n const project = useEditorProject(props.project);\n const railNavigate = useCallback(\n (to: RailNavigation) => {\n if (to.type === \"list\") onNavigate({ type: \"list\" });\n else if (to.kind === \"workflow\") onNavigate({ type: \"workflow\", id: to.id });\n },\n [onNavigate],\n );\n return (\n <div\n className=\"w6w-embed-root\"\n style={{ display: \"flex\", width: \"100%\", height: \"100%\", minHeight: 0 }}\n >\n <WorkspaceProvider>\n <RailEnvProvider project={project} onNavigate={railNavigate}>\n <ProjectExpressionScope project={project}>\n <EditorBody\n workflowId={workflowId}\n project={project}\n initialRunId={initialRunId}\n onNavigate={onNavigate}\n slots={slots}\n />\n <RightRail\n tools={editorRailTools}\n storageKey={project === null ? null : `w6w.rail.embed.${project}`}\n />\n </ProjectExpressionScope>\n </RailEnvProvider>\n </WorkspaceProvider>\n </div>\n );\n}\n"],"names":["EditableTitle","title","value","placeholder","maxLength","ariaLabel","onChange","onBlur","jsx","e","ExecutionProfileHeader","onBack","backLabel","titleAdornment","actions","jsxs","SEARCH_DEBOUNCE_MS","HistoryView","props","scope","showKind","filters","onFiltersChange","onOpenInEditor","filtersRef","useRef","q","setQ","useState","searchTimer","selected","setSelected","useEffect","listQuery","useHistoryQuery","statsQuery","useHistoryStatsQuery","detailQuery","useExecutionDetailQuery","executions","_a","offset","hasMore","_b","applyFilters","next","onPrev","HISTORY_PAGE_SIZE","onNext","onSelect","useCallback","executionId","row","filterValue","openInEditor","Fragment","ExecutionStats","ExecutionFilters","ExecutionList","ExecutionDetail","historyOpenRun","kind","onOpenRun","onClose","execution","HistoryModal","id","setFilters","EMPTY_HISTORY_FILTERS","Modal","IconButton","HistoryButtonChrome","hasExecuted","onClick","buttonRef","HistoryButtonProbe","useHasExecutedQuery","open","setOpen","wasOpen","HistoryProbeBoundary","Component","__publicField","error","HistoryButton","children","wide","xl","headerRight","ref","el","onCancel","r","JsonToggleButton","JsonToggle","mode","onValidityChange","invalidReason","guard","onSave","saving","editorLabel","guardReason","JsonEditor","valid","err","WorkspaceContext","createContext","WorkspaceProvider","resource","setCallable","useWorkspace","ctx","useContext","key","useWorkspaceCallable","CLOSED","readStoredState","raw","activeTool","restoreRailState","RailShell","tools","state","onToggle","t","tool","PersistedRail","storageKey","setState","prev","RightRail","available","useProjectExpressionOptions","project","projectId","varsQuery","useVarsQuery","secretsQuery","useSecretsQuery","documentsQuery","useDocumentsQuery","sealSecretFn","useSealSecret","createVarMut","useCreateVarMutation","createSecretMut","useCreateSecretMutation","useMemo","v","s","projectDocumentSources","documentSampleValues","input","ProjectExpressionScope","options","ExpressionOptionsProvider","TABS","snippetTabsFor","snippet","buildSnippet","CallFromCodeBody","triggers","wrap","maxHeight","initialTab","tab","setTab","triggerIndex","setTriggerIndex","hasTriggers","selectedTrigger","tabs","activeTab","code","unavailableReason","i","CodeBlock","_c","CodePanel","openTab","setOpenTab","snippetCallable","toSnippetCallable","label","icon","Icon","CodeToolIcon","codeTool","isAvailable","DEFAULT_ENV","RailEnvContext","RailEnvProvider","onNavigate","useRailEnv","CALL_APP","refOf","target","nounOf","useFunctionsLabels","enabled","client","useEmbedClient","useQuery","ErrorHandlerSection","policy","ready","onPersist","functionsQuery","workflowsQuery","useWorkflowsQuery","pickerOpen","setPickerOpen","setError","selfDecision","errorHandlerSelfDecision","_d","w","fn","f","persist","pickHandler","built","nextTarget","nextId","RetryPolicyFields","StepBuilderModal","WorkflowErrorHandlingPanel","wfPolicy","onPolicyChange","policyFromDefinition","ErrorHandlingToolIcon","errorHandlingTool","isSettingsRailAvailable","commitTag","tags","typed","removeTag","tag","TagEditor","setTyped","handleTypedChange","result","CallableSettingsModal","settings","descriptorFor","initial","displayName","setDisplayName","setKey","setTags","isSaving","setIsSaving","displayNameChanged","keyChanged","tagsChanged","isDirty","canEditKey","keyGrammarOk","isEndpointKey","canSubmit","handleSave","ApiError","enterSubmit","useEnterSubmit","filterKeyInput","COLLECTION","TESTIDS","ImportSpecModal","collection","testids","text","setText","unresolved","setUnresolved","importMut","useImportSpecMutation","parsed","blockedReason","parseImportPaste","disabled","goto","submit","ConfirmModal","message","onConfirm","confirmLabel","cancelLabel","destructive","VersionHistoryModal","versionNumber","versionQuery","useVersionQuery","revertMut","useRevertMutation","invokeMut","useInvokeVersionMutation","confirmingRevert","setConfirmingRevert","DangerZone","archived","deleteLabel","deleteTestId","archiveTestId","onRequestDelete","onRequestArchive","deleteError","archiveError","DeleteButton","SettingsHeading","EditButton","MetadataSection","fields","SpecActionsTrigger","SpecChooserModal","onImport","VersionSection","versions","VersionListModal","loading","DANGER_COPY","SettingsDangerZone","copy","IMPORT_LIST_KEYS","workflowsKey","WorkflowSettingsPanel","editingSettings","setEditingSettings","historyOpen","setHistoryOpen","versionListOpen","setVersionListOpen","isWorkflow","wfDefQuery","useWorkflowQuery","saveWfMut","useSaveWorkflowMutation","archiveWfMut","useArchiveWorkflowMutation","deleteWfMut","useDeleteWorkflowMutation","specMenuOpen","setSpecMenuOpen","importing","setImporting","deleteConfirming","setDeleteConfirming","archiveConfirming","setArchiveConfirming","setDeleteError","setArchiveError","versionsQuery","useVersionsQuery","publishMut","usePublishMutation","setEnabledMut","useSetEnabledMutation","publishError","setPublishError","enableError","setEnableError","openVersion","setOpenVersion","listRow","onDelete","onArchive","metadataFieldsForKind","data","stored","resolve","reject","updated","newId","SettingsToolPanel","SettingsToolIcon","settingsTool","editorRailTools","VARIABLE_TYPES","WorkflowSettingsModal","autoSave","savePosition","variables","onVariablesChange","inheritedVars","useExpressionOptions","addVariable","updateVariable","idx","removeVariable","_","dupIndexes","duplicateKeyIndexes","varsRailFor","ExpressionInput","ID_RE","TITLE_PLACEHOLDER","appActionsKey","NO_APPS","useEditorApps","ids","api","useW6WApi","list","signal","a","WorkflowFlowEditor","lazy","m","EditorBody","workflowId","initialRunId","slots","apiClient","setValid","validityError","setValidityError","showJson","setShowJson","showSettings","setShowSettings","reloading","setReloading","loadedKey","setLoadedKey","autoSaveRef","publishReasonRef","saveGuard","def","d","workflowKeyEditAllowed","draft","useWorkflowDraft","json","canSave","dirty","staleDismissed","setStaleDismissed","saved","setSaved","wasSaving","activeRunId","setActiveRunId","startRunMut","useStartRunMutation","cancelRunMut","useCancelRunMutation","runQuery","useLiveRunQuery","runStatus","runPollFailed","runInFlight","isRunInFlight","runLogSteps","mapRunStateToLogSteps","runLogErrors","runLevelErrors","runStartingRef","runStarting","setRunStarting","runAfterFlush","action","onRunClick","resolveHeaderRunInput","triggerPreviewList","stepId","listStepTests","res","onStopClick","classifyCancelError","reloadFromServer","draftFailure","bannerError","flowUsable","readSettings","readVariables","keyEdit","keyGuardReason","steps","flowHelpers","setFlowHelpers","canceled","app","triggerPreviews","hasTrigger","triggerKeys","n","thirdPartyAppIds","fetchedAppsById","appsList","appActionsQueries","useQueries","appId","actionParamsByKey","out","fetched","appsById","testGatedSteps","isTestRequired","stepTestsQueries","stepTestsKey","testStatus","validityCtx","requiredParamsFilled","workflowIsValid","workflowValid","publishInvalidReason","patchMeta","patch","saveMeta","parsedRef","commitRef","saveNowRef","onKey","current","definitionWithPolicy","runButtonLabel","_e","runId","Suspense","ExecutionLogPanel","writeSetting","variablesForSave","NOOP","WorkflowEditor","useEditorProject","railNavigate","to"],"mappings":";;;;;;;;;;;;;;AAkEA,SAASA,GAAc,EAAE,OAAAC,KAA0C;AACjE,QAAM,EAAE,OAAAC,GAAO,aAAAC,GAAa,WAAAC,GAAW,WAAAC,GAAW,UAAAC,GAAU,QAAAC,MAAWN;AACvE,SACE,gBAAAO;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAAN;AAAA,MACA,aAAAC;AAAA,MACA,WAAAC;AAAA,MACA,MAAM,KAAK,IAAI,KAAK,IAAIF,EAAM,QAAQC,EAAY,MAAM,GAAG,EAAE;AAAA,MAC7D,cAAYE;AAAA,MACZ,UAAU,CAACI,MAAMH,EAASG,EAAE,OAAO,KAAK;AAAA,MACxC,QAAAF;AAAA,IAAA;AAAA,EAAA;AAGN;AAiBO,SAASG,GAAuB;AAAA,EACrC,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAX;AAAA,EACA,gBAAAY;AAAA,EACA,SAAAC;AACF,GAAgC;AAC9B,SACE,gBAAAC,EAAC,OAAA,EAAI,WAAU,qBACb,UAAA;AAAA,IAAA,gBAAAP;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,WAAU;AAAA,QACV,eAAY;AAAA,QACZ,SAASG;AAAA,QAER,UAAAC;AAAA,MAAA;AAAA,IAAA;AAAA,IAEFX,EAAM,WACL,gBAAAO,EAACR,IAAA,EAAc,OAAAC,GAAc,IAE7B,gBAAAc,EAAC,MAAA,EAAG,WAAU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