@epam/ai-dial-chat-hooks 1.3.0-dev.28 → 1.3.0-dev.29

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/index.d.ts CHANGED
@@ -6320,7 +6320,7 @@ export declare interface UsePublishFoldersResult {
6320
6320
  }
6321
6321
 
6322
6322
  /** Shared, cancellation-safe pagination and background refresh for one schedule's run history. */
6323
- export declare const useScheduledTaskRuns: (client: ScheduledTasksApiClient, { scheduleId, enabled, pageSize, nextRunTime, }: UseScheduledTaskRunsOptions) => {
6323
+ export declare const useScheduledTaskRuns: (client: ScheduledTasksApiClient, { scheduleId, enabled, pageSize, nextRunTime, pollWhileActive, }: UseScheduledTaskRunsOptions) => {
6324
6324
  items: ScheduledTaskRunDto[];
6325
6325
  isLoading: boolean;
6326
6326
  isLoadingMore: boolean;
@@ -6342,6 +6342,12 @@ export declare interface UseScheduledTaskRunsOptions {
6342
6342
  * The caller already holds the task DTO — this hook never fetches it.
6343
6343
  */
6344
6344
  nextRunTime?: string | null;
6345
+ /**
6346
+ * Keeps the 15s background poll running even when no loaded run is
6347
+ * `InProgress`. For a run the caller started itself and tracks outside this
6348
+ * hook, which the first poll then merges into `items`.
6349
+ */
6350
+ pollWhileActive?: boolean;
6345
6351
  }
6346
6352
 
6347
6353
  /** Shared scheduler-list lifecycle with generation-scoped stale-response guards. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epam/ai-dial-chat-hooks",
3
3
  "description": "Framework-level React hooks extracted from AI DIAL Chat for building custom chat interfaces",
4
- "version": "1.3.0-dev.28",
4
+ "version": "1.3.0-dev.29",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -111,7 +111,7 @@
111
111
  }
112
112
  },
113
113
  "dependencies": {
114
- "@epam/ai-dial-chat-api-client": "1.3.0-dev.28",
114
+ "@epam/ai-dial-chat-api-client": "1.3.0-dev.29",
115
115
  "dompurify": "3.4.16",
116
116
  "fflate": "^0.8.3",
117
117
  "lru-cache": "^10.4.3",
@@ -120,21 +120,21 @@
120
120
  },
121
121
  "peerDependencies": {
122
122
  "react": "^19.2.8",
123
- "@epam/ai-dial-attachment-canvas": "1.3.0-dev.28",
124
- "@epam/ai-dial-attachment-input": "1.3.0-dev.28",
125
- "@epam/ai-dial-catalog": "1.3.0-dev.28",
126
- "@epam/ai-dial-chat-overlay": "1.3.0-dev.28",
127
- "@epam/ai-dial-chat-shared": "1.3.0-dev.28",
128
- "@epam/ai-dial-mcp-apps": "1.3.0-dev.28",
129
- "@epam/ai-dial-publish-panel": "1.3.0-dev.28",
130
- "@epam/ai-dial-quotations": "1.3.0-dev.28",
123
+ "@epam/ai-dial-attachment-canvas": "1.3.0-dev.29",
124
+ "@epam/ai-dial-attachment-input": "1.3.0-dev.29",
125
+ "@epam/ai-dial-catalog": "1.3.0-dev.29",
126
+ "@epam/ai-dial-chat-overlay": "1.3.0-dev.29",
127
+ "@epam/ai-dial-chat-shared": "1.3.0-dev.29",
128
+ "@epam/ai-dial-mcp-apps": "1.3.0-dev.29",
129
+ "@epam/ai-dial-publish-panel": "1.3.0-dev.29",
130
+ "@epam/ai-dial-quotations": "1.3.0-dev.29",
131
131
  "@epam/ai-dial-react-file-manager": "^0.3.2",
132
- "@epam/ai-dial-scheduled-tasks": "1.3.0-dev.28",
133
- "@epam/ai-dial-share": "1.3.0-dev.28",
134
- "@epam/ai-dial-skill-editor": "1.3.0-dev.28",
135
- "@epam/ai-dial-source-panel": "1.3.0-dev.28",
132
+ "@epam/ai-dial-scheduled-tasks": "1.3.0-dev.29",
133
+ "@epam/ai-dial-share": "1.3.0-dev.29",
134
+ "@epam/ai-dial-skill-editor": "1.3.0-dev.29",
135
+ "@epam/ai-dial-source-panel": "1.3.0-dev.29",
136
136
  "@epam/ai-dial-ui-kit": "^0.15.3",
137
- "@epam/ai-dial-usage-dashboard": "1.3.0-dev.28",
137
+ "@epam/ai-dial-usage-dashboard": "1.3.0-dev.29",
138
138
  "@modelcontextprotocol/sdk": "^1.32.1",
139
139
  "@epam/pdf-highlighter-kit": "^0.0.19",
140
140
  "@mcp-ui/client": "^7.1.1"
@@ -1,7 +1,7 @@
1
1
  import { useCallback as e, useEffect as t, useRef as n, useState as r } from "react";
2
2
  import { ScheduledTaskRunDtoStatusEnum as i } from "@epam/ai-dial-chat-api-client";
3
3
  //#region src/scheduled-task/use-scheduled-task-runs.ts
4
- var a = 15e3, o = 20, s = 5e3, c = 2147483647, l = (e, t) => {
4
+ var a = 15e3, o = 48, s = 5e3, c = 2147483647, l = (e, t) => {
5
5
  if (e <= c) {
6
6
  let n = setTimeout(t, Math.max(e, 0));
7
7
  return () => clearTimeout(n);
@@ -20,18 +20,18 @@ var a = 15e3, o = 20, s = 5e3, c = 2147483647, l = (e, t) => {
20
20
  let t = n.get(e.id);
21
21
  return !t || JSON.stringify(t) !== JSON.stringify(e);
22
22
  });
23
- }, f = (c, { scheduleId: f, enabled: p = !0, pageSize: m = 10, nextRunTime: h }) => {
24
- let [g, _] = r([]), [v, y] = r(p), [b, x] = r(!1), [S, C] = r(null), [w, T] = r(null), [E, D] = r(!1), [O, k] = r(0), A = n(0), j = n(0), M = n(!1), N = n(null), P = n(g), F = n(v), I = n(b), L = n(null), R = n(0), z = n(null), B = n(!1);
25
- P.current = g, F.current = v, I.current = b;
26
- let V = g.some((e) => e.status === i.InProgress);
23
+ }, f = (c, { scheduleId: f, enabled: p = !0, pageSize: m = 10, nextRunTime: h, pollWhileActive: g = !1 }) => {
24
+ let [_, v] = r([]), [y, b] = r(p), [x, S] = r(!1), [C, w] = r(null), [T, E] = r(null), [D, O] = r(!1), [k, A] = r(0), j = n(0), M = n(0), N = n(!1), P = n(null), F = n(_), I = n(y), L = n(x), R = n(null), z = n(0), B = n(null), V = n(!1);
25
+ F.current = _, I.current = y, L.current = x;
26
+ let H = g || _.some((e) => e.status === i.InProgress);
27
27
  t(() => {
28
- let e = ++A.current, t = new AbortController();
29
- N.current?.abort(), N.current = null, L.current?.abort(), L.current = null, M.current = !1, R.current = 0, z.current = null, B.current = !1, x(!1), C(null), T(null), _([]), D(!1), j.current = 0;
28
+ let e = ++j.current, t = new AbortController();
29
+ P.current?.abort(), P.current = null, R.current?.abort(), R.current = null, N.current = !1, z.current = 0, B.current = null, V.current = !1, S(!1), w(null), E(null), v([]), O(!1), M.current = 0;
30
30
  let n = () => {
31
- ++A.current, t.abort(), N.current?.abort(), N.current = null, L.current?.abort(), L.current = null;
31
+ ++j.current, t.abort(), P.current?.abort(), P.current = null, R.current?.abort(), R.current = null;
32
32
  };
33
- return !p || !f ? (y(!1), _([]), D(!1), n) : ((async () => {
34
- y(!0);
33
+ return !p || !f ? (b(!1), v([]), O(!1), n) : ((async () => {
34
+ b(!0);
35
35
  try {
36
36
  let n = await c.listScheduledTaskRuns({
37
37
  scheduleId: f,
@@ -39,29 +39,29 @@ var a = 15e3, o = 20, s = 5e3, c = 2147483647, l = (e, t) => {
39
39
  offset: 0,
40
40
  signal: t.signal
41
41
  });
42
- if (A.current !== e) return;
43
- _(n.items), j.current = n.items.length, D(n.next != null || (n.count == null ? n.items.length === m : n.items.length < n.count));
42
+ if (j.current !== e) return;
43
+ v(n.items), M.current = n.items.length, O(n.next != null || (n.count == null ? n.items.length === m : n.items.length < n.count));
44
44
  } catch (t) {
45
- A.current === e && C(t instanceof Error ? t : /* @__PURE__ */ Error("Failed to load scheduled task runs"));
45
+ j.current === e && w(t instanceof Error ? t : /* @__PURE__ */ Error("Failed to load scheduled task runs"));
46
46
  } finally {
47
- A.current === e && y(!1);
47
+ j.current === e && b(!1);
48
48
  }
