fix(term, cli): Give details views a declared JSON shape - #984
Merged
Conversation
A details view is rendered from a list of rows, each of which may or
may not carry a label. `details_json` keyed its object by that label,
so a row without one had no key to file its value under and was
emitted as `{"<value>": ""}` — the data ended up in the object's key
space, where a consumer has to parse it back out. `jp attachment ls`
listed URLs that way, and any listing built on the same renderer
would have too.
Deriving the shape from the rows instead is worse: it makes the
output depend on what an invocation happened to produce. A listing
holding one row would be an array and the same listing holding none
an object, so every consumer needs a fallback for every field.
The shape is now a property of the view rather than of its data.
`Details` is either `Fields`, a record of named rows that renders as
a JSON object, or `Items`, a sequence that renders as a JSON array.
A record cannot hold an unlabelled row and a listing cannot hold a
labelled one, so neither can drift into the other's shape, and an
empty view keeps its variant's form.
Conversation details are a record and read as they always did.
Attachment listings are a sequence and now emit an array of values.
BREAKING CHANGE: `jp attachment ls --format=json` emits an array
The `details` field of a listing was an object whose keys were the
listed values (`{"file:///x": ""}`) and is now an array of those
values (`["file:///x"]`). A consumer reading keys should read
elements instead. `jp conversation show` is unaffected: its rows are
all named, so `details` remains an object keyed by field name.
Signed-off-by: Jean Mertz <git@jeanmertz.com>
Signed-off-by: Jean Mertz <git@jeanmertz.com>
JeanMertz
force-pushed
the
json-formatting-tweaks
branch
from
August 15, 2026 11:10
8feeede to
3798797
Compare
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.
A details view is rendered from a list of rows, each of which may or may not carry a label.
details_jsonkeyed its object by that label, so a row without one had no key to file its value under and was emitted as{"<value>": ""}— the data ended up in the object's key space, where a consumer has to parse it back out.jp attachment lslisted URLs that way, and any listing built on the same renderer would have too.Deriving the shape from the rows instead is worse: it makes the output depend on what an invocation happened to produce. A listing holding one row would be an array and the same listing holding none an object, so every consumer needs a fallback for every field.
The shape is now a property of the view rather than of its data.
Detailsis eitherFields, a record of named rows that renders as a JSON object, orItems, a sequence that renders as a JSON array. A record cannot hold an unlabelled row and a listing cannot hold a labelled one, so neither can drift into the other's shape, and an empty view keeps its variant's form.Conversation details are a record and read as they always did. Attachment listings are a sequence and now emit an array of values.
BREAKING CHANGE:
jp attachment ls --format=jsonemits an arrayThe
detailsfield of a listing was an object whose keys were the listed values ({"file:///x": ""}) and is now an array of those values (["file:///x"]). A consumer reading keys should read elements instead.jp conversation showis unaffected: its rows are all named, sodetailsremains an object keyed by field name.