Skip to content

feat(dashboard): optimal stale-while-revalidate cache for system stats#3033

Open
OlziYT wants to merge 2 commits into
getarcaneapp:mainfrom
OlziYT:feature/dashboard-metrics-cache
Open

feat(dashboard): optimal stale-while-revalidate cache for system stats#3033
OlziYT wants to merge 2 commits into
getarcaneapp:mainfrom
OlziYT:feature/dashboard-metrics-cache

Conversation

@OlziYT

@OlziYT OlziYT commented Jun 25, 2026

Copy link
Copy Markdown

This PR extracts the stale-while-revalidate cache from the bugfix PR #3024 into its own dedicated feature, using Svelte 5 store patterns to ensure state is safely encapsulated.

Changes

  • Introduces system-stats-cache.store.svelte.ts which provides a clean API for caching system metrics with a configurable TTL (currently 5 minutes).
  • Refactors dashboard-all-environments-view.svelte to read from and write to this store instead of a module-level variable.

This provides the optimal UX by preventing skeleton flashes during menu navigation, while respecting SvelteKit architecture best practices.

Disclaimer Greptiles Reviews use AI, make sure to check over its work.

To better help train Greptile on our codebase, if the comment is useful and valid Like the comment, if its not helpful or invalid Dislike

To have Greptile Re-Review the changes, mention greptileai.

Greptile Summary

This PR adds stale-while-revalidate caching for dashboard system stats. The main changes are:

  • Adds a context-scoped systemStatsCacheStore with TTL-based cached stats.
  • Initializes the cache context from the app layout.
  • Seeds dashboard live stats from cached values and refreshes them from WebSocket updates.

Confidence Score: 5/5

The changes are focused on dashboard stats caching and do not introduce identified merge-blocking concerns.

The reviewed changes are small, localized, and align with the stated cache behavior without identified correctness or security issues.

T-Rex T-Rex Logs

What T-Rex did

  • Attempted to start the app environment by running docker-compose up -d --build, but the command failed because docker was not found.
  • The setup attempt was repeated, and it again failed at the same step due to the missing Docker engine.
  • Because the app server never started, no valid before/after UI video or dashboard screenshot could be produced.
  • A cache contract probe was run to evaluate head versus base cache behavior, showing that base initially had no system-stats-cache.store.svelte.ts and no dashboard cache references, and after the probe the head passes the cache contract with expected results: same-env cache hit, different-env null, a valid timestamp at 5 minutes, null after TTL, context store reuse, and dashboard cached state initialized with loading false and hasLoaded true, with fresh stats overwriting the cache.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (2): Last reviewed commit: "fix(dashboard): address greptile code re..." | Re-trigger Greptile

@OlziYT OlziYT requested a review from a team June 25, 2026 19:18
Comment thread frontend/src/lib/stores/system-stats-cache.store.svelte.ts Outdated
Comment thread frontend/src/lib/stores/system-stats-cache.store.svelte.ts Outdated
- Refactored store to use Svelte context API instead of a module-level singleton to prevent SSR data leakage.
- Converted the internal cache map to a reactive \$state\ object to ensure proper updates inside effects/derived state.
@OlziYT

OlziYT commented Jun 25, 2026

Copy link
Copy Markdown
Author

@greptileai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant