Skip to content

[Explorer] Render boolean values - #2830

Merged
nezaj merged 3 commits into
mainfrom
render-boolean-vals-explorer
Aug 4, 2026
Merged

[Explorer] Render boolean values#2830
nezaj merged 3 commits into
mainfrom
render-boolean-vals-explorer

Conversation

@nezaj

@nezaj nezaj commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Noticed the explorer wasn't rendering boolean values if they were set as "Any" -- now it will!

Before
CleanShot 2026-08-03 at 17 34 33@2x

After
CleanShot 2026-08-03 at 17 28 20@2x

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The explorer now uses a shared formatVal utility for cell rendering and copying. The utility formats objects and non-objects, with boolean tests added. The shared package version changes to v1.0.59.

Changes

Explorer value formatting

Layer / File(s) Summary
Shared formatter implementation and validation
client/packages/components/src/components/explorer/format-value.ts, client/packages/components/src/components/explorer/__tests__/format-value.test.ts
Adds formatVal for object serialization and non-object string conversion. Tests cover both boolean values.
Shared formatter integration
client/packages/components/src/components/explorer/inner-explorer.tsx, client/packages/components/src/components/explorer/table-components.tsx
Cell rendering and copying use the shared formatter. Duplicate local implementations are removed.
Package version update
client/packages/version/src/version.ts
Updates the shared package version from v1.0.58 to v1.0.59.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title clearly identifies the main change: rendering boolean values in the Explorer.
Description check ✅ Passed The description explains that the Explorer now renders boolean values and provides before-and-after evidence.
✨ 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 render-boolean-vals-explorer

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.

@stopachka stopachka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SGTM!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
client/packages/components/src/components/explorer/__tests__/format-value.test.ts (1)

5-7: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for object serialization.

The current test covers only the non-object path. Add compact and pretty object assertions to cover JSON.stringify and the pretty argument.

🧪 Proposed coverage
   test('formats boolean values as visible text', () => {
     expect(formatVal(true)).toBe('true');
     expect(formatVal(false)).toBe('false');
   });
+
+  test('formats object values', () => {
+    expect(formatVal({ enabled: true })).toBe('{"enabled":true}');
+    expect(formatVal({ enabled: true }, true)).toBe('{\n  "enabled": true\n}');
+  });
🤖 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
`@client/packages/components/src/components/explorer/__tests__/format-value.test.ts`
around lines 5 - 7, Add tests alongside “formats boolean values as visible text”
for formatVal using an object input: assert compact JSON output with the default
pretty setting and indented JSON output when pretty is enabled, covering both
JSON.stringify paths.
🤖 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.

Inline comments:
In `@client/packages/components/src/components/explorer/format-value.ts`:
- Around line 3-5: Update formatVal so JSON.stringify results are guaranteed to
be a string when handling objects, including function-like or otherwise
non-JSON-compatible values. Add an appropriate plain/object-type validation or
use a defined string fallback while preserving the existing pretty-print
behavior.

---

Nitpick comments:
In
`@client/packages/components/src/components/explorer/__tests__/format-value.test.ts`:
- Around line 5-7: Add tests alongside “formats boolean values as visible text”
for formatVal using an object input: assert compact JSON output with the default
pretty setting and indented JSON output when pretty is enabled, covering both
JSON.stringify paths.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7551494e-c0c3-4925-b3a9-d52400097c79

📥 Commits

Reviewing files that changed from the base of the PR and between 9c1be91 and 213abba.

📒 Files selected for processing (3)
  • client/packages/components/src/components/explorer/__tests__/format-value.test.ts
  • client/packages/components/src/components/explorer/format-value.ts
  • client/packages/version/src/version.ts

Comment on lines +3 to +5
export function formatVal(data: any, pretty?: boolean): string {
if (isObject(data)) {
return JSON.stringify(data, null, pretty ? 2 : undefined);

@coderabbitai coderabbitai Bot Aug 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 6 '\bformatVal\s*\(' client/packages/components/src/components/explorer

Repository: instantdb/instant

Length of output: 7391


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== candidate file =="
cat -n client/packages/components/src/components/explorer/format-value.ts

echo "== explorer data typing/search =="
rg -n -C 4 'info\.row\.original\[attr\.name\]|\brow\.original\b|interface .*Raw|type .*Raw|data.*JSON|fromJSON|Json|Date|function' client/packages/components/src/components/explorer/inner-explorer.tsx client/packages/components/src/components/explorer/table-components.tsx | head -n 240

echo "== tests =="
cat -n client/packages/components/src/components/explorer/__tests__/format-value.test.ts

Repository: instantdb/instant

Length of output: 20093


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== rows type construction =="
rg -n -C 8 "itemsRes\.data|fallbackItems|Record<string, any>|itemsRes|QueryData|queryItems|fetch.*items|attributes|checkedDataType" client/packages/components/src/components/explorer/inner-explorer.tsx | head -n 220

echo "== possible row.original construction in repo =="
rg -n -C 5 'row\.original|info\.row\.original|row_original|original:' client/packages/components/src/components/explorer | head -n 200

echo "== lockfile package versions =="
fd -a 'package-lock\.json$|pnpm-lock\.yaml$|yarn\.lock$|bun\.lockb$' . | sed 's#^\./##' | head -n 20

Repository: instantdb/instant

Length of output: 12197


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== useNamespacesQuery references =="
rg -n -C 8 'function useNamespacesQuery|const useNamespacesQuery|export .*useNamespacesQuery|useNamespacesQuery\s*=' . | head -n 240

echo "== JS behavioral probe for formatVal contract edge case =="
node - <<'JS'
const isObjectLike = (value) => typeof value === 'object' && value <> null;
const isPlainObject = isObjectLike;
const isArray = Array.isArray;
const getTag = (value) => Object.prototype.toString.call(value);
const isFunction = (value) => typeof value === 'function';
const isObject = (value) => {
  const type = typeof value;
  return value !== null && (type === 'object' || type === 'function');
};
function stringifyProxy(data) {
  try { return JSON.stringify(data); } catch (e) { console.error('JSON.stringify proxy', e.name, e.message); return undefined; }
}
console.log('lodash-style object guard:', isObject(String), isObject(() => {}), isObject({}));
console.log('function stringify:', JSON.stringify(String), JSON.stringify(() => {}));
console.log('object stringify:', JSON.stringify({}));
console.log('proxy:', stringifyProxy(new Proxy({}, {})));
JS

Repository: instantdb/instant

Length of output: 2223


Ensure formatVal only formats JSON-compatible values.

formatVal(data, pretty) passes directly from explorer row values after explicit ref/date handling. If an attribute contains a function-like object, JSON.stringify returns undefined while the return type says string; add a plain/object-type check or a defined fallback.

🤖 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 `@client/packages/components/src/components/explorer/format-value.ts` around
lines 3 - 5, Update formatVal so JSON.stringify results are guaranteed to be a
string when handling objects, including function-like or otherwise
non-JSON-compatible values. Add an appropriate plain/object-type validation or
use a defined string fallback while preserving the existing pretty-print
behavior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is same behavior as before

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@nezaj, correct. This PR preserves the existing JSON.stringify behavior for object values. It only centralizes the formatter and adds boolean rendering. The Comment images confirm that true now displays in the Explorer.

I will withdraw this comment.

You are interacting with an AI system.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

View Vercel preview at instant-www-js-render-boolean-vals-explorer-jsv.vercel.app.

@nezaj
nezaj merged commit 794b010 into main Aug 4, 2026
30 checks passed
@nezaj
nezaj deleted the render-boolean-vals-explorer branch August 4, 2026 00:38
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