Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

fix(web): prevent duplicate bot panes

Leoc1fbe0d76470
diff --git a/apps/web/src/routes/_chat.bots.$botId.tsx b/apps/web/src/routes/_chat.bots.$botId.tsx
index 6bcecd660..77147715d 100644
--- a/apps/web/src/routes/_chat.bots.$botId.tsx
+++ b/apps/web/src/routes/_chat.bots.$botId.tsx
@@ -20,6 +20,7 @@ import { toRoutinePanelItem, toRoutineSchedule } from "../components/roster/rout
import { useRosterStore } from "../components/roster/rosterStore";
import { toastManager } from "../components/ui/toast";
import { randomUUID } from "../lib/utils";
+import { botRoutePanelKeys } from "./botRoutePanelKeys";
import { botEnvironment } from "../state/bots";
import { usePrimaryEnvironmentId } from "../state/environments";
import { routineEnvironment } from "../state/routines";
@@ -31,6 +32,7 @@ const NO_ENVIRONMENT = "" as EnvironmentId;
function BotThreadRouteView() {
const { botId } = Route.useParams();
+ const panelKeys = botRoutePanelKeys(botId);
const environmentId = usePrimaryEnvironmentId();
const updateBot = useAtomCommand(botEnvironment.update, { reportFailure: false });
const draftRoutine = useAtomCommand(routineEnvironment.draft, { reportFailure: false });
@@ -148,10 +150,10 @@ function BotThreadRouteView() {
return (
<>
- <BotThreadLanding key={botId} botId={botId} />
+ <BotThreadLanding key={panelKeys.thread} botId={botId} />
{bot ? (
<BotDetailsPanel
- key={bot.id}
+ key={panelKeys.details}
bot={bot}
threadRef={threadRef}
routinePanel={{
diff --git a/apps/web/src/routes/botRoutePanelKeys.test.ts b/apps/web/src/routes/botRoutePanelKeys.test.ts
new file mode 100644
index 000000000..1b8a18ba3
--- /dev/null
+++ b/apps/web/src/routes/botRoutePanelKeys.test.ts
@@ -0,0 +1,21 @@
+// @effect-diagnostics nodeBuiltinImport:off - The route contract reads its source.
+import * as NodeFS from "node:fs";
+
+import { describe, expect, it } from "vite-plus/test";
+
+import { botRoutePanelKeys } from "./botRoutePanelKeys";
+
+describe("bot route panel keys", () => {
+ it("gives sibling panels separate identities for the same bot", () => {
+ const keys = botRoutePanelKeys("bot-1");
+
+ expect(keys.thread).not.toBe(keys.details);
+ });
+
+ it("uses the separate identities for both route siblings", () => {
+ const source = NodeFS.readFileSync(new URL("./_chat.bots.$botId.tsx", import.meta.url), "utf8");
+
+ expect(source).toContain("key={panelKeys.thread}");
+ expect(source).toContain("key={panelKeys.details}");
+ });
+});
diff --git a/apps/web/src/routes/botRoutePanelKeys.ts b/apps/web/src/routes/botRoutePanelKeys.ts
new file mode 100644
index 000000000..f01a06d00
--- /dev/null
+++ b/apps/web/src/routes/botRoutePanelKeys.ts
@@ -0,0 +1,6 @@
+export function botRoutePanelKeys(botId: string) {
+ return {
+ thread: `thread:${botId}`,
+ details: `details:${botId}`,
+ } as const;
+}