Skip to content

fix(devtools ui): fix json tree nan values#430

Merged
AlemTuzlak merged 1 commit into
mainfrom
fix-nan
May 11, 2026
Merged

fix(devtools ui): fix json tree nan values#430
AlemTuzlak merged 1 commit into
mainfrom
fix-nan

Conversation

@harry-whorlow
Copy link
Copy Markdown
Collaborator

@harry-whorlow harry-whorlow commented May 11, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Fixed JsonTree rendering to correctly display NaN values instead of converting them to null.
  • Tests

    • Comprehensive test suite added for JsonTree component covering various data types, expansion behavior, and formatting options.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

📝 Walkthrough

Walkthrough

A NaN rendering bug in JsonTree is fixed by explicitly stringifying numeric values. A new comprehensive test suite validates rendering across all data types and configurations. Vitest test discovery is configured, and the fix is documented in a changeset for patch release.

Changes

JsonTree NaN Rendering Fix and Test Coverage

Layer / File(s) Summary
Numeric Rendering Fix
packages/devtools-ui/src/components/tree.tsx
Numeric primitive values are now explicitly stringified via String(props.value) to correctly render NaN and other numeric values instead of relying on JSX rendering behavior.
Test Infrastructure & Setup
packages/devtools-ui/tests/tree.tsx
Test suite imports Vitest, Solid rendering utilities, JsonTree, and ThemeContextProvider. renderTree helper mounts JsonTree with configurable expansion/collapse settings and cleans up DOM state after each test.
Test Discovery Configuration
packages/devtools-ui/vite.config.ts
Vitest test configuration explicitly includes tests/**/*.{ts,tsx} and excludes tests/test-setup.ts and node_modules for test discovery.
Comprehensive Test Coverage
packages/devtools-ui/tests/tree.tsx
Test cases validate rendering of strings, numbers (including NaN, zero, negative), booleans, null, undefined, named and arrow functions, arrays (empty, expanded, nested, mixed types), objects (empty, keyed, nested with depth limits), Date formatting with custom dateFormat, expansion depth behavior with collapsePaths, and quoted key/bracket ordering.
Release Documentation
.changeset/fix-nan-tree-rendering.md
Changeset documents a patch version bump for @tanstack/devtools-ui noting that JsonTree now correctly renders NaN instead of displaying it as null.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A hop, a fix, a stringified delight,
NaN no longer hides in shadowed night,
Tests bloom across each type and case,
While Vite keeps discovery in its place,
The JsonTree renders true and bright! 🌳✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is completely empty, missing all required template sections including Changes, Checklist items, and Release Impact information. Add a description following the template: explain what changes were made and why, confirm testing with 'pnpm test:pr', and verify the changeset was generated for the published code change.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(devtools ui): fix json tree nan values' clearly and specifically describes the main change: fixing how JsonTree renders NaN values.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-nan

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

3 package(s) bumped directly, 10 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/devtools 0.12.0 → 0.12.1 Changeset
@tanstack/devtools-ui 0.5.1 → 0.5.2 Changeset
@tanstack/devtools-vite 0.6.0 → 0.6.1 Changeset
@tanstack/angular-devtools 0.0.2 → 0.0.3 Dependent
@tanstack/devtools-a11y 0.1.2 → 0.1.3 Dependent
@tanstack/devtools-example-angular-a11y-devtools 0.0.1 → 0.0.2 Dependent
@tanstack/devtools-example-angular-basic 0.0.1 → 0.0.2 Dependent
@tanstack/devtools-example-angular-panel 0.0.1 → 0.0.2 Dependent
@tanstack/devtools-example-angular-with-devtools 0.0.1 → 0.0.2 Dependent
@tanstack/preact-devtools 0.10.3 → 0.10.4 Dependent
@tanstack/react-devtools 0.10.3 → 0.10.4 Dependent
@tanstack/solid-devtools 0.8.3 → 0.8.4 Dependent
@tanstack/vue-devtools 0.2.17 → 0.2.18 Dependent

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 11, 2026

View your CI Pipeline Execution ↗ for commit a52fbd7

