@axiom-lattice/react-sdk 2.1.75 → 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.d.mts CHANGED
@@ -1427,6 +1427,11 @@ interface LatticeChatShellConfig {
1427
1427
  * Defaults to true
1428
1428
  */
1429
1429
  sidebarDefaultExpanded?: boolean;
1430
+ /**
1431
+ * Whether workspace menu is expanded by default
1432
+ * Defaults to true
1433
+ */
1434
+ workspaceMenuDefaultExpanded?: boolean;
1430
1435
  /**
1431
1436
  * Whether to show the expand/collapse toggle button
1432
1437
  * Defaults to true
package/dist/index.d.ts CHANGED
@@ -1427,6 +1427,11 @@ interface LatticeChatShellConfig {
1427
1427
  * Defaults to true
1428
1428
  */
1429
1429
  sidebarDefaultExpanded?: boolean;
1430
+ /**
1431
+ * Whether workspace menu is expanded by default
1432
+ * Defaults to true
1433
+ */
1434
+ workspaceMenuDefaultExpanded?: boolean;
1430
1435
  /**
1431
1436
  * Whether to show the expand/collapse toggle button
1432
1437
  * Defaults to true
package/dist/index.js CHANGED
@@ -1443,6 +1443,7 @@ var DEFAULT_CONFIG = {
1443
1443
  enableModelSelector: false,
1444
1444
  sidebarMode: "icon",
1445
1445
  sidebarDefaultExpanded: true,
1446
+ workspaceMenuDefaultExpanded: true,
1446
1447
  sidebarShowToggle: true,
1447
1448
  sidebarShowNewAnalysis: true,
1448
1449
  sidebarLogoText: "Lattice"
@@ -19390,20 +19391,59 @@ function RunSummaryBanner({ run, agentName }) {
19390
19391
  }
19391
19392
  );
19392
19393
  }
19393
- var RunDetail = ({ run, agentName, open, onClose }) => {
19394
+ var RunDetail = ({ run, agentName, open, onClose, onRunUpdate, autoRefresh }) => {
19394
19395
  const { get } = useApi();
19395
19396
  const [steps, setSteps] = (0, import_react65.useState)([]);
19396
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]);
19397
19418
  (0, import_react65.useEffect)(() => {
19398
19419
  if (!open) return;
19399
19420
  setLoading(true);
19400
- get(
19401
- `/api/workflows/runs/${run.id}/steps`
19402
- ).then((res) => {
19403
- if (res.success) setSteps(res.data?.records || []);
19404
- }).catch(() => {
19405
- }).finally(() => setLoading(false));
19406
- }, [open, run.id, get]);
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]);
19407
19447
  return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(
19408
19448
  import_antd57.Drawer,
19409
19449
  {
@@ -19435,6 +19475,7 @@ var RunDetail = ({ run, agentName, open, onClose }) => {
19435
19475
  }
19436
19476
  );
19437
19477
  };
19478
+ var POLLING_INTERVAL = 3e3;
19438
19479
  var TopologyRuntimeView = () => {
19439
19480
  const { get } = useApi();
19440
19481
  const [runs, setRuns] = (0, import_react65.useState)([]);
@@ -19442,9 +19483,46 @@ var TopologyRuntimeView = () => {
19442
19483
  const [loading, setLoading] = (0, import_react65.useState)(true);
19443
19484
  const [error, setError] = (0, import_react65.useState)(null);
19444
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]);
19445
19523
  (0, import_react65.useEffect)(() => {
19446
19524
  let cancelled = false;
19447
- const fetchData = async () => {
19525
+ const init2 = async () => {
19448
19526
  try {
19449
19527
  setLoading(true);
19450
19528
  const defsRes = await get("/api/workflows/definitions");
@@ -19473,11 +19551,16 @@ var TopologyRuntimeView = () => {
19473
19551
  if (!cancelled) setLoading(false);
19474
19552
  }
19475
19553
  };
19476
- fetchData();
19554
+ init2();
19477
19555
  return () => {
19478
19556
  cancelled = true;
19479
19557
  };
19480
19558
  }, [get]);
19559
+ (0, import_react65.useEffect)(() => {
19560
+ return () => {
19561
+ pollingSessionRef.current = 0;
19562
+ };
19563
+ }, []);
19481
19564
  if (loading) {
19482
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" }) });
19483
19566
  }
@@ -19488,7 +19571,27 @@ var TopologyRuntimeView = () => {
19488
19571
  return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_antd57.Empty, { description: "No workflow runs yet. Execute a processing agent to see results here." });
19489
19572
  }
19490
19573
  return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)("div", { style: { padding: 16, overflow: "auto", height: "100%" }, children: [
19491
- /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Title5, { level: 5, style: { marginBottom: 16 }, children: "Workflow Runs" }),
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
+ ] }),
19492
19595
  /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
19493
19596
  import_antd57.List,
19494
19597
  {
@@ -19544,7 +19647,9 @@ var TopologyRuntimeView = () => {
19544
19647
  run: selectedRun,
19545
19648
  agentName: agentNames[selectedRun.assistantId] || selectedRun.assistantId,
19546
19649
  open: !!selectedRun,
19547
- onClose: () => setSelectedRun(null)
19650
+ onClose: () => setSelectedRun(null),
19651
+ onRunUpdate: handleRunUpdate,
19652
+ autoRefresh
19548
19653
  }
19549
19654
  )
19550
19655
  ] });
@@ -20998,7 +21103,7 @@ var WorkspaceResourceManager = ({
20998
21103
  logo,
20999
21104
  logoText: workspaceName || "Workspace",
21000
21105
  showToggle: true,
21001
- defaultExpanded: true,
21106
+ defaultExpanded: config.workspaceMenuDefaultExpanded ?? true,
21002
21107
  collapsed: menuCollapsed,
21003
21108
  onCollapsedChange: setMenuCollapsed,
21004
21109
  footer: ({ isIconMode }) => user && /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
@@ -32571,11 +32676,6 @@ var import_antd97 = require("antd");
32571
32676
  var import_lucide_react34 = require("lucide-react");
32572
32677
  var import_jsx_runtime126 = require("react/jsx-runtime");
32573
32678
  var { Text: Text47, Title: Title17 } = import_antd97.Typography;
32574
- var MAPPING_MODE_OPTIONS = [
32575
- { label: "User", value: "user" },
32576
- { label: "Group", value: "group" },
32577
- { label: "Hybrid", value: "hybrid" }
32578
- ];
32579
32679
  var ChannelInstallationsDrawerContent = () => {
32580
32680
  const { get, post, put, del } = useApi();
32581
32681
  const [installations, setInstallations] = (0, import_react104.useState)([]);
@@ -32697,22 +32797,6 @@ var ChannelInstallationsDrawerContent = () => {
32697
32797
  "ID: ",
32698
32798
  installation.id
32699
32799
  ] }),
32700
- /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(Text47, { style: { fontSize: 13 }, children: [
32701
- "Assistant ID: ",
32702
- installation.config.assistantId
32703
- ] }),
32704
- /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(Text47, { style: { fontSize: 13 }, children: [
32705
- "Mapping Mode: ",
32706
- installation.config.mappingMode
32707
- ] }),
32708
- installation.config.workspaceId ? /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(Text47, { style: { fontSize: 13 }, children: [
32709
- "Workspace ID: ",
32710
- installation.config.workspaceId
32711
- ] }) : null,
32712
- installation.config.projectId ? /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(Text47, { style: { fontSize: 13 }, children: [
32713
- "Project ID: ",
32714
- installation.config.projectId
32715
- ] }) : null,
32716
32800
  webhookPath ? /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(Text47, { code: true, style: { fontSize: 12 }, children: webhookPath }) : /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(Text47, { type: "secondary", style: { fontSize: 12 }, children: "Unsupported channel configuration UI" })
32717
32801
  ]
32718
32802
  }
@@ -32768,23 +32852,17 @@ var LarkChannelInstallationFormModal = ({ installation, open, post, put, onCance
32768
32852
  const [form] = import_antd97.Form.useForm();
32769
32853
  (0, import_react104.useEffect)(() => {
32770
32854
  if (installation) {
32855
+ const config = installation.config;
32771
32856
  form.setFieldsValue({
32772
32857
  name: installation.name,
32773
- appId: installation.config.appId,
32774
- appSecret: installation.config.appSecret,
32775
- verificationToken: installation.config.verificationToken,
32776
- encryptKey: installation.config.encryptKey,
32777
- mappingMode: installation.config.mappingMode,
32778
- assistantId: installation.config.assistantId,
32779
- workspaceId: installation.config.workspaceId,
32780
- projectId: installation.config.projectId
32858
+ appId: config.appId,
32859
+ appSecret: config.appSecret,
32860
+ verificationToken: config.verificationToken,
32861
+ encryptKey: config.encryptKey
32781
32862
  });
32782
32863
  return;
32783
32864
  }
32784
32865
  form.resetFields();
32785
- form.setFieldsValue({
32786
- mappingMode: "hybrid"
32787
- });
32788
32866
  }, [installation, form]);
32789
32867
  const handleSubmit = async () => {
32790
32868
  const values = await form.validateFields();
@@ -32792,11 +32870,7 @@ var LarkChannelInstallationFormModal = ({ installation, open, post, put, onCance
32792
32870
  appId: values.appId,
32793
32871
  appSecret: values.appSecret,
32794
32872
  verificationToken: values.verificationToken,
32795
- encryptKey: values.encryptKey,
32796
- mappingMode: values.mappingMode,
32797
- assistantId: values.assistantId,
32798
- workspaceId: values.workspaceId,
32799
- projectId: values.projectId
32873
+ encryptKey: values.encryptKey
32800
32874
  };
32801
32875
  try {
32802
32876
  if (installation) {
@@ -32869,27 +32943,7 @@ var LarkChannelInstallationFormModal = ({ installation, open, post, put, onCance
32869
32943
  }
32870
32944
  ),
32871
32945
  /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(import_antd97.Form.Item, { name: "verificationToken", label: "Verification Token", children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(import_antd97.Input, {}) }),
32872
- /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(import_antd97.Form.Item, { name: "encryptKey", label: "Encrypt Key", children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(import_antd97.Input, {}) }),
32873
- /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
32874
- import_antd97.Form.Item,
32875
- {
32876
- name: "mappingMode",
32877
- label: "Mapping Mode",
32878
- rules: [{ required: true, message: "Mapping Mode is required" }],
32879
- children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(import_antd97.Select, { options: MAPPING_MODE_OPTIONS })
32880
- }
32881
- ),
32882
- /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
32883
- import_antd97.Form.Item,
32884
- {
32885
- name: "assistantId",
32886
- label: "Assistant ID",
32887
- rules: [{ required: true, message: "Assistant ID is required" }],
32888
- children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(import_antd97.Input, {})
32889
- }
32890
- ),
32891
- /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(import_antd97.Form.Item, { name: "workspaceId", label: "Workspace ID", children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(import_antd97.Input, {}) }),
32892
- /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(import_antd97.Form.Item, { name: "projectId", label: "Project ID", children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(import_antd97.Input, {}) })
32946
+ /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(import_antd97.Form.Item, { name: "encryptKey", label: "Encrypt Key", children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(import_antd97.Input, {}) })
32893
32947
  ] })
32894
32948
  }
32895
32949
  );