-
Notifications
You must be signed in to change notification settings - Fork 64
Fix JSON value viewer crash and add interactive tree view #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…up parsing crash JSON data containing bracket patterns like [0,23] was being interpreted as Rich markup tags, causing MarkupError crashes in Preview (v) and View (V). - Use rich.Syntax for JSON content with syntax highlighting - Set markup=False on Static widgets for non-JSON content - Store raw value separately in ValueViewScreen for copy functionality
Add collapsible tree view for JSON data in Preview (v) and View (V) modes: - New JSONTreeView widget with expand/collapse support - Tree view is default for valid JSON, with syntax highlighting fallback - Key bindings: t (toggle tree/syntax), E (expand all), Z (collapse all) - Proper focus management and scrolling in both view modes - Simplified footer hints to avoid duplication with app bindings The tree view makes exploring nested JSON (like Twitter API responses) much easier than scrolling through syntax-highlighted text.
|
Nice PR. But why isn't the keybindings in the footer? And expanding a node isn't "e", it should have been enter. It's just textual default. Expanding a node shouldn't have a keybinding. Please be careful about integrating your code with the rest of its structure and practices. |
|
yes good points. i will fix these in the morning. what binding should be used for collapse? |
|
Lower case 'z' is preferred. |
|
When I say integration with rest of the code base I am particularly concerned about duplicated detect json method. Also the code adds manual key handling directly in the widget. Should instead register with ValueViewActiveState._setup_actions to use the hierarchical state machine. Please use a ValueViewActiveState and create children ValueViewTreeModeState and ValueViewSyntaxModeState. |
Address maintainer feedback on PR Maxteabag#78: - Remove manual key handling from InlineValueView widget - Create ValueViewTreeModeState and ValueViewSyntaxModeState child states - Register actions via _setup_actions() using hierarchical state machine - Add shared parse_json_value() to eliminate duplicate JSON detection - Display keybindings in footer via get_display_bindings() - Use lowercase 'z' for collapse all (per maintainer preference) - Remove 'e'/'E' expand binding (enter is textual default) - Show contextual toggle labels: "Syntax View" / "Tree View" - Add value_view_tree_mode and value_view_is_json to InputContext Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add contextual copy options when viewing JSON in tree mode: - yy: Copy current node's value - yf: Copy field as "key": value format - ya: Copy entire JSON Follows existing 'ry' (results yank) menu pattern. Includes visual flash feedback on copy (cursor flash for value/field, background flash for all). Syntax mode retains direct copy behavior (no submenu). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for parse_json_value function and state machine guards to ensure JSON tree view only activates for valid JSON content. Fix bug in ValueViewSyntaxModeState.is_active() that was missing the value_view_is_json check, which would have allowed toggle for non-JSON content. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
finally, added these tests (from claude):
Adds regression tests for the JSON tree viewer functionality: tests/ui/test_json_tree.py - 7 tests for parse_json_value
tests/ui/keybindings/test_state_machine.py - 3 tests for TestValueViewStates
The test_toggle_blocked_for_non_json test identified a missing value_view_is_json check in ValueViewSyntaxModeState.is_active(). Without this fix, the toggle keybinding would have been incorrectly available for non-JSON content. |
|
the only thing i'm unsure about is the thanks again for your patience and for the awesome tool. its been a big help for me. |





Summary
[0,23]interpreted as Rich markup tags)v) and View (V) modesProblem
JSON data containing bracket patterns like
[0,23]was being interpreted as Rich markup tags, causingMarkupErrorcrashes when using Preview (v) or View (V) on cells containing JSON.Solution
Bug Fix
rich.Syntaxfor JSON content rendering with proper syntax highlightingmarkup=Falseon Static widgets for non-JSON content to prevent markup parsingFeature: Interactive JSON Tree Viewer
JSONTreeViewwidget with collapsible tree structure for JSON data{}for objects (cyan),[]for arrays (magenta) with item countsKey Bindings
tE/eZFiles Changed
sqlit/shared/ui/widgets_json_tree.pysqlit/shared/ui/widgets_value_view.pysqlit/domains/results/ui/screens/value_view.pyValidation
ruff check .- passesruff format --check .- passespyright- passes (0 errors)pytest tests/ -k sqlite- 31 passed, 6 skippedpytest tests/cli/ tests/ui/- 127 passed, 1 pre-existing failure unrelated to this PR