The best way to control Claude Code, Codex and more from any computer or phone
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
Julius Marminge committed
Mar 2, 2026 at 10:33 UTC
410444aead745b3a27e5c645643c74a3cb3479c3
3 files changed
+16
-11
apps/web/src/components/DiffPanel.tsx
+7
-6
@@ -166,14 +166,15 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
166
select: (params) => (params.threadId ? ThreadId.makeUnsafe(params.threadId) : null),
167
});
168
const diffSearch = useSearch({ strict: false, select: (search) => parseDiffRouteSearch(search) });
169
+ const { state } = useStore();
170
const activeThreadId = routeThreadId;
170
- const activeThread = useStore((state) =>
171
- activeThreadId ? state.threads.find((thread) => thread.id === activeThreadId) : undefined,
172
- );
171
+ const activeThread = activeThreadId
172
+ ? state.threads.find((thread) => thread.id === activeThreadId)
173
+ : undefined;
174
const activeProjectId = activeThread?.projectId ?? null;
174
- const activeProject = useStore((state) =>
175
- activeProjectId ? state.projects.find((project) => project.id === activeProjectId) : undefined,
176
- );
175
+ const activeProject = activeProjectId
176
+ ? state.projects.find((project) => project.id === activeProjectId)
177
+ : undefined;
178
const activeCwd = activeThread?.worktreePath ?? activeProject?.cwd;
179
const { turnDiffSummaries, inferredCheckpointTurnCountByTurnId } =
180
useTurnDiffSummaries(activeThread);
apps/web/src/routes/_chat.$threadId.tsx
+3
-4
@@ -133,15 +133,14 @@ const DiffPanelInlineSidebar = (props: {
133
};
134
135
function ChatThreadRouteView() {
136
- const threadsHydrated = useStore((state) => state.threadsHydrated);
136
+ const { state } = useStore();
137
+ const threadsHydrated = state.threadsHydrated;
138
const navigate = useNavigate();
139
const threadId = Route.useParams({
140
select: (params) => ThreadId.makeUnsafe(params.threadId),
141
});
142
const search = Route.useSearch();
142
- const threadExists = useStore((state) =>
143
- state.threads.some((thread) => thread.id === threadId),
144
- );
143
+ const threadExists = state.threads.some((thread) => thread.id === threadId);
144
const draftThreadExists = useComposerDraftStore(
145
(store) => Object.hasOwn(store.draftThreadsByThreadId, threadId),
146
);
apps/web/src/store.ts
+6
-1
@@ -432,7 +432,12 @@ export function StoreProvider({ children }: { children: ReactNode }) {
432
return createElement(Fragment, null, children);
433
}
434
435
-export function useStore() {
435
+type UseStoreCombinedResult = {
436
+ state: Pick<AppStore, "projects" | "threads" | "threadsHydrated" | "runtimeMode">;
437
+ dispatch: AppStore;
438
+};
439
+
440
+export function useStore(): UseStoreCombinedResult {
441
const state = useAppStore((s) => ({
442
projects: s.projects,
443
threads: s.threads,