@@ -96,7 +96,11 @@ import { threadEnvironment } from "../state/threads";
9696import { projectEnvironment } from "../state/projects" ;
9797import { useEnvironmentQuery } from "../state/query" ;
9898import { useAtomCommand } from "../state/use-atom-command" ;
99- import { buildThreadRouteParams , resolveThreadRouteTarget } from "../threadRoutes" ;
99+ import {
100+ buildThreadRouteParams ,
101+ resolveActiveThreadRouteRef ,
102+ resolveThreadRouteTarget ,
103+ } from "../threadRoutes" ;
100104import { formatRelativeTimeLabel , parseTimestampDate } from "../timestampFormat" ;
101105import type { SidebarThreadSummary } from "../types" ;
102106import { cn } from "~/lib/utils" ;
@@ -1052,7 +1056,13 @@ export default function SidebarV2() {
10521056 strict : false ,
10531057 select : ( params ) => resolveThreadRouteTarget ( params ) ,
10541058 } ) ;
1055- const routeThreadRef = routeTarget ?. kind === "server" ? routeTarget . threadRef : null ;
1059+ const routeDraftThread = useComposerDraftStore ( ( store ) =>
1060+ routeTarget ?. kind === "draft" ? store . getDraftSession ( routeTarget . draftId ) : null ,
1061+ ) ;
1062+ const routeThreadRef = useMemo (
1063+ ( ) => resolveActiveThreadRouteRef ( routeTarget , routeDraftThread ) ,
1064+ [ routeDraftThread , routeTarget ] ,
1065+ ) ;
10561066 const routeThreadKey = routeThreadRef ? scopedThreadKey ( routeThreadRef ) : null ;
10571067 const routeTargetRef = useRef ( routeTarget ) ;
10581068 routeTargetRef . current = routeTarget ;
0 commit comments