fix(frontend): rewrite BeautifiedJsonView as collapsible tree#4343
Conversation
…cessibility Replace the flat field-per-key layout with a recursive tree renderer that supports collapse/expand, indent guides, type-colored scalars, hover-to-copy, and shallow chat detection. Fix hierarchy-collapsing bug caused by deep extractChatMessages search, while preserving OpenAI choices format and sender/author role alias detection from the old version.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughBeautifiedJsonView is refactored into a component-driven, collapsible row tree: chat-detection helpers extract messages, simplifyValue centralizes AI envelope and metadata cleanup, new UI primitives (ScalarValue, CopyButton, NodeRow, TruncatedMessageBody, MessageNodeRow) render interactive rows, and RecursiveNode performs depth-limited recursive rendering; TraceSpanDrillInView resets viewMode when available modes change. ChangesBeautifiedJsonView Row-Based Rendering Refactor
TraceSpan viewMode reinitialization
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
web/oss/src/components/DrillInView/BeautifiedJsonView.tsx (1)
174-185:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winAll-noise metadata objects still leak through simplification.
The
noiseKeys.length < keys.lengthguard only cleans mixed objects. An object made entirely ofMETADATA_NOISE_KEYScomes back unchanged, so the metadata-stripping path misses the noisiest case.🧹 Minimal fix
- if (noiseKeys.length > 0 && noiseKeys.length < keys.length) { + if (noiseKeys.length > 0) { const cleaned: Record<string, unknown> = {} for (const k of keys) { if (!METADATA_NOISE_KEYS.has(k)) { cleaned[k] = rec[k] } } return cleaned }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: fc10ea21-010e-404f-9478-32a72bc9b09d
📒 Files selected for processing (1)
web/oss/src/components/DrillInView/BeautifiedJsonView.tsx
Railway Preview Environment
Updated at 2026-05-19T17:50:10.415Z |
- Preserve sibling fields when extracting chat from wrapper objects
(e.g. {messages: [...], usage, model} now shows usage and model
alongside the chat, not just the messages)
- Fix metadata noise guard to also clean all-noise objects
- Use async/await for clipboard instead of .then() chains
- Initialize timer ref with null for React 19 compatibility
478e43c to
5ada416
Compare
…vigation useState initializer only runs on mount — navigating from a text-only parent span to a child span with structured messages kept the stale "text" mode instead of defaulting to "beautified-json".
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 189948f5-b89d-4123-bcab-be40175314ba
📒 Files selected for processing (1)
web/oss/src/components/DrillInView/TraceSpanDrillInView.tsx
…gation
EditorProvider uses initialValue which only sets content on mount.
When navigating between spans, the Lexical editor kept stale content
from the previous span. Adding key={text} forces a remount when the
underlying text changes.
…tree Tool messages (role=tool) often contain JSON responses from function calls. Instead of showing raw JSON text in the editor, parse the content and render it as a RecursiveNode tree with the same collapse/expand and copy behavior as tool call arguments.
ardaerzin
left a comment
There was a problem hiding this comment.
I'm ok with the changes, however would like us to consider making collapsible headers sticky so that in large data
- context is not lost
- folding can still happen without scrolling up
feat(frontend): add fade+pill truncation for long chat messages
Adds position:sticky to collapsible NodeRow headers so the innermost visible parent stays pinned at the top of the scroll container. Child headers naturally overlap parent headers, so only the deepest context is shown at any scroll position.
|
@ardaerzin unfortunately that didn't work. I struggled implementing sticky headers. Can we postpone it to a follow-up PR? |
@mmabrouk fair enough. I'll create a follow up ticket and assign it to @ashrafchowdury |
Summary
Rewrites the
BeautifiedJsonViewcomponent from a flat key-value list into a recursive, collapsible tree.Multiple changes:
What changed
choicesformat). It no longer digs throughinputs/outputs/datawrappers, so the surrounding structure stays visible.Test plan
{choices: [{message: {role: "assistant", content: "..."}}]}payload. Verify it renders as a chat message with a role badge.{role: "user", content: "hello"}). Verify it renders as a chat message.Demo Before and After
demo-beautify.mp4