Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(editor): a run the endpoint dropped can be carried on

yhh0c0b022d230f
diff --git a/desktop/src/store/AgentStore.ts b/desktop/src/store/AgentStore.ts
index 18d12162a..49b76f35a 100644
--- a/desktop/src/store/AgentStore.ts
+++ b/desktop/src/store/AgentStore.ts
@@ -102,8 +102,17 @@ export type AgentEntry =
export type TurnReason = 'end_turn' | 'aborted' | 'error' | 'refusal' | 'max_rounds';
-/** Endings the run could have gone further from, so the person can say so. */
-export const RESUMABLE: ReadonlySet<TurnReason> = new Set<TurnReason>(['aborted', 'max_rounds']);
+/**
+ * Endings the run could have gone further from, so the person can say so.
+ *
+ * `error` is one of them. A turn that died because the endpoint dropped mid-run
+ * ("could not reach the endpoint: terminated" — seen in a real session) leaves
+ * half-built work and no way forward: the ending that most needs the offer was
+ * the one ending without it, and retyping the request starts the model over
+ * instead of continuing. A cause that has not cleared (a rejected key) simply
+ * says so again, which is honest.
+ */
+export const RESUMABLE: ReadonlySet<TurnReason> = new Set<TurnReason>(['aborted', 'max_rounds', 'error']);
export interface AgentTurn {
/** Position in the conversation; stable, so React keys are too. */
diff --git a/desktop/tests/agent-replay.test.ts b/desktop/tests/agent-replay.test.ts
index 9071368ee..b15ed488d 100644
--- a/desktop/tests/agent-replay.test.ts
+++ b/desktop/tests/agent-replay.test.ts
@@ -10,7 +10,7 @@
* the session's own coordinate now, and the stream is replayed on attach.
*/
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
-import { useAgent, attachAgentBridge } from '@/store/AgentStore';
+import { useAgent, attachAgentBridge, RESUMABLE } from '@/store/AgentStore';
import type { AgentEvent } from '../electron/agent/types';
import type { AgentStatus } from '../electron/agent/host';
@@ -90,3 +90,20 @@ describe('attaching to a conversation already in progress', () => {
expect(useAgent.getState().turns).toEqual([]);
});
});
+
+describe('which endings offer to carry on', () => {
+ // A person's way forward from a run that stopped early. `error` belongs here:
+ // a turn that died because the endpoint dropped mid-run leaves half-built work
+ // and retyping the request starts the model over instead of continuing.
+ it('offers it for every ending the run could have gone further from', () => {
+ expect(RESUMABLE.has('aborted')).toBe(true);
+ expect(RESUMABLE.has('max_rounds')).toBe(true);
+ expect(RESUMABLE.has('error')).toBe(true);
+ });
+
+ // Not for the two that are DONE — an offer there reads as "that wasn't it?".
+ it('does not offer it for a run that finished or was declined', () => {
+ expect(RESUMABLE.has('end_turn')).toBe(false);
+ expect(RESUMABLE.has('refusal')).toBe(false);
+ });
+});