fix(cli): single-key note rows render as raw indented lines under their step (Task 14 review)

This commit is contained in:
Joseph Doherty
2026-09-09 12:15:05 -04:00
parent c6529fa996
commit c1b1702397
5 changed files with 159 additions and 17 deletions
@@ -255,6 +255,20 @@ internal static class CommandHelpers
// element, in first-seen order. Using only items[0] would silently drop
// columns for any later element with a different shape.
var objectItems = items.Where(i => i.ValueKind == JsonValueKind.Object).ToList();
// A "note" property that appears ONLY on single-property rows (a trailing
// run-level note, or — Task 14 review, 2026-09-09 — a step's folded log/exception
// line) is not a real column: every other row's cell there would render blank,
// and column padding would swallow the raw line's own leading indentation. Such
// rows print as a raw unpadded line instead, at their position in the sequence,
// and "note" is excluded from the header union so nothing renders a blank column
// for it.
var noteOnlyRows = objectItems
.Where(i => i.EnumerateObject().Any(p => p.Name == "note"))
.ToList();
var noteIsRawLine = noteOnlyRows.Count > 0
&& noteOnlyRows.All(i => i.EnumerateObject().Count() == 1);
string[] headers;
if (objectItems.Count > 0)
{
@@ -262,8 +276,12 @@ internal static class CommandHelpers
var known = new HashSet<string>(StringComparer.Ordinal);
foreach (var item in objectItems)
foreach (var prop in item.EnumerateObject())
{
if (noteIsRawLine && prop.Name == "note")
continue;
if (known.Add(prop.Name))
seen.Add(prop.Name);
}
headers = seen.ToArray();
}
else
@@ -275,12 +293,20 @@ internal static class CommandHelpers
{
if (item.ValueKind == JsonValueKind.Object)
{
return headers.Select(h =>
if (noteIsRawLine
&& item.EnumerateObject().Count() == 1
&& item.TryGetProperty("note", out var noteValue))
{
return OutputFormatter.TableRow.Raw(
noteValue.ValueKind == JsonValueKind.Null ? "" : noteValue.ToString());
}
return OutputFormatter.TableRow.Columns(headers.Select(h =>
item.TryGetProperty(h, out var val)
? val.ValueKind == JsonValueKind.Null ? "" : val.ToString()
: "").ToArray();
: "").ToArray());
}
return new[] { item.ToString() };
return OutputFormatter.TableRow.Columns(new[] { item.ToString() });
});
OutputFormatter.WriteTable(rows, headers);