diff --git a/apps/web/src/components/BranchToolbar.tsx b/apps/web/src/components/BranchToolbar.tsx index 564eea5417381493c859a092fccd333bcebd443c..57bee94c601f8aff09384eeefec6ae84589481f9 100644 --- a/apps/web/src/components/BranchToolbar.tsx +++ b/apps/web/src/components/BranchToolbar.tsx @@ -1,6 +1,6 @@ import type { GitBranch, ThreadId } from "@t3tools/contracts"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; -import { useCallback, useEffect, useState } from "react"; +import { useEffect, useState } from "react"; import { newCommandId } from "../lib/utils"; import { @@ -46,16 +46,12 @@ export default function BranchToolbar({ const setThreadBranchAction = useStore((state) => state.setThreadBranch); const setThreadErrorAction = useStore((state) => state.setThreadError); const draftThread = useComposerDraftStore((store) => store.getDraftThread(threadId)); - const serverThread = useStore( - useCallback((state) => state.threads.find((thread) => thread.id === threadId), [threadId]), + const serverThread = useStore((state) => + state.threads.find((thread) => thread.id === threadId), ); const activeProjectId = serverThread?.projectId ?? draftThread?.projectId ?? null; - const activeProject = useStore( - useCallback( - (state) => - activeProjectId ? state.projects.find((project) => project.id === activeProjectId) : undefined, - [activeProjectId], - ), + const activeProject = useStore((state) => + activeProjectId ? state.projects.find((project) => project.id === activeProjectId) : undefined, ); const setDraftThreadContext = useComposerDraftStore((store) => store.setDraftThreadContext); const queryClient = useQueryClient(); diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 74f10378de4e43e1f603f0f4435b447edf76b6fa..338dd72402266e1023ae53ba771a1982a4331aff 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -490,18 +490,14 @@ export default function ChatView({ threadId }: ChatViewProps) { const clearDraftThread = useComposerDraftStore((store) => store.clearDraftThread); const setDraftThreadContext = useComposerDraftStore((store) => store.setDraftThreadContext); const draftThread = useComposerDraftStore((store) => store.draftThreadsByThreadId[threadId] ?? null); - const serverThread = useStore( - useCallback((state) => state.threads.find((thread) => thread.id === threadId), [threadId]), + const serverThread = useStore((state) => + state.threads.find((thread) => thread.id === threadId), ); const fallbackDraftProjectId = draftThread?.projectId ?? null; - const fallbackDraftProject = useStore( - useCallback( - (state) => - fallbackDraftProjectId - ? state.projects.find((project) => project.id === fallbackDraftProjectId) - : undefined, - [fallbackDraftProjectId], - ), + const fallbackDraftProject = useStore((state) => + fallbackDraftProjectId + ? state.projects.find((project) => project.id === fallbackDraftProjectId) + : undefined, ); const promptRef = useRef(prompt); const [isDragOverComposer, setIsDragOverComposer] = useState(false); @@ -601,12 +597,8 @@ export default function ChatView({ threadId }: ChatViewProps) { const activeLatestTurn = activeThread?.latestTurn ?? null; const latestTurnSettled = isLatestTurnSettled(activeLatestTurn, activeThread?.session ?? null); const activeProjectId = activeThread?.projectId ?? null; - const activeProject = useStore( - useCallback( - (state) => - activeProjectId ? state.projects.find((project) => project.id === activeProjectId) : undefined, - [activeProjectId], - ), + const activeProject = useStore((state) => + activeProjectId ? state.projects.find((project) => project.id === activeProjectId) : undefined, ); useEffect(() => { @@ -3541,20 +3533,12 @@ const OpenInPicker = memo(function OpenInPicker({ ] satisfies { label: string; Icon: Icon; value: EditorId }[]; const primaryOption = options.find(({ value }) => value === lastEditor); - const activeThread = useStore( - useCallback( - (state) => - activeThreadId ? state.threads.find((thread) => thread.id === activeThreadId) : undefined, - [activeThreadId], - ), + const activeThread = useStore((state) => + activeThreadId ? state.threads.find((thread) => thread.id === activeThreadId) : undefined, ); const activeProjectId = activeThread?.projectId ?? null; - const activeProject = useStore( - useCallback( - (state) => - activeProjectId ? state.projects.find((project) => project.id === activeProjectId) : undefined, - [activeProjectId], - ), + const activeProject = useStore((state) => + activeProjectId ? state.projects.find((project) => project.id === activeProjectId) : undefined, ); const openInEditor = useCallback( diff --git a/apps/web/src/components/DiffPanel.tsx b/apps/web/src/components/DiffPanel.tsx index 99b2d518058f5a62833c31100d73392b50ceed5b..8a963c6e2212c0730ba369b0034dac6adfa6e2d6 100644 --- a/apps/web/src/components/DiffPanel.tsx +++ b/apps/web/src/components/DiffPanel.tsx @@ -167,20 +167,12 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) { }); const diffSearch = useSearch({ strict: false, select: (search) => parseDiffRouteSearch(search) }); const activeThreadId = routeThreadId; - const activeThread = useStore( - useCallback( - (state) => - activeThreadId ? state.threads.find((thread) => thread.id === activeThreadId) : undefined, - [activeThreadId], - ), + const activeThread = useStore((state) => + activeThreadId ? state.threads.find((thread) => thread.id === activeThreadId) : undefined, ); const activeProjectId = activeThread?.projectId ?? null; - const activeProject = useStore( - useCallback( - (state) => - activeProjectId ? state.projects.find((project) => project.id === activeProjectId) : undefined, - [activeProjectId], - ), + const activeProject = useStore((state) => + activeProjectId ? state.projects.find((project) => project.id === activeProjectId) : undefined, ); const activeCwd = activeThread?.worktreePath ?? activeProject?.cwd; const { turnDiffSummaries, inferredCheckpointTurnCountByTurnId } = diff --git a/apps/web/src/routes/_chat.$threadId.tsx b/apps/web/src/routes/_chat.$threadId.tsx index 14d832e7af696b6f53037c93923708de48d378db..ce8ec5aec16b6416a183483058250db577f56d6a 100644 --- a/apps/web/src/routes/_chat.$threadId.tsx +++ b/apps/web/src/routes/_chat.$threadId.tsx @@ -139,8 +139,8 @@ function ChatThreadRouteView() { select: (params) => ThreadId.makeUnsafe(params.threadId), }); const search = Route.useSearch(); - const threadExists = useStore( - useCallback((state) => state.threads.some((thread) => thread.id === threadId), [threadId]), + const threadExists = useStore((state) => + state.threads.some((thread) => thread.id === threadId), ); const draftThreadExists = useComposerDraftStore( (store) => Object.hasOwn(store.draftThreadsByThreadId, threadId),