dp-widgets-framework 1.6.7 → 1.6.8
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.esm.js +167 -61
- package/dist/index.js +167 -61
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -43606,6 +43606,24 @@ const loadAgentState$5 = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
43606
43606
|
return null;
|
|
43607
43607
|
}
|
|
43608
43608
|
};
|
|
43609
|
+
const loadSessionStateDirect$5 = async (widgetBackendUrl, sessionId) => {
|
|
43610
|
+
try {
|
|
43611
|
+
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
43612
|
+
method: "GET",
|
|
43613
|
+
headers: {
|
|
43614
|
+
"Content-Type": "application/json"
|
|
43615
|
+
}
|
|
43616
|
+
});
|
|
43617
|
+
if (!response.ok) {
|
|
43618
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
43619
|
+
}
|
|
43620
|
+
const result = await response.json();
|
|
43621
|
+
return result;
|
|
43622
|
+
} catch (error) {
|
|
43623
|
+
console.error("Failed to load session state directly:", error);
|
|
43624
|
+
return null;
|
|
43625
|
+
}
|
|
43626
|
+
};
|
|
43609
43627
|
const parseAndUpdateChartState$4 = (apiResponse, setChartState) => {
|
|
43610
43628
|
var _a, _b;
|
|
43611
43629
|
try {
|
|
@@ -44130,7 +44148,7 @@ function CopilotKitAgent({
|
|
|
44130
44148
|
datasetId,
|
|
44131
44149
|
widgetData
|
|
44132
44150
|
}) {
|
|
44133
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _
|
|
44151
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$;
|
|
44134
44152
|
const agentType = (_a = widget.config) == null ? void 0 : _a.agentType;
|
|
44135
44153
|
const orientation = (_b = widget.config) == null ? void 0 : _b.orientation;
|
|
44136
44154
|
const isFirstLoad = (_c = widget.config) == null ? void 0 : _c.isFirstLoad;
|
|
@@ -44141,6 +44159,7 @@ function CopilotKitAgent({
|
|
|
44141
44159
|
const [apiCallCount, setApiCallCount] = useState(0);
|
|
44142
44160
|
const [hasTimeoutError, setHasTimeoutError] = useState(false);
|
|
44143
44161
|
const hasInitialFetchRef = useRef(false);
|
|
44162
|
+
const [isInitialFetchComplete, setIsInitialFetchComplete] = useState(false);
|
|
44144
44163
|
useEffect(() => {
|
|
44145
44164
|
setThreadId(widget.id);
|
|
44146
44165
|
}, [widget.id, setThreadId]);
|
|
@@ -44150,17 +44169,16 @@ function CopilotKitAgent({
|
|
|
44150
44169
|
});
|
|
44151
44170
|
useEffect(() => {
|
|
44152
44171
|
const fetchInitialState = async () => {
|
|
44153
|
-
var _a2;
|
|
44154
44172
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
44155
44173
|
hasInitialFetchRef.current = true;
|
|
44156
|
-
const
|
|
44157
|
-
const apiResponse = await loadAgentState$5(widgetBackendUrl, widget.id, agentName);
|
|
44174
|
+
const apiResponse = await loadSessionStateDirect$5(widgetBackendUrl, widget.id);
|
|
44158
44175
|
if (apiResponse) {
|
|
44159
44176
|
parseAndUpdateChartState$4(apiResponse, setChartState);
|
|
44160
44177
|
}
|
|
44178
|
+
setIsInitialFetchComplete(true);
|
|
44161
44179
|
};
|
|
44162
44180
|
fetchInitialState();
|
|
44163
|
-
}, [widgetBackendUrl, widget.id,
|
|
44181
|
+
}, [widgetBackendUrl, widget.id, setChartState]);
|
|
44164
44182
|
const handleLoadingTimeout = useCallback(async () => {
|
|
44165
44183
|
var _a2;
|
|
44166
44184
|
if (!widgetBackendUrl || !widget.id || isTimeoutTriggered || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) return;
|
|
@@ -44180,7 +44198,7 @@ function CopilotKitAgent({
|
|
|
44180
44198
|
if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
|
|
44181
44199
|
parseAndUpdateChartState$4(apiResponse, setChartState);
|
|
44182
44200
|
}
|
|
44183
|
-
}, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (
|
|
44201
|
+
}, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
44184
44202
|
const startLoadingTimeout = useCallback(() => {
|
|
44185
44203
|
if (timeoutRef.current) {
|
|
44186
44204
|
clearTimeout(timeoutRef.current);
|
|
@@ -44263,8 +44281,8 @@ function CopilotKitAgent({
|
|
|
44263
44281
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }),
|
|
44264
44282
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
|
|
44265
44283
|
] }) }),
|
|
44266
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && agentType !== "chatbot" && // Check if data is empty based on agent type
|
|
44267
|
-
(agentType === "Bar Chart Agent" && (!((
|
|
44284
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: !isInitialFetchComplete && !isFirstLoad ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RefreshCw, { className: "h-6 w-6 animate-spin text-gray-400" }) }) : (chartState == null ? void 0 : chartState.agent_message) && agentType !== "chatbot" && // Check if data is empty based on agent type
|
|
44285
|
+
(agentType === "Bar Chart Agent" && (!((_i = (_h = (_g = chartState.bar_chart_data) == null ? void 0 : _g.data) == null ? void 0 : _h.labels) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.bar_chart_data) == null ? void 0 : _j.data) == null ? void 0 : _k.values) == null ? void 0 : _l.length)) || agentType === "Series Bar Chart Agent" && (!((_o = (_n = (_m = chartState.series_bar_chart_data) == null ? void 0 : _m.data) == null ? void 0 : _n.labels) == null ? void 0 : _o.length) || !((_r = (_q = (_p = chartState.series_bar_chart_data) == null ? void 0 : _p.data) == null ? void 0 : _q.series) == null ? void 0 : _r.length)) || agentType === "Series Line Chart Agent" && (!((_u = (_t = (_s = chartState.series_bar_chart_data) == null ? void 0 : _s.data) == null ? void 0 : _t.labels) == null ? void 0 : _u.length) || !((_x = (_w = (_v = chartState.series_bar_chart_data) == null ? void 0 : _v.data) == null ? void 0 : _w.series) == null ? void 0 : _x.length)) || agentType === "Pie Chart Agent" && (!((_A = (_z = (_y = chartState.pie_chart_data) == null ? void 0 : _y.data) == null ? void 0 : _z.labels) == null ? void 0 : _A.length) || !((_D = (_C = (_B = chartState.pie_chart_data) == null ? void 0 : _B.data) == null ? void 0 : _C.values) == null ? void 0 : _D.length)) || agentType === "Line Chart Agent" && (!((_G = (_F = (_E = chartState.bar_chart_data) == null ? void 0 : _E.data) == null ? void 0 : _F.labels) == null ? void 0 : _G.length) || !((_J = (_I = (_H = chartState.bar_chart_data) == null ? void 0 : _H.data) == null ? void 0 : _I.values) == null ? void 0 : _J.length)) || agentType === "Data Grid Agent" && (!((_M = (_L = (_K = chartState.matrix_grid_data) == null ? void 0 : _K.data) == null ? void 0 : _L.headers) == null ? void 0 : _M.length) || !((_P = (_O = (_N = chartState.matrix_grid_data) == null ? void 0 : _N.data) == null ? void 0 : _O.rows) == null ? void 0 : _P.length)) || agentType === "Summary Agent" && (!((_R = (_Q = chartState.summary_data) == null ? void 0 : _Q.data) == null ? void 0 : _R.content) || ((_U = (_T = (_S = chartState.summary_data) == null ? void 0 : _S.data) == null ? void 0 : _T.content) == null ? void 0 : _U.trim()) === "")) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : agentType === "Bar Chart Agent" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
44268
44286
|
BarChartComponent,
|
|
44269
44287
|
{
|
|
44270
44288
|
barChartState: chartState,
|
|
@@ -44272,7 +44290,7 @@ function CopilotKitAgent({
|
|
|
44272
44290
|
orientation,
|
|
44273
44291
|
content,
|
|
44274
44292
|
appendMessage,
|
|
44275
|
-
query: (
|
|
44293
|
+
query: (_V = widget.config) == null ? void 0 : _V.query,
|
|
44276
44294
|
isFirstLoad,
|
|
44277
44295
|
widgetBackendUrl,
|
|
44278
44296
|
widgetId: widget.id,
|
|
@@ -44287,7 +44305,7 @@ function CopilotKitAgent({
|
|
|
44287
44305
|
orientation,
|
|
44288
44306
|
content,
|
|
44289
44307
|
appendMessage,
|
|
44290
|
-
query: (
|
|
44308
|
+
query: (_W = widget.config) == null ? void 0 : _W.query,
|
|
44291
44309
|
isFirstLoad,
|
|
44292
44310
|
widgetBackendUrl,
|
|
44293
44311
|
widgetId: widget.id,
|
|
@@ -44302,7 +44320,7 @@ function CopilotKitAgent({
|
|
|
44302
44320
|
orientation,
|
|
44303
44321
|
content,
|
|
44304
44322
|
appendMessage,
|
|
44305
|
-
query: (
|
|
44323
|
+
query: (_X = widget.config) == null ? void 0 : _X.query,
|
|
44306
44324
|
isFirstLoad,
|
|
44307
44325
|
widgetBackendUrl,
|
|
44308
44326
|
widgetId: widget.id,
|
|
@@ -44316,7 +44334,7 @@ function CopilotKitAgent({
|
|
|
44316
44334
|
styles,
|
|
44317
44335
|
appendMessage,
|
|
44318
44336
|
content,
|
|
44319
|
-
query: (
|
|
44337
|
+
query: (_Y = widget.config) == null ? void 0 : _Y.query,
|
|
44320
44338
|
isFirstLoad,
|
|
44321
44339
|
widgetBackendUrl,
|
|
44322
44340
|
widgetId: widget.id,
|
|
@@ -44330,7 +44348,7 @@ function CopilotKitAgent({
|
|
|
44330
44348
|
styles,
|
|
44331
44349
|
appendMessage,
|
|
44332
44350
|
content,
|
|
44333
|
-
query: (
|
|
44351
|
+
query: (_Z = widget.config) == null ? void 0 : _Z.query,
|
|
44334
44352
|
isFirstLoad,
|
|
44335
44353
|
widgetBackendUrl,
|
|
44336
44354
|
widgetId: widget.id,
|
|
@@ -44343,7 +44361,7 @@ function CopilotKitAgent({
|
|
|
44343
44361
|
dataGridState: chartState,
|
|
44344
44362
|
styles,
|
|
44345
44363
|
appendMessage,
|
|
44346
|
-
query: (
|
|
44364
|
+
query: (__ = widget.config) == null ? void 0 : __.query,
|
|
44347
44365
|
isFirstLoad,
|
|
44348
44366
|
widgetBackendUrl,
|
|
44349
44367
|
widgetId: widget.id,
|
|
@@ -44356,7 +44374,7 @@ function CopilotKitAgent({
|
|
|
44356
44374
|
summaryState: chartState,
|
|
44357
44375
|
styles,
|
|
44358
44376
|
appendMessage,
|
|
44359
|
-
query: (
|
|
44377
|
+
query: (_$ = widget.config) == null ? void 0 : _$.query,
|
|
44360
44378
|
isFirstLoad,
|
|
44361
44379
|
widgetBackendUrl,
|
|
44362
44380
|
widgetId: widget.id,
|
|
@@ -44787,6 +44805,24 @@ const loadAgentState$4 = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
44787
44805
|
return null;
|
|
44788
44806
|
}
|
|
44789
44807
|
};
|
|
44808
|
+
const loadSessionStateDirect$4 = async (widgetBackendUrl, sessionId) => {
|
|
44809
|
+
try {
|
|
44810
|
+
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
44811
|
+
method: "GET",
|
|
44812
|
+
headers: {
|
|
44813
|
+
"Content-Type": "application/json"
|
|
44814
|
+
}
|
|
44815
|
+
});
|
|
44816
|
+
if (!response.ok) {
|
|
44817
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
44818
|
+
}
|
|
44819
|
+
const result = await response.json();
|
|
44820
|
+
return result;
|
|
44821
|
+
} catch (error) {
|
|
44822
|
+
console.error("Failed to load session state directly:", error);
|
|
44823
|
+
return null;
|
|
44824
|
+
}
|
|
44825
|
+
};
|
|
44790
44826
|
const parseAndUpdateFilterState = (apiResponse, setFilterState) => {
|
|
44791
44827
|
var _a, _b;
|
|
44792
44828
|
try {
|
|
@@ -45243,7 +45279,7 @@ function CopilotKitFilters({
|
|
|
45243
45279
|
onApplyFilters,
|
|
45244
45280
|
isEditing = false
|
|
45245
45281
|
}) {
|
|
45246
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
45282
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
45247
45283
|
const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
|
|
45248
45284
|
const widget_data = (_b = widget.widget_data) == null ? void 0 : _b.column_values;
|
|
45249
45285
|
const { setThreadId } = useCopilotContext();
|
|
@@ -45261,17 +45297,15 @@ function CopilotKitFilters({
|
|
|
45261
45297
|
const [filterState, setFilterState] = useState(createInitialFilterState(datasetId, widget_data));
|
|
45262
45298
|
useEffect(() => {
|
|
45263
45299
|
const fetchInitialState = async () => {
|
|
45264
|
-
var _a2;
|
|
45265
45300
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
45266
45301
|
hasInitialFetchRef.current = true;
|
|
45267
|
-
const
|
|
45268
|
-
const apiResponse = await loadAgentState$4(widgetBackendUrl, widget.id, agentName);
|
|
45302
|
+
const apiResponse = await loadSessionStateDirect$4(widgetBackendUrl, widget.id);
|
|
45269
45303
|
if (apiResponse) {
|
|
45270
45304
|
parseAndUpdateFilterState(apiResponse, setFilterState);
|
|
45271
45305
|
}
|
|
45272
45306
|
};
|
|
45273
45307
|
fetchInitialState();
|
|
45274
|
-
}, [widgetBackendUrl, widget.id,
|
|
45308
|
+
}, [widgetBackendUrl, widget.id, setFilterState]);
|
|
45275
45309
|
const handleLoadingTimeout = useCallback(async () => {
|
|
45276
45310
|
var _a2;
|
|
45277
45311
|
if (!widgetBackendUrl || !widget.id || (filterState == null ? void 0 : filterState.agent_message) || hasTimeoutError) {
|
|
@@ -45295,7 +45329,7 @@ function CopilotKitFilters({
|
|
|
45295
45329
|
if (apiResponse && !(filterState == null ? void 0 : filterState.agent_message)) {
|
|
45296
45330
|
parseAndUpdateFilterState(apiResponse, setFilterState);
|
|
45297
45331
|
}
|
|
45298
|
-
}, [widgetBackendUrl, widget.id, setFilterState, (
|
|
45332
|
+
}, [widgetBackendUrl, widget.id, setFilterState, (_d = widget.config) == null ? void 0 : _d.agentName, filterState, apiCallCount, hasTimeoutError]);
|
|
45299
45333
|
const startLoadingTimeout = useCallback(() => {
|
|
45300
45334
|
if (timeoutRef.current) {
|
|
45301
45335
|
clearTimeout(timeoutRef.current);
|
|
@@ -45421,7 +45455,7 @@ function CopilotKitFilters({
|
|
|
45421
45455
|
setHasTimeoutError(false);
|
|
45422
45456
|
console.log("[FiltersWidget] Starting polling after confirmation");
|
|
45423
45457
|
startLoadingTimeout();
|
|
45424
|
-
}, [filterState.filter_columns, filterState.ambiguous_columns, (
|
|
45458
|
+
}, [filterState.filter_columns, filterState.ambiguous_columns, (_e = widget.config) == null ? void 0 : _e.query, datasetId, appendMessage, setFilterState, setAgentState, startLoadingTimeout, setApiCallCount, setHasTimeoutError]);
|
|
45425
45459
|
const handleCancelConfirmation = useCallback(() => {
|
|
45426
45460
|
setFilterState((prev) => __spreadProps$7(__spreadValues$9({}, prev), {
|
|
45427
45461
|
status: void 0,
|
|
@@ -45434,7 +45468,7 @@ function CopilotKitFilters({
|
|
|
45434
45468
|
console.log("[CopilotKitFilters] Filter state check:", {
|
|
45435
45469
|
status: filterState.status,
|
|
45436
45470
|
hasAmbiguousColumns: !!filterState.ambiguous_columns,
|
|
45437
|
-
ambiguousColumnsLength: ((
|
|
45471
|
+
ambiguousColumnsLength: ((_f = filterState.ambiguous_columns) == null ? void 0 : _f.length) || 0,
|
|
45438
45472
|
isWaitingForConfirmation,
|
|
45439
45473
|
fullFilterState: filterState
|
|
45440
45474
|
});
|
|
@@ -45450,7 +45484,7 @@ function CopilotKitFilters({
|
|
|
45450
45484
|
onCancel: handleCancelConfirmation
|
|
45451
45485
|
}
|
|
45452
45486
|
)
|
|
45453
|
-
) : (filterState == null ? void 0 : filterState.agent_message) && !((
|
|
45487
|
+
) : (filterState == null ? void 0 : filterState.agent_message) && !((_g = filterState.column_values) == null ? void 0 : _g.length) && filterState.status !== "waiting_for_confirmation" ? (
|
|
45454
45488
|
// Show agent message (errors, warnings, etc.)
|
|
45455
45489
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700 whitespace-pre-line", children: filterState.agent_message }) }) })
|
|
45456
45490
|
) : (
|
|
@@ -45463,7 +45497,7 @@ function CopilotKitFilters({
|
|
|
45463
45497
|
onFilterChange,
|
|
45464
45498
|
widget,
|
|
45465
45499
|
appendMessage,
|
|
45466
|
-
query: (
|
|
45500
|
+
query: (_h = widget.config) == null ? void 0 : _h.query,
|
|
45467
45501
|
isFirstLoad,
|
|
45468
45502
|
widgetBackendUrl,
|
|
45469
45503
|
widgetId: widget.id,
|
|
@@ -45602,6 +45636,24 @@ const loadAgentState$3 = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
45602
45636
|
return null;
|
|
45603
45637
|
}
|
|
45604
45638
|
};
|
|
45639
|
+
const loadSessionStateDirect$3 = async (widgetBackendUrl, sessionId) => {
|
|
45640
|
+
try {
|
|
45641
|
+
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
45642
|
+
method: "GET",
|
|
45643
|
+
headers: {
|
|
45644
|
+
"Content-Type": "application/json"
|
|
45645
|
+
}
|
|
45646
|
+
});
|
|
45647
|
+
if (!response.ok) {
|
|
45648
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
45649
|
+
}
|
|
45650
|
+
const result = await response.json();
|
|
45651
|
+
return result;
|
|
45652
|
+
} catch (error) {
|
|
45653
|
+
console.error("Failed to load session state directly:", error);
|
|
45654
|
+
return null;
|
|
45655
|
+
}
|
|
45656
|
+
};
|
|
45605
45657
|
const parseAndUpdateChartState$3 = (apiResponse, setChartState) => {
|
|
45606
45658
|
var _a, _b;
|
|
45607
45659
|
try {
|
|
@@ -45727,7 +45779,7 @@ function CopilotKitPieChart({
|
|
|
45727
45779
|
datasetId,
|
|
45728
45780
|
widgetData
|
|
45729
45781
|
}) {
|
|
45730
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p
|
|
45782
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
45731
45783
|
const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
|
|
45732
45784
|
const content = (_b = widget.config) == null ? void 0 : _b.content;
|
|
45733
45785
|
const widget_data = (_c = widget.widget_data) == null ? void 0 : _c.pie_chart_data;
|
|
@@ -45744,19 +45796,19 @@ function CopilotKitPieChart({
|
|
|
45744
45796
|
initialState: createInitialChartState$3(datasetId, widget_data)
|
|
45745
45797
|
});
|
|
45746
45798
|
const [chartState, setChartState] = useState(createInitialChartState$3(datasetId, widget_data));
|
|
45799
|
+
const [isInitialFetchComplete, setIsInitialFetchComplete] = useState(false);
|
|
45747
45800
|
useEffect(() => {
|
|
45748
45801
|
const fetchInitialState = async () => {
|
|
45749
|
-
var _a2;
|
|
45750
45802
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
45751
45803
|
hasInitialFetchRef.current = true;
|
|
45752
|
-
const
|
|
45753
|
-
const apiResponse = await loadAgentState$3(widgetBackendUrl, widget.id, agentName);
|
|
45804
|
+
const apiResponse = await loadSessionStateDirect$3(widgetBackendUrl, widget.id);
|
|
45754
45805
|
if (apiResponse) {
|
|
45755
45806
|
parseAndUpdateChartState$3(apiResponse, setChartState);
|
|
45756
45807
|
}
|
|
45808
|
+
setIsInitialFetchComplete(true);
|
|
45757
45809
|
};
|
|
45758
45810
|
fetchInitialState();
|
|
45759
|
-
}, [widgetBackendUrl, widget.id,
|
|
45811
|
+
}, [widgetBackendUrl, widget.id, setChartState]);
|
|
45760
45812
|
const handleLoadingTimeout = useCallback(async () => {
|
|
45761
45813
|
var _a2;
|
|
45762
45814
|
if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
|
|
@@ -45780,7 +45832,7 @@ function CopilotKitPieChart({
|
|
|
45780
45832
|
if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
|
|
45781
45833
|
parseAndUpdateChartState$3(apiResponse, setChartState);
|
|
45782
45834
|
}
|
|
45783
|
-
}, [widgetBackendUrl, widget.id, setChartState, (
|
|
45835
|
+
}, [widgetBackendUrl, widget.id, setChartState, (_e = widget.config) == null ? void 0 : _e.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
45784
45836
|
const startLoadingTimeout = useCallback(() => {
|
|
45785
45837
|
if (timeoutRef.current) {
|
|
45786
45838
|
clearTimeout(timeoutRef.current);
|
|
@@ -45854,20 +45906,20 @@ function CopilotKitPieChart({
|
|
|
45854
45906
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }),
|
|
45855
45907
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
|
|
45856
45908
|
] }) }),
|
|
45857
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((
|
|
45909
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: !isInitialFetchComplete && !isFirstLoad ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RefreshCw, { className: "h-6 w-6 animate-spin text-gray-400" }) }) : (chartState == null ? void 0 : chartState.agent_message) && (!((_h = (_g = (_f = chartState.pie_chart_data) == null ? void 0 : _f.data) == null ? void 0 : _g.labels) == null ? void 0 : _h.length) || !((_k = (_j = (_i = chartState.pie_chart_data) == null ? void 0 : _i.data) == null ? void 0 : _j.values) == null ? void 0 : _k.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
45858
45910
|
PieChartComponent,
|
|
45859
45911
|
{
|
|
45860
45912
|
pieChartState: chartState,
|
|
45861
45913
|
styles,
|
|
45862
45914
|
appendMessage,
|
|
45863
45915
|
content,
|
|
45864
|
-
query: (
|
|
45916
|
+
query: (_l = widget.config) == null ? void 0 : _l.query,
|
|
45865
45917
|
isFirstLoad,
|
|
45866
45918
|
widgetBackendUrl,
|
|
45867
45919
|
widgetId: widget.id,
|
|
45868
45920
|
startLoadingTimeout,
|
|
45869
45921
|
clearLoadingTimeout,
|
|
45870
|
-
hasWidgetData: !!(((
|
|
45922
|
+
hasWidgetData: !!(((_n = (_m = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _m.labels) == null ? void 0 : _n.length) && ((_p = (_o = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _o.values) == null ? void 0 : _p.length))
|
|
45871
45923
|
}
|
|
45872
45924
|
) })
|
|
45873
45925
|
] });
|
|
@@ -46016,6 +46068,24 @@ const loadAgentState$2 = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
46016
46068
|
return null;
|
|
46017
46069
|
}
|
|
46018
46070
|
};
|
|
46071
|
+
const loadSessionStateDirect$2 = async (widgetBackendUrl, sessionId) => {
|
|
46072
|
+
try {
|
|
46073
|
+
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
46074
|
+
method: "GET",
|
|
46075
|
+
headers: {
|
|
46076
|
+
"Content-Type": "application/json"
|
|
46077
|
+
}
|
|
46078
|
+
});
|
|
46079
|
+
if (!response.ok) {
|
|
46080
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
46081
|
+
}
|
|
46082
|
+
const result = await response.json();
|
|
46083
|
+
return result;
|
|
46084
|
+
} catch (error) {
|
|
46085
|
+
console.error("Failed to load session state directly:", error);
|
|
46086
|
+
return null;
|
|
46087
|
+
}
|
|
46088
|
+
};
|
|
46019
46089
|
const parseAndUpdateChartState$2 = (apiResponse, setChartState) => {
|
|
46020
46090
|
var _a, _b;
|
|
46021
46091
|
try {
|
|
@@ -46150,7 +46220,7 @@ function CopilotKitSeriesBarChart$1({
|
|
|
46150
46220
|
datasetId,
|
|
46151
46221
|
widgetData
|
|
46152
46222
|
}) {
|
|
46153
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q
|
|
46223
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
46154
46224
|
const orientation = ((_a = widget.config) == null ? void 0 : _a.orientation) || "vertical";
|
|
46155
46225
|
const isFirstLoad = (_b = widget.config) == null ? void 0 : _b.isFirstLoad;
|
|
46156
46226
|
const content = (_c = widget.config) == null ? void 0 : _c.content;
|
|
@@ -46168,19 +46238,19 @@ function CopilotKitSeriesBarChart$1({
|
|
|
46168
46238
|
initialState: createInitialChartState$2(datasetId, widget_data)
|
|
46169
46239
|
});
|
|
46170
46240
|
const [chartState, setChartState] = useState(createInitialChartState$2(datasetId, widget_data));
|
|
46241
|
+
const [isInitialFetchComplete, setIsInitialFetchComplete] = useState(false);
|
|
46171
46242
|
useEffect(() => {
|
|
46172
46243
|
const fetchInitialState = async () => {
|
|
46173
|
-
var _a2;
|
|
46174
46244
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
46175
46245
|
hasInitialFetchRef.current = true;
|
|
46176
|
-
const
|
|
46177
|
-
const apiResponse = await loadAgentState$2(widgetBackendUrl, widget.id, agentName);
|
|
46246
|
+
const apiResponse = await loadSessionStateDirect$2(widgetBackendUrl, widget.id);
|
|
46178
46247
|
if (apiResponse) {
|
|
46179
46248
|
parseAndUpdateChartState$2(apiResponse, setChartState);
|
|
46180
46249
|
}
|
|
46250
|
+
setIsInitialFetchComplete(true);
|
|
46181
46251
|
};
|
|
46182
46252
|
fetchInitialState();
|
|
46183
|
-
}, [widgetBackendUrl, widget.id,
|
|
46253
|
+
}, [widgetBackendUrl, widget.id, setChartState]);
|
|
46184
46254
|
const handleLoadingTimeout = useCallback(async () => {
|
|
46185
46255
|
var _a2;
|
|
46186
46256
|
if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
|
|
@@ -46204,7 +46274,7 @@ function CopilotKitSeriesBarChart$1({
|
|
|
46204
46274
|
if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
|
|
46205
46275
|
parseAndUpdateChartState$2(apiResponse, setChartState);
|
|
46206
46276
|
}
|
|
46207
|
-
}, [widgetBackendUrl, widget.id, setChartState, (
|
|
46277
|
+
}, [widgetBackendUrl, widget.id, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
46208
46278
|
const startLoadingTimeout = useCallback(() => {
|
|
46209
46279
|
if (timeoutRef.current) {
|
|
46210
46280
|
clearTimeout(timeoutRef.current);
|
|
@@ -46278,7 +46348,7 @@ function CopilotKitSeriesBarChart$1({
|
|
|
46278
46348
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }),
|
|
46279
46349
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
|
|
46280
46350
|
] }) }),
|
|
46281
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((
|
|
46351
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: !isInitialFetchComplete && !isFirstLoad ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RefreshCw, { className: "h-6 w-6 animate-spin text-gray-400" }) }) : (chartState == null ? void 0 : chartState.agent_message) && (!((_i = (_h = (_g = chartState.series_bar_chart_data) == null ? void 0 : _g.data) == null ? void 0 : _h.labels) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.series_bar_chart_data) == null ? void 0 : _j.data) == null ? void 0 : _k.series) == null ? void 0 : _l.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
46282
46352
|
SeriesBarChartComponent$1,
|
|
46283
46353
|
{
|
|
46284
46354
|
orientation,
|
|
@@ -46286,13 +46356,13 @@ function CopilotKitSeriesBarChart$1({
|
|
|
46286
46356
|
styles,
|
|
46287
46357
|
appendMessage,
|
|
46288
46358
|
content,
|
|
46289
|
-
query: (
|
|
46359
|
+
query: (_m = widget.config) == null ? void 0 : _m.query,
|
|
46290
46360
|
isFirstLoad,
|
|
46291
46361
|
widgetBackendUrl,
|
|
46292
46362
|
widgetId: widget.id,
|
|
46293
46363
|
startLoadingTimeout,
|
|
46294
46364
|
clearLoadingTimeout,
|
|
46295
|
-
hasWidgetData: !!(((
|
|
46365
|
+
hasWidgetData: !!(((_o = (_n = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _n.labels) == null ? void 0 : _o.length) && ((_q = (_p = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _p.series) == null ? void 0 : _q.length))
|
|
46296
46366
|
}
|
|
46297
46367
|
) })
|
|
46298
46368
|
] });
|
|
@@ -46441,6 +46511,24 @@ const loadAgentState$1 = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
46441
46511
|
return null;
|
|
46442
46512
|
}
|
|
46443
46513
|
};
|
|
46514
|
+
const loadSessionStateDirect$1 = async (widgetBackendUrl, sessionId) => {
|
|
46515
|
+
try {
|
|
46516
|
+
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
46517
|
+
method: "GET",
|
|
46518
|
+
headers: {
|
|
46519
|
+
"Content-Type": "application/json"
|
|
46520
|
+
}
|
|
46521
|
+
});
|
|
46522
|
+
if (!response.ok) {
|
|
46523
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
46524
|
+
}
|
|
46525
|
+
const result = await response.json();
|
|
46526
|
+
return result;
|
|
46527
|
+
} catch (error) {
|
|
46528
|
+
console.error("Failed to load session state directly:", error);
|
|
46529
|
+
return null;
|
|
46530
|
+
}
|
|
46531
|
+
};
|
|
46444
46532
|
const parseAndUpdateChartState$1 = (apiResponse, setChartState) => {
|
|
46445
46533
|
var _a, _b;
|
|
46446
46534
|
try {
|
|
@@ -46575,7 +46663,7 @@ function CopilotKitSeriesBarChart({
|
|
|
46575
46663
|
datasetId,
|
|
46576
46664
|
widgetData
|
|
46577
46665
|
}) {
|
|
46578
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q
|
|
46666
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
46579
46667
|
const orientation = ((_a = widget.config) == null ? void 0 : _a.orientation) || "vertical";
|
|
46580
46668
|
const isFirstLoad = (_b = widget.config) == null ? void 0 : _b.isFirstLoad;
|
|
46581
46669
|
const content = (_c = widget.config) == null ? void 0 : _c.content;
|
|
@@ -46593,19 +46681,19 @@ function CopilotKitSeriesBarChart({
|
|
|
46593
46681
|
initialState: createInitialChartState$1(datasetId, widget_data)
|
|
46594
46682
|
});
|
|
46595
46683
|
const [chartState, setChartState] = useState(createInitialChartState$1(datasetId, widget_data));
|
|
46684
|
+
const [isInitialFetchComplete, setIsInitialFetchComplete] = useState(false);
|
|
46596
46685
|
useEffect(() => {
|
|
46597
46686
|
const fetchInitialState = async () => {
|
|
46598
|
-
var _a2;
|
|
46599
46687
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
46600
46688
|
hasInitialFetchRef.current = true;
|
|
46601
|
-
const
|
|
46602
|
-
const apiResponse = await loadAgentState$1(widgetBackendUrl, widget.id, agentName);
|
|
46689
|
+
const apiResponse = await loadSessionStateDirect$1(widgetBackendUrl, widget.id);
|
|
46603
46690
|
if (apiResponse) {
|
|
46604
46691
|
parseAndUpdateChartState$1(apiResponse, setChartState);
|
|
46605
46692
|
}
|
|
46693
|
+
setIsInitialFetchComplete(true);
|
|
46606
46694
|
};
|
|
46607
46695
|
fetchInitialState();
|
|
46608
|
-
}, [widgetBackendUrl, widget.id,
|
|
46696
|
+
}, [widgetBackendUrl, widget.id, setChartState]);
|
|
46609
46697
|
const handleLoadingTimeout = useCallback(async () => {
|
|
46610
46698
|
var _a2;
|
|
46611
46699
|
if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
|
|
@@ -46629,7 +46717,7 @@ function CopilotKitSeriesBarChart({
|
|
|
46629
46717
|
if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
|
|
46630
46718
|
parseAndUpdateChartState$1(apiResponse, setChartState);
|
|
46631
46719
|
}
|
|
46632
|
-
}, [widgetBackendUrl, widget.id, setChartState, (
|
|
46720
|
+
}, [widgetBackendUrl, widget.id, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
46633
46721
|
const startLoadingTimeout = useCallback(() => {
|
|
46634
46722
|
if (timeoutRef.current) {
|
|
46635
46723
|
clearTimeout(timeoutRef.current);
|
|
@@ -46703,7 +46791,7 @@ function CopilotKitSeriesBarChart({
|
|
|
46703
46791
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }),
|
|
46704
46792
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
|
|
46705
46793
|
] }) }),
|
|
46706
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((
|
|
46794
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: !isInitialFetchComplete && !isFirstLoad ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RefreshCw, { className: "h-6 w-6 animate-spin text-gray-400" }) }) : (chartState == null ? void 0 : chartState.agent_message) && (!((_i = (_h = (_g = chartState.series_bar_chart_data) == null ? void 0 : _g.data) == null ? void 0 : _h.labels) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.series_bar_chart_data) == null ? void 0 : _j.data) == null ? void 0 : _k.series) == null ? void 0 : _l.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
46707
46795
|
SeriesBarChartComponent,
|
|
46708
46796
|
{
|
|
46709
46797
|
orientation,
|
|
@@ -46711,13 +46799,13 @@ function CopilotKitSeriesBarChart({
|
|
|
46711
46799
|
styles,
|
|
46712
46800
|
appendMessage,
|
|
46713
46801
|
content,
|
|
46714
|
-
query: (
|
|
46802
|
+
query: (_m = widget.config) == null ? void 0 : _m.query,
|
|
46715
46803
|
isFirstLoad,
|
|
46716
46804
|
widgetBackendUrl,
|
|
46717
46805
|
widgetId: widget.id,
|
|
46718
46806
|
startLoadingTimeout,
|
|
46719
46807
|
clearLoadingTimeout,
|
|
46720
|
-
hasWidgetData: !!(((
|
|
46808
|
+
hasWidgetData: !!(((_o = (_n = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _n.labels) == null ? void 0 : _o.length) && ((_q = (_p = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _p.series) == null ? void 0 : _q.length))
|
|
46721
46809
|
}
|
|
46722
46810
|
) })
|
|
46723
46811
|
] });
|
|
@@ -46856,6 +46944,24 @@ const loadAgentState = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
46856
46944
|
return null;
|
|
46857
46945
|
}
|
|
46858
46946
|
};
|
|
46947
|
+
const loadSessionStateDirect = async (widgetBackendUrl, sessionId) => {
|
|
46948
|
+
try {
|
|
46949
|
+
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
46950
|
+
method: "GET",
|
|
46951
|
+
headers: {
|
|
46952
|
+
"Content-Type": "application/json"
|
|
46953
|
+
}
|
|
46954
|
+
});
|
|
46955
|
+
if (!response.ok) {
|
|
46956
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
46957
|
+
}
|
|
46958
|
+
const result = await response.json();
|
|
46959
|
+
return result;
|
|
46960
|
+
} catch (error) {
|
|
46961
|
+
console.error("Failed to load session state directly:", error);
|
|
46962
|
+
return null;
|
|
46963
|
+
}
|
|
46964
|
+
};
|
|
46859
46965
|
const parseAndUpdateChartState = (apiResponse, setChartState) => {
|
|
46860
46966
|
var _a, _b;
|
|
46861
46967
|
try {
|
|
@@ -46972,7 +47078,7 @@ function CopilotKitDataGrid({
|
|
|
46972
47078
|
datasetId,
|
|
46973
47079
|
widgetData
|
|
46974
47080
|
}) {
|
|
46975
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p
|
|
47081
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
46976
47082
|
const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
|
|
46977
47083
|
const content = (_b = widget.config) == null ? void 0 : _b.content;
|
|
46978
47084
|
const widget_data = (_c = widget.widget_data) == null ? void 0 : _c.matrix_grid_data;
|
|
@@ -46989,19 +47095,19 @@ function CopilotKitDataGrid({
|
|
|
46989
47095
|
initialState: createInitialChartState(datasetId, widget_data)
|
|
46990
47096
|
});
|
|
46991
47097
|
const [chartState, setChartState] = useState(createInitialChartState(datasetId, widget_data));
|
|
47098
|
+
const [isInitialFetchComplete, setIsInitialFetchComplete] = useState(false);
|
|
46992
47099
|
useEffect(() => {
|
|
46993
47100
|
const fetchInitialState = async () => {
|
|
46994
|
-
var _a2;
|
|
46995
47101
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
46996
47102
|
hasInitialFetchRef.current = true;
|
|
46997
|
-
const
|
|
46998
|
-
const apiResponse = await loadAgentState(widgetBackendUrl, widget.id, agentName);
|
|
47103
|
+
const apiResponse = await loadSessionStateDirect(widgetBackendUrl, widget.id);
|
|
46999
47104
|
if (apiResponse) {
|
|
47000
47105
|
parseAndUpdateChartState(apiResponse, setChartState);
|
|
47001
47106
|
}
|
|
47107
|
+
setIsInitialFetchComplete(true);
|
|
47002
47108
|
};
|
|
47003
47109
|
fetchInitialState();
|
|
47004
|
-
}, [widgetBackendUrl, widget.id,
|
|
47110
|
+
}, [widgetBackendUrl, widget.id, setChartState]);
|
|
47005
47111
|
const handleLoadingTimeout = useCallback(async () => {
|
|
47006
47112
|
var _a2;
|
|
47007
47113
|
if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
|
|
@@ -47025,7 +47131,7 @@ function CopilotKitDataGrid({
|
|
|
47025
47131
|
if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
|
|
47026
47132
|
parseAndUpdateChartState(apiResponse, setChartState);
|
|
47027
47133
|
}
|
|
47028
|
-
}, [widgetBackendUrl, widget.id, setChartState, (
|
|
47134
|
+
}, [widgetBackendUrl, widget.id, setChartState, (_e = widget.config) == null ? void 0 : _e.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
47029
47135
|
const startLoadingTimeout = useCallback(() => {
|
|
47030
47136
|
if (timeoutRef.current) {
|
|
47031
47137
|
clearTimeout(timeoutRef.current);
|
|
@@ -47099,20 +47205,20 @@ function CopilotKitDataGrid({
|
|
|
47099
47205
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }),
|
|
47100
47206
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
|
|
47101
47207
|
] }) }),
|
|
47102
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((
|
|
47208
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: !isInitialFetchComplete && !isFirstLoad ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RefreshCw, { className: "h-6 w-6 animate-spin text-gray-400" }) }) : (chartState == null ? void 0 : chartState.agent_message) && (!((_h = (_g = (_f = chartState.matrix_grid_data) == null ? void 0 : _f.data) == null ? void 0 : _g.headers) == null ? void 0 : _h.length) || !((_k = (_j = (_i = chartState.matrix_grid_data) == null ? void 0 : _i.data) == null ? void 0 : _j.rows) == null ? void 0 : _k.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
47103
47209
|
DataGridComponent,
|
|
47104
47210
|
{
|
|
47105
47211
|
dataGridState: chartState,
|
|
47106
47212
|
styles,
|
|
47107
47213
|
appendMessage,
|
|
47108
47214
|
content,
|
|
47109
|
-
query: (
|
|
47215
|
+
query: (_l = widget.config) == null ? void 0 : _l.query,
|
|
47110
47216
|
isFirstLoad,
|
|
47111
47217
|
widgetBackendUrl,
|
|
47112
47218
|
widgetId: widget.id,
|
|
47113
47219
|
startLoadingTimeout,
|
|
47114
47220
|
clearLoadingTimeout,
|
|
47115
|
-
hasWidgetData: !!(((
|
|
47221
|
+
hasWidgetData: !!(((_n = (_m = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _m.headers) == null ? void 0 : _n.length) && ((_p = (_o = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _o.rows) == null ? void 0 : _p.length))
|
|
47116
47222
|
}
|
|
47117
47223
|
) })
|
|
47118
47224
|
] });
|
package/dist/index.js
CHANGED
|
@@ -43634,6 +43634,24 @@ const loadAgentState$5 = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
43634
43634
|
return null;
|
|
43635
43635
|
}
|
|
43636
43636
|
};
|
|
43637
|
+
const loadSessionStateDirect$5 = async (widgetBackendUrl, sessionId) => {
|
|
43638
|
+
try {
|
|
43639
|
+
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
43640
|
+
method: "GET",
|
|
43641
|
+
headers: {
|
|
43642
|
+
"Content-Type": "application/json"
|
|
43643
|
+
}
|
|
43644
|
+
});
|
|
43645
|
+
if (!response.ok) {
|
|
43646
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
43647
|
+
}
|
|
43648
|
+
const result = await response.json();
|
|
43649
|
+
return result;
|
|
43650
|
+
} catch (error) {
|
|
43651
|
+
console.error("Failed to load session state directly:", error);
|
|
43652
|
+
return null;
|
|
43653
|
+
}
|
|
43654
|
+
};
|
|
43637
43655
|
const parseAndUpdateChartState$4 = (apiResponse, setChartState) => {
|
|
43638
43656
|
var _a, _b;
|
|
43639
43657
|
try {
|
|
@@ -44158,7 +44176,7 @@ function CopilotKitAgent({
|
|
|
44158
44176
|
datasetId,
|
|
44159
44177
|
widgetData
|
|
44160
44178
|
}) {
|
|
44161
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _
|
|
44179
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$;
|
|
44162
44180
|
const agentType = (_a = widget.config) == null ? void 0 : _a.agentType;
|
|
44163
44181
|
const orientation = (_b = widget.config) == null ? void 0 : _b.orientation;
|
|
44164
44182
|
const isFirstLoad = (_c = widget.config) == null ? void 0 : _c.isFirstLoad;
|
|
@@ -44169,6 +44187,7 @@ function CopilotKitAgent({
|
|
|
44169
44187
|
const [apiCallCount, setApiCallCount] = React.useState(0);
|
|
44170
44188
|
const [hasTimeoutError, setHasTimeoutError] = React.useState(false);
|
|
44171
44189
|
const hasInitialFetchRef = React.useRef(false);
|
|
44190
|
+
const [isInitialFetchComplete, setIsInitialFetchComplete] = React.useState(false);
|
|
44172
44191
|
React.useEffect(() => {
|
|
44173
44192
|
setThreadId(widget.id);
|
|
44174
44193
|
}, [widget.id, setThreadId]);
|
|
@@ -44178,17 +44197,16 @@ function CopilotKitAgent({
|
|
|
44178
44197
|
});
|
|
44179
44198
|
React.useEffect(() => {
|
|
44180
44199
|
const fetchInitialState = async () => {
|
|
44181
|
-
var _a2;
|
|
44182
44200
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
44183
44201
|
hasInitialFetchRef.current = true;
|
|
44184
|
-
const
|
|
44185
|
-
const apiResponse = await loadAgentState$5(widgetBackendUrl, widget.id, agentName);
|
|
44202
|
+
const apiResponse = await loadSessionStateDirect$5(widgetBackendUrl, widget.id);
|
|
44186
44203
|
if (apiResponse) {
|
|
44187
44204
|
parseAndUpdateChartState$4(apiResponse, setChartState);
|
|
44188
44205
|
}
|
|
44206
|
+
setIsInitialFetchComplete(true);
|
|
44189
44207
|
};
|
|
44190
44208
|
fetchInitialState();
|
|
44191
|
-
}, [widgetBackendUrl, widget.id,
|
|
44209
|
+
}, [widgetBackendUrl, widget.id, setChartState]);
|
|
44192
44210
|
const handleLoadingTimeout = React.useCallback(async () => {
|
|
44193
44211
|
var _a2;
|
|
44194
44212
|
if (!widgetBackendUrl || !widget.id || isTimeoutTriggered || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) return;
|
|
@@ -44208,7 +44226,7 @@ function CopilotKitAgent({
|
|
|
44208
44226
|
if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
|
|
44209
44227
|
parseAndUpdateChartState$4(apiResponse, setChartState);
|
|
44210
44228
|
}
|
|
44211
|
-
}, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (
|
|
44229
|
+
}, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
44212
44230
|
const startLoadingTimeout = React.useCallback(() => {
|
|
44213
44231
|
if (timeoutRef.current) {
|
|
44214
44232
|
clearTimeout(timeoutRef.current);
|
|
@@ -44291,8 +44309,8 @@ function CopilotKitAgent({
|
|
|
44291
44309
|
/* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.Bot, { className: "h-4 w-4" }),
|
|
44292
44310
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
|
|
44293
44311
|
] }) }),
|
|
44294
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && agentType !== "chatbot" && // Check if data is empty based on agent type
|
|
44295
|
-
(agentType === "Bar Chart Agent" && (!((
|
|
44312
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: !isInitialFetchComplete && !isFirstLoad ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.RefreshCw, { className: "h-6 w-6 animate-spin text-gray-400" }) }) : (chartState == null ? void 0 : chartState.agent_message) && agentType !== "chatbot" && // Check if data is empty based on agent type
|
|
44313
|
+
(agentType === "Bar Chart Agent" && (!((_i = (_h = (_g = chartState.bar_chart_data) == null ? void 0 : _g.data) == null ? void 0 : _h.labels) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.bar_chart_data) == null ? void 0 : _j.data) == null ? void 0 : _k.values) == null ? void 0 : _l.length)) || agentType === "Series Bar Chart Agent" && (!((_o = (_n = (_m = chartState.series_bar_chart_data) == null ? void 0 : _m.data) == null ? void 0 : _n.labels) == null ? void 0 : _o.length) || !((_r = (_q = (_p = chartState.series_bar_chart_data) == null ? void 0 : _p.data) == null ? void 0 : _q.series) == null ? void 0 : _r.length)) || agentType === "Series Line Chart Agent" && (!((_u = (_t = (_s = chartState.series_bar_chart_data) == null ? void 0 : _s.data) == null ? void 0 : _t.labels) == null ? void 0 : _u.length) || !((_x = (_w = (_v = chartState.series_bar_chart_data) == null ? void 0 : _v.data) == null ? void 0 : _w.series) == null ? void 0 : _x.length)) || agentType === "Pie Chart Agent" && (!((_A = (_z = (_y = chartState.pie_chart_data) == null ? void 0 : _y.data) == null ? void 0 : _z.labels) == null ? void 0 : _A.length) || !((_D = (_C = (_B = chartState.pie_chart_data) == null ? void 0 : _B.data) == null ? void 0 : _C.values) == null ? void 0 : _D.length)) || agentType === "Line Chart Agent" && (!((_G = (_F = (_E = chartState.bar_chart_data) == null ? void 0 : _E.data) == null ? void 0 : _F.labels) == null ? void 0 : _G.length) || !((_J = (_I = (_H = chartState.bar_chart_data) == null ? void 0 : _H.data) == null ? void 0 : _I.values) == null ? void 0 : _J.length)) || agentType === "Data Grid Agent" && (!((_M = (_L = (_K = chartState.matrix_grid_data) == null ? void 0 : _K.data) == null ? void 0 : _L.headers) == null ? void 0 : _M.length) || !((_P = (_O = (_N = chartState.matrix_grid_data) == null ? void 0 : _N.data) == null ? void 0 : _O.rows) == null ? void 0 : _P.length)) || agentType === "Summary Agent" && (!((_R = (_Q = chartState.summary_data) == null ? void 0 : _Q.data) == null ? void 0 : _R.content) || ((_U = (_T = (_S = chartState.summary_data) == null ? void 0 : _S.data) == null ? void 0 : _T.content) == null ? void 0 : _U.trim()) === "")) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : agentType === "Bar Chart Agent" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
44296
44314
|
BarChartComponent,
|
|
44297
44315
|
{
|
|
44298
44316
|
barChartState: chartState,
|
|
@@ -44300,7 +44318,7 @@ function CopilotKitAgent({
|
|
|
44300
44318
|
orientation,
|
|
44301
44319
|
content,
|
|
44302
44320
|
appendMessage,
|
|
44303
|
-
query: (
|
|
44321
|
+
query: (_V = widget.config) == null ? void 0 : _V.query,
|
|
44304
44322
|
isFirstLoad,
|
|
44305
44323
|
widgetBackendUrl,
|
|
44306
44324
|
widgetId: widget.id,
|
|
@@ -44315,7 +44333,7 @@ function CopilotKitAgent({
|
|
|
44315
44333
|
orientation,
|
|
44316
44334
|
content,
|
|
44317
44335
|
appendMessage,
|
|
44318
|
-
query: (
|
|
44336
|
+
query: (_W = widget.config) == null ? void 0 : _W.query,
|
|
44319
44337
|
isFirstLoad,
|
|
44320
44338
|
widgetBackendUrl,
|
|
44321
44339
|
widgetId: widget.id,
|
|
@@ -44330,7 +44348,7 @@ function CopilotKitAgent({
|
|
|
44330
44348
|
orientation,
|
|
44331
44349
|
content,
|
|
44332
44350
|
appendMessage,
|
|
44333
|
-
query: (
|
|
44351
|
+
query: (_X = widget.config) == null ? void 0 : _X.query,
|
|
44334
44352
|
isFirstLoad,
|
|
44335
44353
|
widgetBackendUrl,
|
|
44336
44354
|
widgetId: widget.id,
|
|
@@ -44344,7 +44362,7 @@ function CopilotKitAgent({
|
|
|
44344
44362
|
styles,
|
|
44345
44363
|
appendMessage,
|
|
44346
44364
|
content,
|
|
44347
|
-
query: (
|
|
44365
|
+
query: (_Y = widget.config) == null ? void 0 : _Y.query,
|
|
44348
44366
|
isFirstLoad,
|
|
44349
44367
|
widgetBackendUrl,
|
|
44350
44368
|
widgetId: widget.id,
|
|
@@ -44358,7 +44376,7 @@ function CopilotKitAgent({
|
|
|
44358
44376
|
styles,
|
|
44359
44377
|
appendMessage,
|
|
44360
44378
|
content,
|
|
44361
|
-
query: (
|
|
44379
|
+
query: (_Z = widget.config) == null ? void 0 : _Z.query,
|
|
44362
44380
|
isFirstLoad,
|
|
44363
44381
|
widgetBackendUrl,
|
|
44364
44382
|
widgetId: widget.id,
|
|
@@ -44371,7 +44389,7 @@ function CopilotKitAgent({
|
|
|
44371
44389
|
dataGridState: chartState,
|
|
44372
44390
|
styles,
|
|
44373
44391
|
appendMessage,
|
|
44374
|
-
query: (
|
|
44392
|
+
query: (__ = widget.config) == null ? void 0 : __.query,
|
|
44375
44393
|
isFirstLoad,
|
|
44376
44394
|
widgetBackendUrl,
|
|
44377
44395
|
widgetId: widget.id,
|
|
@@ -44384,7 +44402,7 @@ function CopilotKitAgent({
|
|
|
44384
44402
|
summaryState: chartState,
|
|
44385
44403
|
styles,
|
|
44386
44404
|
appendMessage,
|
|
44387
|
-
query: (
|
|
44405
|
+
query: (_$ = widget.config) == null ? void 0 : _$.query,
|
|
44388
44406
|
isFirstLoad,
|
|
44389
44407
|
widgetBackendUrl,
|
|
44390
44408
|
widgetId: widget.id,
|
|
@@ -44815,6 +44833,24 @@ const loadAgentState$4 = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
44815
44833
|
return null;
|
|
44816
44834
|
}
|
|
44817
44835
|
};
|
|
44836
|
+
const loadSessionStateDirect$4 = async (widgetBackendUrl, sessionId) => {
|
|
44837
|
+
try {
|
|
44838
|
+
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
44839
|
+
method: "GET",
|
|
44840
|
+
headers: {
|
|
44841
|
+
"Content-Type": "application/json"
|
|
44842
|
+
}
|
|
44843
|
+
});
|
|
44844
|
+
if (!response.ok) {
|
|
44845
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
44846
|
+
}
|
|
44847
|
+
const result = await response.json();
|
|
44848
|
+
return result;
|
|
44849
|
+
} catch (error) {
|
|
44850
|
+
console.error("Failed to load session state directly:", error);
|
|
44851
|
+
return null;
|
|
44852
|
+
}
|
|
44853
|
+
};
|
|
44818
44854
|
const parseAndUpdateFilterState = (apiResponse, setFilterState) => {
|
|
44819
44855
|
var _a, _b;
|
|
44820
44856
|
try {
|
|
@@ -45271,7 +45307,7 @@ function CopilotKitFilters({
|
|
|
45271
45307
|
onApplyFilters,
|
|
45272
45308
|
isEditing = false
|
|
45273
45309
|
}) {
|
|
45274
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
45310
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
45275
45311
|
const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
|
|
45276
45312
|
const widget_data = (_b = widget.widget_data) == null ? void 0 : _b.column_values;
|
|
45277
45313
|
const { setThreadId } = reactCore.useCopilotContext();
|
|
@@ -45289,17 +45325,15 @@ function CopilotKitFilters({
|
|
|
45289
45325
|
const [filterState, setFilterState] = React.useState(createInitialFilterState(datasetId, widget_data));
|
|
45290
45326
|
React.useEffect(() => {
|
|
45291
45327
|
const fetchInitialState = async () => {
|
|
45292
|
-
var _a2;
|
|
45293
45328
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
45294
45329
|
hasInitialFetchRef.current = true;
|
|
45295
|
-
const
|
|
45296
|
-
const apiResponse = await loadAgentState$4(widgetBackendUrl, widget.id, agentName);
|
|
45330
|
+
const apiResponse = await loadSessionStateDirect$4(widgetBackendUrl, widget.id);
|
|
45297
45331
|
if (apiResponse) {
|
|
45298
45332
|
parseAndUpdateFilterState(apiResponse, setFilterState);
|
|
45299
45333
|
}
|
|
45300
45334
|
};
|
|
45301
45335
|
fetchInitialState();
|
|
45302
|
-
}, [widgetBackendUrl, widget.id,
|
|
45336
|
+
}, [widgetBackendUrl, widget.id, setFilterState]);
|
|
45303
45337
|
const handleLoadingTimeout = React.useCallback(async () => {
|
|
45304
45338
|
var _a2;
|
|
45305
45339
|
if (!widgetBackendUrl || !widget.id || (filterState == null ? void 0 : filterState.agent_message) || hasTimeoutError) {
|
|
@@ -45323,7 +45357,7 @@ function CopilotKitFilters({
|
|
|
45323
45357
|
if (apiResponse && !(filterState == null ? void 0 : filterState.agent_message)) {
|
|
45324
45358
|
parseAndUpdateFilterState(apiResponse, setFilterState);
|
|
45325
45359
|
}
|
|
45326
|
-
}, [widgetBackendUrl, widget.id, setFilterState, (
|
|
45360
|
+
}, [widgetBackendUrl, widget.id, setFilterState, (_d = widget.config) == null ? void 0 : _d.agentName, filterState, apiCallCount, hasTimeoutError]);
|
|
45327
45361
|
const startLoadingTimeout = React.useCallback(() => {
|
|
45328
45362
|
if (timeoutRef.current) {
|
|
45329
45363
|
clearTimeout(timeoutRef.current);
|
|
@@ -45449,7 +45483,7 @@ function CopilotKitFilters({
|
|
|
45449
45483
|
setHasTimeoutError(false);
|
|
45450
45484
|
console.log("[FiltersWidget] Starting polling after confirmation");
|
|
45451
45485
|
startLoadingTimeout();
|
|
45452
|
-
}, [filterState.filter_columns, filterState.ambiguous_columns, (
|
|
45486
|
+
}, [filterState.filter_columns, filterState.ambiguous_columns, (_e = widget.config) == null ? void 0 : _e.query, datasetId, appendMessage, setFilterState, setAgentState, startLoadingTimeout, setApiCallCount, setHasTimeoutError]);
|
|
45453
45487
|
const handleCancelConfirmation = React.useCallback(() => {
|
|
45454
45488
|
setFilterState((prev) => __spreadProps$7(__spreadValues$9({}, prev), {
|
|
45455
45489
|
status: void 0,
|
|
@@ -45462,7 +45496,7 @@ function CopilotKitFilters({
|
|
|
45462
45496
|
console.log("[CopilotKitFilters] Filter state check:", {
|
|
45463
45497
|
status: filterState.status,
|
|
45464
45498
|
hasAmbiguousColumns: !!filterState.ambiguous_columns,
|
|
45465
|
-
ambiguousColumnsLength: ((
|
|
45499
|
+
ambiguousColumnsLength: ((_f = filterState.ambiguous_columns) == null ? void 0 : _f.length) || 0,
|
|
45466
45500
|
isWaitingForConfirmation,
|
|
45467
45501
|
fullFilterState: filterState
|
|
45468
45502
|
});
|
|
@@ -45478,7 +45512,7 @@ function CopilotKitFilters({
|
|
|
45478
45512
|
onCancel: handleCancelConfirmation
|
|
45479
45513
|
}
|
|
45480
45514
|
)
|
|
45481
|
-
) : (filterState == null ? void 0 : filterState.agent_message) && !((
|
|
45515
|
+
) : (filterState == null ? void 0 : filterState.agent_message) && !((_g = filterState.column_values) == null ? void 0 : _g.length) && filterState.status !== "waiting_for_confirmation" ? (
|
|
45482
45516
|
// Show agent message (errors, warnings, etc.)
|
|
45483
45517
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700 whitespace-pre-line", children: filterState.agent_message }) }) })
|
|
45484
45518
|
) : (
|
|
@@ -45491,7 +45525,7 @@ function CopilotKitFilters({
|
|
|
45491
45525
|
onFilterChange,
|
|
45492
45526
|
widget,
|
|
45493
45527
|
appendMessage,
|
|
45494
|
-
query: (
|
|
45528
|
+
query: (_h = widget.config) == null ? void 0 : _h.query,
|
|
45495
45529
|
isFirstLoad,
|
|
45496
45530
|
widgetBackendUrl,
|
|
45497
45531
|
widgetId: widget.id,
|
|
@@ -45630,6 +45664,24 @@ const loadAgentState$3 = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
45630
45664
|
return null;
|
|
45631
45665
|
}
|
|
45632
45666
|
};
|
|
45667
|
+
const loadSessionStateDirect$3 = async (widgetBackendUrl, sessionId) => {
|
|
45668
|
+
try {
|
|
45669
|
+
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
45670
|
+
method: "GET",
|
|
45671
|
+
headers: {
|
|
45672
|
+
"Content-Type": "application/json"
|
|
45673
|
+
}
|
|
45674
|
+
});
|
|
45675
|
+
if (!response.ok) {
|
|
45676
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
45677
|
+
}
|
|
45678
|
+
const result = await response.json();
|
|
45679
|
+
return result;
|
|
45680
|
+
} catch (error) {
|
|
45681
|
+
console.error("Failed to load session state directly:", error);
|
|
45682
|
+
return null;
|
|
45683
|
+
}
|
|
45684
|
+
};
|
|
45633
45685
|
const parseAndUpdateChartState$3 = (apiResponse, setChartState) => {
|
|
45634
45686
|
var _a, _b;
|
|
45635
45687
|
try {
|
|
@@ -45755,7 +45807,7 @@ function CopilotKitPieChart({
|
|
|
45755
45807
|
datasetId,
|
|
45756
45808
|
widgetData
|
|
45757
45809
|
}) {
|
|
45758
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p
|
|
45810
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
45759
45811
|
const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
|
|
45760
45812
|
const content = (_b = widget.config) == null ? void 0 : _b.content;
|
|
45761
45813
|
const widget_data = (_c = widget.widget_data) == null ? void 0 : _c.pie_chart_data;
|
|
@@ -45772,19 +45824,19 @@ function CopilotKitPieChart({
|
|
|
45772
45824
|
initialState: createInitialChartState$3(datasetId, widget_data)
|
|
45773
45825
|
});
|
|
45774
45826
|
const [chartState, setChartState] = React.useState(createInitialChartState$3(datasetId, widget_data));
|
|
45827
|
+
const [isInitialFetchComplete, setIsInitialFetchComplete] = React.useState(false);
|
|
45775
45828
|
React.useEffect(() => {
|
|
45776
45829
|
const fetchInitialState = async () => {
|
|
45777
|
-
var _a2;
|
|
45778
45830
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
45779
45831
|
hasInitialFetchRef.current = true;
|
|
45780
|
-
const
|
|
45781
|
-
const apiResponse = await loadAgentState$3(widgetBackendUrl, widget.id, agentName);
|
|
45832
|
+
const apiResponse = await loadSessionStateDirect$3(widgetBackendUrl, widget.id);
|
|
45782
45833
|
if (apiResponse) {
|
|
45783
45834
|
parseAndUpdateChartState$3(apiResponse, setChartState);
|
|
45784
45835
|
}
|
|
45836
|
+
setIsInitialFetchComplete(true);
|
|
45785
45837
|
};
|
|
45786
45838
|
fetchInitialState();
|
|
45787
|
-
}, [widgetBackendUrl, widget.id,
|
|
45839
|
+
}, [widgetBackendUrl, widget.id, setChartState]);
|
|
45788
45840
|
const handleLoadingTimeout = React.useCallback(async () => {
|
|
45789
45841
|
var _a2;
|
|
45790
45842
|
if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
|
|
@@ -45808,7 +45860,7 @@ function CopilotKitPieChart({
|
|
|
45808
45860
|
if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
|
|
45809
45861
|
parseAndUpdateChartState$3(apiResponse, setChartState);
|
|
45810
45862
|
}
|
|
45811
|
-
}, [widgetBackendUrl, widget.id, setChartState, (
|
|
45863
|
+
}, [widgetBackendUrl, widget.id, setChartState, (_e = widget.config) == null ? void 0 : _e.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
45812
45864
|
const startLoadingTimeout = React.useCallback(() => {
|
|
45813
45865
|
if (timeoutRef.current) {
|
|
45814
45866
|
clearTimeout(timeoutRef.current);
|
|
@@ -45882,20 +45934,20 @@ function CopilotKitPieChart({
|
|
|
45882
45934
|
/* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.Bot, { className: "h-4 w-4" }),
|
|
45883
45935
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
|
|
45884
45936
|
] }) }),
|
|
45885
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((
|
|
45937
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: !isInitialFetchComplete && !isFirstLoad ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.RefreshCw, { className: "h-6 w-6 animate-spin text-gray-400" }) }) : (chartState == null ? void 0 : chartState.agent_message) && (!((_h = (_g = (_f = chartState.pie_chart_data) == null ? void 0 : _f.data) == null ? void 0 : _g.labels) == null ? void 0 : _h.length) || !((_k = (_j = (_i = chartState.pie_chart_data) == null ? void 0 : _i.data) == null ? void 0 : _j.values) == null ? void 0 : _k.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
45886
45938
|
PieChartComponent,
|
|
45887
45939
|
{
|
|
45888
45940
|
pieChartState: chartState,
|
|
45889
45941
|
styles,
|
|
45890
45942
|
appendMessage,
|
|
45891
45943
|
content,
|
|
45892
|
-
query: (
|
|
45944
|
+
query: (_l = widget.config) == null ? void 0 : _l.query,
|
|
45893
45945
|
isFirstLoad,
|
|
45894
45946
|
widgetBackendUrl,
|
|
45895
45947
|
widgetId: widget.id,
|
|
45896
45948
|
startLoadingTimeout,
|
|
45897
45949
|
clearLoadingTimeout,
|
|
45898
|
-
hasWidgetData: !!(((
|
|
45950
|
+
hasWidgetData: !!(((_n = (_m = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _m.labels) == null ? void 0 : _n.length) && ((_p = (_o = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _o.values) == null ? void 0 : _p.length))
|
|
45899
45951
|
}
|
|
45900
45952
|
) })
|
|
45901
45953
|
] });
|
|
@@ -46044,6 +46096,24 @@ const loadAgentState$2 = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
46044
46096
|
return null;
|
|
46045
46097
|
}
|
|
46046
46098
|
};
|
|
46099
|
+
const loadSessionStateDirect$2 = async (widgetBackendUrl, sessionId) => {
|
|
46100
|
+
try {
|
|
46101
|
+
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
46102
|
+
method: "GET",
|
|
46103
|
+
headers: {
|
|
46104
|
+
"Content-Type": "application/json"
|
|
46105
|
+
}
|
|
46106
|
+
});
|
|
46107
|
+
if (!response.ok) {
|
|
46108
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
46109
|
+
}
|
|
46110
|
+
const result = await response.json();
|
|
46111
|
+
return result;
|
|
46112
|
+
} catch (error) {
|
|
46113
|
+
console.error("Failed to load session state directly:", error);
|
|
46114
|
+
return null;
|
|
46115
|
+
}
|
|
46116
|
+
};
|
|
46047
46117
|
const parseAndUpdateChartState$2 = (apiResponse, setChartState) => {
|
|
46048
46118
|
var _a, _b;
|
|
46049
46119
|
try {
|
|
@@ -46178,7 +46248,7 @@ function CopilotKitSeriesBarChart$1({
|
|
|
46178
46248
|
datasetId,
|
|
46179
46249
|
widgetData
|
|
46180
46250
|
}) {
|
|
46181
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q
|
|
46251
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
46182
46252
|
const orientation = ((_a = widget.config) == null ? void 0 : _a.orientation) || "vertical";
|
|
46183
46253
|
const isFirstLoad = (_b = widget.config) == null ? void 0 : _b.isFirstLoad;
|
|
46184
46254
|
const content = (_c = widget.config) == null ? void 0 : _c.content;
|
|
@@ -46196,19 +46266,19 @@ function CopilotKitSeriesBarChart$1({
|
|
|
46196
46266
|
initialState: createInitialChartState$2(datasetId, widget_data)
|
|
46197
46267
|
});
|
|
46198
46268
|
const [chartState, setChartState] = React.useState(createInitialChartState$2(datasetId, widget_data));
|
|
46269
|
+
const [isInitialFetchComplete, setIsInitialFetchComplete] = React.useState(false);
|
|
46199
46270
|
React.useEffect(() => {
|
|
46200
46271
|
const fetchInitialState = async () => {
|
|
46201
|
-
var _a2;
|
|
46202
46272
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
46203
46273
|
hasInitialFetchRef.current = true;
|
|
46204
|
-
const
|
|
46205
|
-
const apiResponse = await loadAgentState$2(widgetBackendUrl, widget.id, agentName);
|
|
46274
|
+
const apiResponse = await loadSessionStateDirect$2(widgetBackendUrl, widget.id);
|
|
46206
46275
|
if (apiResponse) {
|
|
46207
46276
|
parseAndUpdateChartState$2(apiResponse, setChartState);
|
|
46208
46277
|
}
|
|
46278
|
+
setIsInitialFetchComplete(true);
|
|
46209
46279
|
};
|
|
46210
46280
|
fetchInitialState();
|
|
46211
|
-
}, [widgetBackendUrl, widget.id,
|
|
46281
|
+
}, [widgetBackendUrl, widget.id, setChartState]);
|
|
46212
46282
|
const handleLoadingTimeout = React.useCallback(async () => {
|
|
46213
46283
|
var _a2;
|
|
46214
46284
|
if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
|
|
@@ -46232,7 +46302,7 @@ function CopilotKitSeriesBarChart$1({
|
|
|
46232
46302
|
if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
|
|
46233
46303
|
parseAndUpdateChartState$2(apiResponse, setChartState);
|
|
46234
46304
|
}
|
|
46235
|
-
}, [widgetBackendUrl, widget.id, setChartState, (
|
|
46305
|
+
}, [widgetBackendUrl, widget.id, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
46236
46306
|
const startLoadingTimeout = React.useCallback(() => {
|
|
46237
46307
|
if (timeoutRef.current) {
|
|
46238
46308
|
clearTimeout(timeoutRef.current);
|
|
@@ -46306,7 +46376,7 @@ function CopilotKitSeriesBarChart$1({
|
|
|
46306
46376
|
/* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.Bot, { className: "h-4 w-4" }),
|
|
46307
46377
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
|
|
46308
46378
|
] }) }),
|
|
46309
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((
|
|
46379
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: !isInitialFetchComplete && !isFirstLoad ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.RefreshCw, { className: "h-6 w-6 animate-spin text-gray-400" }) }) : (chartState == null ? void 0 : chartState.agent_message) && (!((_i = (_h = (_g = chartState.series_bar_chart_data) == null ? void 0 : _g.data) == null ? void 0 : _h.labels) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.series_bar_chart_data) == null ? void 0 : _j.data) == null ? void 0 : _k.series) == null ? void 0 : _l.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
46310
46380
|
SeriesBarChartComponent$1,
|
|
46311
46381
|
{
|
|
46312
46382
|
orientation,
|
|
@@ -46314,13 +46384,13 @@ function CopilotKitSeriesBarChart$1({
|
|
|
46314
46384
|
styles,
|
|
46315
46385
|
appendMessage,
|
|
46316
46386
|
content,
|
|
46317
|
-
query: (
|
|
46387
|
+
query: (_m = widget.config) == null ? void 0 : _m.query,
|
|
46318
46388
|
isFirstLoad,
|
|
46319
46389
|
widgetBackendUrl,
|
|
46320
46390
|
widgetId: widget.id,
|
|
46321
46391
|
startLoadingTimeout,
|
|
46322
46392
|
clearLoadingTimeout,
|
|
46323
|
-
hasWidgetData: !!(((
|
|
46393
|
+
hasWidgetData: !!(((_o = (_n = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _n.labels) == null ? void 0 : _o.length) && ((_q = (_p = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _p.series) == null ? void 0 : _q.length))
|
|
46324
46394
|
}
|
|
46325
46395
|
) })
|
|
46326
46396
|
] });
|
|
@@ -46469,6 +46539,24 @@ const loadAgentState$1 = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
46469
46539
|
return null;
|
|
46470
46540
|
}
|
|
46471
46541
|
};
|
|
46542
|
+
const loadSessionStateDirect$1 = async (widgetBackendUrl, sessionId) => {
|
|
46543
|
+
try {
|
|
46544
|
+
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
46545
|
+
method: "GET",
|
|
46546
|
+
headers: {
|
|
46547
|
+
"Content-Type": "application/json"
|
|
46548
|
+
}
|
|
46549
|
+
});
|
|
46550
|
+
if (!response.ok) {
|
|
46551
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
46552
|
+
}
|
|
46553
|
+
const result = await response.json();
|
|
46554
|
+
return result;
|
|
46555
|
+
} catch (error) {
|
|
46556
|
+
console.error("Failed to load session state directly:", error);
|
|
46557
|
+
return null;
|
|
46558
|
+
}
|
|
46559
|
+
};
|
|
46472
46560
|
const parseAndUpdateChartState$1 = (apiResponse, setChartState) => {
|
|
46473
46561
|
var _a, _b;
|
|
46474
46562
|
try {
|
|
@@ -46603,7 +46691,7 @@ function CopilotKitSeriesBarChart({
|
|
|
46603
46691
|
datasetId,
|
|
46604
46692
|
widgetData
|
|
46605
46693
|
}) {
|
|
46606
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q
|
|
46694
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
46607
46695
|
const orientation = ((_a = widget.config) == null ? void 0 : _a.orientation) || "vertical";
|
|
46608
46696
|
const isFirstLoad = (_b = widget.config) == null ? void 0 : _b.isFirstLoad;
|
|
46609
46697
|
const content = (_c = widget.config) == null ? void 0 : _c.content;
|
|
@@ -46621,19 +46709,19 @@ function CopilotKitSeriesBarChart({
|
|
|
46621
46709
|
initialState: createInitialChartState$1(datasetId, widget_data)
|
|
46622
46710
|
});
|
|
46623
46711
|
const [chartState, setChartState] = React.useState(createInitialChartState$1(datasetId, widget_data));
|
|
46712
|
+
const [isInitialFetchComplete, setIsInitialFetchComplete] = React.useState(false);
|
|
46624
46713
|
React.useEffect(() => {
|
|
46625
46714
|
const fetchInitialState = async () => {
|
|
46626
|
-
var _a2;
|
|
46627
46715
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
46628
46716
|
hasInitialFetchRef.current = true;
|
|
46629
|
-
const
|
|
46630
|
-
const apiResponse = await loadAgentState$1(widgetBackendUrl, widget.id, agentName);
|
|
46717
|
+
const apiResponse = await loadSessionStateDirect$1(widgetBackendUrl, widget.id);
|
|
46631
46718
|
if (apiResponse) {
|
|
46632
46719
|
parseAndUpdateChartState$1(apiResponse, setChartState);
|
|
46633
46720
|
}
|
|
46721
|
+
setIsInitialFetchComplete(true);
|
|
46634
46722
|
};
|
|
46635
46723
|
fetchInitialState();
|
|
46636
|
-
}, [widgetBackendUrl, widget.id,
|
|
46724
|
+
}, [widgetBackendUrl, widget.id, setChartState]);
|
|
46637
46725
|
const handleLoadingTimeout = React.useCallback(async () => {
|
|
46638
46726
|
var _a2;
|
|
46639
46727
|
if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
|
|
@@ -46657,7 +46745,7 @@ function CopilotKitSeriesBarChart({
|
|
|
46657
46745
|
if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
|
|
46658
46746
|
parseAndUpdateChartState$1(apiResponse, setChartState);
|
|
46659
46747
|
}
|
|
46660
|
-
}, [widgetBackendUrl, widget.id, setChartState, (
|
|
46748
|
+
}, [widgetBackendUrl, widget.id, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
46661
46749
|
const startLoadingTimeout = React.useCallback(() => {
|
|
46662
46750
|
if (timeoutRef.current) {
|
|
46663
46751
|
clearTimeout(timeoutRef.current);
|
|
@@ -46731,7 +46819,7 @@ function CopilotKitSeriesBarChart({
|
|
|
46731
46819
|
/* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.Bot, { className: "h-4 w-4" }),
|
|
46732
46820
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
|
|
46733
46821
|
] }) }),
|
|
46734
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((
|
|
46822
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: !isInitialFetchComplete && !isFirstLoad ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.RefreshCw, { className: "h-6 w-6 animate-spin text-gray-400" }) }) : (chartState == null ? void 0 : chartState.agent_message) && (!((_i = (_h = (_g = chartState.series_bar_chart_data) == null ? void 0 : _g.data) == null ? void 0 : _h.labels) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.series_bar_chart_data) == null ? void 0 : _j.data) == null ? void 0 : _k.series) == null ? void 0 : _l.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
46735
46823
|
SeriesBarChartComponent,
|
|
46736
46824
|
{
|
|
46737
46825
|
orientation,
|
|
@@ -46739,13 +46827,13 @@ function CopilotKitSeriesBarChart({
|
|
|
46739
46827
|
styles,
|
|
46740
46828
|
appendMessage,
|
|
46741
46829
|
content,
|
|
46742
|
-
query: (
|
|
46830
|
+
query: (_m = widget.config) == null ? void 0 : _m.query,
|
|
46743
46831
|
isFirstLoad,
|
|
46744
46832
|
widgetBackendUrl,
|
|
46745
46833
|
widgetId: widget.id,
|
|
46746
46834
|
startLoadingTimeout,
|
|
46747
46835
|
clearLoadingTimeout,
|
|
46748
|
-
hasWidgetData: !!(((
|
|
46836
|
+
hasWidgetData: !!(((_o = (_n = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _n.labels) == null ? void 0 : _o.length) && ((_q = (_p = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _p.series) == null ? void 0 : _q.length))
|
|
46749
46837
|
}
|
|
46750
46838
|
) })
|
|
46751
46839
|
] });
|
|
@@ -46884,6 +46972,24 @@ const loadAgentState = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
46884
46972
|
return null;
|
|
46885
46973
|
}
|
|
46886
46974
|
};
|
|
46975
|
+
const loadSessionStateDirect = async (widgetBackendUrl, sessionId) => {
|
|
46976
|
+
try {
|
|
46977
|
+
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
46978
|
+
method: "GET",
|
|
46979
|
+
headers: {
|
|
46980
|
+
"Content-Type": "application/json"
|
|
46981
|
+
}
|
|
46982
|
+
});
|
|
46983
|
+
if (!response.ok) {
|
|
46984
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
46985
|
+
}
|
|
46986
|
+
const result = await response.json();
|
|
46987
|
+
return result;
|
|
46988
|
+
} catch (error) {
|
|
46989
|
+
console.error("Failed to load session state directly:", error);
|
|
46990
|
+
return null;
|
|
46991
|
+
}
|
|
46992
|
+
};
|
|
46887
46993
|
const parseAndUpdateChartState = (apiResponse, setChartState) => {
|
|
46888
46994
|
var _a, _b;
|
|
46889
46995
|
try {
|
|
@@ -47000,7 +47106,7 @@ function CopilotKitDataGrid({
|
|
|
47000
47106
|
datasetId,
|
|
47001
47107
|
widgetData
|
|
47002
47108
|
}) {
|
|
47003
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p
|
|
47109
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
47004
47110
|
const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
|
|
47005
47111
|
const content = (_b = widget.config) == null ? void 0 : _b.content;
|
|
47006
47112
|
const widget_data = (_c = widget.widget_data) == null ? void 0 : _c.matrix_grid_data;
|
|
@@ -47017,19 +47123,19 @@ function CopilotKitDataGrid({
|
|
|
47017
47123
|
initialState: createInitialChartState(datasetId, widget_data)
|
|
47018
47124
|
});
|
|
47019
47125
|
const [chartState, setChartState] = React.useState(createInitialChartState(datasetId, widget_data));
|
|
47126
|
+
const [isInitialFetchComplete, setIsInitialFetchComplete] = React.useState(false);
|
|
47020
47127
|
React.useEffect(() => {
|
|
47021
47128
|
const fetchInitialState = async () => {
|
|
47022
|
-
var _a2;
|
|
47023
47129
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
47024
47130
|
hasInitialFetchRef.current = true;
|
|
47025
|
-
const
|
|
47026
|
-
const apiResponse = await loadAgentState(widgetBackendUrl, widget.id, agentName);
|
|
47131
|
+
const apiResponse = await loadSessionStateDirect(widgetBackendUrl, widget.id);
|
|
47027
47132
|
if (apiResponse) {
|
|
47028
47133
|
parseAndUpdateChartState(apiResponse, setChartState);
|
|
47029
47134
|
}
|
|
47135
|
+
setIsInitialFetchComplete(true);
|
|
47030
47136
|
};
|
|
47031
47137
|
fetchInitialState();
|
|
47032
|
-
}, [widgetBackendUrl, widget.id,
|
|
47138
|
+
}, [widgetBackendUrl, widget.id, setChartState]);
|
|
47033
47139
|
const handleLoadingTimeout = React.useCallback(async () => {
|
|
47034
47140
|
var _a2;
|
|
47035
47141
|
if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
|
|
@@ -47053,7 +47159,7 @@ function CopilotKitDataGrid({
|
|
|
47053
47159
|
if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
|
|
47054
47160
|
parseAndUpdateChartState(apiResponse, setChartState);
|
|
47055
47161
|
}
|
|
47056
|
-
}, [widgetBackendUrl, widget.id, setChartState, (
|
|
47162
|
+
}, [widgetBackendUrl, widget.id, setChartState, (_e = widget.config) == null ? void 0 : _e.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
47057
47163
|
const startLoadingTimeout = React.useCallback(() => {
|
|
47058
47164
|
if (timeoutRef.current) {
|
|
47059
47165
|
clearTimeout(timeoutRef.current);
|
|
@@ -47127,20 +47233,20 @@ function CopilotKitDataGrid({
|
|
|
47127
47233
|
/* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.Bot, { className: "h-4 w-4" }),
|
|
47128
47234
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
|
|
47129
47235
|
] }) }),
|
|
47130
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((
|
|
47236
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: !isInitialFetchComplete && !isFirstLoad ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.RefreshCw, { className: "h-6 w-6 animate-spin text-gray-400" }) }) : (chartState == null ? void 0 : chartState.agent_message) && (!((_h = (_g = (_f = chartState.matrix_grid_data) == null ? void 0 : _f.data) == null ? void 0 : _g.headers) == null ? void 0 : _h.length) || !((_k = (_j = (_i = chartState.matrix_grid_data) == null ? void 0 : _i.data) == null ? void 0 : _j.rows) == null ? void 0 : _k.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
47131
47237
|
DataGridComponent,
|
|
47132
47238
|
{
|
|
47133
47239
|
dataGridState: chartState,
|
|
47134
47240
|
styles,
|
|
47135
47241
|
appendMessage,
|
|
47136
47242
|
content,
|
|
47137
|
-
query: (
|
|
47243
|
+
query: (_l = widget.config) == null ? void 0 : _l.query,
|
|
47138
47244
|
isFirstLoad,
|
|
47139
47245
|
widgetBackendUrl,
|
|
47140
47246
|
widgetId: widget.id,
|
|
47141
47247
|
startLoadingTimeout,
|
|
47142
47248
|
clearLoadingTimeout,
|
|
47143
|
-
hasWidgetData: !!(((
|
|
47249
|
+
hasWidgetData: !!(((_n = (_m = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _m.headers) == null ? void 0 : _n.length) && ((_p = (_o = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _o.rows) == null ? void 0 : _p.length))
|
|
47144
47250
|
}
|
|
47145
47251
|
) })
|
|
47146
47252
|
] });
|