Skip to content

fix(analytics): improve dashboard navigation snappiness#714

Merged
steve8708 merged 2 commits into
mainfrom
codex/analytics-snappiness
May 16, 2026
Merged

fix(analytics): improve dashboard navigation snappiness#714
steve8708 merged 2 commits into
mainfrom
codex/analytics-snappiness

Conversation

@steve8708
Copy link
Copy Markdown
Contributor

Summary

  • remove the duplicate SQL dashboard existence request from the navigation path
  • prefetch SQL dashboard and analysis detail data when users hover/focus sidebar links
  • fetch saved dashboard views only for the active dashboard in the sidebar
  • update optimistic sidebar cache writes to cover versioned React Query keys

Validation

  • pnpm --filter analytics typecheck
  • pnpm --filter analytics build

@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for agent-native-images canceled.

Name Link
🔨 Latest commit 21ec06a
🔍 Latest deploy log https://app.netlify.com/projects/agent-native-images/deploys/6a078cb990291f0008a324af

@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for agent-native-meeting-notes ready!

Name Link
🔨 Latest commit 21ec06a
🔍 Latest deploy log https://app.netlify.com/projects/agent-native-meeting-notes/deploys/6a078cb9a71e3b00083a0d91
😎 Deploy Preview https://deploy-preview-714--agent-native-meeting-notes.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for agent-native-design ready!

Name Link
🔨 Latest commit 21ec06a
🔍 Latest deploy log https://app.netlify.com/projects/agent-native-design/deploys/6a078cb9df598b0008e3fe21
😎 Deploy Preview https://deploy-preview-714--agent-native-design.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for agent-native-voice ready!

Name Link
🔨 Latest commit 21ec06a
🔍 Latest deploy log https://app.netlify.com/projects/agent-native-voice/deploys/6a078cb91335d90008ac0c86
😎 Deploy Preview https://deploy-preview-714--agent-native-voice.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for agent-native-scheduling ready!

Name Link
🔨 Latest commit 21ec06a
🔍 Latest deploy log https://app.netlify.com/projects/agent-native-scheduling/deploys/6a078cb9c55f550008c80102
😎 Deploy Preview https://deploy-preview-714--agent-native-scheduling.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@cloudflare-workers-and-pages

This comment has been minimized.

@cloudflare-workers-and-pages

This comment has been minimized.

@cloudflare-workers-and-pages

This comment has been minimized.

@cloudflare-workers-and-pages

This comment has been minimized.

@cloudflare-workers-and-pages

This comment has been minimized.

@cloudflare-workers-and-pages

This comment has been minimized.

@cloudflare-workers-and-pages

This comment has been minimized.

builder-io-integration[bot]

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

@builder-io-integration builder-io-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Visual Verification

Browser testing: 14/15 passed

Test Results: 14/15 passed ⚠️

✅ TC-01: Direct navigation to valid SQL dashboard loads without existence-check request (succeeded)

Steps: 1. Logged in. 2. Navigated directly to /analytics/adhoc/test-dashboard-1778877304721. 3. Inspected network for existence-check. 4. Verified dashboard title and empty-panels message.

URLs tested: http://127.0.0.1:8080/analytics/adhoc/test-dashboard-1778877304721

Evidence: 1 screenshot captured

✅ TC-02: BlankDashboard fallback shows for a non-existent dashboard ID (succeeded)

Steps: 1. Navigated to /analytics/adhoc/nonexistent-id-99999-fake. 2. Waited up to 15s. 3. Verified Empty Dashboard content.

URLs tested: http://127.0.0.1:8080/analytics/adhoc/nonexistent-id-99999-fake

Evidence: 1 screenshot captured

✅ TC-03: Sidebar shows saved views only for the active dashboard (succeeded)

Steps: 1. Navigated to dashboard 1. 2. Verified "Last 30 Days" and "Last 7 Days" under active dashboard. 3. Confirmed no sub-items under Second Test Dashboard. 4. Verified network only called views for dashboard 1.

URLs tested: http://127.0.0.1:8080/analytics/adhoc/test-dashboard-1778877304721

Evidence: 1 screenshot captured

✅ TC-04: Prefetch network request fires on hover over a SQL dashboard in sidebar (succeeded)

