Skip to content

fix(output): apply transforms to interactive list items - #172

Open
markstuart-oai wants to merge 1 commit into
mainfrom
markstuart-oai/c23-explorer-transform
Open

fix(output): apply transforms to interactive list items#172
markstuart-oai wants to merge 1 commit into
mainfrom
markstuart-oai/c23-explorer-transform

Conversation

@markstuart-oai

Copy link
Copy Markdown
Contributor

Problem and result

Interactive list output ignored --transform: for example, files list --format explore --transform id displayed 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

  • Reproduced on clean main and verified the fix with the normal CLI against a synthetic localhost two-page server in a real PTY, including a genuinely lazy second-page row, printing, toggles, and nested navigation. Separate production-output helper instrumentation verified iterator call counts without eager consumption.
  • Regression tests cover once-only projection, missing versus explicit values, unknown SDK fields, marshal/upstream errors, initial and lazy rows, pending loads, terminal sanitization, and empty-object rows followed by other values.
  • Passed focused tests and race tests, 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.
  • All-package Windows test cross-compilation passed; native Windows execution was not performed. Local runtime was Go 1.27.0; the module minimum remains Go 1.25.0.
  • Trusted-main custom-code budget check passed against the actual committed candidate: 495/1000 lines, with no budget or generation-policy changes.

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.

@markstuart-oai
markstuart-oai requested a review from a team as a code owner September 8, 2026 12:54
Copilot AI lite review requested due to automatic review settings September 8, 2026 12:54
@markstuart-oai markstuart-oai added the autoimprove Scoped automated improvement label Sep 8, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-08T12:57:27.579288Z 2a031a2 PR opened
🔒 Security Review Completed 2026-09-08T13:01:04.892224Z 2a031a2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Castiron custom code

✅ No new custom-code files detected.

5 mixed files remain; 0 existing customizations changed.

Compared 265cf6378ab22a031a25ecba. Generated baselines verified.

5 existing customizations unchanged
  • pkg/cmd/adminorganizationcertificate.go
  • pkg/cmd/cmd.go
  • scripts/castiron/README.md
  • scripts/castiron/custom_code_report.py
  • scripts/castiron/test_custom_code_report.py

A changed generated baseline means this report cannot reliably identify which handwritten lines changed.

Inspect the custom-code diff

Download 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.patch

Or 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.patch

This is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR.

Full report and patch

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.Transform into 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.

Comment on lines +372 to +376
if transform != "" {
if result := gjson.Get(data, transform); result.Exists() {
data = result.Raw
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autoimprove Scoped automated improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants