Skip to content

fix: Use cached logs instead of refetch when switching views#329

Closed
Pikago-hub wants to merge 2 commits intotraceroot-ai:mainfrom
Pikago-hub:fix/log-details-refetch-on-view-switch
Closed

fix: Use cached logs instead of refetch when switching views#329
Pikago-hub wants to merge 2 commits intotraceroot-ai:mainfrom
Pikago-hub:fix/log-details-refetch-on-view-switch

Conversation

@Pikago-hub
Copy link

Summary

Fixes #311: Implements client side caching for log details using TanStack Query to prevent unnecessary refetches when switching between views

Type of Change

  • feat - A new feature
  • fix - A bug fix
  • docs - Documentation only changes
  • style - Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor - A code change that neither fixes a bug nor adds a feature
  • perf - A code change that improves performance
  • test - Adding missing tests or correcting existing tests
  • build - Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
  • ci - Changes to our Cl configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  • chore - Other changes that don't modify sc or test files
  • revert - Reverts a previous commit
  • security - A security fix or improvement
  • github - Changes to our GitHub configuration files and scripts
  • other (please describe):

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

  • Added @tanstack/react-query dependency
  • Added src/providers/QueryProvider.tsx(Global query client with 10 minute cache TTL)
  • Added src/hooks/useLogs.ts(Reusable hook that encapsulates log fetching logic with caching)
  • Modified src/app/layout.tsx(Wrapped app with QueryProvider)
  • Modified src/components/right-panel/log/LogDetail.tsx(Replaced 130+ lines of useEffect fetch logic with 4 lines useLogs hook call, fixed TypeScript any types with proper SpanLog typing)

Future Work

Following this pattern, remaining useEffect + fetch calls should be migrated to TanStack Query hooks for
consistency 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

  • I have read the CONTRIBUTING.md
  • I have added/updated tests where applicable
  • I have added screenshots or recordings for UI changes (if applicable)
  • I have updated documentation where necessary

@Pikago-hub Pikago-hub requested a review from a team as a code owner November 8, 2025 17:09
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@XinweiHe XinweiHe closed this Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][UI] Use the cached logs instead of refetch when switching from agent

3 participants