Steps: 1. Navigated to overview page. 2. Hovered "Second Test Dashboard" without clicking. 3. Confirmed GET /api/sql-dashboards/test-dashboard-b-... in network log.

URLs tested: http://127.0.0.1:8080/analytics/overview

Evidence: 1 screenshot captured

✅ TC-05: No duplicate request after clicking a pre-hovered dashboard link (succeeded)

Steps: 1. Hovered Second Test Dashboard to trigger prefetch. 2. Clicked. 3. Waited for navigation. 4. Verified no duplicate request in network log.

URLs tested: http://127.0.0.1:8080/analytics/adhoc/test-dashboard-b-1778877310827

Evidence: 1 screenshot captured

✅ TC-06: Prefetch fires on hover over an analysis name in the sidebar (succeeded)

Steps: 1. On dashboard 1 page, hovered analysis link without clicking. 2. Confirmed GET /api/analyses/test-analysis-123 in network.

URLs tested: http://127.0.0.1:8080/analytics/adhoc/test-dashboard-1778877304721

Evidence: 1 screenshot captured

✅ TC-07: Second dashboard shows no views in sidebar when it is not active (succeeded)

Steps: 1. Loaded dashboard 1. 2. Verified both views visible under dashboard 1. 3. Confirmed no view sub-items under dashboard 2. 4. Verified via performance API no views request for dashboard 2.

URLs tested: http://127.0.0.1:8080/analytics/adhoc/test-dashboard-1778877304721

Evidence: 1 screenshot captured

✅ TC-08: Views update correctly when navigating between dashboards (succeeded)

Steps: 1. Loaded dashboard 1, confirmed views. 2. Clicked Second Test Dashboard. 3. Waited for navigation. 4. Verified views gone and dashboard 2 highlighted.

URLs tested: http://127.0.0.1:8080/analytics/adhoc/test-dashboard-1778877304721, http://127.0.0.1:8080/analytics/adhoc/test-dashboard-b-1778877310827

Evidence: 2 screenshots captured

✅ TC-09: Sidebar highlights the correct active dashboard (succeeded)

Steps: 1. Loaded dashboard 1 and verified highlight. 2. Clicked dashboard 2. 3. Verified dashboard 2 is now highlighted, dashboard 1 is not.

URLs tested: http://127.0.0.1:8080/analytics/adhoc/test-dashboard-1778877304721, http://127.0.0.1:8080/analytics/adhoc/test-dashboard-b-1778877310827

Evidence: 2 screenshots captured

⚠️ TC-10: Focus (keyboard Tab) triggers prefetch on a dashboard sidebar link (couldnt_verify)

Steps: 1. Executor: tabbed to Second Test Dashboard link on dashboard-b page (warm cache) — no network request observed. 2. Planner: navigated to dashboard 1 (cold cache for dashboard 2), called .focus() on Second Test Dashboard link via JS, observed GET /api/sql-dashboards/test-dashboard-b-... in performance entries. Feature confirmed working.

Failure: assertion_failed — In the executor's batch, TC-09 navigated to dashboard 2, warming the query cache. TC-10 then tried to focus dashboard 2's link — but prefetchQuery correctly skipped the network call because data was fresh (staleTime: 30_000). Planner re-tested with cold cache: programmatic .focus() on the Second Test Dashboard link fired GET /api/sql-dashboards/test-dashboard-b-... confirming onFocus works correctly. The feature is verified to work; the test was confounded by cache state.

URLs tested: http://127.0.0.1:8080/analytics/adhoc/test-dashboard-1778877304721

✅ TC-11: Rapid hovering over multiple dashboards causes no UI flash or spinner (succeeded)

Steps: 1. On dashboard 1. 2. Rapidly hovered both dashboards back and forth. 3. Checked for spinners/flash. 4. Verified stable state after hovering.

URLs tested: http://127.0.0.1:8080/analytics/adhoc/test-dashboard-1778877304721

Evidence: 2 screenshots captured

✅ TC-12: Reload on a valid dashboard doesn't show a prolonged skeleton (succeeded)

Steps: 1. Navigated to dashboard 1. 2. Hard-reloaded with ignoreCache. 3. Observed skeleton then content. 4. Verified no stuck loading state.

