[Explorer] Render boolean values - #2830
Conversation
📝 WalkthroughWalkthroughThe explorer now uses a shared ChangesExplorer value formatting
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 winAdd coverage for object serialization.
The current test covers only the non-object path. Add compact and pretty object assertions to cover
JSON.stringifyand theprettyargument.🧪 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
📒 Files selected for processing (3)
client/packages/components/src/components/explorer/__tests__/format-value.test.tsclient/packages/components/src/components/explorer/format-value.tsclient/packages/version/src/version.ts
| export function formatVal(data: any, pretty?: boolean): string { | ||
| if (isObject(data)) { | ||
| return JSON.stringify(data, null, pretty ? 2 : undefined); |
There was a problem hiding this comment.
🎯 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/explorerRepository: 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.tsRepository: 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 20Repository: 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({}, {})));
JSRepository: 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.
There was a problem hiding this comment.
This is same behavior as before
There was a problem hiding this comment.
@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.
|
View Vercel preview at instant-www-js-render-boolean-vals-explorer-jsv.vercel.app. |
Noticed the explorer wasn't rendering boolean values if they were set as "Any" -- now it will!
Before

After
