Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Let a same-thread snapshot clear the open branch with null.
Ryan3ed3601863a8
diff --git a/src/state/snapshot-navigation.keep.test.ts b/src/state/snapshot-navigation.keep.test.tsindex 536d5f834a..e18becdf57 100644--- a/src/state/snapshot-navigation.keep.test.ts+++ b/src/state/snapshot-navigation.keep.test.ts@@ -53,6 +53,24 @@ describe("a reconnect snapshot must not replace a hand-off the person is readingexpect(kept.messages.map(message => message.id)).toEqual(["work"]);});+ it("clears the open branch when the same hand-off snapshot sets activeLeafId to null", () => {+ const previous = fixture("work", true);+ previous.activeLeafId = "work";+ const incoming = fixture("work", true);+ incoming.activeLeafId = null;+ incoming.messages = [line("work"), line("tail")];+ const kept = keepBotNavigation(previous, incoming, false);+ expect(kept.activeLeafId).toBeNull();+ expect(kept.messages.map(message => message.id)).toEqual(["work", "tail"]);+ });++ it("keeps the open branch when the same hand-off snapshot omits activeLeafId", () => {+ const previous = fixture("work", true);+ previous.activeLeafId = "work";+ const kept = keepBotNavigation(previous, fixture("work", true), false);+ expect(kept.activeLeafId).toBe("work");+ });+it("follows the server when that hand-off no longer exists", () => {const incoming = fixture("main");incoming.tasks = [{ threadId: "main", title: "Main", createdAt: 1 }];diff --git a/src/state/snapshot-navigation.ts b/src/state/snapshot-navigation.tsindex e283f1e38d..c57a8be561 100644--- a/src/state/snapshot-navigation.ts+++ b/src/state/snapshot-navigation.ts@@ -68,7 +68,7 @@ export function keepBotNavigation(previous: Bot | undefined, incoming: Bot, presawaitingThreadSnapshot: previous.awaitingThreadSnapshot,messages: sameOpenHandoff ? reconcileTranscript(previous.messages, incoming.messages) : previous.messages,hasMore: sameOpenHandoff ? Boolean(previous.hasMore || incoming.hasMore) : previous.hasMore,- activeLeafId: sameOpenHandoff ? incoming.activeLeafId ?? previous.activeLeafId : previous.activeLeafId,+ activeLeafId: sameOpenHandoff ? (incoming.activeLeafId === undefined ? previous.activeLeafId : incoming.activeLeafId) : previous.activeLeafId,pinnedMessageId: previous.pinnedMessageId,};}