URLs tested: http://127.0.0.1:8080/analytics/adhoc/test-dashboard-1778877304721

Evidence: 1 screenshot captured

✅ TC-13: Navigating to an analysis detail page doesn't trigger dashboard-views requests (succeeded)

Steps: 1. Navigated directly to /analytics/analyses/test-analysis-123. 2. Verified analysis content loaded. 3. Confirmed no /api/dashboard-views/ in network. 4. Checked sidebar shows analysis highlighted.

URLs tested: http://127.0.0.1:8080/analytics/analyses/test-analysis-123

Evidence: 1 screenshot captured

✅ TC-14: Back button navigation restores correct sidebar active state (succeeded)

Steps: 1. Dashboard 1 loaded. 2. Clicked dashboard 2 in sidebar. 3. Used browser back. 4. Verified dashboard 1 active with views restored.

URLs tested: http://127.0.0.1:8080/analytics/adhoc/test-dashboard-1778877304721, http://127.0.0.1:8080/analytics/adhoc/test-dashboard-b-1778877310827

Evidence: 3 screenshots captured

✅ TC-15: Dashboard views endpoint is NOT called for all dashboards on load (efficiency regression) (succeeded)

Steps: 1. Loaded dashboard 1. 2. Counted /api/dashboard-views/ requests. 3. Confirmed exactly 1 (for active dashboard only).

URLs tested: http://127.0.0.1:8080/analytics/adhoc/test-dashboard-1778877304721

Evidence: 1 screenshot captured

Details

PR #714 analytics navigation snappiness improvements: 14/15 TCs passed, 1 couldnt_verify (TC-10 — test isolation issue, feature confirmed working via planner re-test). All core behaviors verified: BlankDashboard fallback, prefetch on hover for dashboards and analyses, active-dashboard-only views fetching (N→1 optimization), no duplicate requests after hover+click, no UI flash on rapid hover, correct sidebar active state on forward/back navigation, and no existence-check request in router.

@steve8708
Copy link
Copy Markdown
Contributor Author

Addressing the browser-testing review: TC-10 does not need a code change. The executor focused a dashboard link after TC-09 had already navigated to that dashboard, so the React Query entry was still fresh under the 30s staleTime and prefetchQuery correctly skipped a duplicate network request. The same review notes a planner re-test with a cold cache where programmatic focus did fire the expected /api/sql-dashboards request, so the focus prefetch behavior is working as intended.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for nutritrack-daily-calories canceled.

Name Link
🔨 Latest commit 21ec06a
🔍 Latest deploy log https://app.netlify.com/projects/nutritrack-daily-calories/deploys/6a078cb986ac7f0008139681

@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for agent-native-starter canceled.

Name Link
🔨 Latest commit 21ec06a
🔍 Latest deploy log https://app.netlify.com/projects/agent-native-starter/deploys/6a078cb990bd66000832e3e2

@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for agent-native-dispatch canceled.

Name Link
🔨 Latest commit 21ec06a
🔍 Latest deploy log https://app.netlify.com/projects/agent-native-dispatch/deploys/6a078cb961c1d20008d76e88

@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for agent-native-content canceled.

Name Link
🔨 Latest commit 21ec06a
🔍 Latest deploy log https://app.netlify.com/projects/agent-native-content/deploys/6a078cb9bb5a2600088d9301

@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for agent-native-calendar canceled.

Name Link
🔨 Latest commit 21ec06a
🔍 Latest deploy log https://app.netlify.com/projects/agent-native-calendar/deploys/6a078cb990bd66000832e3dd

@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for agent-native-issues canceled.

Name Link
🔨 Latest commit 21ec06a
🔍 Latest deploy log https://app.netlify.com/projects/agent-native-issues/deploys/6a078cb9a0ade50008eacea2

@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for agent-native-slides canceled.

Name Link
🔨 Latest commit 21ec06a
🔍 Latest deploy log https://app.netlify.com/projects/agent-native-slides/deploys/6a078cb955e3760008cb86cd

@steve8708
Copy link
Copy Markdown
Contributor Author

