@parhelia/core 0.1.12730 → 0.1.12741
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/editor/ItemInfo.js +2 -1
- package/dist/editor/ItemInfo.js.map +1 -1
- package/dist/editor/ai/AgentTerminal.js +166 -59
- package/dist/editor/ai/AgentTerminal.js.map +1 -1
- package/dist/editor/ai/AgentTerminalStatusBar.js +32 -1
- package/dist/editor/ai/AgentTerminalStatusBar.js.map +1 -1
- package/dist/editor/ai/ToolCallDisplay.js +29 -17
- package/dist/editor/ai/ToolCallDisplay.js.map +1 -1
- package/dist/editor/ai/agentDiagnostics.d.ts +4 -1
- package/dist/editor/ai/agentDiagnostics.js +25 -1
- package/dist/editor/ai/agentDiagnostics.js.map +1 -1
- package/dist/editor/client/EditorShell.d.ts +5 -0
- package/dist/editor/client/EditorShell.js.map +1 -1
- package/dist/editor/client/hooks/useSocketMessageHandler.d.ts +8 -0
- package/dist/editor/client/hooks/useSocketMessageHandler.js +101 -4
- package/dist/editor/client/hooks/useSocketMessageHandler.js.map +1 -1
- package/dist/editor/commands/itemCommands.js +2 -0
- package/dist/editor/commands/itemCommands.js.map +1 -1
- package/dist/editor/menubar/toolbar-sections/UtilityControls.js +1 -2
- package/dist/editor/menubar/toolbar-sections/UtilityControls.js.map +1 -1
- package/dist/editor/menubar/toolbar-sections/ViewportControls.js +3 -2
- package/dist/editor/menubar/toolbar-sections/ViewportControls.js.map +1 -1
- package/dist/editor/settings/WebSocketMessages.js +6 -3
- package/dist/editor/settings/WebSocketMessages.js.map +1 -1
- package/dist/editor/settings/panels/ProjectTemplatesPanel.js +3 -1
- package/dist/editor/settings/panels/ProjectTemplatesPanel.js.map +1 -1
- package/dist/editor/ui/ItemNameDialogNew.d.ts +4 -0
- package/dist/editor/ui/ItemNameDialogNew.js +7 -5
- package/dist/editor/ui/ItemNameDialogNew.js.map +1 -1
- package/dist/revision.d.ts +2 -2
- package/dist/revision.js +2 -2
- package/dist/task-board/components/ProjectDashboard.d.ts +11 -0
- package/dist/task-board/components/ProjectDashboard.js +87 -59
- package/dist/task-board/components/ProjectDashboard.js.map +1 -1
- package/package.json +1 -1
package/dist/editor/ItemInfo.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from "react";
|
|
4
|
-
import { GitBranch, Pencil, RefreshCw } from "lucide-react";
|
|
4
|
+
import { GitBranch, Pencil, RefreshCw, Type } from "lucide-react";
|
|
5
5
|
import { useEditContext } from "./client/editContext";
|
|
6
6
|
import { CopyButton } from "../components/ui/copy-button";
|
|
7
7
|
import { Section } from "./ui/Section";
|
|
@@ -51,6 +51,7 @@ export function ItemInfo({ item }) {
|
|
|
51
51
|
name: item.displayName || "",
|
|
52
52
|
title: "Edit Display Name",
|
|
53
53
|
message: "Enter a display name for the item:",
|
|
54
|
+
headerIcon: _jsx(Type, { strokeWidth: 1 }),
|
|
54
55
|
validateAsItemName: false,
|
|
55
56
|
allowEmpty: true,
|
|
56
57
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemInfo.js","sourceRoot":"","sources":["../../src/editor/ItemInfo.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"ItemInfo.js","sourceRoot":"","sources":["../../src/editor/ItemInfo.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,cAAc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SACnB,EACN,eAAK,SAAS,EAAC,yBAAyB,aACrC,IAAI,CAAC,KAAK,EACX,KAAC,UAAU,IAAC,UAAU,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,SAAG,IAC3C,KAPE,IAAI,CAAC,GAAG,CAQZ,CACP,CAAC,IACA,GACE,IACN,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import React, { useEffect, useState, useRef, useCallback, useLayoutEffect, useMemo, } from "react";
|
|
3
3
|
import { flushSync } from "react-dom";
|
|
4
4
|
import { Send, AlertCircle, Loader2, User, Wand2, Square, Mic, MicOff, ChevronDown, ChevronUp, ListTodo, ArrowLeft, DollarSign, ExternalLink, Settings2, Target, X, Plus, } from "lucide-react";
|
|
5
|
-
import { getAgent, startAgent, claimAgentBrowser, cancelAgentDialog, assignAgentSkill, persistDraftAgent, updateAgentSettings, updateAgentCostLimit, updateAgentContext, getAgentSkillCatalog, getAgentAvailableTools, getAgentOperationAllowances, getAgentTriggerSubscriptions, cancelAgent, canonicalizeAgentMetadata, getPendingPrompts, releaseAgentBrowser, revokeAgentSkill, } from "../services/agentService";
|
|
5
|
+
import { getAgent, startAgent, claimAgentBrowser, cancelAgentDialog, assignAgentSkill, persistDraftAgent, updateAgentSettings, updateAgentCostLimit, updateAgentContext, getAgentSkillCatalog, getAgentAvailableTools, getAgentOperationAllowances, getAgentTriggerSubscriptions, cancelAgent, canonicalizeAgentMetadata, getPendingPrompts, getAgentDiagnostics, releaseAgentBrowser, revokeAgentSkill, } from "../services/agentService";
|
|
6
6
|
import { parseAgentStatus } from "../services/agentStatus";
|
|
7
7
|
import { useEditContext, useFieldsEditContext } from "../client/editContext";
|
|
8
8
|
import { localStorageService } from "../services/localStorageService";
|
|
@@ -83,6 +83,13 @@ function buildPlaceholderAgentDetails(agentStub) {
|
|
|
83
83
|
function normalizeDialogAgentId(value) {
|
|
84
84
|
return value?.trim().toLowerCase() || "";
|
|
85
85
|
}
|
|
86
|
+
function normalizeServerExecutionStatus(value) {
|
|
87
|
+
return (value || "").replace(/\s+/g, "").toLowerCase();
|
|
88
|
+
}
|
|
89
|
+
function isFinishedServerExecutionStatus(value) {
|
|
90
|
+
const normalized = normalizeServerExecutionStatus(value);
|
|
91
|
+
return normalized === "completed" || normalized === "cancelled";
|
|
92
|
+
}
|
|
86
93
|
const MACHINE_CAPACITY_REASON = "machineCapacity";
|
|
87
94
|
const MACHINE_CAPACITY_DETAIL = "waitingForCapacity";
|
|
88
95
|
function formatAllowanceSource(source) {
|
|
@@ -1015,12 +1022,16 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
|
|
|
1015
1022
|
}
|
|
1016
1023
|
return getAgentRunMessageAgentId(message.payload) === normalizedAgentId;
|
|
1017
1024
|
})
|
|
1018
|
-
.slice(
|
|
1025
|
+
.slice(0, 8)
|
|
1026
|
+
.reverse()
|
|
1019
1027
|
.map((message) => ({
|
|
1020
1028
|
timestamp: message.timestamp,
|
|
1029
|
+
direction: message.direction ?? "incoming",
|
|
1021
1030
|
type: message.type,
|
|
1022
|
-
seq: getAgentRunMessageSeq(message.payload),
|
|
1023
|
-
detail: getAgentRunMessageDetail(message.type, message.payload),
|
|
1031
|
+
seq: message.seq ?? getAgentRunMessageSeq(message.payload),
|
|
1032
|
+
detail: message.detail ?? getAgentRunMessageDetail(message.type, message.payload),
|
|
1033
|
+
rawMessage: message.rawMessage,
|
|
1034
|
+
payloadBytes: message.payloadBytes ?? null,
|
|
1024
1035
|
}));
|
|
1025
1036
|
}, [currentAgentId, editContext?.webSocketMessages]);
|
|
1026
1037
|
const appendToolUiEvent = useCallback((type, detail, seq) => {
|
|
@@ -1827,6 +1838,8 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
|
|
|
1827
1838
|
const lastSeqRef = useRef(0);
|
|
1828
1839
|
const subscribedAgentIdRef = useRef(null);
|
|
1829
1840
|
const reconcileServerStateInFlightRef = useRef(false);
|
|
1841
|
+
const streamRecoveryInFlightRef = useRef(false);
|
|
1842
|
+
const lastStreamRecoveryAtRef = useRef(0);
|
|
1830
1843
|
const toolCallFirstSeenAtRef = useRef({});
|
|
1831
1844
|
const pendingToolCompletionTimersRef = useRef({});
|
|
1832
1845
|
// Cache mode/model/profile changes made while the agent is still "new" (not yet persisted)
|
|
@@ -2183,6 +2196,37 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
|
|
|
2183
2196
|
return updated;
|
|
2184
2197
|
});
|
|
2185
2198
|
}, [stripHeartbeatMessages]);
|
|
2199
|
+
const settleCompletedRun = useCallback((finalStatus = "completed") => {
|
|
2200
|
+
clearStopGuard();
|
|
2201
|
+
setError(null);
|
|
2202
|
+
lastSeqRef.current = 0;
|
|
2203
|
+
setLastRunStatusReason(null);
|
|
2204
|
+
clearHeartbeatMessages();
|
|
2205
|
+
setMessages((prev) => {
|
|
2206
|
+
const updated = prev.map((msg) => msg.role === "assistant" && !msg.isCompleted
|
|
2207
|
+
? {
|
|
2208
|
+
...msg,
|
|
2209
|
+
isCompleted: true,
|
|
2210
|
+
messageType: "completed",
|
|
2211
|
+
}
|
|
2212
|
+
: msg);
|
|
2213
|
+
messagesRef.current = updated;
|
|
2214
|
+
return updated;
|
|
2215
|
+
});
|
|
2216
|
+
setAgent((prev) => prev
|
|
2217
|
+
? {
|
|
2218
|
+
...prev,
|
|
2219
|
+
status: "idle",
|
|
2220
|
+
statusMessage: finalStatus === "cancelled" ? "Run cancelled" : undefined,
|
|
2221
|
+
}
|
|
2222
|
+
: prev);
|
|
2223
|
+
setIsWaitingForResponse(false);
|
|
2224
|
+
isWaitingRef.current = false;
|
|
2225
|
+
setIsConnecting(false);
|
|
2226
|
+
setIsSubmitting(false);
|
|
2227
|
+
shouldCreateNewMessage.current = false;
|
|
2228
|
+
setIsAgentThinking(false);
|
|
2229
|
+
}, [clearHeartbeatMessages]);
|
|
2186
2230
|
const handleContentChunk = useCallback((message, agentData) => {
|
|
2187
2231
|
// Get messageId from data, or generate one from agent ID (for backward compatibility)
|
|
2188
2232
|
// If no messageId is provided, we'll use the last assistant message or create a new one
|
|
@@ -3484,6 +3528,7 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
|
|
|
3484
3528
|
}
|
|
3485
3529
|
// Deduplicate by sequence
|
|
3486
3530
|
if (seq && seq <= lastSeqRef.current) {
|
|
3531
|
+
appendToolUiEvent("ui:stream-seq-dropped", `agent:run:delta seq=${seq} lastSeq=${lastSeqRef.current}`, seq);
|
|
3487
3532
|
return; // Already processed
|
|
3488
3533
|
}
|
|
3489
3534
|
if (seq) {
|
|
@@ -3552,6 +3597,7 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
|
|
|
3552
3597
|
const { seq, data: statusData } = message.payload;
|
|
3553
3598
|
// Deduplicate by sequence
|
|
3554
3599
|
if (seq && seq <= lastSeqRef.current) {
|
|
3600
|
+
appendToolUiEvent("ui:stream-seq-dropped", `agent:run:status seq=${seq} lastSeq=${lastSeqRef.current}`, seq);
|
|
3555
3601
|
return;
|
|
3556
3602
|
}
|
|
3557
3603
|
if (seq) {
|
|
@@ -3809,31 +3855,7 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
|
|
|
3809
3855
|
}
|
|
3810
3856
|
// Handle "completed" state (fallback for legacy code paths that send status instead of lifecycle event)
|
|
3811
3857
|
if (normalizedStatus === "completed") {
|
|
3812
|
-
|
|
3813
|
-
setError(null);
|
|
3814
|
-
// Reset deduplication for the next run
|
|
3815
|
-
lastSeqRef.current = 0;
|
|
3816
|
-
clearHeartbeatMessages();
|
|
3817
|
-
// Mark the last assistant message as completed
|
|
3818
|
-
setMessages((prev) => {
|
|
3819
|
-
const updated = prev.map((msg) => msg.role === "assistant" && !msg.isCompleted
|
|
3820
|
-
? {
|
|
3821
|
-
...msg,
|
|
3822
|
-
isCompleted: true,
|
|
3823
|
-
messageType: "completed",
|
|
3824
|
-
}
|
|
3825
|
-
: msg);
|
|
3826
|
-
messagesRef.current = updated;
|
|
3827
|
-
return updated;
|
|
3828
|
-
});
|
|
3829
|
-
// Update agent status to idle
|
|
3830
|
-
setAgent((prev) => (prev ? { ...prev, status: "idle" } : prev));
|
|
3831
|
-
setIsWaitingForResponse(false);
|
|
3832
|
-
isWaitingRef.current = false;
|
|
3833
|
-
setIsConnecting(false);
|
|
3834
|
-
shouldCreateNewMessage.current = false;
|
|
3835
|
-
// Server says agent finished thinking
|
|
3836
|
-
setIsAgentThinking(false);
|
|
3858
|
+
settleCompletedRun("completed");
|
|
3837
3859
|
return;
|
|
3838
3860
|
}
|
|
3839
3861
|
// Handle "Running" state - agent is actively processing
|
|
@@ -3895,30 +3917,8 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
|
|
|
3895
3917
|
}
|
|
3896
3918
|
// Lifecycle: agent:run:complete
|
|
3897
3919
|
if (messageType === "agent:run:complete") {
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
setLastRunStatusReason(null);
|
|
3901
|
-
clearHeartbeatMessages();
|
|
3902
|
-
// Mark the last assistant message as completed
|
|
3903
|
-
setMessages((prev) => {
|
|
3904
|
-
const updated = prev.map((msg) => msg.role === "assistant" && !msg.isCompleted
|
|
3905
|
-
? {
|
|
3906
|
-
...msg,
|
|
3907
|
-
isCompleted: true,
|
|
3908
|
-
messageType: "completed",
|
|
3909
|
-
}
|
|
3910
|
-
: msg);
|
|
3911
|
-
messagesRef.current = updated;
|
|
3912
|
-
return updated;
|
|
3913
|
-
});
|
|
3914
|
-
// Update agent status to idle
|
|
3915
|
-
setAgent((prev) => (prev ? { ...prev, status: "idle" } : prev));
|
|
3916
|
-
setIsWaitingForResponse(false);
|
|
3917
|
-
isWaitingRef.current = false;
|
|
3918
|
-
setIsConnecting(false);
|
|
3919
|
-
shouldCreateNewMessage.current = false;
|
|
3920
|
-
// Server says agent finished thinking
|
|
3921
|
-
setIsAgentThinking(false);
|
|
3920
|
+
const finalStatus = normalizeServerExecutionStatus(message.payload?.finalStatus);
|
|
3921
|
+
settleCompletedRun(finalStatus === "cancelled" ? "cancelled" : "completed");
|
|
3922
3922
|
return;
|
|
3923
3923
|
}
|
|
3924
3924
|
// Lifecycle: agent:run:error
|
|
@@ -3941,12 +3941,14 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
|
|
|
3941
3941
|
}
|
|
3942
3942
|
}, [
|
|
3943
3943
|
agent,
|
|
3944
|
+
appendToolUiEvent,
|
|
3944
3945
|
clearHeartbeatMessages,
|
|
3945
3946
|
handleContentChunk,
|
|
3946
3947
|
handleHeartbeatMessage,
|
|
3947
3948
|
handleToolCall,
|
|
3948
3949
|
handleToolResult,
|
|
3949
3950
|
onAgentUpdate,
|
|
3951
|
+
settleCompletedRun,
|
|
3950
3952
|
]);
|
|
3951
3953
|
// Keep refs for latest agent to avoid adding them to effect deps
|
|
3952
3954
|
const agentRef = useRef(agent);
|
|
@@ -3965,10 +3967,12 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
|
|
|
3965
3967
|
if (subscribedAgentIdRef.current) {
|
|
3966
3968
|
const socket = globalThis.editorSocket;
|
|
3967
3969
|
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
3968
|
-
|
|
3970
|
+
const payload = {
|
|
3969
3971
|
type: "agent:unsubscribe",
|
|
3970
3972
|
agentId: subscribedAgentIdRef.current,
|
|
3971
|
-
}
|
|
3973
|
+
};
|
|
3974
|
+
console.debug("[AgentWebSocket] sent", payload);
|
|
3975
|
+
socket.send(JSON.stringify(payload));
|
|
3972
3976
|
}
|
|
3973
3977
|
subscribedAgentIdRef.current = null;
|
|
3974
3978
|
}
|
|
@@ -3977,10 +3981,12 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
|
|
|
3977
3981
|
// Send subscription message to server
|
|
3978
3982
|
const socket = globalThis.editorSocket;
|
|
3979
3983
|
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
3980
|
-
|
|
3984
|
+
const payload = {
|
|
3981
3985
|
type: "agent:subscribe",
|
|
3982
3986
|
agentId: agentStub.id,
|
|
3983
|
-
}
|
|
3987
|
+
};
|
|
3988
|
+
console.debug("[AgentWebSocket] sent", payload);
|
|
3989
|
+
socket.send(JSON.stringify(payload));
|
|
3984
3990
|
}
|
|
3985
3991
|
// Use the addSocketMessageListener helper from editContext
|
|
3986
3992
|
// Wrap the handler in a stable function that uses the ref
|
|
@@ -4025,10 +4031,12 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
|
|
|
4025
4031
|
if (socket &&
|
|
4026
4032
|
socket.readyState === WebSocket.OPEN &&
|
|
4027
4033
|
subscribedAgentIdRef.current) {
|
|
4028
|
-
|
|
4034
|
+
const payload = {
|
|
4029
4035
|
type: "agent:unsubscribe",
|
|
4030
4036
|
agentId: subscribedAgentIdRef.current,
|
|
4031
|
-
}
|
|
4037
|
+
};
|
|
4038
|
+
console.debug("[AgentWebSocket] sent", payload);
|
|
4039
|
+
socket.send(JSON.stringify(payload));
|
|
4032
4040
|
}
|
|
4033
4041
|
unsubscribe();
|
|
4034
4042
|
subscribedAgentIdRef.current = null;
|
|
@@ -4607,6 +4615,17 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
|
|
|
4607
4615
|
// Don't set isWaitingForResponse since the agent is already running
|
|
4608
4616
|
setIsWaitingForResponse(false);
|
|
4609
4617
|
isWaitingRef.current = false;
|
|
4618
|
+
// Remove the optimistic user message: a queued prompt must not be
|
|
4619
|
+
// inserted into the conversation now, because the still-running agent's
|
|
4620
|
+
// assistant response is going to be appended after it. The queued
|
|
4621
|
+
// prompts UI displays it via agent:prompt:queued, and when the server
|
|
4622
|
+
// dequeues and processes it, agent:user:message will append it in the
|
|
4623
|
+
// correct position (after the prior assistant response).
|
|
4624
|
+
setMessages((prev) => {
|
|
4625
|
+
const updated = prev.filter((m) => m.id !== tempMessageId);
|
|
4626
|
+
messagesRef.current = updated;
|
|
4627
|
+
return updated;
|
|
4628
|
+
});
|
|
4610
4629
|
}
|
|
4611
4630
|
else {
|
|
4612
4631
|
setLastRunStatusReason(null);
|
|
@@ -5479,6 +5498,94 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
|
|
|
5479
5498
|
totalToolCallCount,
|
|
5480
5499
|
agent?.statusMessage,
|
|
5481
5500
|
]);
|
|
5501
|
+
useEffect(() => {
|
|
5502
|
+
if (!isActive || !isExecuting || !currentAgentId) {
|
|
5503
|
+
return;
|
|
5504
|
+
}
|
|
5505
|
+
let disposed = false;
|
|
5506
|
+
const checkServerCompletion = async () => {
|
|
5507
|
+
try {
|
|
5508
|
+
const diagnostics = await getAgentDiagnostics(currentAgentId, editContext?.sessionId);
|
|
5509
|
+
if (disposed) {
|
|
5510
|
+
return;
|
|
5511
|
+
}
|
|
5512
|
+
const serverStatus = diagnostics.execution?.status;
|
|
5513
|
+
if (isFinishedServerExecutionStatus(serverStatus)) {
|
|
5514
|
+
settleCompletedRun(normalizeServerExecutionStatus(serverStatus) === "cancelled"
|
|
5515
|
+
? "cancelled"
|
|
5516
|
+
: "completed");
|
|
5517
|
+
return;
|
|
5518
|
+
}
|
|
5519
|
+
const serverLastSeq = diagnostics.currentSession?.lastDelivery?.lastSeq ??
|
|
5520
|
+
diagnostics.transport?.lastSeq ??
|
|
5521
|
+
null;
|
|
5522
|
+
const serverLastSuccessAt = diagnostics.currentSession?.lastDelivery?.lastSuccessAt ??
|
|
5523
|
+
diagnostics.transport?.lastBroadcastAt ??
|
|
5524
|
+
diagnostics.transport?.lastProducedAt ??
|
|
5525
|
+
null;
|
|
5526
|
+
const serverLastSuccessTime = serverLastSuccessAt
|
|
5527
|
+
? Date.parse(serverLastSuccessAt)
|
|
5528
|
+
: Number.NaN;
|
|
5529
|
+
const now = Date.now();
|
|
5530
|
+
const serverDeliveryOldEnough = Number.isFinite(serverLastSuccessTime) &&
|
|
5531
|
+
now - serverLastSuccessTime > 8_000;
|
|
5532
|
+
const recoveryCooldownElapsed = now - lastStreamRecoveryAtRef.current > 30_000;
|
|
5533
|
+
const localLastSeq = lastSeqRef.current;
|
|
5534
|
+
if (diagnostics.currentSession?.isConnected &&
|
|
5535
|
+
diagnostics.currentSession?.isSubscribed &&
|
|
5536
|
+
typeof serverLastSeq === "number" &&
|
|
5537
|
+
serverLastSeq > localLastSeq &&
|
|
5538
|
+
serverDeliveryOldEnough &&
|
|
5539
|
+
recoveryCooldownElapsed &&
|
|
5540
|
+
!streamRecoveryInFlightRef.current) {
|
|
5541
|
+
streamRecoveryInFlightRef.current = true;
|
|
5542
|
+
lastStreamRecoveryAtRef.current = now;
|
|
5543
|
+
appendToolUiEvent("ui:stream-recovery", `server seq ${serverLastSeq} is ahead of local seq ${localLastSeq}; reconnecting socket`, serverLastSeq);
|
|
5544
|
+
try {
|
|
5545
|
+
await loadAgent();
|
|
5546
|
+
}
|
|
5547
|
+
catch (loadError) {
|
|
5548
|
+
console.warn("[AgentTerminal] Failed to reload agent during stream recovery", loadError);
|
|
5549
|
+
}
|
|
5550
|
+
try {
|
|
5551
|
+
const socket = globalThis.editorSocket;
|
|
5552
|
+
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
5553
|
+
socket.close(4000, "agent-stream-lag");
|
|
5554
|
+
}
|
|
5555
|
+
}
|
|
5556
|
+
catch (socketError) {
|
|
5557
|
+
console.warn("[AgentTerminal] Failed to reconnect stale agent stream socket", socketError);
|
|
5558
|
+
}
|
|
5559
|
+
finally {
|
|
5560
|
+
window.setTimeout(() => {
|
|
5561
|
+
streamRecoveryInFlightRef.current = false;
|
|
5562
|
+
}, 5_000);
|
|
5563
|
+
}
|
|
5564
|
+
}
|
|
5565
|
+
}
|
|
5566
|
+
catch (error) {
|
|
5567
|
+
console.warn("[AgentTerminal] Failed to reconcile agent run status", error);
|
|
5568
|
+
streamRecoveryInFlightRef.current = false;
|
|
5569
|
+
}
|
|
5570
|
+
};
|
|
5571
|
+
// Avoid racing a freshly submitted run before the backend has registered it.
|
|
5572
|
+
const timeoutId = window.setTimeout(checkServerCompletion, 10_000);
|
|
5573
|
+
const intervalId = window.setInterval(checkServerCompletion, 15_000);
|
|
5574
|
+
return () => {
|
|
5575
|
+
disposed = true;
|
|
5576
|
+
window.clearTimeout(timeoutId);
|
|
5577
|
+
window.clearInterval(intervalId);
|
|
5578
|
+
};
|
|
5579
|
+
}, [
|
|
5580
|
+
currentAgentId,
|
|
5581
|
+
editContext?.sessionId,
|
|
5582
|
+
editContext?.socketConnectionVersion,
|
|
5583
|
+
isActive,
|
|
5584
|
+
isExecuting,
|
|
5585
|
+
appendToolUiEvent,
|
|
5586
|
+
loadAgent,
|
|
5587
|
+
settleCompletedRun,
|
|
5588
|
+
]);
|
|
5482
5589
|
const showInitialThinkingSplash = messages.length === 0 &&
|
|
5483
5590
|
!error &&
|
|
5484
5591
|
hideGreeting &&
|