📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
fix pagination offsets for deduped lists
Blue Mouse379f87e0e79c
diff --git a/web/app/pages/Project/tabs/AskAI/AskAIView.tsx b/web/app/pages/Project/tabs/AskAI/AskAIView.tsxindex 20175e4b1..da63d95aa 100644--- a/web/app/pages/Project/tabs/AskAI/AskAIView.tsx+++ b/web/app/pages/Project/tabs/AskAI/AskAIView.tsx@@ -1818,6 +1818,7 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {const [recentChats, setRecentChats] = useState<AIChatSummary[]>([])const [allChats, setAllChats] = useState<AIChatSummary[]>([])const [allChatsTotal, setAllChatsTotal] = useState(0)+ const [allChatsFetchOffset, setAllChatsFetchOffset] = useState(0)const [isHistoryPanelOpen, setIsHistoryPanelOpen] = useState(false)const [chatToDelete, setChatToDelete] = useState<string | null>(null)const [historySearch, setHistorySearch] = useState('')@@ -1934,17 +1935,18 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {[allChatsFetcher.submit],)- const [pendingAllChatsSkip, setPendingAllChatsSkip] = useState<number | null>(- null,- )+ const pendingAllChatsSkipRef = useRef<number | null>(null)useEffect(() => {if (allChatsFetcher.state === 'idle' && allChatsFetcher.data) {+ const pendingAllChatsSkip = pendingAllChatsSkipRef.current+if (allChatsFetcher.data.success && allChatsFetcher.data.data) {const result = allChatsFetcher.data.data as {chats: AIChatSummary[]total: number}+ setAllChatsFetchOffset((pendingAllChatsSkip ?? 0) + result.chats.length)if (pendingAllChatsSkip === 0 || pendingAllChatsSkip === null) {setAllChats(result.chats)} else {@@ -1958,15 +1960,15 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {}setAllChatsTotal(result.total)}- setPendingAllChatsSkip(null)+ pendingAllChatsSkipRef.current = null}- }, [allChatsFetcher.state, allChatsFetcher.data, pendingAllChatsSkip])+ }, [allChatsFetcher.state, allChatsFetcher.data])const loadAllChatsWithSkip = useCallback((skip: number, opts: { search?: string; tag?: string | null } = {}) => {if (allChatsFetcher.state !== 'idle') return- setPendingAllChatsSkip(skip)+ pendingAllChatsSkipRef.current = skiploadAllChats(skip, opts)},[allChatsFetcher.state, loadAllChats],@@ -3375,7 +3377,7 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {actions={chatRowActions}onLoadMore={() => {const term = debouncedHistorySearch.trim()- loadAllChatsWithSkip(allChats.length, {+ loadAllChatsWithSkip(allChatsFetchOffset, {search: term.length >= 2 ? term : undefined,tag: historyTagFilter,})diff --git a/web/app/pages/Project/tabs/Experiments/ExperimentsView.tsx b/web/app/pages/Project/tabs/Experiments/ExperimentsView.tsxindex 606e93c04..809160fa9 100644--- a/web/app/pages/Project/tabs/Experiments/ExperimentsView.tsx+++ b/web/app/pages/Project/tabs/Experiments/ExperimentsView.tsx@@ -678,6 +678,7 @@ const ExperimentsView = ({const isMountedRef = useRef(true)const [total, setTotal] = useState(0)const [experiments, setExperiments] = useState<Experiment[]>([])+ const [experimentsServerSkip, setExperimentsServerSkip] = useState(0)const [error, setError] = useState<string | null>(null)const [filterQuery, setFilterQuery] = useState('')const processedActionRef = useRef<string | null>(null)@@ -756,6 +757,7 @@ const ExperimentsView = ({total: number}if (experimentsRequestModeRef.current === 'append') {+ setExperimentsServerSkip((prev) => prev + result.results.length)setExperiments((prev) => {const existingIds = new Set(prev.map((experiment) => experiment.id),@@ -766,6 +768,7 @@ const ExperimentsView = ({return [...prev, ...uniqueExperiments]})} else {+ setExperimentsServerSkip(result.results.length)setExperiments(result.results)}setTotal(result.total)@@ -993,7 +996,7 @@ const ExperimentsView = ({})}, [updateExperimentSearchParams])- const canLoadMoreExperiments = experiments.length < total+ const canLoadMoreExperiments = experimentsServerSkip < totalconst loadMoreExperiments = useCallback(() => {if (isLoading || !canLoadMoreExperiments) {return@@ -1001,14 +1004,14 @@ const ExperimentsView = ({loadExperiments(DEFAULT_EXPERIMENTS_TAKE,- experiments.length,+ experimentsServerSkip,true,filterQuery || undefined,'append',)}, [canLoadMoreExperiments,- experiments.length,+ experimentsServerSkip,filterQuery,isLoading,loadExperiments,diff --git a/web/app/pages/Project/tabs/Sessions/SessionsView.tsx b/web/app/pages/Project/tabs/Sessions/SessionsView.tsxindex 95e626de8..b329ddacf 100644--- a/web/app/pages/Project/tabs/Sessions/SessionsView.tsx+++ b/web/app/pages/Project/tabs/Sessions/SessionsView.tsx@@ -453,6 +453,7 @@ const SessionsViewInner = ({onLoadMore={loadMoreSessions}disabled={sessionsLoading}className={sessionsLoading && _isEmpty(sessions) ? 'hidden' : ''}+ spinnerClassName='mr-0! ml-0!'/></div></>diff --git a/web/app/ui/InfiniteScrollTrigger.tsx b/web/app/ui/InfiniteScrollTrigger.tsxindex 0e730593c..088e3b8fb 100644--- a/web/app/ui/InfiniteScrollTrigger.tsx+++ b/web/app/ui/InfiniteScrollTrigger.tsx@@ -9,6 +9,7 @@ interface InfiniteScrollTriggerProps {isLoading: booleanonLoadMore: () => voidclassName?: string+ spinnerClassName?: stringdisabled?: booleanroot?: RefObject<Element | null>rootMargin?: string@@ -19,6 +20,7 @@ const InfiniteScrollTrigger = ({isLoading,onLoadMore,className,+ spinnerClassName,disabled = false,root,rootMargin = '240px',@@ -72,7 +74,8 @@ const InfiniteScrollTrigger = ({><SpinclassName={cx(- 'size-5 text-gray-400 transition-opacity duration-150 ease-out dark:text-gray-500',+ 'transition-opacity duration-150 ease-out',+ spinnerClassName || 'size-5 text-gray-400 dark:text-gray-500',!isLoading && 'opacity-0',)}/>