Skip to content

Keep Charts preview history in sync - #1179

Open
tannerlinsley wants to merge 1 commit into
mainfrom
agent/sync-charts-preview-history
Open

Keep Charts preview history in sync#1179
tannerlinsley wants to merge 1 commit into
mainfrom
agent/sync-charts-preview-history

Conversation

@tannerlinsley

@tannerlinsley tannerlinsley commented Aug 25, 2026

Copy link
Copy Markdown
Member

Evidence

Both Charts preview message handlers read previewHistoryRef.current, but updated that ref inside a React state updater. State updaters can be evaluated after the message handler returns, so a second browser-state message can read stale history and calculate navigation or annotation state from the wrong URL. The notebook instance was also left as an unresolved review finding on merged PR #1171.

The same pattern exists in the catalog result handler. No open issue or PR addresses the synchronization bug. PR #1173 touches the catalog result only to remove an unused callback, not preview history behavior.

Impact

Rapid preview navigation messages now build on the latest accepted history in both Charts surfaces. This prevents stale back/forward entries and annotation targets.

Change

Compute the next history from the current ref, update the ref synchronously, then pass that exact value to React state. This keeps the existing history helper and behavior, with no new abstraction or API change.

Validation

  • pnpm test
  • TypeScript and type-aware lint passed
  • 367 tests total, 366 passed, 1 environment-gated docs smoke test skipped
  • git diff --check

Risk

Low. The same pure updateExamplePreviewHistory result still drives state, but the mutable ref now advances in the message handler before another message can arrive.

Summary by CodeRabbit

  • Bug Fixes
    • Improved preview browser history updates for more consistent navigation behavior.
    • Preserved URL normalization, navigation-error clearing, and annotation-target reset behavior.

@tannerlinsley tannerlinsley added the source-audit Tracked by the automated source audit label Aug 25, 2026
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: da864317-4afe-40c2-b322-f2b714e05b61

📥 Commits

Reviewing files that changed from the base of the PR and between 6ec1fbe and 302e8e3.

📒 Files selected for processing (2)
  • src/components/charts/ChartsCatalogResult.client.tsx
  • src/components/charts/ChartsNotebookPage.client.tsx

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

Preview browser-state handlers now compute history from the current ref, update the ref immediately, and pass the same snapshot to React state. Existing URL normalization, navigation-error clearing, and annotation-target reset behavior remain intact.

Changes

Preview history synchronization

Layer / File(s) Summary
Synchronize preview history snapshots
src/components/charts/ChartsCatalogResult.client.tsx, src/components/charts/ChartsNotebookPage.client.tsx
Both browser-state handlers replace functional state updates with direct updates based on previewHistoryRef.current. Each handler updates the ref before calling setPreviewHistory.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 302e8

The change keeps preview navigation history synchronized across the affected Charts surfaces without changing the existing behavior contract. No actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: synchronizing Charts preview history across the affected surfaces.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/sync-charts-preview-history

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
tanstack-com 302e8e3 Commit Preview URL

Branch Preview URL
Aug 25 2026, 02:11 PM

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

Labels

source-audit Tracked by the automated source audit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant