Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(chat): a Compact-button summary leaves an ended turn ended
AdityaUmalebb314547f464
diff --git a/src/state/turn-status.test.ts b/src/state/turn-status.test.tsindex ef326d9232..a522dd0b16 100644--- a/src/state/turn-status.test.ts+++ b/src/state/turn-status.test.ts@@ -74,15 +74,17 @@ describe("a thread's live turn", () => {it("says it is summarizing earlier messages until the summary is done, and leaves anything newer on the line", () => {note({ type: "turn.completed", ok: true } as Partial<RuntimeEvent>);note({ type: "context.summarizing", active: true, turnId: undefined } as Partial<RuntimeEvent>);- expect(turnLive("t")).toEqual({ turnId: "turn-1", ended: false, status: { activity: "summarizing" } });+ expect(turnLive("t")).toMatchObject({ turnId: "turn-1", ended: false, status: { activity: "summarizing" } });note({ type: "context.summarizing", active: false, turnId: undefined } as Partial<RuntimeEvent>);expect(turnLive("t").status, "a finished or stopped summary clears the line").toBeNull();+ expect(turnLive("t").ended, "a summary after the turn ended (Compact button) leaves it ended").toBe(true);note({ type: "context.summarizing", active: true, turnId: undefined } as Partial<RuntimeEvent>);note({ type: "turn.started", turnId: "turn-2" } as Partial<RuntimeEvent>);expect(turnLive("t")).toEqual({ turnId: "turn-2", ended: false, status: null });note({ type: "content.delta", streamKind: "reasoning_text", delta: "x", turnId: "turn-2" } as Partial<RuntimeEvent>);note({ type: "context.summarizing", active: false, turnId: undefined } as Partial<RuntimeEvent>);expect(turnLive("t").status, "a late end leaves the turn's own status").toEqual({ activity: "thinking" });+ expect(turnLive("t").ended, "a summary inside a running turn leaves it running").toBe(false);});it("carries what a call works on, how it is doing and its last output, and changes only when one of them does", () => {diff --git a/src/state/turn-status.ts b/src/state/turn-status.tsindex 69afc3e3d0..dff7e34a20 100644--- a/src/state/turn-status.ts+++ b/src/state/turn-status.ts@@ -15,6 +15,8 @@ export interface TurnLive {/** The newest turn this thread showed has completed, failed or stopped. */ended: boolean;status: LiveStatus | null;+ /** A summary started after this turn had ended (the Compact button); its end puts the ended state back. */+ reopened?: true;}const UNKNOWN: TurnLive = { ended: false, status: null };@@ -70,9 +72,12 @@ export function noteTurnEvent(event: RuntimeEvent): void {case "item.completed":case "request.opened":return put(threadId, { ...live, status: null });- case "context.summarizing":- if (event.active) return put(threadId, { ...live, ended: false, status: { activity: "summarizing" } });- return put(threadId, { ...live, status: live.status?.activity === "summarizing" ? null : live.status });+ case "context.summarizing": {+ if (event.active) return put(threadId, { ...live, ended: false, status: { activity: "summarizing" }, ...(live.ended ? { reopened: true as const } : {}) });+ const { reopened, ...rest } = live;+ const stillSummarizing = rest.status?.activity === "summarizing";+ return put(threadId, { ...rest, ended: rest.ended || (!!reopened && stillSummarizing), status: stillSummarizing ? null : rest.status });+ }default:if (live !== current) put(threadId, live);}