Skip to content

feat: JSON viewer with Text/Tree toggle for query results#826

Merged
datlechin merged 7 commits into
mainfrom
feat/json-viewer
Apr 22, 2026
Merged

feat: JSON viewer with Text/Tree toggle for query results#826
datlechin merged 7 commits into
mainfrom
feat/json-viewer

Conversation

@datlechin
Copy link
Copy Markdown
Member

Summary

Closes #752. Adds a full-featured JSON viewer for query results with two modes:

  • Text mode: syntax-highlighted JSON with brace matching, auto-formatted on open, format button for re-indentation
  • Tree mode: hierarchical tree view with expand/collapse disclosure triangles, search filtering, copy value/key path via right-click context menu

Both the grid popover (double-click a JSON cell) and the details pane (expand button on JSON fields) use the new viewer. The preferred view mode is persisted in Settings > Editor > JSON Viewer.

Changes

  • 3 new files: JSONTreeNode.swift (data model + parser), JSONTreeView.swift (tree component), JSONViewerView.swift (container with toggle)
  • Details pane: JSON fields show compact preview (120pt) with expand button that opens a full-height viewer with back navigation
  • Grid popover: enlarged from 420x340 to 560x480, now uses the viewer with Text/Tree toggle
  • Settings: new "JSON Viewer" section in Editor settings with default view mode picker
  • Performance: tree parser capped at 5,000 nodes, 100K character input limit, O(1) string length checks

Test plan

  • Open a table with JSON/JSONB columns
  • Double-click a JSON cell — popover opens at larger size with Text/Tree toggle
  • Switch to Tree mode — hierarchical tree with expand/collapse
  • Use Expand All / Collapse All buttons
  • Search within tree — filters nodes, auto-expands matches
  • Right-click a tree node — Copy Value, Copy Key Path, Copy Key
  • Open details pane — JSON field shows compact preview with expand button
  • Click expand button — full-height JSON viewer replaces field list
  • Click "Fields" back button — returns to field list
  • Edit JSON in text mode, save — compacted JSON stored correctly
  • Check Settings > Editor > JSON Viewer — default view mode persists across sessions
  • Test with large JSON (>10K chars) — text mode works, tree may show truncation marker
  • Test with invalid JSON — text mode works, tree shows error state
  • Test with empty/null JSON values

@datlechin datlechin merged commit 2135b67 into main Apr 22, 2026
2 checks passed
@datlechin datlechin deleted the feat/json-viewer branch April 22, 2026 05:29
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.

feat: Better JSON viewer for query results

1 participant