fix(chat): recover active requests and preserve finish order

This commit is contained in:
john
2026-07-16 21:04:32 +08:00
parent 933466c8ab
commit c1012da120
4 changed files with 65 additions and 3 deletions
+18 -1
View File
@@ -1618,7 +1618,7 @@ export function useTKMindChat(
if (
activeSessionId &&
err instanceof ApiError &&
shouldKeepStreamingAfterRunError(err.status)
shouldKeepStreamingAfterRunError(err.status, err.message, err.code)
) {
subscribeToSession(activeSessionId);
setChatState('streaming');
@@ -1626,6 +1626,23 @@ export function useTKMindChat(
scheduleReplyRecoverySync(activeSessionId, submitToken);
return;
}
if (
activeSessionId &&
shouldKeepStreamingAfterRunError(
undefined,
err instanceof Error ? err.message : String(err),
err instanceof ApiError ? err.code : '',
)
) {
// Goose may report its session concurrency guard as a failed run
// message instead of an HTTP 409. Reattach to the session stream
// and reconcile the snapshot; do not strand the composer in error.
subscribeToSession(activeSessionId);
setChatState('streaming');
setError(null);
scheduleReplyRecoverySync(activeSessionId, submitToken);
return;
}
if (session && activeSessionId) setSessions((prev) => touchSession(prev, activeSessionId!, -1));
if (err instanceof ApiError && err.status === 402) {
notifyInsufficientBalance();