Conversation
appendItem picked the row shape from the column count, so a streamed array
whose items share exactly one key appended `{id:"x"}` cells under a column
that already rendered bare values for the preloaded rows. Discriminate on
columnKeys, which only the array-of-objects constructor populates.
Author
|
Authorship note, for consistency with #208: an AI coding agent produced this change under the account owner's standing instruction for this repo, ran every command quoted above and read its output. No human reviewed the diff before it was opened. |
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.
Summary
In the interactive JSON explorer, a row that arrives through the lazy stream loader is rendered differently from the preloaded rows above it whenever the streamed objects share exactly one key: the preloaded rows show the bare value under the key's column, and every lazily loaded row shows
{key:"value"}instead.Problem
TableView.appendItemdecided whether a table is column-shaped by counting columns:newArrayOfObjectsTableViewbuilds one column per unique key, so a stream whose items all carry a single key gives a table with one column andcolumnKeys = ["id"]. That table is column-shaped, but the count check says otherwise, so the appended row falls through to the generic single-cell row and renders the whole object.Measured with the new test against
internal/jsonview/explorer.gofrom0169bff:and in raw mode
expected []string{"\"second\""}/actual []string{"{\"id\":\"second\"}"}.toggleRawre-renders the whole table throughnewArrayOfObjectsTableView, so after pressingrthe lazily loaded row snaps back to the bare value — the same cell changes content twice per keypress.Because the row is also the input to
updateColumnWidths, the{key:"value"}cell additionally drives the single column's width off the value widths the rest of the table was laid out for.Fix
columnKeysis populated only by the array-of-objects constructor, so it — not the column count — says whether a table is column-shaped. One line plus a comment explaining the invariant; a plain array (columnKeys == nil) keeps the singleItemscell rendering it already had.Where this is reachable
pkg/cmd/cmdutil.go:503hands an auto-paging iterator tojsonview.ExploreJSONStreamfor--format explore, and the lazy path activates once a collection has more items than the preload count. Every list endpoint I checked returns multi-key items, so on today's API this needs a collection whose items share a single key — I am not claiming a specific public command reproduces it, only that the two row-building paths disagree in the shipped code.#172 widens this: it projects each item through
--transformbefore it becomes row data, so a projection onto a one-key object lands exactly here. My change is in a different function and shares no lines with that diff, so either order merges cleanly.Tests
internal/jsonview/explorer_single_key_test.go, three cases:rowData(which is whatprint and navigation read);Itemscolumn, so the fix is not broader than the column-shaped case.Validation
go1.25.0 darwin/arm64, on top of
0169bff:main'sexplorer.gowith the output quoted above, and pass with the fix;go test ./internal/...— every package ok;go test -race -count=3 ./internal/jsonview— ok;go test ./... -run '^$',./scripts/lint,go vet ./internal/jsonview,gofmt -l internal/jsonview,go mod verify,go mod tidy -diff(no diff) — all clean.What I did not verify: I did not run
./scripts/testagainst the Steady mock server (it needs the pinned Deno source install), and I did not drive a real terminal session. The reproduction is atTableViewlevel, driven throughJSONViewer.Updatewith the sametea.KeyMsgthe explorer's key handling receives, so it covers the production path up to the TUI renderer.No generated files, dependencies, or budget/policy files change;
internal/jsonview/explorer.gois handwritten.