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 sidebar highlighting for draft threads (#4679)

Julius Marminge6a3df51707b6
diff --git a/apps/web/src/components/SidebarV2.tsx b/apps/web/src/components/SidebarV2.tsx
index 8677ee114..ed9eadd90 100644
--- a/apps/web/src/components/SidebarV2.tsx
+++ b/apps/web/src/components/SidebarV2.tsx
@@ -96,7 +96,11 @@ import { threadEnvironment } from "../state/threads";
import { projectEnvironment } from "../state/projects";
import { useEnvironmentQuery } from "../state/query";
import { useAtomCommand } from "../state/use-atom-command";
-import { buildThreadRouteParams, resolveThreadRouteTarget } from "../threadRoutes";
+import {
+ buildThreadRouteParams,
+ resolveActiveThreadRouteRef,
+ resolveThreadRouteTarget,
+} from "../threadRoutes";
import { formatRelativeTimeLabel, parseTimestampDate } from "../timestampFormat";
import type { SidebarThreadSummary } from "../types";
import { cn } from "~/lib/utils";
@@ -1052,7 +1056,13 @@ export default function SidebarV2() {
strict: false,
select: (params) => resolveThreadRouteTarget(params),
});
- const routeThreadRef = routeTarget?.kind === "server" ? routeTarget.threadRef : null;
+ const routeDraftThread = useComposerDraftStore((store) =>
+ routeTarget?.kind === "draft" ? store.getDraftSession(routeTarget.draftId) : null,
+ );
+ const routeThreadRef = useMemo(
+ () => resolveActiveThreadRouteRef(routeTarget, routeDraftThread),
+ [routeDraftThread, routeTarget],
+ );
const routeThreadKey = routeThreadRef ? scopedThreadKey(routeThreadRef) : null;
const routeTargetRef = useRef(routeTarget);
routeTargetRef.current = routeTarget;