Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Thread tabs: closing the blank New thread tab goes back to the thread open before it
milind-soni092faf4e4532
diff --git a/src/components/ThreadTabStrip.dom.test.ts b/src/components/ThreadTabStrip.dom.test.tsindex ce28c117d0..ec7e26a8a8 100644--- a/src/components/ThreadTabStrip.dom.test.ts+++ b/src/components/ThreadTabStrip.dom.test.ts@@ -3,11 +3,13 @@ import { act, createElement } from "react";import { createRoot, type Root } from "react-dom/client";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import type { Action, Bot, Task } from "@/state/store";+import { newChatThreadId } from "@/state/new-chat";const feature = vi.hoisted(() => ({ on: true }));const dispatch = vi.hoisted(() => vi.fn());+const store = vi.hoisted(() => ({ state: { bots: [] as unknown[], newChat: null } }));vi.mock("@/lib/use-feature", () => ({ useFeature: (name: string) => name === "threadTabs" && feature.on }));-vi.mock("@/state/store-select", () => ({ useStoreDispatch: () => dispatch, useStoreSelector: () => false }));+vi.mock("@/state/store-select", () => ({ useStoreDispatch: () => dispatch, useStoreSelector: (select: (state: unknown) => unknown) => select(store.state) }));import { ThreadTabStrip } from "./ThreadTabStrip";@@ -70,6 +72,14 @@ describe("thread tab strip", () => {expect(sent()[0]).toMatchObject({ botId: "kiwi", threadId: "trip" });});+ it("closes the blank New thread tab by going back to the thread open before it, archiving nothing", () => {+ store.state = { bots: [{ id: "kiwi", threadId: "launch" }], newChat: null };+ render(kiwi(FIVE, newChatThreadId("kiwi")));+ expect(tab("New thread").getAttribute("aria-selected")).toBe("true");+ act(() => closeOf("New thread").click());+ expect(sent()).toEqual([{ type: "switchTask", botId: "kiwi", threadId: "launch" }]);+ });+it("archives on a middle click", () => {render(kiwi(FIVE, "launch"));act(() => { tab("Call notes").dispatchEvent(new MouseEvent("auxclick", { bubbles: true, button: 1 })); });diff --git a/src/components/ThreadTabStrip.tsx b/src/components/ThreadTabStrip.tsxindex 2dea66f08f..aa6c69c6fc 100644--- a/src/components/ThreadTabStrip.tsx+++ b/src/components/ThreadTabStrip.tsx@@ -57,6 +57,7 @@ function Strip({ bot, tabs }: { bot: Bot; tabs: ThreadTab[] }) {const [toast, setToast] = useUndoToast();const [fade, setFade] = useState<string | undefined>();const canWrite = bot.yourAccess !== "view";+ const behindDraft = useStoreSelector((state) => state.bots.find((each) => each.id === bot.id)?.threadId);const measure = useCallback(() => {const element = scroller.current;@@ -80,11 +81,14 @@ function Strip({ bot, tabs }: { bot: Bot; tabs: ThreadTab[] }) {};const close = (tab: ThreadTab) => {if (!tab.closable) return;+ if (tab.draft) {+ if (behindDraft) dispatch({ type: "switchTask", botId: bot.id, threadId: behindDraft });+ return;+ }if (tab.threadId === active) {const next = neighbourOf(tabs, tab.threadId);if (next) dispatch({ type: "switchTask", botId: bot.id, threadId: next });}- if (tab.draft) return;dispatch({ type: "updateTask", botId: bot.id, threadId: tab.threadId, patch: { archivedAt: Date.now() } });setToast({ text: t("sidebar.threads.hidden"), undo: () => dispatch({ type: "updateTask", botId: bot.id, threadId: tab.threadId, patch: { archivedAt: null } }) });};