@axiom-lattice/react-sdk 2.1.76 → 2.1.77
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/index.js +116 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +164 -57
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19391,20 +19391,59 @@ function RunSummaryBanner({ run, agentName }) {
|
|
|
19391
19391
|
}
|
|
19392
19392
|
);
|
|
19393
19393
|
}
|
|
19394
|
-
var RunDetail = ({ run, agentName, open, onClose }) => {
|
|
19394
|
+
var RunDetail = ({ run, agentName, open, onClose, onRunUpdate, autoRefresh }) => {
|
|
19395
19395
|
const { get } = useApi();
|
|
19396
19396
|
const [steps, setSteps] = (0, import_react65.useState)([]);
|
|
19397
19397
|
const [loading, setLoading] = (0, import_react65.useState)(false);
|
|
19398
|
+
const stepsPollTimeoutRef = (0, import_react65.useRef)(null);
|
|
19399
|
+
const stepsPollSessionRef = (0, import_react65.useRef)(0);
|
|
19400
|
+
const fetchSteps = (0, import_react65.useCallback)(async () => {
|
|
19401
|
+
try {
|
|
19402
|
+
const [stepsRes, runsRes] = await Promise.all([
|
|
19403
|
+
get(
|
|
19404
|
+
`/api/workflows/runs/${run.id}/steps`
|
|
19405
|
+
),
|
|
19406
|
+
get(
|
|
19407
|
+
"/api/workflows/runs"
|
|
19408
|
+
)
|
|
19409
|
+
]);
|
|
19410
|
+
if (stepsRes.success) setSteps(stepsRes.data?.records || []);
|
|
19411
|
+
if (runsRes.success && runsRes.data?.records) {
|
|
19412
|
+
const matched = runsRes.data.records.find((r) => r.id === run.id);
|
|
19413
|
+
if (matched) onRunUpdate(matched);
|
|
19414
|
+
}
|
|
19415
|
+
} catch {
|
|
19416
|
+
}
|
|
19417
|
+
}, [get, run.id, onRunUpdate]);
|
|
19398
19418
|
(0, import_react65.useEffect)(() => {
|
|
19399
19419
|
if (!open) return;
|
|
19400
19420
|
setLoading(true);
|
|
19401
|
-
|
|
19402
|
-
|
|
19403
|
-
|
|
19404
|
-
|
|
19405
|
-
|
|
19406
|
-
|
|
19407
|
-
|
|
19421
|
+
fetchSteps().finally(() => setLoading(false));
|
|
19422
|
+
}, [open, run.id, fetchSteps]);
|
|
19423
|
+
(0, import_react65.useEffect)(() => {
|
|
19424
|
+
if (stepsPollTimeoutRef.current) {
|
|
19425
|
+
clearTimeout(stepsPollTimeoutRef.current);
|
|
19426
|
+
stepsPollTimeoutRef.current = null;
|
|
19427
|
+
}
|
|
19428
|
+
if (!open || run.status !== "running" || !autoRefresh) return;
|
|
19429
|
+
const sessionId = Date.now();
|
|
19430
|
+
stepsPollSessionRef.current = sessionId;
|
|
19431
|
+
const poll = async () => {
|
|
19432
|
+
if (stepsPollSessionRef.current !== sessionId) return;
|
|
19433
|
+
await fetchSteps();
|
|
19434
|
+
if (stepsPollSessionRef.current === sessionId) {
|
|
19435
|
+
stepsPollTimeoutRef.current = setTimeout(poll, POLLING_INTERVAL);
|
|
19436
|
+
}
|
|
19437
|
+
};
|
|
19438
|
+
poll();
|
|
19439
|
+
return () => {
|
|
19440
|
+
stepsPollSessionRef.current = 0;
|
|
19441
|
+
if (stepsPollTimeoutRef.current) {
|
|
19442
|
+
clearTimeout(stepsPollTimeoutRef.current);
|
|
19443
|
+
stepsPollTimeoutRef.current = null;
|
|
19444
|
+
}
|
|
19445
|
+
};
|
|
19446
|
+
}, [open, run.status, fetchSteps, autoRefresh]);
|
|
19408
19447
|
return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(
|
|
19409
19448
|
import_antd57.Drawer,
|
|
19410
19449
|
{
|
|
@@ -19436,6 +19475,7 @@ var RunDetail = ({ run, agentName, open, onClose }) => {
|
|
|
19436
19475
|
}
|
|
19437
19476
|
);
|
|
19438
19477
|
};
|
|
19478
|
+
var POLLING_INTERVAL = 3e3;
|
|
19439
19479
|
var TopologyRuntimeView = () => {
|
|
19440
19480
|
const { get } = useApi();
|
|
19441
19481
|
const [runs, setRuns] = (0, import_react65.useState)([]);
|
|
@@ -19443,9 +19483,46 @@ var TopologyRuntimeView = () => {
|
|
|
19443
19483
|
const [loading, setLoading] = (0, import_react65.useState)(true);
|
|
19444
19484
|
const [error, setError] = (0, import_react65.useState)(null);
|
|
19445
19485
|
const [selectedRun, setSelectedRun] = (0, import_react65.useState)(null);
|
|
19486
|
+
const [autoRefresh, setAutoRefresh] = (0, import_react65.useState)(true);
|
|
19487
|
+
const pollingSessionRef = (0, import_react65.useRef)(0);
|
|
19488
|
+
const handleRunUpdate = (0, import_react65.useCallback)((updated) => {
|
|
19489
|
+
setRuns(
|
|
19490
|
+
(prev) => prev.map((r) => r.id === updated.id ? updated : r)
|
|
19491
|
+
);
|
|
19492
|
+
setSelectedRun((prev) => prev?.id === updated.id ? updated : prev);
|
|
19493
|
+
}, []);
|
|
19494
|
+
const refreshRuns = (0, import_react65.useCallback)(async () => {
|
|
19495
|
+
setLoading(true);
|
|
19496
|
+
try {
|
|
19497
|
+
const defsRes = await get("/api/workflows/definitions");
|
|
19498
|
+
const nameMap = {};
|
|
19499
|
+
if (defsRes.success && defsRes.data?.records) {
|
|
19500
|
+
defsRes.data.records.forEach((d) => {
|
|
19501
|
+
nameMap[d.assistantId] = d.assistantName;
|
|
19502
|
+
});
|
|
19503
|
+
}
|
|
19504
|
+
setAgentNames(nameMap);
|
|
19505
|
+
const runsRes = await get("/api/workflows/runs");
|
|
19506
|
+
if (runsRes.success && runsRes.data?.records) {
|
|
19507
|
+
runsRes.data.records.sort(
|
|
19508
|
+
(a, b) => new Date(b.startedAt).getTime() - new Date(a.startedAt).getTime()
|
|
19509
|
+
);
|
|
19510
|
+
setRuns(runsRes.data.records);
|
|
19511
|
+
setSelectedRun((prev) => {
|
|
19512
|
+
if (!prev) return null;
|
|
19513
|
+
return runsRes.data.records.find((r) => r.id === prev.id) || prev;
|
|
19514
|
+
});
|
|
19515
|
+
}
|
|
19516
|
+
setError(null);
|
|
19517
|
+
} catch (err) {
|
|
19518
|
+
setError(err instanceof Error ? err.message : "Failed to load workflow runs");
|
|
19519
|
+
} finally {
|
|
19520
|
+
setLoading(false);
|
|
19521
|
+
}
|
|
19522
|
+
}, [get]);
|
|
19446
19523
|
(0, import_react65.useEffect)(() => {
|
|
19447
19524
|
let cancelled = false;
|
|
19448
|
-
const
|
|
19525
|
+
const init2 = async () => {
|
|
19449
19526
|
try {
|
|
19450
19527
|
setLoading(true);
|
|
19451
19528
|
const defsRes = await get("/api/workflows/definitions");
|
|
@@ -19474,11 +19551,16 @@ var TopologyRuntimeView = () => {
|
|
|
19474
19551
|
if (!cancelled) setLoading(false);
|
|
19475
19552
|
}
|
|
19476
19553
|
};
|
|
19477
|
-
|
|
19554
|
+
init2();
|
|
19478
19555
|
return () => {
|
|
19479
19556
|
cancelled = true;
|
|
19480
19557
|
};
|
|
19481
19558
|
}, [get]);
|
|
19559
|
+
(0, import_react65.useEffect)(() => {
|
|
19560
|
+
return () => {
|
|
19561
|
+
pollingSessionRef.current = 0;
|
|
19562
|
+
};
|
|
19563
|
+
}, []);
|
|
19482
19564
|
if (loading) {
|
|
19483
19565
|
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("div", { style: { display: "flex", justifyContent: "center", alignItems: "center", height: "100%" }, children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_antd57.Spin, { size: "large" }) });
|
|
19484
19566
|
}
|
|
@@ -19489,7 +19571,27 @@ var TopologyRuntimeView = () => {
|
|
|
19489
19571
|
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_antd57.Empty, { description: "No workflow runs yet. Execute a processing agent to see results here." });
|
|
19490
19572
|
}
|
|
19491
19573
|
return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)("div", { style: { padding: 16, overflow: "auto", height: "100%" }, children: [
|
|
19492
|
-
/* @__PURE__ */ (0, import_jsx_runtime76.
|
|
19574
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 16 }, children: [
|
|
19575
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Title5, { level: 5, style: { marginBottom: 0 }, children: "Workflow Runs" }),
|
|
19576
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_antd57.Space, { size: 8, children: [
|
|
19577
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Text27, { type: "secondary", style: { fontSize: 11 }, children: "Auto-refresh" }),
|
|
19578
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
19579
|
+
import_antd57.Switch,
|
|
19580
|
+
{
|
|
19581
|
+
size: "small",
|
|
19582
|
+
checked: autoRefresh,
|
|
19583
|
+
onChange: setAutoRefresh
|
|
19584
|
+
}
|
|
19585
|
+
),
|
|
19586
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_antd57.Tooltip, { title: "Refresh now", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
19587
|
+
import_icons33.ReloadOutlined,
|
|
19588
|
+
{
|
|
19589
|
+
style: { cursor: "pointer", color: "#999" },
|
|
19590
|
+
onClick: () => refreshRuns()
|
|
19591
|
+
}
|
|
19592
|
+
) })
|
|
19593
|
+
] })
|
|
19594
|
+
] }),
|
|
19493
19595
|
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
19494
19596
|
import_antd57.List,
|
|
19495
19597
|
{
|
|
@@ -19545,7 +19647,9 @@ var TopologyRuntimeView = () => {
|
|
|
19545
19647
|
run: selectedRun,
|
|
19546
19648
|
agentName: agentNames[selectedRun.assistantId] || selectedRun.assistantId,
|
|
19547
19649
|
open: !!selectedRun,
|
|
19548
|
-
onClose: () => setSelectedRun(null)
|
|
19650
|
+
onClose: () => setSelectedRun(null),
|
|
19651
|
+
onRunUpdate: handleRunUpdate,
|
|
19652
|
+
autoRefresh
|
|
19549
19653
|
}
|
|
19550
19654
|
)
|
|
19551
19655
|
] });
|