Addressed review 4301181018 in 21ec06a:

  • Stable prefetch snapshots now bridge sidebar/page query-key version changes while still refetching when the sync version changed.
  • Prefetch fetchers cache null only for 404; transient non-2xx statuses now throw.
  • Analysis prefetch JSON parsing now has explicit error handling.
  • Sidebar active dashboard detection now honors legacy ?id= dashboard URLs, so saved views and highlighting use the real dashboard id.

Verified with pnpm --filter analytics typecheck, pnpm --filter analytics build, and git diff --check.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for agent-native-mail canceled.

Name Link
🔨 Latest commit 21ec06a
🔍 Latest deploy log https://app.netlify.com/projects/agent-native-mail/deploys/6a078cb99bff0300080bdc43

@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for agent-native-macros canceled.

Name Link
🔨 Latest commit 21ec06a
🔍 Latest deploy log https://app.netlify.com/projects/agent-native-macros/deploys/6a078cb9b4e8f4000970431d

@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for agent-native-forms canceled.

Name Link
🔨 Latest commit 21ec06a
🔍 Latest deploy log https://app.netlify.com/projects/agent-native-forms/deploys/6a078cb97fc4790008a8bca7

@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for agent-native-videos canceled.

Name Link
🔨 Latest commit 21ec06a
🔍 Latest deploy log https://app.netlify.com/projects/agent-native-videos/deploys/6a078cb99bff0300080bdc48

@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for agent-native-recruiting canceled.

Name Link
🔨 Latest commit 21ec06a
🔍 Latest deploy log https://app.netlify.com/projects/agent-native-recruiting/deploys/6a078cb91bd5a00008fb7090

Copy link
Copy Markdown
Contributor

@builder-io-integration builder-io-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Builder reviewed your changes — looks good ✅

Review Details

Incremental Code Review — PR #714 (Updated)

All previously reported issues have been comprehensively fixed.

Issues Resolved ✅

  1. Query Key Versioning Mismatch (was HIGH) — FIXED

    • Introduced separate prefetch query keys (sqlDashboardPrefetchKey, analysisDetailPrefetchKey) that don't include the sync version
    • Wrapped prefetch data in a PrefetchSnapshot<T> type carrying both data and syncVersion
    • Pages now use initialData hook to detect version mismatches and safely reuse prefetch data
    • When versions differ, sets staleTime: 0 to force immediate refetch
    • This elegantly avoids the cache miss problem while respecting invalidation semantics
  2. Transient Errors Cached as Permanent (was MEDIUM) — FIXED

    • Changed prefetch error handling: only res.status === 404 returns null
    • Other non-OK responses now throw instead of returning null, marking prefetch as failed
    • Pages can now safely refetch on error instead of showing stale "not found" states
  3. JSON Parse Error Handling (was MEDIUM) — FIXED

    • Added try-catch around res.json() in both fetchSqlDashboardForPrefetch and fetchAnalysisDetailForPrefetch
    • Parse errors now throw instead of being silently swallowed
  4. Query Parameter Support (was LOW) — FIXED

    • Active dashboard ID detection now supports ?id= parameter
    • Uses new URLSearchParams(location.search).get("id") || routeParamId
    • Restores support for legacy dashboard URLs

Quality of the Fix

The implementation is sophisticated and correct:

  • ✅ Prefetch snapshot pattern elegantly solves version mismatch without bypassing invalidation
  • initialData and initialDataUpdatedAt logic properly handles stale-null and version-change edge cases
  • staleTime conditional (0 vs 30_000) correctly determines when to refetch vs reuse
  • ✅ Cleanup removeQueries calls placed after successful mutations to avoid wiping optimistic state
  • ✅ Type safety maintained with PrefetchSnapshot<T> wrapping
  • ✅ No new bugs or regressions detected

Verdict

The fix is solid, well-structured, and ready to merge. The author took the feedback seriously and implemented a principled solution that respects React Query's semantics while fixing the core issues.

🧪 Browser testing: Already completed on prior commit; fixes maintain all previously-verified behaviors.

@steve8708 steve8708 merged commit 8a2355e into main May 16, 2026
34 checks passed
@steve8708 steve8708 deleted the codex/analytics-snappiness branch May 16, 2026 15:24
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.

1 participant