feat: fold blocks in the large-response body viewer - #52
Merged
axbarchuk merged 3 commits intoAug 18, 2026
Conversation
The windowed viewer only ever holds a slice of the body, so it cannot tell where a block ends. fold_ends walks the pretty-printed text once with a bracket stack, and each window carries the ends of its own lines.
Responses over 256 KB render in the virtualized viewer, which had no fold controls — the bigger the payload, the less there was to navigate with. Collapsed blocks become runs of hidden lines, so rows on screen no longer map one to one onto the body and have to be translated back before anything is fetched or searched. That math lives in lib/lineFolds.ts with its own tests; useLineFolds owns the state, and the scrolled content moves out of VirtualBody to keep both files under the size limit. Closes voleeo#51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Collapse chevrons disappeared once a response got large. Bodies over 256 KB render in the virtualized viewer, which never had fold controls — so on a 31 MB payload the only ways to navigate were scrolling ~1.4M lines or the JSONPath filter, which answers "show me this path", not "what's in here".
This PR adds folding to the windowed viewer:
fold_endswalks the pretty-printed body once with a bracket stack, inside the parse that already runs for windowing, and everyBodyWindowcarries the closing line of each line it returns. The frontend only holds a slice at a time, so it can't find a block's end itself. Unbalanced (non-JSON) text yields no folds.lib/lineFolds.ts(pure, tested);useLineFoldsowns the state.{ … },the way CodeMirror does — the closing line's own text when it's loaded, the mirrored bracket when it isn't.VirtualBodyintoVirtualBodyLinesto stay under the 250-line limit.Small responses are untouched: the Rust and React entry points sit behind the same 256 KB gate (
response.rs:93,BodyTab.tsx:93), so nothing on the CodeMirror path reaches a changed line.BodyWindowis the only shared type that changed, and it exists solely on the windowed path.Closes #51
Folding individual blocks
Collapsing the whole array
How to test
GET https://jsonplaceholder.typicode.com/photos— 1.0 MB, past the 256 KB threshold/comments, 158 KB) still renders in CodeMirror, unchangedOut of scope
The line-wrap toggle, which the issue mentions for the same reason. Row heights are uniform today; wrapping makes them depend on line lengths the viewer only learns as blocks load, so the scrollbar would drift on a 1.4M-line body. Worth its own change.
Checklist
bun run typecheck,bun run lint, and the cargo checks pass (see CONTRIBUTING.md)bun run test(9 newlineFoldstests),bun run check:sizes,cargo test --workspacecollect_commands!andbun run codegenwas runBodyWindowgained a field