fix(output): apply transforms to interactive list items - #172
fix(output): apply transforms to interactive list items#172markstuart-oai wants to merge 1 commit into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Castiron custom code✅ No new custom-code files detected. 5 mixed files remain; 0 existing customizations changed. Compared 5 existing customizations unchanged
A changed generated baseline means this report cannot reliably identify which handwritten lines changed. Inspect the custom-code diffDownload the exact patch produced by this run (requires repository access): gh run download 34228781025 --repo openai/openai-cli \
--name castiron-custom-code-34228781025-1 --dir /tmp/castiron-custom-code-34228781025-1
git apply --stat /tmp/castiron-custom-code-34228781025-1/custom-code.patch
cat /tmp/castiron-custom-code-34228781025-1/custom-code.patchOr reproduce it from an SDK checkout containing the vendored reporter: git fetch --no-tags origin 265cf6378ab2e6a27c17bc7c0b6a6cbe6dbd477b 2a031a25ecbacd001731013ed036371b116f6110
python3 scripts/castiron/custom_code_report.py report \
--base 265cf6378ab2e6a27c17bc7c0b6a6cbe6dbd477b \
--head 2a031a25ecbacd001731013ed036371b116f6110 --fetch --require-head-hash --public \
--out /tmp/castiron-custom-code-2a031a25ecba
cat /tmp/castiron-custom-code-2a031a25ecba/custom-code.patchThis is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR. |
There was a problem hiding this comment.
🟡 Changes recommended
The new transform path can retain large backing JSON strings in memory via substring slicing, and a small, safe fix is recommended before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Fixes interactive “explore” output so --transform is applied to each item in an iterator before it becomes explorer row data, ensuring printing, navigation, and raw-mode toggles operate on the projected value for both preloaded and lazily fetched rows.
Changes:
- Pass
opts.Transforminto the interactive explorer path for iterators. - Apply the GJSON transform once per item during both preload and lazy-load (including
RawJSON()items), with added regression tests. - Improve explorer table behavior for arrays of empty objects by falling back to the generic Items view when there are no object columns.
File summaries
| File | Description |
|---|---|
| pkg/cmd/cmdutil.go | Plumbs --transform into interactive explorer for iterator output. |
| internal/jsonview/explorer.go | Applies per-item projection for preload + lazy-load, stores transform on the view, and adjusts empty-object table handling. |
| internal/jsonview/explorer_transform_test.go | Adds focused regression coverage for transform correctness across values, lazy-loading, pending loads, and errors. |
| internal/jsonview/explorer_test.go | Updates existing tests for the new marshalItemsToJSONArray signature. |
| internal/jsonview/explorer_stream_test.go | Updates streaming explorer tests and ensures lazy-load behavior remains correct with the new marshaling path. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if transform != "" { | ||
| if result := gjson.Get(data, transform); result.Exists() { | ||
| data = result.Raw | ||
| } | ||
| } |
Problem and result
Interactive list output ignored
--transform: for example,files list --format explore --transform iddisplayed and printed whole file objects. Apply the existing GJSON projection once to each original item before it becomes explorer row data, for both initially loaded and subsequently fetched items. Printing, navigation, and raw-mode toggles now use the projected value.Preserve missing-path fallback, explicit null and other scalar/object/array values, SDK
RawJSON()fields, serialization errors, and lazy loading across pending UI transitions. Empty-object rows use the existing generic Items presentation when there are no object columns, keeping later values visible. Existing formats, raw response handling, dependencies, generated commands, and pagination limits are unchanged.Validation
go test ./internal/...,go test ./... -run '^$',go mod verify,go vet ./pkg/cmd ./internal/jsonview, and./scripts/lint(build only). Terminal controls and 22 baseline/candidate nonterminal comparisons passed.The full local mock suite did not run: the supported Steady launcher returned
Missing or linked Steady cache. The denied setup route was not retried. Full hosted CI/mock validation remains required. All runtime probes used synthetic inputs; no live API calls, real credentials, or customer data were used. SDK CODEOWNER review remains required.