@lumerahq/ui 0.20.1 → 0.20.2-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/{RecordSheet-DXoTTH7T.js → RecordSheet-DWpgx9O_.js} +3 -3
- package/dist/components/index.js +1 -1
- package/dist/{highlighted-body-OFNGDK62-95pvcwdb.js → highlighted-body-OFNGDK62-BhPnE-9T.js} +1 -1
- package/dist/hooks/agent-chat-reconnect.d.ts +35 -0
- package/dist/hooks/agent-chat-reconnect.d.ts.map +1 -0
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/use-agent-chat.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/mermaid-GHXKKRXX-VehRUDbr.js +4 -0
- package/dist/{use-automation-run-BaW82zqJ.js → use-automation-run-DsfzeSNA.js} +81 -17
- package/package.json +1 -1
- package/dist/mermaid-GHXKKRXX-Dq4bMBai.js +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Notable changes to `@lumerahq/ui`. Earlier releases are not documented here.
|
|
4
4
|
|
|
5
|
+
## 0.20.2
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- `AgentChat` / `useAgentChat` reconnect to a turn that is already running when the chat loads. Opening, refreshing, or switching to a session mid-turn now attaches to the request's live stream (revealed by history's pending overlay) instead of waiting on history polls; assistant output already restored from history is rebuilt from the stream replay so nothing doubles. One attach attempt is made per request id, with the transport's reconnects, the watchdog, and the discovery poll unchanged as the recovery path.
|
|
10
|
+
|
|
5
11
|
## 0.20.1
|
|
6
12
|
|
|
7
13
|
The assistant surfaces now render on `AgentChat`, so existing apps get the redesigned look without code changes. Nothing exported in 0.20 is removed.
|
|
@@ -3,7 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
import React__default, { useContext, createContext, forwardRef, createElement, memo, useId as useId$1, useTransition, useMemo, useRef, useEffect, useState, isValidElement, cloneElement, useCallback, Suspense, lazy, useLayoutEffect } from "react";
|
|
4
4
|
import { t as twMerge, p as clsx, c as cn$2, a as formatCellValue$2 } from "./formatters-BuHr2I8Z.js";
|
|
5
5
|
import { T as pbSql, o as getDownloadUrl, K as parentApiRequest, L as parentApiStream, B as BridgeError, k as getAppProjectExternalId, a3 as resolveProjectResourceId, a as automationStatuses, n as getAutomationRunFileDownloadUrl, D as listAutomationRunFiles } from "./automations-DD15itWa.js";
|
|
6
|
-
import { u as useAgentChat, b as useAgentChatSessions, a as areAgentChatMutationsBlocked, c as useAutomationRun } from "./use-automation-run-
|
|
6
|
+
import { u as useAgentChat, b as useAgentChatSessions, a as areAgentChatMutationsBlocked, c as useAutomationRun } from "./use-automation-run-DsfzeSNA.js";
|
|
7
7
|
import * as ReactDOM from "react-dom";
|
|
8
8
|
import { createPortal } from "react-dom";
|
|
9
9
|
const mergeClasses = (...classes) => classes.filter((className, index2, array) => {
|
|
@@ -23975,7 +23975,7 @@ var lr = (e) => {
|
|
|
23975
23975
|
for (; t > 0 && e[t - 1] === `
|
|
23976
23976
|
`; ) t--;
|
|
23977
23977
|
return e.slice(0, t);
|
|
23978
|
-
}, cr = lazy(() => import("./highlighted-body-OFNGDK62-
|
|
23978
|
+
}, cr = lazy(() => import("./highlighted-body-OFNGDK62-BhPnE-9T.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), st = ({ code: e, language: t, className: o, children: n, isIncomplete: r = false, startLine: s2, lineNumbers: a, ...l }) => {
|
|
23979
23979
|
let i = y2(), d2 = useMemo(() => lr(e), [e]), c2 = useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: d2.split(`
|
|
23980
23980
|
`).map((p2) => [{ content: p2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [d2]);
|
|
23981
23981
|
return jsx(nt.Provider, { value: { code: e }, children: jsxs(ot, { isIncomplete: r, language: t, children: [jsx(rt, { language: t }), n ? jsx("div", { className: i("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"), children: jsx("div", { className: i("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"), "data-streamdown": "code-block-actions", children: n }) }) : null, jsx(Suspense, { fallback: jsx(At, { className: o, language: t, lineNumbers: a, result: c2, startLine: s2, ...l }), children: jsx(cr, { className: o, code: d2, language: t, lineNumbers: a, raw: c2, startLine: s2, ...l }) })] }) });
|
|
@@ -24337,7 +24337,7 @@ var vo = ({ children: e, className: t, showControls: o, showCopy: n = true, show
|
|
|
24337
24337
|
let l = y2(), i = o && n, d2 = o && r, c2 = o && s2, p2 = i || d2 || c2;
|
|
24338
24338
|
return jsxs("div", { className: l("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"), "data-streamdown": "table-wrapper", children: [p2 ? jsxs("div", { className: l("flex items-center justify-end gap-1"), children: [i ? jsx(Te, {}) : null, d2 ? jsx(Pe, {}) : null, c2 ? jsx(Co, { showCopy: i, showDownload: d2, children: e }) : null] }) : null, jsx("div", { className: l("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"), children: jsx("table", { className: l("w-full divide-y divide-border", t), "data-streamdown": "table", ...a, children: e }) })] });
|
|
24339
24339
|
};
|
|
24340
|
-
var es = /startLine=(\d+)/, ts = /\bnoLineNumbers\b/, os = lazy(() => import("./mermaid-GHXKKRXX-
|
|
24340
|
+
var es = /startLine=(\d+)/, ts = /\bnoLineNumbers\b/, os = lazy(() => import("./mermaid-GHXKKRXX-VehRUDbr.js").then((e) => ({ default: e.Mermaid }))), ns = /language-([^\s]+)/;
|
|
24341
24341
|
function qe(e, t) {
|
|
24342
24342
|
if (!(e != null && e.position || t != null && t.position)) return true;
|
|
24343
24343
|
if (!(e != null && e.position && (t != null && t.position))) return false;
|
package/dist/components/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A, a, b, c, d, e, f, g, h, D, i, j, k, R, S, T, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, B, C, E, F, G } from "../RecordSheet-
|
|
1
|
+
import { A, a, b, c, d, e, f, g, h, D, i, j, k, R, S, T, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, B, C, E, F, G } from "../RecordSheet-DWpgx9O_.js";
|
|
2
2
|
export {
|
|
3
3
|
A as ActivityStrip,
|
|
4
4
|
a as AgentChat,
|
package/dist/{highlighted-body-OFNGDK62-95pvcwdb.js → highlighted-body-OFNGDK62-BhPnE-9T.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as R$1, L as Li, J as At } from "./RecordSheet-
|
|
1
|
+
import { I as R$1, L as Li, J as At } from "./RecordSheet-DWpgx9O_.js";
|
|
2
2
|
import { useContext, useState, useEffect } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
var R = ({ code: s, language: e, raw: t, className: h, startLine: d, lineNumbers: m, ...p }) => {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AgentChatID, AgentChatMessage, AgentChatMetadata, AgentChatStreamEvent, AgentChatTurnStatus } from '../components/agent-chat/types.js';
|
|
2
|
+
/** True while the runtime still owes output for the turn. */
|
|
3
|
+
export declare function isActiveStatus(status: AgentChatTurnStatus | undefined): boolean;
|
|
4
|
+
/** Oldest active user turn: the one the runtime is executing (or will next). */
|
|
5
|
+
export declare function headActiveRequestId<TMeta extends AgentChatMetadata, TToolInput, TActionData>(messages: AgentChatMessage<TMeta, TToolInput, TActionData>[]): AgentChatID | undefined;
|
|
6
|
+
export interface ReattachDecisionInput {
|
|
7
|
+
/** Auto-subscribe is on and the transport can stream. */
|
|
8
|
+
canSubscribe: boolean;
|
|
9
|
+
/** Durable history has been projected at least once for this identity. */
|
|
10
|
+
historyLoaded: boolean;
|
|
11
|
+
isStreaming: boolean;
|
|
12
|
+
isSubmitting: boolean;
|
|
13
|
+
isAborting: boolean;
|
|
14
|
+
/** Oldest active user turn found in the transcript. */
|
|
15
|
+
headActiveRequestId?: AgentChatID;
|
|
16
|
+
/** Last request id an automatic attach was already attempted for. */
|
|
17
|
+
attemptedRequestId?: AgentChatID;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The in-flight request an idle chat should attach to, or `undefined`.
|
|
21
|
+
* Sends subscribe themselves; this covers requests discovered from history.
|
|
22
|
+
* One attempt per request id — when the attach fails, the transport's own
|
|
23
|
+
* reconnects, the watchdog, and the discovery poll remain the recovery path,
|
|
24
|
+
* so a dead request never causes an attach/fail loop.
|
|
25
|
+
*/
|
|
26
|
+
export declare function reattachRequestId(input: ReattachDecisionInput): AgentChatID | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Request id of an event that projects assistant output. A fresh stream
|
|
29
|
+
* attach replays the request from its first event, so the first such event
|
|
30
|
+
* marks where history's projection must give way to the replay.
|
|
31
|
+
*/
|
|
32
|
+
export declare function replayedOutputRequestId<TMeta extends AgentChatMetadata, TToolInput, TActionData>(event: AgentChatStreamEvent<TMeta, TToolInput, TActionData>): AgentChatID | undefined;
|
|
33
|
+
/** Drop a request's projected assistant output so a stream replay rebuilds it without doubling. */
|
|
34
|
+
export declare function dropAssistantMessagesForRequest<TMeta extends AgentChatMetadata, TToolInput, TActionData>(messages: AgentChatMessage<TMeta, TToolInput, TActionData>[], requestId: AgentChatID): AgentChatMessage<TMeta, TToolInput, TActionData>[];
|
|
35
|
+
//# sourceMappingURL=agent-chat-reconnect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-chat-reconnect.d.ts","sourceRoot":"","sources":["../../src/hooks/agent-chat-reconnect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,mCAAmC,CAAC;AA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ation-run-
|
|
1
|
+
import { a, u, b, c } from "../use-automation-run-DsfzeSNA.js";
|
|
2
2
|
import { u as u2, a as a2, b as b2, c as c2, d, e, f, g } from "../use-sql-table-_aMNbZ6w.js";
|
|
3
3
|
export {
|
|
4
4
|
a as areAgentChatMutationsBlocked,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-agent-chat.d.ts","sourceRoot":"","sources":["../../src/hooks/use-agent-chat.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,oBAAoB,EAEpB,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EAEd,qBAAqB,EAGrB,mBAAmB,EAEnB,kBAAkB,EAClB,aAAa,
|
|
1
|
+
{"version":3,"file":"use-agent-chat.d.ts","sourceRoot":"","sources":["../../src/hooks/use-agent-chat.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,oBAAoB,EAEpB,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EAEd,qBAAqB,EAGrB,mBAAmB,EAEnB,kBAAkB,EAClB,aAAa,EACd,MAAM,yBAAyB,CAAC;AAejC,MAAM,WAAW,mBAAmB,CAClC,KAAK,SAAS,iBAAiB,GAAG,iBAAiB,EACnD,UAAU,GAAG,OAAO,EACpB,WAAW,GAAG,OAAO;IAErB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,kBAAkB,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;IAC9D,eAAe,CAAC,EAAE,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,CAAC,EAAE,CAAC;IACrE,WAAW,CAAC,EAAE,oBAAoB,CAAC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;I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E,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,CAAC,EAAE,GAC5D,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,CAAC,EAAE,CAwBpD"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A, a, b, c, d, e, f, g, h, D, i, j, k, R, S, T, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, B, C, E, F, G } from "./RecordSheet-
|
|
2
|
-
import { a as a2, u as u2, b as b2, c as c2 } from "./use-automation-run-
|
|
1
|
+
import { A, a, b, c, d, e, f, g, h, D, i, j, k, R, S, T, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, B, C, E, F, G } from "./RecordSheet-DWpgx9O_.js";
|
|
2
|
+
import { a as a2, u as u2, b as b2, c as c2 } from "./use-automation-run-DsfzeSNA.js";
|
|
3
3
|
import { u as u3, a as a3, b as b3, c as c3, d as d2, e as e2, f as f2, g as g2 } from "./use-sql-table-_aMNbZ6w.js";
|
|
4
4
|
import { B as B2, E as E2, a as a4, b as b4, c as c4, d as d3, e as e3, f as f3, g as g3, h as h2, i as i2, j as j2, k as k2, l as l2, m as m2, n as n2, o as o2, p as p2, q as q2, r as r2, s as s2, t as t2, u as u4, v as v2, w as w2, x as x2, y as y2, z as z2, A as A2, C as C2, D as D2, F as F2, G as G2, H, I, J, K, L, M, N, O, P, Q, R as R2, S as S2, T as T2, U, V, W, X, Y, Z, _, $, a0, a1 } from "./automations-DD15itWa.js";
|
|
5
5
|
import { c as c5, f as f4, a as a5, b as b5, d as d4, e as e4, g as g4, h as h3, i as i3, j as j3, k as k3, l as l3, m as m3, n as n3, o as o3, s as s3 } from "./formatters-BuHr2I8Z.js";
|
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
import { useEffect, useState, useRef, useCallback, useMemo } from "react";
|
|
2
2
|
import { useQueryClient, useMutation, useQuery } from "@tanstack/react-query";
|
|
3
3
|
import { i as ensureAutomationRun, g as createAutomationRun, c as cancelAutomationRun, a as automationStatuses, m as getAutomationRun } from "./automations-DD15itWa.js";
|
|
4
|
+
function isActiveStatus(status) {
|
|
5
|
+
return status === "queued" || status === "claimed" || status === "preparing" || status === "submitting" || status === "running";
|
|
6
|
+
}
|
|
7
|
+
function headActiveRequestId(messages) {
|
|
8
|
+
for (const message of messages) {
|
|
9
|
+
if (message.role === "user" && isActiveStatus(message.status) && message.requestId) {
|
|
10
|
+
return message.requestId;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return void 0;
|
|
14
|
+
}
|
|
15
|
+
function reattachRequestId(input) {
|
|
16
|
+
if (!input.canSubscribe || !input.historyLoaded) return void 0;
|
|
17
|
+
if (input.isStreaming || input.isSubmitting || input.isAborting) return void 0;
|
|
18
|
+
if (!input.headActiveRequestId || input.headActiveRequestId === input.attemptedRequestId) return void 0;
|
|
19
|
+
return input.headActiveRequestId;
|
|
20
|
+
}
|
|
21
|
+
function replayedOutputRequestId(event) {
|
|
22
|
+
switch (event.type) {
|
|
23
|
+
case "text_delta":
|
|
24
|
+
case "thinking_delta":
|
|
25
|
+
case "tool_start":
|
|
26
|
+
case "tool_update":
|
|
27
|
+
case "tool_end":
|
|
28
|
+
case "action":
|
|
29
|
+
case "file":
|
|
30
|
+
case "info":
|
|
31
|
+
return event.requestId;
|
|
32
|
+
default:
|
|
33
|
+
return void 0;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function dropAssistantMessagesForRequest(messages, requestId) {
|
|
37
|
+
return messages.filter((message) => !(message.role === "assistant" && message.requestId === requestId));
|
|
38
|
+
}
|
|
4
39
|
const QUEUED_DISCOVERY_POLL_MS = 2e3;
|
|
5
40
|
const IDLE_DISCOVERY_POLL_MS = 1e4;
|
|
6
41
|
const HIDDEN_DISCOVERY_POLL_MS = 3e4;
|
|
@@ -133,7 +168,7 @@ function useAgentChat({
|
|
|
133
168
|
const [isStreaming, setIsStreaming] = useState(false);
|
|
134
169
|
const [isAborting, setIsAborting] = useState(false);
|
|
135
170
|
const [isCompacting, setIsCompacting] = useState(false);
|
|
136
|
-
const [
|
|
171
|
+
const [historyLoadedFor, setHistoryLoadedFor] = useState(null);
|
|
137
172
|
const [webSearchOn, setWebSearchOn] = useState(webSearchDefault);
|
|
138
173
|
useEffect(() => {
|
|
139
174
|
if (webSearchDefault !== void 0) setWebSearchOn((current) => current ?? webSearchDefault);
|
|
@@ -141,6 +176,8 @@ function useAgentChat({
|
|
|
141
176
|
const messagesRef = useRef(messages);
|
|
142
177
|
const subscriptionRef = useRef(null);
|
|
143
178
|
const activeRequestIdRef = useRef(void 0);
|
|
179
|
+
const streamRebuildRequestIdRef = useRef(void 0);
|
|
180
|
+
const autoAttachedRequestIdRef = useRef(void 0);
|
|
144
181
|
const mountedRef = useRef(true);
|
|
145
182
|
const refreshInFlightRef = useRef(false);
|
|
146
183
|
const isStreamingRef = useRef(false);
|
|
@@ -210,7 +247,7 @@ function useAgentChat({
|
|
|
210
247
|
const result = await transport.loadHistory({ agentId, sessionId, limit: historyLimit });
|
|
211
248
|
if (!mountedRef.current || identityKeyRef.current !== requestedIdentity) return;
|
|
212
249
|
applyHistoryResult(result);
|
|
213
|
-
|
|
250
|
+
setHistoryLoadedFor(requestedIdentity);
|
|
214
251
|
} catch (err) {
|
|
215
252
|
if (identityKeyRef.current !== requestedIdentity) return;
|
|
216
253
|
handleError(err);
|
|
@@ -237,7 +274,7 @@ function useAgentChat({
|
|
|
237
274
|
const result = await transport.loadHistory({ agentId, sessionId, limit: historyLimit });
|
|
238
275
|
if (!mountedRef.current || identityKeyRef.current !== requestedIdentity) return;
|
|
239
276
|
applyHistoryResult(result);
|
|
240
|
-
|
|
277
|
+
setHistoryLoadedFor(requestedIdentity);
|
|
241
278
|
} catch {
|
|
242
279
|
} finally {
|
|
243
280
|
refreshInFlightRef.current = false;
|
|
@@ -318,6 +355,7 @@ function useAgentChat({
|
|
|
318
355
|
(requestId, status, errorMessage) => {
|
|
319
356
|
if (!requestId) return;
|
|
320
357
|
clearWatchdog();
|
|
358
|
+
if (streamRebuildRequestIdRef.current === requestId) streamRebuildRequestIdRef.current = void 0;
|
|
321
359
|
setMessages(
|
|
322
360
|
(current) => closeOpenThinking(
|
|
323
361
|
current.map(
|
|
@@ -338,6 +376,11 @@ function useAgentChat({
|
|
|
338
376
|
const applyStreamEvent = useCallback(
|
|
339
377
|
(event) => {
|
|
340
378
|
setError(null);
|
|
379
|
+
const rebuildTarget = streamRebuildRequestIdRef.current;
|
|
380
|
+
if (rebuildTarget && replayedOutputRequestId(event) === rebuildTarget) {
|
|
381
|
+
streamRebuildRequestIdRef.current = void 0;
|
|
382
|
+
setMessages((current) => dropAssistantMessagesForRequest(current, rebuildTarget));
|
|
383
|
+
}
|
|
341
384
|
switch (event.type) {
|
|
342
385
|
case "text_delta":
|
|
343
386
|
setMessages((current) => applyAssistantDelta(current, event.requestId, "text", event.delta));
|
|
@@ -399,11 +442,12 @@ function useAgentChat({
|
|
|
399
442
|
[handleError, setMessages, settleRequest]
|
|
400
443
|
);
|
|
401
444
|
const startSubscription = useCallback(
|
|
402
|
-
(requestId) => {
|
|
445
|
+
(requestId, options) => {
|
|
403
446
|
if (!autoSubscribe || !transport.subscribe || !requestId) return;
|
|
404
447
|
subscriptionRef.current?.close();
|
|
405
448
|
clearWatchdog();
|
|
406
449
|
activeRequestIdRef.current = requestId;
|
|
450
|
+
streamRebuildRequestIdRef.current = options?.rebuildFromReplay ? requestId : void 0;
|
|
407
451
|
setIsStreaming(true);
|
|
408
452
|
subscriptionRef.current = transport.subscribe(
|
|
409
453
|
{ agentId, sessionId, requestId },
|
|
@@ -655,6 +699,8 @@ function useAgentChat({
|
|
|
655
699
|
subscriptionRef.current = null;
|
|
656
700
|
clearWatchdog();
|
|
657
701
|
activeRequestIdRef.current = void 0;
|
|
702
|
+
streamRebuildRequestIdRef.current = void 0;
|
|
703
|
+
autoAttachedRequestIdRef.current = void 0;
|
|
658
704
|
setMessages([]);
|
|
659
705
|
setPage(initialPage ?? null);
|
|
660
706
|
setTokenUsage(null);
|
|
@@ -665,12 +711,41 @@ function useAgentChat({
|
|
|
665
711
|
setIsSubmitting(false);
|
|
666
712
|
setIsAborting(false);
|
|
667
713
|
setIsCompacting(false);
|
|
668
|
-
|
|
714
|
+
setHistoryLoadedFor(null);
|
|
669
715
|
}, [identityKey, clearWatchdog, initialPage, setMessages]);
|
|
670
716
|
useEffect(() => {
|
|
671
717
|
if (!autoLoadHistory) return;
|
|
672
718
|
void loadHistory();
|
|
673
719
|
}, [autoLoadHistory, loadHistory]);
|
|
720
|
+
useEffect(() => {
|
|
721
|
+
if (disabled) return;
|
|
722
|
+
const target = reattachRequestId({
|
|
723
|
+
canSubscribe: Boolean(autoSubscribe && transport.subscribe),
|
|
724
|
+
// Requiring history projected for THIS identity also skips the render
|
|
725
|
+
// passes right after a session switch, where messages and flags still
|
|
726
|
+
// hold the previous session's values.
|
|
727
|
+
historyLoaded: historyLoadedFor === identityKey,
|
|
728
|
+
isStreaming,
|
|
729
|
+
isSubmitting,
|
|
730
|
+
isAborting,
|
|
731
|
+
headActiveRequestId: headActiveRequestId(messages),
|
|
732
|
+
attemptedRequestId: autoAttachedRequestIdRef.current
|
|
733
|
+
});
|
|
734
|
+
if (!target) return;
|
|
735
|
+
autoAttachedRequestIdRef.current = target;
|
|
736
|
+
startSubscription(target, { rebuildFromReplay: true });
|
|
737
|
+
}, [
|
|
738
|
+
autoSubscribe,
|
|
739
|
+
disabled,
|
|
740
|
+
historyLoadedFor,
|
|
741
|
+
identityKey,
|
|
742
|
+
isAborting,
|
|
743
|
+
isStreaming,
|
|
744
|
+
isSubmitting,
|
|
745
|
+
messages,
|
|
746
|
+
startSubscription,
|
|
747
|
+
transport.subscribe
|
|
748
|
+
]);
|
|
674
749
|
const turns = useMemo(() => buildAgentChatTurns(messages), [messages]);
|
|
675
750
|
const queueLength = useMemo(
|
|
676
751
|
() => messages.filter((message) => message.role === "user" && message.status === "queued").length,
|
|
@@ -693,7 +768,7 @@ function useAgentChat({
|
|
|
693
768
|
[]
|
|
694
769
|
);
|
|
695
770
|
useDiscoveryPoll({
|
|
696
|
-
enabled: discoveryPoll && autoLoadHistory &&
|
|
771
|
+
enabled: discoveryPoll && autoLoadHistory && historyLoadedFor === identityKey && !disabled,
|
|
697
772
|
isTransportActive: isTransportActiveCb,
|
|
698
773
|
isRefreshInFlight: isRefreshInFlightCb,
|
|
699
774
|
hasQueuedPending: hasQueuedPendingCb,
|
|
@@ -750,20 +825,9 @@ function defaultIDFactory() {
|
|
|
750
825
|
}
|
|
751
826
|
return `chat_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`;
|
|
752
827
|
}
|
|
753
|
-
function isActiveStatus(status) {
|
|
754
|
-
return status === "queued" || status === "claimed" || status === "preparing" || status === "submitting" || status === "running";
|
|
755
|
-
}
|
|
756
828
|
function activeUserMessages(messages) {
|
|
757
829
|
return messages.filter((message) => message.role === "user" && isActiveStatus(message.status));
|
|
758
830
|
}
|
|
759
|
-
function headActiveRequestId(messages) {
|
|
760
|
-
for (const message of messages) {
|
|
761
|
-
if (message.role === "user" && isActiveStatus(message.status) && message.requestId) {
|
|
762
|
-
return message.requestId;
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
return void 0;
|
|
766
|
-
}
|
|
767
831
|
function messageKeys(message) {
|
|
768
832
|
const keys = [`${message.role}:id:${message.id}`];
|
|
769
833
|
if (message.role === "user" && message.requestId) {
|
package/package.json
CHANGED