Command Status Duration Result
nx affected --targets=test:eslint,test:sherif,t... ✅ Succeeded 2m 5s View ↗
nx run-many --targets=build --exclude=examples/** ✅ Succeeded 32s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-11 10:19:32 UTC

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 11, 2026

More templates

@tanstack/angular-devtools

npm i https://pkg.pr.new/@tanstack/angular-devtools@430

@tanstack/devtools

npm i https://pkg.pr.new/@tanstack/devtools@430

@tanstack/devtools-a11y

npm i https://pkg.pr.new/@tanstack/devtools-a11y@430

@tanstack/devtools-client

npm i https://pkg.pr.new/@tanstack/devtools-client@430

@tanstack/devtools-ui

npm i https://pkg.pr.new/@tanstack/devtools-ui@430

@tanstack/devtools-utils

npm i https://pkg.pr.new/@tanstack/devtools-utils@430

@tanstack/devtools-vite

npm i https://pkg.pr.new/@tanstack/devtools-vite@430

@tanstack/devtools-event-bus

npm i https://pkg.pr.new/@tanstack/devtools-event-bus@430

@tanstack/devtools-event-client

npm i https://pkg.pr.new/@tanstack/devtools-event-client@430

@tanstack/preact-devtools

npm i https://pkg.pr.new/@tanstack/preact-devtools@430

@tanstack/react-devtools

npm i https://pkg.pr.new/@tanstack/react-devtools@430

@tanstack/solid-devtools

npm i https://pkg.pr.new/@tanstack/solid-devtools@430

@tanstack/vue-devtools

npm i https://pkg.pr.new/@tanstack/vue-devtools@430

commit: a52fbd7

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/devtools-ui/tests/tree.tsx (1)

58-78: ⚡ Quick win

Consider adding tests for Infinity edge cases.

While the current numeric tests are solid, consider adding coverage for Infinity and -Infinity to ensure the String() conversion handles all special numeric values consistently.

📝 Optional additional test cases
    it('renders NaN as "NaN"', () => {
      const el = renderTree(NaN)
      expect(el.textContent).toContain('NaN')
    })
+
+   it('renders Infinity as "Infinity"', () => {
+     const el = renderTree(Infinity)
+     expect(el.textContent).toContain('Infinity')
+   })
+
+   it('renders -Infinity as "-Infinity"', () => {
+     const el = renderTree(-Infinity)
+     expect(el.textContent).toContain('-Infinity')
+   })
  })
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/devtools-ui/tests/tree.tsx` around lines 58 - 78, Add test cases for
the Infinity edge cases inside the existing describe('number') block: call
renderTree(Infinity) and renderTree(-Infinity) and assert their rendered
textContent contains 'Infinity' and '-Infinity' respectively (matching how other
tests use expect(el.textContent).toContain(...)); update the tests in
packages/devtools-ui/tests/tree.tsx near the existing renderTree calls so Number
special values are covered consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/devtools-ui/tests/tree.tsx`:
- Around line 58-78: Add test cases for the Infinity edge cases inside the
existing describe('number') block: call renderTree(Infinity) and
renderTree(-Infinity) and assert their rendered textContent contains 'Infinity'
and '-Infinity' respectively (matching how other tests use
expect(el.textContent).toContain(...)); update the tests in
packages/devtools-ui/tests/tree.tsx near the existing renderTree calls so Number
special values are covered consistently.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a30944eb-075e-4b20-aa4f-19d0cae05a80

📥 Commits

Reviewing files that changed from the base of the PR and between 3ee47f9 and a52fbd7.

📒 Files selected for processing (4)
  • .changeset/fix-nan-tree-rendering.md
  • packages/devtools-ui/src/components/tree.tsx
  • packages/devtools-ui/tests/tree.tsx
  • packages/devtools-ui/vite.config.ts

@AlemTuzlak AlemTuzlak merged commit 015b733 into main May 11, 2026
7 checks passed
@AlemTuzlak AlemTuzlak deleted the fix-nan branch May 11, 2026 10:29
@github-actions github-actions Bot mentioned this pull request May 11, 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.

2 participants