refactor: update comments and remove staleTime from useResolvedTabs for clarity and consistency

This commit is contained in:
Anish Sarkar 2026-07-22 12:58:31 +05:30
parent fd6e54f122
commit ddfddb2d83

View file

@ -10,11 +10,10 @@ import { NotFoundError } from "@/lib/error";
import { cacheKeys } from "@/lib/query-client/cache-keys"; import { cacheKeys } from "@/lib/query-client/cache-keys";
// Thread/document metadata is read-only for tabs: the DB is the single source // Thread/document metadata is read-only for tabs: the DB is the single source
// of truth and react-query is the cache. Titles/visibility stay fresh because // of truth and react-query is the cache (default staleTime from the shared
// the rename/visibility/delete mutations patch these same query caches (see // QueryClient). Titles/visibility stay fresh because the rename/visibility/
// lib/chat/thread-cache.ts), so a rename reflects in the tab bar immediately. // delete mutations patch these same query caches (see lib/chat/thread-cache.ts),
const METADATA_STALE_TIME_MS = 60 * 1000; // so a rename reflects in the tab bar immediately regardless of staleness.
interface ThreadRow { interface ThreadRow {
id: number; id: number;
title: string; title: string;
@ -123,7 +122,6 @@ export function useResolvedTabs(): ResolvedTab[] {
queries: chatIds.map((id) => ({ queries: chatIds.map((id) => ({
queryKey: cacheKeys.threads.detail(id), queryKey: cacheKeys.threads.detail(id),
queryFn: () => getThreadFull(id), queryFn: () => getThreadFull(id),
staleTime: METADATA_STALE_TIME_MS,
retry: retryUnlessNotFound, retry: retryUnlessNotFound,
})), })),
}); });
@ -132,7 +130,6 @@ export function useResolvedTabs(): ResolvedTab[] {
queries: documentIds.map((id) => ({ queries: documentIds.map((id) => ({
queryKey: cacheKeys.documents.document(String(id)), queryKey: cacheKeys.documents.document(String(id)),
queryFn: () => documentsApiService.getDocument({ id }), queryFn: () => documentsApiService.getDocument({ id }),
staleTime: METADATA_STALE_TIME_MS,
retry: retryUnlessNotFound, retry: retryUnlessNotFound,
})), })),
}); });