From 410444aead745b3a27e5c645643c74a3cb3479c3 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 2 Mar 2026 10:33:38 -0800 Subject: [PATCH] Remove useStore selector compatibility shim Drop the temporary selector overload from useStore and migrate the remaining selector call sites to the unified { state, dispatch } API so the store surface stays single-path. Made-with: Cursor --- apps/web/src/components/DiffPanel.tsx | 13 +++++++------ apps/web/src/routes/_chat.$threadId.tsx | 7 +++---- apps/web/src/store.ts | 7 ++++++- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/apps/web/src/components/DiffPanel.tsx b/apps/web/src/components/DiffPanel.tsx index 8a963c6e2212c0730ba369b0034dac6adfa6e2d6..ed4559d3bfb1605bee982d763a0f9d3d2d8f799c 100644 --- a/apps/web/src/components/DiffPanel.tsx +++ b/apps/web/src/components/DiffPanel.tsx @@ -166,14 +166,15 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) { select: (params) => (params.threadId ? ThreadId.makeUnsafe(params.threadId) : null), }); const diffSearch = useSearch({ strict: false, select: (search) => parseDiffRouteSearch(search) }); + const { state } = useStore(); const activeThreadId = routeThreadId; - const activeThread = useStore((state) => - activeThreadId ? state.threads.find((thread) => thread.id === activeThreadId) : undefined, - ); + const activeThread = activeThreadId + ? state.threads.find((thread) => thread.id === activeThreadId) + : undefined; const activeProjectId = activeThread?.projectId ?? null; - const activeProject = useStore((state) => - activeProjectId ? state.projects.find((project) => project.id === activeProjectId) : undefined, - ); + const activeProject = activeProjectId + ? state.projects.find((project) => project.id === activeProjectId) + : undefined; const activeCwd = activeThread?.worktreePath ?? activeProject?.cwd; const { turnDiffSummaries, inferredCheckpointTurnCountByTurnId } = useTurnDiffSummaries(activeThread); diff --git a/apps/web/src/routes/_chat.$threadId.tsx b/apps/web/src/routes/_chat.$threadId.tsx index ce8ec5aec16b6416a183483058250db577f56d6a..3cafa85ceccabac303096b5295f005aa72b235c3 100644 --- a/apps/web/src/routes/_chat.$threadId.tsx +++ b/apps/web/src/routes/_chat.$threadId.tsx @@ -133,15 +133,14 @@ const DiffPanelInlineSidebar = (props: { }; function ChatThreadRouteView() { - const threadsHydrated = useStore((state) => state.threadsHydrated); + const { state } = useStore(); + const threadsHydrated = state.threadsHydrated; const navigate = useNavigate(); const threadId = Route.useParams({ select: (params) => ThreadId.makeUnsafe(params.threadId), }); const search = Route.useSearch(); - const threadExists = useStore((state) => - state.threads.some((thread) => thread.id === threadId), - ); + const threadExists = state.threads.some((thread) => thread.id === threadId); const draftThreadExists = useComposerDraftStore( (store) => Object.hasOwn(store.draftThreadsByThreadId, threadId), ); diff --git a/apps/web/src/store.ts b/apps/web/src/store.ts index 1b1bc9d288fa7510a4a791cde29a287f02c0b94c..c76309a60a5d7a494d9c05371fc57acaa2c4a372 100644 --- a/apps/web/src/store.ts +++ b/apps/web/src/store.ts @@ -432,7 +432,12 @@ export function StoreProvider({ children }: { children: ReactNode }) { return createElement(Fragment, null, children); } -export function useStore() { +type UseStoreCombinedResult = { + state: Pick; + dispatch: AppStore; +}; + +export function useStore(): UseStoreCombinedResult { const state = useAppStore((s) => ({ projects: s.projects, threads: s.threads, -- 2.54.0