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
This commit is contained in:
Julius Marminge committed 2026-03-02 11:01:13 -08:00
1 parent 669ef4a61b
commit fcc903e53e
3 files changed
+16 -11

No files matched your search

+7 -6
View File
@@ -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);
+3 -4
View File
@@ -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),
);
+6 -1
View File
@@ -432,7 +432,12 @@ export function StoreProvider({ children }: { children: ReactNode }) {
return createElement(Fragment, null, children);
}
export function useStore() {
type UseStoreCombinedResult = {
state: Pick<AppStore, "projects" | "threads" | "threadsHydrated" | "runtimeMode">;
dispatch: AppStore;
};
export function useStore(): UseStoreCombinedResult {
const state = useAppStore((s) => ({
projects: s.projects,
threads: s.threads,