@mcp-b/react-components 0.57.0 → 0.58.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/dist/Card-BPkXIkBz.d.ts +46 -0
- package/dist/{CodeBlock-Dw1z6jc8.js → CodeBlock-Bs_Z03eC.js} +2 -1
- package/dist/{CodeBlock-CPotpyyM.d.ts → CodeBlock-DYp5V_4O.d.ts} +1 -1
- package/dist/{EmployeeChrome-CN99SVfF.d.ts → EmployeeChrome-DsdIek0l.d.ts} +2 -10
- package/dist/ExecutionBoard-DHfMvKlB.d.ts +64 -0
- package/dist/ExecutionResult-BSZsUbrL.js +279 -0
- package/dist/{FileTree-D61EeWRU.js → FileTree-DyLBn7O_.js} +1 -1
- package/dist/{ManagerOffice-D4L_xO4i.js → ManagerOffice-DHcLRhFu.js} +2 -17
- package/dist/{McpConnectorForm-BPWCo9bU.d.ts → McpConnectorForm-D4bY-lm_.d.ts} +1 -1
- package/dist/{McpPluginCatalog-uSh0gGeY.d.ts → McpPluginCatalog-2FZDLCeK.d.ts} +2 -2
- package/dist/{SetupChecklist-DWyifWWg.js → SetupChecklist-CKQ-mKYt.js} +1 -1
- package/dist/{ThinkRoutine-DGlKJbIy.d.ts → ThinkRoutine-DoZjbzyn.d.ts} +15 -3
- package/dist/{Workspace-Cr-aGDfx.d.ts → Workspace-iCkXvQRJ.d.ts} +1 -1
- package/dist/WorkspaceConcept-ByaG-kBq.d.ts +38 -0
- package/dist/WorkspaceExecutionTable-DNhj6YDX.d.ts +239 -0
- package/dist/{WorkspaceFile-DiwiJEwO.d.ts → WorkspaceFile-DkIZKoK6.d.ts} +1 -1
- package/dist/{WorkspaceFileView-DCvGBsI1.js → WorkspaceFileView-M2jC2P4p.js} +217 -139
- package/dist/components/agents-sdk/AgentActivity.js +1 -1
- package/dist/components/agents-sdk/AgentChat.js +4 -4
- package/dist/components/agents-sdk/BrowserLiveScreen.js +1 -1
- package/dist/components/agents-sdk/BrowserLiveView.js +1 -1
- package/dist/components/agents-sdk/BrowserReplay.js +1 -1
- package/dist/components/agents-sdk/BrowserRunPanel.js +1 -1
- package/dist/components/agents-sdk/EmployeeApp.d.ts +1 -1
- package/dist/components/agents-sdk/EmployeeApp.js +3 -7
- package/dist/components/agents-sdk/EmployeeChat.d.ts +3 -1
- package/dist/components/agents-sdk/EmployeeChat.js +11 -4
- package/dist/components/agents-sdk/EmployeeChrome.d.ts +1 -1
- package/dist/components/agents-sdk/EmployeeChrome.js +72 -57
- package/dist/components/agents-sdk/EmployeeSchedules.d.ts +6 -3
- package/dist/components/agents-sdk/EmployeeSchedules.js +12 -10
- package/dist/components/agents-sdk/EmployeeStartScreen.d.ts +2 -2
- package/dist/components/agents-sdk/EmployeeStartScreen.js +2 -2
- package/dist/components/agents-sdk/ExecutionBoard.d.ts +2 -0
- package/dist/components/agents-sdk/ExecutionBoard.js +648 -0
- package/dist/components/agents-sdk/ManagerAccountActions.js +1 -1
- package/dist/components/agents-sdk/ManagerOffice.d.ts +1 -1
- package/dist/components/agents-sdk/ManagerOffice.js +1 -1
- package/dist/components/agents-sdk/ManagerOfficeScreens.d.ts +1 -1
- package/dist/components/agents-sdk/ManagerOfficeScreens.js +4 -3
- package/dist/components/agents-sdk/McpConnectionRequest.d.ts +1 -1
- package/dist/components/agents-sdk/McpConnectionRequest.js +1 -1
- package/dist/components/agents-sdk/McpConnectorForm.d.ts +1 -1
- package/dist/components/agents-sdk/McpPluginCatalog.d.ts +1 -1
- package/dist/components/agents-sdk/McpPluginCatalog.js +16 -7
- package/dist/components/agents-sdk/McpServerIcon.d.ts +1 -1
- package/dist/components/agents-sdk/McpServerPicker.d.ts +2 -2
- package/dist/components/agents-sdk/McpServerPicker.js +1 -1
- package/dist/components/agents-sdk/ModelSelector.js +1 -1
- package/dist/components/agents-sdk/PromptInputCommands.js +1 -1
- package/dist/components/agents-sdk/SubagentRunIndicator.js +1 -1
- package/dist/components/agents-sdk/SubagentRunPanel.js +1 -1
- package/dist/components/agents-sdk/ThinkChatToolPanels.js +238 -209
- package/dist/components/agents-sdk/ThinkExecutionDetail.js +13 -34
- package/dist/components/agents-sdk/ThinkExecutionStatus.js +1 -1
- package/dist/components/agents-sdk/ThinkExecutionWorkbench.js +1 -1
- package/dist/components/agents-sdk/ThinkRoutine.d.ts +2 -2
- package/dist/components/agents-sdk/ThinkRoutineActions.d.ts +2 -2
- package/dist/components/agents-sdk/ThinkRoutineActions.js +25 -15
- package/dist/components/agents-sdk/ThinkRoutineBrowser.d.ts +1 -1
- package/dist/components/agents-sdk/ThinkRoutineBrowser.js +1 -1
- package/dist/components/agents-sdk/ThinkRoutineDetail.d.ts +5 -2
- package/dist/components/agents-sdk/ThinkRoutineDetail.js +13 -7
- package/dist/components/agents-sdk/ThinkRoutineForm.d.ts +23 -6
- package/dist/components/agents-sdk/ThinkRoutineForm.js +519 -212
- package/dist/components/agents-sdk/ThinkThreadPicker.js +1 -1
- package/dist/components/agents-sdk/TypeSafeConnectionDialog.d.ts +10 -0
- package/dist/components/agents-sdk/TypeSafeConnectionDialog.js +34 -0
- package/dist/components/agents-sdk/WorkbenchBack.js +1 -1
- package/dist/components/agents-sdk/Workspace.d.ts +1 -1
- package/dist/components/agents-sdk/WorkspaceBrowser.d.ts +1 -1
- package/dist/components/agents-sdk/WorkspaceBrowser.js +1 -1
- package/dist/components/agents-sdk/WorkspaceConcept.d.ts +2 -37
- package/dist/components/agents-sdk/WorkspaceCorrespondence.d.ts +2 -2
- package/dist/components/agents-sdk/WorkspaceCorrespondence.js +3 -2
- package/dist/components/agents-sdk/WorkspaceExecution.d.ts +2 -92
- package/dist/components/agents-sdk/WorkspaceExecution.js +648 -131
- package/dist/components/agents-sdk/WorkspaceExecutionTable.d.ts +2 -0
- package/dist/components/agents-sdk/WorkspaceExecutionTable.js +824 -0
- package/dist/components/agents-sdk/WorkspaceExplorer.d.ts +3 -1
- package/dist/components/agents-sdk/WorkspaceExplorer.js +4 -3
- package/dist/components/agents-sdk/WorkspaceFile.d.ts +1 -1
- package/dist/components/agents-sdk/WorkspaceFileView.d.ts +4 -2
- package/dist/components/agents-sdk/WorkspaceFileView.js +1 -1
- package/dist/components/agents-sdk/WorkspaceHeader.js +1 -1
- package/dist/components/agents-sdk/WorkspaceLive.d.ts +2 -2
- package/dist/components/agents-sdk/WorkspaceProject.d.ts +2 -2
- package/dist/components/agents-sdk/WorkspaceProject.js +4 -3
- package/dist/components/agents-sdk/WorkspaceUserScript.d.ts +1 -1
- package/dist/components/agents-sdk/WorkspaceUserScript.js +3 -2
- package/dist/components/ai-sdk/Activity.js +1 -1
- package/dist/components/ai-sdk/AgentChatStartScreen.js +1 -1
- package/dist/components/ai-sdk/Approval.js +1 -1
- package/dist/components/ai-sdk/Artifact.js +1 -1
- package/dist/components/ai-sdk/ChainOfThought.d.ts +1 -1
- package/dist/components/ai-sdk/ChainOfThought.js +1 -1
- package/dist/components/ai-sdk/Checkpoint.js +1 -1
- package/dist/components/ai-sdk/CodeBlock.d.ts +1 -1
- package/dist/components/ai-sdk/CodeBlock.js +1 -1
- package/dist/components/ai-sdk/ComposerLink.js +1 -1
- package/dist/components/ai-sdk/ConnectedAppCards.d.ts +1 -1
- package/dist/components/ai-sdk/ConnectedAppCards.js +1 -1
- package/dist/components/ai-sdk/Context.js +2 -2
- package/dist/components/ai-sdk/Conversation.js +1 -1
- package/dist/components/ai-sdk/Goal.js +1 -1
- package/dist/components/ai-sdk/MediaPreviewCard.d.ts +1 -1
- package/dist/components/ai-sdk/MediaPreviewCard.js +1 -1
- package/dist/components/ai-sdk/Message.js +2 -2
- package/dist/components/ai-sdk/MessageScroller.js +1 -1
- package/dist/components/ai-sdk/MessageScrollerVirtual.js +1 -1
- package/dist/components/ai-sdk/Plan.js +1 -1
- package/dist/components/ai-sdk/PromptInput.js +1 -1
- package/dist/components/ai-sdk/Queue.js +1 -1
- package/dist/components/ai-sdk/Reasoning.js +1 -1
- package/dist/components/ai-sdk/Sources.js +1 -1
- package/dist/components/ai-sdk/Task.js +1 -1
- package/dist/components/extension/ChatGptSignInScreen.js +2 -2
- package/dist/components/extension/CodexModelSelector.js +1 -1
- package/dist/components/extension/ConversationTabPicker.js +1 -1
- package/dist/components/foundations/Card.d.ts +2 -45
- package/dist/components/foundations/Checkbox.js +1 -1
- package/dist/components/foundations/ContextMenu.js +1 -1
- package/dist/components/foundations/Menubar.js +1 -1
- package/dist/components/foundations/SearchField.js +1 -1
- package/dist/components/foundations/Select.js +1 -1
- package/dist/components/foundations/Stepper.js +1 -1
- package/dist/components/foundations/Toast.js +1 -1
- package/dist/components/foundations/icons.d.ts +2 -2
- package/dist/components/foundations/icons.js +2 -2
- package/dist/components/general-purpose/Commit.js +2 -2
- package/dist/components/general-purpose/EnvironmentVariables.js +2 -2
- package/dist/components/general-purpose/FileTree.js +1 -1
- package/dist/components/general-purpose/PricingPlanCard.js +1 -1
- package/dist/components/general-purpose/ResponsiveSidebarShell.js +1 -1
- package/dist/components/general-purpose/SetupChecklist.js +1 -1
- package/dist/components/general-purpose/Terminal.js +2 -2
- package/dist/components/general-purpose/TestResults.js +1 -1
- package/dist/components/general-purpose/ThemeModeControl.js +1 -1
- package/dist/components/general-purpose/WebPreview.js +1 -1
- package/dist/components/nanites/AgentConnection.js +2 -2
- package/dist/components/nanites/AgentToolDetail.js +1 -1
- package/dist/{copy-button-Dk2vRe9j.js → copy-button-M4sAp9xS.js} +1 -1
- package/dist/execution-result-DWVmm-bL.js +80 -0
- package/dist/{icons-CUuD7iEh.d.ts → icons-Dj6id76o.d.ts} +2 -1
- package/dist/{icons-CeGfXO21.js → icons-DvlrWt54.js} +3 -2
- package/dist/{mcp-server-catalog-DgA9BnL0.d.ts → mcp-server-catalog-kaMWaSAL.d.ts} +3 -1
- package/dist/styles/app-top-bar.css +2 -1
- package/dist/styles/base.css +1 -0
- package/dist/styles/chatgpt-sign-in-screen.css +8 -14
- package/dist/styles/context.css +8 -0
- package/dist/styles/description-list.css +12 -9
- package/dist/styles/execution-board.css +383 -0
- package/dist/styles/index.css +3 -0
- package/dist/styles/mcp-plugin-catalog.css +8 -7
- package/dist/styles/think-chat-tool-panels.css +1 -2
- package/dist/styles/think-execution-workbench.css +1 -12
- package/dist/styles/think-routine.css +39 -41
- package/dist/styles/workspace-concepts.css +441 -17
- package/dist/styles/workspace-explorer.css +18 -4
- package/dist/utils/mcp-server-catalog.d.ts +2 -2
- package/dist/utils/mcp-server-catalog.js +18 -1
- package/dist/utils/structured-code.d.ts +1 -1
- package/dist/{workspace-assets-wW_lQLYK.js → workspace-assets-DVn0d-fN.js} +24 -81
- package/dist/workspace-delete-DfloiBWp.js +80 -0
- package/package.json +3 -2
|
@@ -0,0 +1,824 @@
|
|
|
1
|
+
import { Collapsible } from "../foundations/Collapsible.js";
|
|
2
|
+
import { C as FolderIcon, D as LinkIcon, K as SpinnerIcon, R as PencilIcon, S as FileIcon, Y as StopIcon, d as CheckIcon, h as CopyIcon, nt as WrenchIcon, r as ArrowLeftIcon, tt as WarningIcon, u as CalendarIcon, z as PlayIcon } from "../../icons-DvlrWt54.js";
|
|
3
|
+
import { Button } from "../foundations/Button.js";
|
|
4
|
+
import { Field } from "../foundations/Field.js";
|
|
5
|
+
import { Textarea } from "../foundations/Textarea.js";
|
|
6
|
+
import { IconButton } from "../foundations/IconButton.js";
|
|
7
|
+
import { a as formatErrorMessage } from "../../format-CWaZEp5o.js";
|
|
8
|
+
import { Select } from "../foundations/Select.js";
|
|
9
|
+
import { Checkbox } from "../foundations/Checkbox.js";
|
|
10
|
+
import { Progress } from "../foundations/Progress.js";
|
|
11
|
+
import { a as readExecutionResult, i as executionResultSummary, t as executionErrorSummary } from "../../execution-result-DWVmm-bL.js";
|
|
12
|
+
import { a as httpUrl, r as WebsiteLink, t as FaviconMark } from "../../workspace-assets-DVn0d-fN.js";
|
|
13
|
+
import { n as executionResultLabel, t as ExecutionResult } from "../../ExecutionResult-BSZsUbrL.js";
|
|
14
|
+
import { ExecutionBoard } from "./ExecutionBoard.js";
|
|
15
|
+
import * as React from "react";
|
|
16
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
+
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
18
|
+
//#region src/components/agents-sdk/WorkspaceExecutionTable.tsx
|
|
19
|
+
function isBlankCell(value) {
|
|
20
|
+
return value == null || typeof value === "string" && value.trim() === "";
|
|
21
|
+
}
|
|
22
|
+
function displayCell(value) {
|
|
23
|
+
if (isBlankCell(value)) return "—";
|
|
24
|
+
if (typeof value === "boolean") return value ? "Yes" : "No";
|
|
25
|
+
return typeof value === "string" || typeof value === "number" ? String(value) : "Saved value";
|
|
26
|
+
}
|
|
27
|
+
function defaultColumns(data, parameters) {
|
|
28
|
+
return Object.fromEntries(parameters.flatMap((parameter) => {
|
|
29
|
+
const matches = data.columns.filter((column) => column === parameter.name || column === parameter.label);
|
|
30
|
+
return matches.length === 1 ? [[parameter.name, matches[0]]] : [];
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
function TableSelect({ label, value, options, disabled, onChange }) {
|
|
34
|
+
return /* @__PURE__ */ jsxs(Select.Root, {
|
|
35
|
+
value,
|
|
36
|
+
disabled,
|
|
37
|
+
items: options,
|
|
38
|
+
onValueChange: (next) => {
|
|
39
|
+
if (next != null) onChange(next);
|
|
40
|
+
},
|
|
41
|
+
children: [/* @__PURE__ */ jsxs(Select.Trigger, {
|
|
42
|
+
"aria-label": label,
|
|
43
|
+
children: [/* @__PURE__ */ jsx(Select.Value, {}), /* @__PURE__ */ jsx(Select.Icon, {})]
|
|
44
|
+
}), /* @__PURE__ */ jsx(Select.Portal, { children: /* @__PURE__ */ jsx(Select.Positioner, {
|
|
45
|
+
sideOffset: 4,
|
|
46
|
+
children: /* @__PURE__ */ jsx(Select.Popup, { children: /* @__PURE__ */ jsx(Select.List, { children: options.map((option) => /* @__PURE__ */ jsxs(Select.Item, {
|
|
47
|
+
value: option.value,
|
|
48
|
+
children: [/* @__PURE__ */ jsx(Select.ItemText, { children: option.label }), /* @__PURE__ */ jsx(Select.ItemIndicator, {})]
|
|
49
|
+
}, option.value)) }) })
|
|
50
|
+
}) })]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const rowStatus = {
|
|
54
|
+
waiting: "Waiting",
|
|
55
|
+
running: "Running",
|
|
56
|
+
completed: "Completed",
|
|
57
|
+
error: "Couldn’t finish",
|
|
58
|
+
aborted: "Stopped",
|
|
59
|
+
interrupted: "Interrupted"
|
|
60
|
+
};
|
|
61
|
+
function TablePreview({ data, visibleRows, rowsByIndex, results, resultColumns, showResult, trace, onSelectRow }) {
|
|
62
|
+
return /* @__PURE__ */ jsx("div", {
|
|
63
|
+
className: "workspace-execution-table__scroll",
|
|
64
|
+
role: "region",
|
|
65
|
+
"aria-label": "Table rows",
|
|
66
|
+
tabIndex: 0,
|
|
67
|
+
children: /* @__PURE__ */ jsxs("table", {
|
|
68
|
+
className: "workspace-execution-table__preview",
|
|
69
|
+
style: { minInlineSize: `${(data.columns.length + resultColumns.length + Number(showResult)) * 5.5 + 2}rem` },
|
|
70
|
+
"aria-label": "Table rows",
|
|
71
|
+
children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
72
|
+
/* @__PURE__ */ jsx("th", {
|
|
73
|
+
scope: "col",
|
|
74
|
+
className: "workspace-execution-table__row-number",
|
|
75
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
76
|
+
className: "sigvelo-visually-hidden",
|
|
77
|
+
children: "Row"
|
|
78
|
+
})
|
|
79
|
+
}),
|
|
80
|
+
data.columns.map((column) => /* @__PURE__ */ jsx("th", {
|
|
81
|
+
scope: "col",
|
|
82
|
+
children: column
|
|
83
|
+
}, column)),
|
|
84
|
+
resultColumns.map((column) => /* @__PURE__ */ jsx("th", {
|
|
85
|
+
scope: "col",
|
|
86
|
+
"data-result": "",
|
|
87
|
+
children: executionResultLabel(column)
|
|
88
|
+
}, column)),
|
|
89
|
+
showResult ? /* @__PURE__ */ jsx("th", {
|
|
90
|
+
scope: "col",
|
|
91
|
+
"data-result": "",
|
|
92
|
+
children: "Result"
|
|
93
|
+
}) : null
|
|
94
|
+
] }) }), /* @__PURE__ */ jsx("tbody", { children: visibleRows?.map(({ row: cells, index }) => {
|
|
95
|
+
const row = rowsByIndex.get(index);
|
|
96
|
+
const result = results.get(index);
|
|
97
|
+
const label = displayCell(cells.find((value) => !isBlankCell(value)));
|
|
98
|
+
const RowIcon = row?.status === "completed" ? CheckIcon : row?.status === "running" ? SpinnerIcon : row?.status === "error" || row?.status === "interrupted" ? WarningIcon : row?.status === "aborted" ? StopIcon : void 0;
|
|
99
|
+
const status = row ? rowStatus[row.status] : "Waiting";
|
|
100
|
+
const canInspect = row?.tracePath || row?.executionId !== void 0 && row.executionId === trace?.executionId;
|
|
101
|
+
return /* @__PURE__ */ jsxs("tr", {
|
|
102
|
+
"data-status": row?.status,
|
|
103
|
+
children: [
|
|
104
|
+
/* @__PURE__ */ jsx("th", {
|
|
105
|
+
scope: "row",
|
|
106
|
+
className: "workspace-execution-table__row-number",
|
|
107
|
+
children: canInspect ? /* @__PURE__ */ jsx(IconButton, {
|
|
108
|
+
variant: "ghost",
|
|
109
|
+
color: "neutral",
|
|
110
|
+
label: `Open row ${index + 1}: ${label}`,
|
|
111
|
+
title: status,
|
|
112
|
+
"aria-description": status,
|
|
113
|
+
onClick: () => onSelectRow(index),
|
|
114
|
+
children: RowIcon ? /* @__PURE__ */ jsx(RowIcon, {}) : /* @__PURE__ */ jsx("span", { children: index + 1 })
|
|
115
|
+
}) : RowIcon ? /* @__PURE__ */ jsx("span", {
|
|
116
|
+
role: "img",
|
|
117
|
+
"aria-label": `Row ${index + 1}: ${status}`,
|
|
118
|
+
title: status,
|
|
119
|
+
children: /* @__PURE__ */ jsx(RowIcon, {})
|
|
120
|
+
}) : index + 1
|
|
121
|
+
}),
|
|
122
|
+
data.columns.map((column, columnIndex) => {
|
|
123
|
+
const value = cells[columnIndex];
|
|
124
|
+
const link = typeof value === "string" ? httpUrl(value) : void 0;
|
|
125
|
+
return /* @__PURE__ */ jsx("td", { children: link ? /* @__PURE__ */ jsx(WebsiteLink, { href: link }) : displayCell(value) }, column);
|
|
126
|
+
}),
|
|
127
|
+
resultColumns.map((column) => /* @__PURE__ */ jsx("td", {
|
|
128
|
+
"data-result": "",
|
|
129
|
+
children: result != null && typeof result === "object" && Object.hasOwn(result, column) && (column !== "summary" || typeof readExecutionResult(result[column]) !== "string") ? /* @__PURE__ */ jsx(ExecutionResult, {
|
|
130
|
+
result: result[column],
|
|
131
|
+
showSummary: false
|
|
132
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
133
|
+
className: "workspace-execution-table__hint",
|
|
134
|
+
children: "—"
|
|
135
|
+
})
|
|
136
|
+
}, column)),
|
|
137
|
+
showResult ? /* @__PURE__ */ jsx("td", {
|
|
138
|
+
"data-result": "",
|
|
139
|
+
children: row?.error ? executionErrorSummary(row.error) : result !== void 0 && (result == null || typeof result !== "object" || Array.isArray(result)) ? /* @__PURE__ */ jsx(ExecutionResult, {
|
|
140
|
+
result,
|
|
141
|
+
showSummary: false
|
|
142
|
+
}) : result != null && typeof result === "object" && Object.entries(result).every(([key, value]) => key === "summary" && typeof readExecutionResult(value) === "string") ? executionResultSummary(result) : row?.summary && result === void 0 ? executionResultSummary(row.summary) : status
|
|
143
|
+
}) : null
|
|
144
|
+
]
|
|
145
|
+
}, index);
|
|
146
|
+
}) })]
|
|
147
|
+
})
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function TableSourceSetup({ busy, paste, setPaste, workspacePath, setWorkspacePath, sourceRequest, setSourceRequest, requestPending, onRequestTableSource, onRequestSource, onLoad, path, args }) {
|
|
151
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
152
|
+
className: "sigvelo-stack",
|
|
153
|
+
children: [
|
|
154
|
+
/* @__PURE__ */ jsxs(Field.Root, { children: [/* @__PURE__ */ jsxs(Field.Label, { children: [/* @__PURE__ */ jsx(FileIcon, {}), " Choose a table"] }), /* @__PURE__ */ jsx(Field.Control, {
|
|
155
|
+
"aria-label": "Upload table",
|
|
156
|
+
type: "file",
|
|
157
|
+
accept: ".csv,.tsv,.xlsx,.xls,.ods",
|
|
158
|
+
disabled: busy,
|
|
159
|
+
onChange: (event) => {
|
|
160
|
+
const file = event.currentTarget.files?.[0];
|
|
161
|
+
if (file) onLoad({ input: { file } });
|
|
162
|
+
}
|
|
163
|
+
})] }),
|
|
164
|
+
/* @__PURE__ */ jsxs(Collapsible.Root, { children: [/* @__PURE__ */ jsx(Collapsible.Trigger, { children: /* @__PURE__ */ jsxs("span", {
|
|
165
|
+
className: "sigvelo-cluster",
|
|
166
|
+
children: [/* @__PURE__ */ jsx(CopyIcon, {}), "Paste rows"]
|
|
167
|
+
}) }), /* @__PURE__ */ jsx(Collapsible.Panel, {
|
|
168
|
+
keepMounted: true,
|
|
169
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
170
|
+
className: "sigvelo-stack",
|
|
171
|
+
children: [/* @__PURE__ */ jsxs(Field.Root, { children: [/* @__PURE__ */ jsx(Field.Label, { children: "Rows copied from a spreadsheet" }), /* @__PURE__ */ jsx(Field.Control, {
|
|
172
|
+
render: /* @__PURE__ */ jsx(Textarea, { rows: 5 }),
|
|
173
|
+
value: paste,
|
|
174
|
+
onChange: (event) => setPaste(event.currentTarget.value)
|
|
175
|
+
})] }), /* @__PURE__ */ jsx(Button, {
|
|
176
|
+
type: "button",
|
|
177
|
+
size: "sm",
|
|
178
|
+
disabled: busy || !paste.trim(),
|
|
179
|
+
onClick: () => onLoad({ input: { text: paste } }),
|
|
180
|
+
children: "Use rows"
|
|
181
|
+
})]
|
|
182
|
+
})
|
|
183
|
+
})] }),
|
|
184
|
+
onRequestTableSource ? /* @__PURE__ */ jsxs(Collapsible.Root, { children: [/* @__PURE__ */ jsx(Collapsible.Trigger, { children: /* @__PURE__ */ jsxs("span", {
|
|
185
|
+
className: "sigvelo-cluster",
|
|
186
|
+
children: [/* @__PURE__ */ jsx(LinkIcon, {}), "Use a sheet or app"]
|
|
187
|
+
}) }), /* @__PURE__ */ jsx(Collapsible.Panel, {
|
|
188
|
+
keepMounted: true,
|
|
189
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
190
|
+
className: "sigvelo-stack",
|
|
191
|
+
children: [/* @__PURE__ */ jsxs(Field.Root, { children: [
|
|
192
|
+
/* @__PURE__ */ jsx(Field.Label, { children: "Sheet link or description" }),
|
|
193
|
+
/* @__PURE__ */ jsx(Field.Control, {
|
|
194
|
+
value: sourceRequest,
|
|
195
|
+
placeholder: "Paste a sheet link or describe the table in an open app",
|
|
196
|
+
onChange: (event) => setSourceRequest(event.currentTarget.value)
|
|
197
|
+
}),
|
|
198
|
+
/* @__PURE__ */ jsx(Field.Description, { children: "Rook will open a conversation to prepare a preview for you to review." })
|
|
199
|
+
] }), /* @__PURE__ */ jsxs(Button, {
|
|
200
|
+
type: "button",
|
|
201
|
+
size: "sm",
|
|
202
|
+
disabled: busy || !sourceRequest.trim(),
|
|
203
|
+
onClick: () => void onRequestSource({
|
|
204
|
+
request: sourceRequest.trim(),
|
|
205
|
+
invocation: {
|
|
206
|
+
path,
|
|
207
|
+
args
|
|
208
|
+
}
|
|
209
|
+
}),
|
|
210
|
+
children: [requestPending ? /* @__PURE__ */ jsx(SpinnerIcon, {}) : /* @__PURE__ */ jsx(LinkIcon, {}), requestPending ? "Opening…" : "Ask Rook"]
|
|
211
|
+
})]
|
|
212
|
+
})
|
|
213
|
+
})] }) : null,
|
|
214
|
+
/* @__PURE__ */ jsxs(Collapsible.Root, { children: [/* @__PURE__ */ jsx(Collapsible.Trigger, { children: /* @__PURE__ */ jsxs("span", {
|
|
215
|
+
className: "sigvelo-cluster",
|
|
216
|
+
children: [/* @__PURE__ */ jsx(FolderIcon, {}), "Use a saved file"]
|
|
217
|
+
}) }), /* @__PURE__ */ jsx(Collapsible.Panel, {
|
|
218
|
+
keepMounted: true,
|
|
219
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
220
|
+
className: "sigvelo-stack",
|
|
221
|
+
children: [/* @__PURE__ */ jsxs(Field.Root, { children: [/* @__PURE__ */ jsx(Field.Label, { children: "Workspace file path" }), /* @__PURE__ */ jsx(Field.Control, {
|
|
222
|
+
value: workspacePath,
|
|
223
|
+
placeholder: "/workspace/customers.csv",
|
|
224
|
+
onChange: (event) => setWorkspacePath(event.currentTarget.value)
|
|
225
|
+
})] }), /* @__PURE__ */ jsx(Button, {
|
|
226
|
+
type: "button",
|
|
227
|
+
size: "sm",
|
|
228
|
+
disabled: busy || !workspacePath.trim(),
|
|
229
|
+
onClick: () => onLoad({ input: { path: workspacePath.trim() } }),
|
|
230
|
+
children: "Use table"
|
|
231
|
+
})]
|
|
232
|
+
})
|
|
233
|
+
})] })
|
|
234
|
+
]
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
function tableView({ prepared, loaded, data, source, parameters, columns, args }) {
|
|
238
|
+
const rowCount = prepared && !loaded ? prepared.rows.length : data?.rows.filter((row) => row.some((cell) => !isBlankCell(cell))).length ?? 0;
|
|
239
|
+
const finished = prepared?.rows.filter((row) => row.status !== "waiting" && row.status !== "running").length ?? 0;
|
|
240
|
+
const href = data?.source?.href ? httpUrl(data.source.href) : void 0;
|
|
241
|
+
const sourceDescription = source ? "script" in source ? "Reads current rows for each scheduled run" : "data" in source ? "Repeats these rows on schedule" : "Uses this saved file for each scheduled run" : void 0;
|
|
242
|
+
const visibleRows = data?.rows.map((row, index) => ({
|
|
243
|
+
row,
|
|
244
|
+
index
|
|
245
|
+
})).filter(({ row }) => row.some((cell) => !isBlankCell(cell)));
|
|
246
|
+
const missingRequired = data ? parameters.map((parameter) => {
|
|
247
|
+
if (!parameter.required) return "";
|
|
248
|
+
const column = columns[parameter.name];
|
|
249
|
+
if (column) {
|
|
250
|
+
const index = data.rows.findIndex((row) => row.some((cell) => !isBlankCell(cell)) && isBlankCell(row[data.columns.indexOf(column)]));
|
|
251
|
+
return index < 0 ? "" : `Row ${index + 1} needs ${parameter.label}.`;
|
|
252
|
+
}
|
|
253
|
+
const value = args[parameter.name];
|
|
254
|
+
return isBlankCell(value) ? `Rook needs to know where to find ${parameter.label}.` : "";
|
|
255
|
+
}).find(Boolean) : void 0;
|
|
256
|
+
const requiredError = data ? !parameters.length ? "Rook needs to prepare this workflow for a table." : missingRequired || (!Object.keys(columns).length ? "Rook needs to connect this table to the workflow." : "") : "";
|
|
257
|
+
const rowsByIndex = new Map((!loaded ? prepared?.rows : void 0)?.map((row) => [row.index, row]));
|
|
258
|
+
const results = new Map([...rowsByIndex].map(([index, row]) => [index, readExecutionResult(row.result)]));
|
|
259
|
+
return {
|
|
260
|
+
rowCount,
|
|
261
|
+
finished,
|
|
262
|
+
href,
|
|
263
|
+
sourceDescription,
|
|
264
|
+
visibleRows,
|
|
265
|
+
requiredError,
|
|
266
|
+
rowsByIndex,
|
|
267
|
+
results,
|
|
268
|
+
resultColumns: [...new Set([...results.values()].flatMap((result) => result != null && typeof result === "object" && !Array.isArray(result) ? Object.entries(result).filter(([key, value]) => key !== "summary" || typeof readExecutionResult(value) !== "string").map(([key]) => key) : []))],
|
|
269
|
+
showResult: [...rowsByIndex.values()].some((row) => {
|
|
270
|
+
const result = results.get(row.index);
|
|
271
|
+
return row.error || result !== void 0 && (result == null || typeof result !== "object" || Array.isArray(result) || Object.entries(result).every(([key, value]) => key === "summary" && typeof readExecutionResult(value) === "string")) || row.summary && result === void 0;
|
|
272
|
+
})
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function TableReadOptions({ loaded, loadInput, loadOptions, setLoadOptions, busy, onLoad }) {
|
|
276
|
+
const headerId = React.useId();
|
|
277
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [loaded?.sheets && loaded.sheets.length > 1 && loadInput ? /* @__PURE__ */ jsx(TableSelect, {
|
|
278
|
+
label: "Worksheet",
|
|
279
|
+
value: "path" in loaded.source ? loaded.source.sheet ?? loaded.sheets[0] : loaded.sheets[0],
|
|
280
|
+
options: loaded.sheets.map((sheet) => ({
|
|
281
|
+
value: sheet,
|
|
282
|
+
label: sheet
|
|
283
|
+
})),
|
|
284
|
+
disabled: busy,
|
|
285
|
+
onChange: (sheet) => onLoad({
|
|
286
|
+
input: loadInput,
|
|
287
|
+
options: {
|
|
288
|
+
...loadOptions,
|
|
289
|
+
sheet
|
|
290
|
+
}
|
|
291
|
+
})
|
|
292
|
+
}) : null, loadInput ? /* @__PURE__ */ jsxs(Collapsible.Root, { children: [/* @__PURE__ */ jsx(Collapsible.Trigger, { children: /* @__PURE__ */ jsxs("span", {
|
|
293
|
+
className: "sigvelo-cluster",
|
|
294
|
+
children: [/* @__PURE__ */ jsx(WrenchIcon, {}), "Reading options"]
|
|
295
|
+
}) }), /* @__PURE__ */ jsx(Collapsible.Panel, {
|
|
296
|
+
keepMounted: true,
|
|
297
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
298
|
+
className: "sigvelo-stack",
|
|
299
|
+
children: [
|
|
300
|
+
/* @__PURE__ */ jsxs("div", {
|
|
301
|
+
className: "sigvelo-cluster",
|
|
302
|
+
children: [/* @__PURE__ */ jsx(Checkbox.Root, {
|
|
303
|
+
id: headerId,
|
|
304
|
+
checked: loadOptions.header !== false,
|
|
305
|
+
disabled: busy,
|
|
306
|
+
onCheckedChange: (header) => {
|
|
307
|
+
if (typeof header === "boolean") onLoad({
|
|
308
|
+
input: loadInput,
|
|
309
|
+
options: {
|
|
310
|
+
...loadOptions,
|
|
311
|
+
header
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
},
|
|
315
|
+
children: /* @__PURE__ */ jsx(Checkbox.Indicator, {})
|
|
316
|
+
}), /* @__PURE__ */ jsx("label", {
|
|
317
|
+
htmlFor: headerId,
|
|
318
|
+
children: "First row contains column names"
|
|
319
|
+
})]
|
|
320
|
+
}),
|
|
321
|
+
loadInput && ("file" in loadInput ? /\.(?:xlsx?|ods)$/iu.test(loadInput.file.name) : "path" in loadInput && /\.(?:xlsx?|ods)$/iu.test(loadInput.path)) && !loaded?.sheets?.length ? /* @__PURE__ */ jsxs(Field.Root, { children: [
|
|
322
|
+
/* @__PURE__ */ jsx(Field.Label, { children: "Worksheet" }),
|
|
323
|
+
/* @__PURE__ */ jsx(Field.Control, {
|
|
324
|
+
"aria-label": "Worksheet",
|
|
325
|
+
placeholder: "First worksheet",
|
|
326
|
+
value: loadOptions.sheet ?? "",
|
|
327
|
+
disabled: busy,
|
|
328
|
+
onChange: (event) => {
|
|
329
|
+
const sheet = event.currentTarget.value;
|
|
330
|
+
setLoadOptions((current) => ({
|
|
331
|
+
...current,
|
|
332
|
+
sheet: sheet || void 0
|
|
333
|
+
}));
|
|
334
|
+
}
|
|
335
|
+
}),
|
|
336
|
+
/* @__PURE__ */ jsx(Button, {
|
|
337
|
+
type: "button",
|
|
338
|
+
size: "sm",
|
|
339
|
+
disabled: busy,
|
|
340
|
+
onClick: () => onLoad({
|
|
341
|
+
input: loadInput,
|
|
342
|
+
options: loadOptions
|
|
343
|
+
}),
|
|
344
|
+
children: "Read table"
|
|
345
|
+
})
|
|
346
|
+
] }) : null,
|
|
347
|
+
/* @__PURE__ */ jsx(TableSelect, {
|
|
348
|
+
label: "Column separator",
|
|
349
|
+
value: loadOptions.delimiter ?? "default",
|
|
350
|
+
disabled: busy,
|
|
351
|
+
options: [
|
|
352
|
+
{
|
|
353
|
+
value: "default",
|
|
354
|
+
label: "Default separator"
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
value: ",",
|
|
358
|
+
label: "Comma"
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
value: " ",
|
|
362
|
+
label: "Tab"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
value: ";",
|
|
366
|
+
label: "Semicolon"
|
|
367
|
+
}
|
|
368
|
+
],
|
|
369
|
+
onChange: (delimiter) => {
|
|
370
|
+
if (delimiter === "," || delimiter === " " || delimiter === ";") onLoad({
|
|
371
|
+
input: loadInput,
|
|
372
|
+
options: {
|
|
373
|
+
...loadOptions,
|
|
374
|
+
delimiter
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
else {
|
|
378
|
+
const options = { ...loadOptions };
|
|
379
|
+
delete options.delimiter;
|
|
380
|
+
onLoad({
|
|
381
|
+
input: loadInput,
|
|
382
|
+
options
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
})
|
|
387
|
+
]
|
|
388
|
+
})
|
|
389
|
+
})] }) : null] });
|
|
390
|
+
}
|
|
391
|
+
function TableSelectedRow({ selectedRow, rowCount, selectedTrace, graph, fetching, onClose }) {
|
|
392
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
393
|
+
className: "workspace-execution-table__source",
|
|
394
|
+
children: [/* @__PURE__ */ jsxs(Button, {
|
|
395
|
+
type: "button",
|
|
396
|
+
variant: "ghost",
|
|
397
|
+
color: "neutral",
|
|
398
|
+
onClick: () => onClose(),
|
|
399
|
+
children: [
|
|
400
|
+
/* @__PURE__ */ jsx(ArrowLeftIcon, {}),
|
|
401
|
+
"All ",
|
|
402
|
+
rowCount,
|
|
403
|
+
" rows"
|
|
404
|
+
]
|
|
405
|
+
}), /* @__PURE__ */ jsxs("span", { children: ["Row ", selectedRow.index + 1] })]
|
|
406
|
+
}), selectedTrace ? /* @__PURE__ */ jsx(ExecutionBoard, {
|
|
407
|
+
className: "workspace-execution-workbench__board",
|
|
408
|
+
graph: selectedTrace.graph,
|
|
409
|
+
trace: selectedTrace
|
|
410
|
+
}) : graph && selectedRow.status === "waiting" ? /* @__PURE__ */ jsx(ExecutionBoard, {
|
|
411
|
+
className: "workspace-execution-workbench__board",
|
|
412
|
+
graph
|
|
413
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
414
|
+
role: "status",
|
|
415
|
+
children: fetching ? "Loading row steps…" : "This row’s steps are not available yet."
|
|
416
|
+
})] });
|
|
417
|
+
}
|
|
418
|
+
/** Run one existing workflow for each row, then inspect each row on the same execution board. */
|
|
419
|
+
function useTableReceipt(execution, parameters) {
|
|
420
|
+
const [loaded, setLoaded] = React.useState();
|
|
421
|
+
const [columns, setColumns] = React.useState(() => execution?.invocation.table?.columns ?? {});
|
|
422
|
+
const [args, setArgs] = React.useState(() => execution?.invocation.args ?? Object.fromEntries(parameters.flatMap((parameter) => parameter.value === void 0 ? [] : [[parameter.name, parameter.value]])));
|
|
423
|
+
const [prepared, setPrepared] = React.useState(execution);
|
|
424
|
+
const [seenExecution, setSeenExecution] = React.useState(execution);
|
|
425
|
+
const [selectedIndex, setSelectedIndex] = React.useState();
|
|
426
|
+
if (execution !== seenExecution) {
|
|
427
|
+
setSeenExecution(execution);
|
|
428
|
+
if (execution) {
|
|
429
|
+
setPrepared(execution);
|
|
430
|
+
if (execution.path !== seenExecution?.path) {
|
|
431
|
+
setLoaded(void 0);
|
|
432
|
+
setColumns(execution.invocation.table?.columns ?? {});
|
|
433
|
+
setArgs(execution.invocation.args ?? {});
|
|
434
|
+
setSelectedIndex(void 0);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return {
|
|
439
|
+
loaded,
|
|
440
|
+
setLoaded,
|
|
441
|
+
columns,
|
|
442
|
+
setColumns,
|
|
443
|
+
args,
|
|
444
|
+
setArgs,
|
|
445
|
+
prepared,
|
|
446
|
+
setPrepared,
|
|
447
|
+
selectedIndex,
|
|
448
|
+
setSelectedIndex
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
function useTableExecution({ path, parameters, execution, trace, onLoadTable, onRequestTableSource, onPrepareTable, onRunTable, onStopTable, onLoadTableTrace, onScheduleTable }) {
|
|
452
|
+
const { loaded, setLoaded, columns, setColumns, args, setArgs, prepared, setPrepared, selectedIndex, setSelectedIndex } = useTableReceipt(execution, parameters);
|
|
453
|
+
const [loadInput, setLoadInput] = React.useState();
|
|
454
|
+
const [loadOptions, setLoadOptions] = React.useState({});
|
|
455
|
+
const [paste, setPaste] = React.useState("");
|
|
456
|
+
const [workspacePath, setWorkspacePath] = React.useState("");
|
|
457
|
+
const [sourceRequest, setSourceRequest] = React.useState("");
|
|
458
|
+
const [requestPending, setRequestPending] = React.useState(false);
|
|
459
|
+
const [requestError, setRequestError] = React.useState();
|
|
460
|
+
const [sourceChanged, setSourceChanged] = React.useState(false);
|
|
461
|
+
const data = loaded?.data ?? prepared?.data;
|
|
462
|
+
const source = loaded?.source ?? prepared?.invocation.table?.source;
|
|
463
|
+
const active = prepared?.status === "running";
|
|
464
|
+
const hasRun = prepared !== void 0 && prepared.status !== "ready" && !loaded;
|
|
465
|
+
const selectedRow = selectedIndex === void 0 ? void 0 : prepared?.rows.find((row) => row.index === selectedIndex);
|
|
466
|
+
const selectedLive = selectedRow?.executionId === trace?.executionId ? trace : void 0;
|
|
467
|
+
const savedTrace = useQuery({
|
|
468
|
+
queryKey: [
|
|
469
|
+
"workspace-table-row",
|
|
470
|
+
prepared?.path,
|
|
471
|
+
selectedRow?.tracePath
|
|
472
|
+
],
|
|
473
|
+
enabled: Boolean(selectedRow?.tracePath && onLoadTableTrace && !selectedLive),
|
|
474
|
+
queryFn: async () => {
|
|
475
|
+
if (!selectedRow?.tracePath || !onLoadTableTrace) throw new Error("This row’s steps are not available yet.");
|
|
476
|
+
return onLoadTableTrace(selectedRow.tracePath);
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
const selectedTrace = selectedLive ?? savedTrace.data;
|
|
480
|
+
const load = useMutation({
|
|
481
|
+
onMutate: ({ input, options }) => {
|
|
482
|
+
setLoadInput(input);
|
|
483
|
+
setLoadOptions(options ?? {});
|
|
484
|
+
setLoaded(void 0);
|
|
485
|
+
setPrepared(void 0);
|
|
486
|
+
setSourceChanged(false);
|
|
487
|
+
},
|
|
488
|
+
mutationFn: async ({ input, options }) => {
|
|
489
|
+
if (!onLoadTable) throw new Error("Table loading is unavailable.");
|
|
490
|
+
return onLoadTable(input, options);
|
|
491
|
+
},
|
|
492
|
+
onSuccess: (value) => {
|
|
493
|
+
setLoaded(value);
|
|
494
|
+
if ("path" in value.source) setLoadInput({ path: value.source.path });
|
|
495
|
+
const matched = defaultColumns(value.data, parameters);
|
|
496
|
+
setColumns(matched);
|
|
497
|
+
setArgs((current) => Object.fromEntries(Object.entries(current).filter(([name]) => !matched[name])));
|
|
498
|
+
setPrepared(void 0);
|
|
499
|
+
setSelectedIndex(void 0);
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
async function requestSource(input) {
|
|
503
|
+
if (!onRequestTableSource) return;
|
|
504
|
+
setRequestPending(true);
|
|
505
|
+
setRequestError(void 0);
|
|
506
|
+
try {
|
|
507
|
+
await onRequestTableSource({
|
|
508
|
+
path,
|
|
509
|
+
...input
|
|
510
|
+
});
|
|
511
|
+
} catch (error) {
|
|
512
|
+
setRequestError(error);
|
|
513
|
+
} finally {
|
|
514
|
+
setRequestPending(false);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
const run = useMutation({
|
|
518
|
+
mutationFn: async () => {
|
|
519
|
+
if (!onRunTable) throw new Error("Execution is unavailable.");
|
|
520
|
+
let next = prepared;
|
|
521
|
+
const refreshing = next !== void 0 && next.status !== "ready" && !loaded;
|
|
522
|
+
if (loaded || !next || next.status !== "ready") {
|
|
523
|
+
if (!source || !onPrepareTable) throw new Error("Choose a table first.");
|
|
524
|
+
const visible = data;
|
|
525
|
+
next = await onPrepareTable({
|
|
526
|
+
path,
|
|
527
|
+
args,
|
|
528
|
+
table: {
|
|
529
|
+
source,
|
|
530
|
+
columns
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
setPrepared(next);
|
|
534
|
+
setLoaded(void 0);
|
|
535
|
+
const changed = visible !== void 0 && JSON.stringify([visible.columns, visible.rows]) !== JSON.stringify([next.data.columns, next.data.rows]);
|
|
536
|
+
setSourceChanged(changed);
|
|
537
|
+
if (refreshing || changed) return next;
|
|
538
|
+
}
|
|
539
|
+
setSourceChanged(false);
|
|
540
|
+
return onRunTable(next.path);
|
|
541
|
+
},
|
|
542
|
+
onSuccess: (next) => setPrepared((current) => current?.path === next.path && current.status !== "ready" && next.status === "running" ? current : next)
|
|
543
|
+
});
|
|
544
|
+
const stop = useMutation({ mutationFn: async () => {
|
|
545
|
+
if (prepared && onStopTable) await onStopTable(prepared.path);
|
|
546
|
+
} });
|
|
547
|
+
const schedule = useMutation({ mutationFn: async () => {
|
|
548
|
+
if (!source || !onScheduleTable) throw new Error("Choose a table first.");
|
|
549
|
+
await onScheduleTable({
|
|
550
|
+
path,
|
|
551
|
+
args,
|
|
552
|
+
table: {
|
|
553
|
+
source,
|
|
554
|
+
columns
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
} });
|
|
558
|
+
return {
|
|
559
|
+
loaded,
|
|
560
|
+
setLoaded,
|
|
561
|
+
loadInput,
|
|
562
|
+
loadOptions,
|
|
563
|
+
setLoadOptions,
|
|
564
|
+
columns,
|
|
565
|
+
args,
|
|
566
|
+
prepared,
|
|
567
|
+
setPrepared,
|
|
568
|
+
selectedRow,
|
|
569
|
+
selectedTrace,
|
|
570
|
+
savedTrace,
|
|
571
|
+
setSelectedIndex,
|
|
572
|
+
paste,
|
|
573
|
+
setPaste,
|
|
574
|
+
workspacePath,
|
|
575
|
+
setWorkspacePath,
|
|
576
|
+
sourceRequest,
|
|
577
|
+
setSourceRequest,
|
|
578
|
+
requestPending,
|
|
579
|
+
sourceChanged,
|
|
580
|
+
data,
|
|
581
|
+
source,
|
|
582
|
+
active,
|
|
583
|
+
hasRun,
|
|
584
|
+
load,
|
|
585
|
+
run,
|
|
586
|
+
stop,
|
|
587
|
+
schedule,
|
|
588
|
+
busy: active || load.isPending || run.isPending || requestPending,
|
|
589
|
+
error: [
|
|
590
|
+
load.error,
|
|
591
|
+
requestError,
|
|
592
|
+
run.error,
|
|
593
|
+
stop.error,
|
|
594
|
+
schedule.error,
|
|
595
|
+
savedTrace.error
|
|
596
|
+
].filter(Boolean).map((value) => executionErrorSummary(formatErrorMessage(value))).join(" ") || (prepared?.error ? executionErrorSummary(prepared.error) : ""),
|
|
597
|
+
requestSource,
|
|
598
|
+
view: tableView({
|
|
599
|
+
prepared,
|
|
600
|
+
loaded,
|
|
601
|
+
data,
|
|
602
|
+
source,
|
|
603
|
+
parameters,
|
|
604
|
+
columns,
|
|
605
|
+
args
|
|
606
|
+
})
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
function TableSourceSection({ session, actions }) {
|
|
610
|
+
const { data, source, active, busy, paste, setPaste, workspacePath, setWorkspacePath, sourceRequest, setSourceRequest, requestPending, requestSource, load, setLoaded, setPrepared, args, view: { rowCount, href, sourceDescription } } = session;
|
|
611
|
+
const { path, onLoadTable, onRequestTableSource } = actions;
|
|
612
|
+
if (data) return /* @__PURE__ */ jsxs("div", {
|
|
613
|
+
className: "workspace-execution-table__source-section",
|
|
614
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
615
|
+
className: "workspace-execution-table__source-line",
|
|
616
|
+
children: [
|
|
617
|
+
/* @__PURE__ */ jsx(FaviconMark, {
|
|
618
|
+
href,
|
|
619
|
+
fallback: /* @__PURE__ */ jsx(FileIcon, {})
|
|
620
|
+
}),
|
|
621
|
+
href ? /* @__PURE__ */ jsx("a", {
|
|
622
|
+
className: "sigvelo-truncate-grow",
|
|
623
|
+
href,
|
|
624
|
+
target: "_blank",
|
|
625
|
+
rel: "noreferrer",
|
|
626
|
+
children: data.source?.label ?? "Source table"
|
|
627
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
628
|
+
className: "sigvelo-truncate-grow",
|
|
629
|
+
children: tableSourceLabel(data, source)
|
|
630
|
+
}),
|
|
631
|
+
/* @__PURE__ */ jsxs("span", {
|
|
632
|
+
className: "workspace-execution-table__hint",
|
|
633
|
+
children: [
|
|
634
|
+
rowCount,
|
|
635
|
+
" ",
|
|
636
|
+
rowCount === 1 ? "row" : "rows"
|
|
637
|
+
]
|
|
638
|
+
}),
|
|
639
|
+
!active && (onLoadTable || onRequestTableSource) ? /* @__PURE__ */ jsx(IconButton, {
|
|
640
|
+
label: "Change table source",
|
|
641
|
+
variant: "ghost",
|
|
642
|
+
color: "neutral",
|
|
643
|
+
onClick: () => {
|
|
644
|
+
setLoaded(void 0);
|
|
645
|
+
setPrepared(void 0);
|
|
646
|
+
},
|
|
647
|
+
children: /* @__PURE__ */ jsx(PencilIcon, {})
|
|
648
|
+
}) : null
|
|
649
|
+
]
|
|
650
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
651
|
+
className: "workspace-execution-table__hint",
|
|
652
|
+
children: sourceDescription
|
|
653
|
+
})]
|
|
654
|
+
});
|
|
655
|
+
if (!onLoadTable) return /* @__PURE__ */ jsx("p", { children: "Ask Rook to prepare a table for this workflow." });
|
|
656
|
+
return /* @__PURE__ */ jsx(TableSourceSetup, {
|
|
657
|
+
busy,
|
|
658
|
+
paste,
|
|
659
|
+
setPaste,
|
|
660
|
+
workspacePath,
|
|
661
|
+
setWorkspacePath,
|
|
662
|
+
sourceRequest,
|
|
663
|
+
setSourceRequest,
|
|
664
|
+
requestPending,
|
|
665
|
+
onRequestTableSource,
|
|
666
|
+
onRequestSource: requestSource,
|
|
667
|
+
onLoad: load.mutate,
|
|
668
|
+
path,
|
|
669
|
+
args
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
function tableSourceLabel(data, source) {
|
|
673
|
+
if (data.source?.label !== void 0) return data.source.label;
|
|
674
|
+
if (source && "path" in source) return source.path.split("/").at(-1) ?? "Table";
|
|
675
|
+
return "Table";
|
|
676
|
+
}
|
|
677
|
+
function TableRunStatus({ session, actions }) {
|
|
678
|
+
const { sourceChanged, active, run, schedule, source, busy, requestSource, requestPending, args, columns, hasRun, view: { requiredError, finished, rowCount } } = session;
|
|
679
|
+
const { path, onRequestTableSource } = actions;
|
|
680
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
681
|
+
sourceChanged ? /* @__PURE__ */ jsx("p", {
|
|
682
|
+
role: "status",
|
|
683
|
+
children: "The source changed. Review these rows before running."
|
|
684
|
+
}) : null,
|
|
685
|
+
!active && (requiredError || run.error || schedule.error) ? /* @__PURE__ */ jsxs("div", {
|
|
686
|
+
className: "sigvelo-stack",
|
|
687
|
+
role: "status",
|
|
688
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
689
|
+
className: "workspace-execution-table__hint",
|
|
690
|
+
children: requiredError || "Rook can help prepare this table."
|
|
691
|
+
}), onRequestTableSource && source ? /* @__PURE__ */ jsxs(Button, {
|
|
692
|
+
type: "button",
|
|
693
|
+
variant: "outline",
|
|
694
|
+
color: "neutral",
|
|
695
|
+
disabled: busy,
|
|
696
|
+
onClick: () => void requestSource({
|
|
697
|
+
request: "Prepare this table for the workflow. Match the columns and ask me only for missing information.",
|
|
698
|
+
invocation: {
|
|
699
|
+
path,
|
|
700
|
+
args,
|
|
701
|
+
table: {
|
|
702
|
+
source,
|
|
703
|
+
columns
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}),
|
|
707
|
+
children: [requestPending ? /* @__PURE__ */ jsx(SpinnerIcon, {}) : /* @__PURE__ */ jsx(WrenchIcon, {}), "Ask Rook to prepare"]
|
|
708
|
+
}) : null]
|
|
709
|
+
}) : null,
|
|
710
|
+
hasRun ? /* @__PURE__ */ jsxs("div", {
|
|
711
|
+
className: "sigvelo-stack",
|
|
712
|
+
role: "status",
|
|
713
|
+
children: [/* @__PURE__ */ jsxs("span", { children: [
|
|
714
|
+
finished,
|
|
715
|
+
" of ",
|
|
716
|
+
rowCount,
|
|
717
|
+
" finished"
|
|
718
|
+
] }), /* @__PURE__ */ jsx(Progress.Root, {
|
|
719
|
+
value: finished,
|
|
720
|
+
max: Math.max(1, rowCount),
|
|
721
|
+
"aria-label": "Rows finished",
|
|
722
|
+
children: /* @__PURE__ */ jsx(Progress.Track, { children: /* @__PURE__ */ jsx(Progress.Indicator, {}) })
|
|
723
|
+
})]
|
|
724
|
+
}) : null
|
|
725
|
+
] });
|
|
726
|
+
}
|
|
727
|
+
function TablePrimaryAction({ session, actions }) {
|
|
728
|
+
const { active, stop, selectedRow, data, busy, run, hasRun, view: { rowCount, requiredError } } = session;
|
|
729
|
+
if (active && actions.onStopTable) return /* @__PURE__ */ jsxs(Button, {
|
|
730
|
+
type: "button",
|
|
731
|
+
size: "sm",
|
|
732
|
+
color: "neutral",
|
|
733
|
+
disabled: stop.isPending,
|
|
734
|
+
onClick: () => stop.mutate(),
|
|
735
|
+
children: [stop.isPending ? /* @__PURE__ */ jsx(SpinnerIcon, {}) : /* @__PURE__ */ jsx(StopIcon, {}), stop.isPending ? "Stopping…" : "Stop"]
|
|
736
|
+
});
|
|
737
|
+
if (selectedRow || !data || !actions.onRunTable) return null;
|
|
738
|
+
let label = `Run ${rowCount} ${rowCount === 1 ? "row" : "rows"}`;
|
|
739
|
+
if (hasRun) label = "Prepare another run";
|
|
740
|
+
if (run.isPending) label = "Preparing…";
|
|
741
|
+
return /* @__PURE__ */ jsxs(Button, {
|
|
742
|
+
type: "button",
|
|
743
|
+
size: "sm",
|
|
744
|
+
disabled: busy || rowCount === 0 || Boolean(requiredError),
|
|
745
|
+
onClick: () => run.mutate(),
|
|
746
|
+
children: [run.isPending ? /* @__PURE__ */ jsx(SpinnerIcon, {}) : /* @__PURE__ */ jsx(PlayIcon, {}), label]
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
function TableActionBar({ session, actions }) {
|
|
750
|
+
const { error, active, selectedRow, data, busy, schedule, view: { requiredError } } = session;
|
|
751
|
+
const { onScheduleTable } = actions;
|
|
752
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
753
|
+
className: "workspace-execution-table__footer",
|
|
754
|
+
children: [
|
|
755
|
+
error ? /* @__PURE__ */ jsx(Field.Errors, { errors: [error] }) : null,
|
|
756
|
+
/* @__PURE__ */ jsx(TablePrimaryAction, {
|
|
757
|
+
session,
|
|
758
|
+
actions
|
|
759
|
+
}),
|
|
760
|
+
data && onScheduleTable && !selectedRow && !active ? /* @__PURE__ */ jsxs(Button, {
|
|
761
|
+
type: "button",
|
|
762
|
+
"aria-label": "Schedule table workflow",
|
|
763
|
+
size: "sm",
|
|
764
|
+
variant: "outline",
|
|
765
|
+
color: "neutral",
|
|
766
|
+
disabled: busy || schedule.isPending || Boolean(requiredError),
|
|
767
|
+
onClick: () => schedule.mutate(),
|
|
768
|
+
children: [/* @__PURE__ */ jsx(CalendarIcon, {}), "Schedule"]
|
|
769
|
+
}) : null
|
|
770
|
+
]
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
/** Run one existing workflow for each row, then inspect each row on the same execution board. */
|
|
774
|
+
function WorkspaceExecutionTable(props) {
|
|
775
|
+
const { trace, graph } = props;
|
|
776
|
+
const session = useTableExecution(props);
|
|
777
|
+
const { selectedRow, selectedTrace, savedTrace, setSelectedIndex, data, loaded, loadInput, loadOptions, setLoadOptions, busy, load, view: { rowCount, visibleRows, rowsByIndex, results, resultColumns, showResult } } = session;
|
|
778
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
779
|
+
className: "workspace-execution-table",
|
|
780
|
+
"data-slot": "workspace-execution-table",
|
|
781
|
+
children: [selectedRow ? /* @__PURE__ */ jsx(TableSelectedRow, {
|
|
782
|
+
selectedRow,
|
|
783
|
+
rowCount,
|
|
784
|
+
selectedTrace,
|
|
785
|
+
graph,
|
|
786
|
+
fetching: savedTrace.isFetching,
|
|
787
|
+
onClose: () => setSelectedIndex(void 0)
|
|
788
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
789
|
+
className: "workspace-execution-table__body sigvelo-stack",
|
|
790
|
+
children: [
|
|
791
|
+
/* @__PURE__ */ jsx(TableSourceSection, {
|
|
792
|
+
session,
|
|
793
|
+
actions: props
|
|
794
|
+
}),
|
|
795
|
+
/* @__PURE__ */ jsx(TableReadOptions, {
|
|
796
|
+
loaded,
|
|
797
|
+
loadInput,
|
|
798
|
+
loadOptions,
|
|
799
|
+
setLoadOptions,
|
|
800
|
+
busy,
|
|
801
|
+
onLoad: load.mutate
|
|
802
|
+
}),
|
|
803
|
+
data ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(TableRunStatus, {
|
|
804
|
+
session,
|
|
805
|
+
actions: props
|
|
806
|
+
}), /* @__PURE__ */ jsx(TablePreview, {
|
|
807
|
+
data,
|
|
808
|
+
visibleRows: visibleRows ?? [],
|
|
809
|
+
rowsByIndex,
|
|
810
|
+
results,
|
|
811
|
+
resultColumns,
|
|
812
|
+
showResult,
|
|
813
|
+
trace,
|
|
814
|
+
onSelectRow: setSelectedIndex
|
|
815
|
+
})] }) : null
|
|
816
|
+
]
|
|
817
|
+
}), /* @__PURE__ */ jsx(TableActionBar, {
|
|
818
|
+
session,
|
|
819
|
+
actions: props
|
|
820
|
+
})]
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
//#endregion
|
|
824
|
+
export { WorkspaceExecutionTable };
|