




















@@ -64,6 +64,7 @@ export type ChatHost = ChatInputHistoryState & {
6464chatRunId: string | null;
6565chatSending: boolean;
6666lastError?: string | null;
67+chatError?: string | null;
6768basePath: string;
6869settings?: { token?: string | null };
6970password?: string | null;
@@ -92,6 +93,11 @@ export type ChatHost = ChatInputHistoryState & {
9293onSlashAction?: (action: string) => void | Promise<void>;
9394};
949596+function setChatError(host: ChatHost, error: string | null) {
97+host.lastError = error;
98+host.chatError = error;
99+}
100+95101export type ChatSendOptions = {
96102confirmReset?: boolean;
97103restoreDraft?: boolean;
@@ -586,7 +592,7 @@ async function sendQueuedChatMessage(
586592host.chatSending = true;
587593const isVisibleSession = () => visibleSessionMatches(host, sessionKey, prepared.agentId);
588594if (isVisibleSession()) {
589-host.lastError = null;
595+setChatError(host, null);
590596reconcileChatRunLifecycle(host as unknown as Parameters<typeof reconcileChatRunLifecycle>[0], {
591597clearRunStatus: true,
592598});
@@ -655,7 +661,7 @@ async function sendQueuedChatMessage(
655661sendState: "waiting-reconnect",
656662}));
657663if (isVisibleSession()) {
658-host.lastError = "Message will send when the Gateway reconnects.";
664+setChatError(host, "Message will send when the Gateway reconnects.");
659665}
660666return "pending";
661667}
@@ -665,7 +671,7 @@ async function sendQueuedChatMessage(
665671sendState: "failed",
666672}));
667673if (isVisibleSession()) {
668-host.lastError = error;
674+setChatError(host, error);
669675restoreComposerAfterFailedSend(host, opts ?? {});
670676}
671677return "failed";
@@ -948,7 +954,7 @@ async function flushChatQueue(host: ChatHost) {
948954});
949955}
950956} catch (err) {
951-host.lastError = String(err);
957+setChatError(host, String(err));
952958}
953959if (!ok && next.localCommandName) {
954960host.chatQueue = [next, ...host.chatQueue];
@@ -1248,7 +1254,7 @@ async function dispatchSlashCommand(
12481254return;
12491255case "new":
12501256if (!host.onSlashAction) {
1251-host.lastError = "New Chat is unavailable.";
1257+setChatError(host, "New Chat is unavailable.");
12521258return;
12531259}
12541260await host.onSlashAction("new-session");
@@ -1272,7 +1278,7 @@ async function dispatchSlashCommand(
12721278}
1273127912741280if (!host.client || !host.connected) {
1275-host.lastError = "Gateway not connected";
1281+setChatError(host, "Gateway not connected");
12761282injectCommandResult(
12771283host,
12781284`Cannot run \`/${name}\`: Control UI is not connected to the Gateway.`,
@@ -1290,7 +1296,7 @@ async function dispatchSlashCommand(
12901296agentId: scopedAgentIdForSession(host, targetSessionKey),
12911297});
12921298} catch (err) {
1293-host.lastError = String(err);
1299+setChatError(host, String(err));
12941300injectCommandResult(host, `Command \`/${name}\` failed unexpectedly.`);
12951301scheduleChatScroll(host as unknown as Parameters<typeof scheduleChatScroll>[0]);
12961302return;
@@ -1350,7 +1356,7 @@ async function clearChatHistory(host: ChatHost) {
13501356});
13511357await loadChatHistory(host as unknown as ChatState);
13521358} catch (err) {
1353-host.lastError = String(err);
1359+setChatError(host, String(err));
13541360}
13551361scheduleChatScroll(host as unknown as Parameters<typeof scheduleChatScroll>[0]);
13561362}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。