49
49
  })(), n);
50
50
  }, [
51
51
  c,
52
52
  p,
53
53
  m,
54
- O,
54
+ k,
55
55
  f
56
56
  ]);
57
- let H = e(() => {
58
- if (!p || !f || !E || v || M.current) return;
59
- M.current = !0;
57
+ let U = e(() => {
58
+ if (!p || !f || !D || y || N.current) return;
59
+ N.current = !0;
60
60
  let e = new AbortController();
61
- N.current = e;
62
- let t = A.current, n = j.current;
61
+ P.current = e;
62
+ let t = j.current, n = M.current;
63
63
  (async () => {
64
- x(!0), T(null);
64
+ S(!0), E(null);
65
65
  try {
66
66
  let r = await c.listScheduledTaskRuns({
67
67
  scheduleId: f,
@@ -69,28 +69,28 @@ var a = 15e3, o = 20, s = 5e3, c = 2147483647, l = (e, t) => {
69
69
  offset: n,
70
70
  signal: e.signal
71
71
  });
72
- if (A.current !== t) return;
73
- _((e) => {
72
+ if (j.current !== t) return;
73
+ v((e) => {
74
74
  let t = new Set(e.map(({ id: e }) => e));
75
75
  return [...e, ...r.items.filter(({ id: e }) => t.has(e) ? !1 : (t.add(e), !0))];
76
- }), j.current = n + r.items.length, D(r.next != null || (r.count == null ? r.items.length === m : n + r.items.length < r.count));
76
+ }), M.current = n + r.items.length, O(r.next != null || (r.count == null ? r.items.length === m : n + r.items.length < r.count));
77
77
  } catch (e) {
78
- A.current === t && T(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load more scheduled task runs"));
78
+ j.current === t && E(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load more scheduled task runs"));
79
79
  } finally {
80
- A.current === t && (x(!1), M.current = !1, N.current = null);
80
+ j.current === t && (S(!1), N.current = !1, P.current = null);
81
81
  }
82
82
  })();
83
83
  }, [
84
84
  c,
85
85
  p,
86
- E,
87
- v,
86
+ D,
87
+ y,
88
88
  m,
89
89
  f
90
- ]), U = e(async () => {
91
- if (F.current || I.current) return "skipped";
92
- let e = A.current, t = new AbortController();
93
- L.current?.abort(), L.current = t;
90
+ ]), W = e(async () => {
91
+ if (I.current || L.current) return "skipped";
92
+ let e = j.current, t = new AbortController();
93
+ R.current?.abort(), R.current = t;
94
94
  try {
95
95
  let n = await c.listScheduledTaskRuns({
96
96
  scheduleId: f,
@@ -98,40 +98,40 @@ var a = 15e3, o = 20, s = 5e3, c = 2147483647, l = (e, t) => {
98
98
  offset: 0,
99
99
  signal: t.signal
100
100
  });
101
- if (A.current !== e || F.current || I.current) return "skipped";
102
- let r = P.current, i = u(r, n.items), a = d(r, i);
103
- return a && (P.current = i, _(i)), a ? "changed" : "unchanged";
101
+ if (j.current !== e || I.current || L.current) return "skipped";
102
+ let r = F.current, i = u(r, n.items), a = d(r, i);
103
+ return a && (F.current = i, v(i)), a ? "changed" : "unchanged";
104
104
  } catch {
105
105
  return "error";
106
106
  } finally {
107
- L.current === t && (L.current = null);
107
+ R.current === t && (R.current = null);
108
108
  }
109
109
  }, [
110
110
  c,
111
111
  f,
112
112
  m
113
- ]), W = e(() => {
113
+ ]), G = e(() => {
114
114
  if (document.visibilityState !== "visible") {
115
- B.current = !0;
115
+ V.current = !0;
116
116
  return;
117
117
  }
118
- U();
119
- }, [U]);
118
+ W();
119
+ }, [W]);
120
120
  return t(() => {
121
- if (!p || !f || !V) return;
122
- R.current = 0;
121
+ if (!p || !f || !H) return;
122
+ z.current = 0;
123
123
  let e = setInterval(() => {
124
124
  if (document.visibilityState !== "visible") {
125
- B.current = !0;
125
+ V.current = !0;
126
126
  return;
127
127
  }
128
128
  (async () => {
129
- let t = await U();
129
+ let t = await W();
130
130
  if (t === "changed") {
131
- R.current = 0;
131
+ z.current = 0;
132
132
  return;
133
133
  }
134
- (t === "unchanged" || t === "error") && (R.current += 1, R.current >= o && e !== null && (clearInterval(e), e = null));
134
+ (t === "unchanged" || t === "error") && (z.current += 1, z.current >= o && e !== null && (clearInterval(e), e = null));
135
135
  })();
136
136
  }, a);
137
137
  return () => {
@@ -140,24 +140,24 @@ var a = 15e3, o = 20, s = 5e3, c = 2147483647, l = (e, t) => {
140
140
  }, [
141
141
  p,
142
142
  f,
143
- V,
144
- U
143
+ H,
144
+ W
145
145
  ]), t(() => {
146
146
  if (!p || !f || !h) return;
147
147
  let e = new Date(h).getTime();
148
148
  if (!(Number.isNaN(e) || e <= Date.now())) return l(e - Date.now() + s, () => {
149
- z.current = h, W();
149
+ B.current = h, G();
150
150
  });
151
151
  }, [
152
152
  p,
153
153
  f,
154
154
  h,
155
- W
155
+ G
156
156
  ]), t(() => {
157
157
  if (!p || !f) return;
158
158
  let e = () => {
159
- document.visibilityState !== "visible" || !B.current || (async () => {
160
- await U() !== "skipped" && (B.current = !1);
159
+ document.visibilityState !== "visible" || !V.current || (async () => {
160
+ await W() !== "skipped" && (V.current = !1);
161
161
  })();
162
162
  };
163
163
  return document.addEventListener("visibilitychange", e), () => {
@@ -166,28 +166,28 @@ var a = 15e3, o = 20, s = 5e3, c = 2147483647, l = (e, t) => {
166
166
  }, [
167
167
  p,
168
168
  f,
169
- U
169
+ W
170
170
  ]), t(() => {
171
- if (!p || !f || !h || v || b) return;
171
+ if (!p || !f || !h || y || x) return;
172
172
  let e = new Date(h).getTime();
173
- Number.isNaN(e) || e > Date.now() || z.current !== h && (z.current = h, W());
173
+ Number.isNaN(e) || e > Date.now() || B.current !== h && (B.current = h, G());
174
174
  }, [
175
175
  p,
176
176
  f,
177
177
  h,
178
- v,
179
- b,
180
- W
178
+ y,
179
+ x,
180
+ G
181
181
  ]), {
182
- items: g,
183
- isLoading: v,
184
- isLoadingMore: b,
185
- initialError: S,
186
- loadMoreError: w,
187
- hasMore: E,
188
- loadMore: H,
189
- retryLoadMore: H,
190
- refetch: e(() => k((e) => e + 1), [])
182
+ items: _,
183
+ isLoading: y,
184
+ isLoadingMore: x,
185
+ initialError: C,
186
+ loadMoreError: T,
187
+ hasMore: D,
188
+ loadMore: U,
189
+ retryLoadMore: U,
190
+ refetch: e(() => A((e) => e + 1), [])
191
191
  };
192
192
  };
193
193
  //#endregion
@@ -196,7 +196,7 @@ export declare enum UnsupportedTriggerReason {
196
196
  }
197
197
 
198
198
  /** Shared, cancellation-safe pagination and background refresh for one schedule's run history. */
199
- export declare const useScheduledTaskRuns: (client: ScheduledTasksApiClient, { scheduleId, enabled, pageSize, nextRunTime, }: UseScheduledTaskRunsOptions) => {
199
+ export declare const useScheduledTaskRuns: (client: ScheduledTasksApiClient, { scheduleId, enabled, pageSize, nextRunTime, pollWhileActive, }: UseScheduledTaskRunsOptions) => {
200
200
  items: ScheduledTaskRunDto[];
201
201
  isLoading: boolean;
202
202
  isLoadingMore: boolean;
@@ -218,6 +218,12 @@ export declare interface UseScheduledTaskRunsOptions {
218
218
  * The caller already holds the task DTO — this hook never fetches it.
219
219
  */
220
220
  nextRunTime?: string | null;
221
+ /**
222
+ * Keeps the 15s background poll running even when no loaded run is
223
+ * `InProgress`. For a run the caller started itself and tracks outside this
224
+ * hook, which the first poll then merges into `items`.
225
+ */
226
+ pollWhileActive?: boolean;
221
227
  }
222
228
 
223
229
  /** Shared scheduler-list lifecycle with generation-scoped stale-response guards. */