@blade-hq/agent-react 2610.0.2 → 2610.0.3-beta.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.
|
@@ -24,7 +24,7 @@ export declare function formatExecutionDuration(durationMs: number): string;
|
|
|
24
24
|
export declare function getExecutionDurationMs({ messages, isStreaming, now, }: {
|
|
25
25
|
messages: ChatMessage[];
|
|
26
26
|
isStreaming: boolean;
|
|
27
|
-
now?: number;
|
|
27
|
+
now?: number | null;
|
|
28
28
|
}): number;
|
|
29
29
|
/** 一轮助手回复:执行过程默认折叠,最终正文始终显示在摘要下方。 */
|
|
30
30
|
export declare function AssistantTurnBlock({ messages, isStreaming, askAnswers, onAnswer, sessionStatus, classNames, renderers, hidePlanUpdateTools, sessionId, }: Props): import("react/jsx-runtime").JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -46757,6 +46757,9 @@ function useStickToBottomContext() {
|
|
|
46757
46757
|
return context;
|
|
46758
46758
|
}
|
|
46759
46759
|
|
|
46760
|
+
// src/components/AssistantTurnBlock.tsx
|
|
46761
|
+
import { getServerTime } from "@blade-hq/agent-client/internal";
|
|
46762
|
+
|
|
46760
46763
|
// src/components/MessageImage.tsx
|
|
46761
46764
|
import { forwardRef as forwardRef3, useEffect as useEffect19, useImperativeHandle as useImperativeHandle2, useRef as useRef21, useState as useState26 } from "react";
|
|
46762
46765
|
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
@@ -56681,7 +56684,7 @@ function formatExecutionDuration(durationMs) {
|
|
|
56681
56684
|
function getExecutionDurationMs({
|
|
56682
56685
|
messages,
|
|
56683
56686
|
isStreaming,
|
|
56684
|
-
now =
|
|
56687
|
+
now = null
|
|
56685
56688
|
}) {
|
|
56686
56689
|
const knownDuration = messages.reduce(
|
|
56687
56690
|
(total, message) => {
|
|
@@ -56695,7 +56698,7 @@ function getExecutionDurationMs({
|
|
|
56695
56698
|
},
|
|
56696
56699
|
0
|
|
56697
56700
|
);
|
|
56698
|
-
if (!isStreaming) return knownDuration;
|
|
56701
|
+
if (!isStreaming || now === null) return knownDuration;
|
|
56699
56702
|
const startedAt = messages.map((message) => message.timestamp ? Date.parse(message.timestamp) : Number.NaN).filter((value) => Number.isFinite(value)).sort((a, b2) => a - b2)[0];
|
|
56700
56703
|
if (startedAt === void 0) return knownDuration;
|
|
56701
56704
|
return Math.max(knownDuration, now - startedAt);
|
|
@@ -56886,17 +56889,23 @@ function AssistantTurnBlock({
|
|
|
56886
56889
|
wasStreamingRef.current = isStreaming;
|
|
56887
56890
|
}, [hasActionableToolCall, isStreaming]);
|
|
56888
56891
|
const effectiveMode = resolveTurnDisplayMode({ isStreaming, displayMode });
|
|
56892
|
+
const client = useOptionalBladeClient();
|
|
56889
56893
|
const executionDurationMs = getExecutionDurationMs({ messages, isStreaming });
|
|
56890
|
-
const [clock, setClock] = useState31(() =>
|
|
56894
|
+
const [clock, setClock] = useState31(() => performance.now());
|
|
56891
56895
|
const hasLiveStartTime = messages.some(
|
|
56892
56896
|
(message) => message.timestamp != null && Number.isFinite(Date.parse(message.timestamp))
|
|
56893
56897
|
);
|
|
56894
56898
|
useEffect23(() => {
|
|
56895
56899
|
if (!isStreaming || !hasLiveStartTime) return;
|
|
56896
|
-
const timer = window.setInterval(() => setClock(
|
|
56900
|
+
const timer = window.setInterval(() => setClock(performance.now()), 1e3);
|
|
56897
56901
|
return () => window.clearInterval(timer);
|
|
56898
56902
|
}, [hasLiveStartTime, isStreaming]);
|
|
56899
|
-
const liveExecutionDurationMs = isStreaming ? getExecutionDurationMs({
|
|
56903
|
+
const liveExecutionDurationMs = isStreaming ? getExecutionDurationMs({
|
|
56904
|
+
messages,
|
|
56905
|
+
isStreaming,
|
|
56906
|
+
// Direct LLM mode has no Blade session and generates its own local timestamps.
|
|
56907
|
+
now: sessionId ? getServerTime(client, clock) : Date.now()
|
|
56908
|
+
}) : executionDurationMs;
|
|
56900
56909
|
const memoryRefs = collectMemoryRefs(messages);
|
|
56901
56910
|
const inlineToolUiCards = collectInlineToolUiCards(messages);
|
|
56902
56911
|
if (!hasExecutionProcess) {
|