fix: Use cached logs instead of refetch when switching views#329
Closed
Pikago-hub wants to merge 2 commits intotraceroot-ai:mainfrom
Closed
fix: Use cached logs instead of refetch when switching views#329Pikago-hub wants to merge 2 commits intotraceroot-ai:mainfrom
Pikago-hub wants to merge 2 commits intotraceroot-ai:mainfrom
Conversation
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #311: Implements client side caching for log details using TanStack Query to prevent unnecessary refetches when switching between views
Type of Change
Details
This PR implements TanStack Query for log data fetching to enable client side caching and prevent unnecessary refetches when switching between views.
Why TanStack Query?
TanStack Query provides automatic client side caching with a 10-minute TTL, request deduplication, and smart cache invalidation. This eliminates manual cache management and ensures log data persists across component remounts when users switch views.
Changes
@tanstack/react-querydependencysrc/providers/QueryProvider.tsx(Global query client with 10 minute cache TTL)src/hooks/useLogs.ts(Reusable hook that encapsulates log fetching logic with caching)src/app/layout.tsx(Wrapped app with QueryProvider)src/components/right-panel/log/LogDetail.tsx(Replaced 130+ lines ofuseEffectfetch logic with 4 linesuseLogshook call, fixed TypeScriptanytypes with properSpanLogtyping)Future Work
Following this pattern, remaining
useEffect+fetchcalls should be migrated to TanStack Query hooks forconsistency and performance benefits, including:
Trace.tsx,LogModeDetail.tsx,Agent.tsx,chat-reasoning.tsx, and settings components.Screenshots / Recordings (if applicable)
https://www.loom.com/share/fc893510651e4664bbf499e3802131f4
Checklist