Skip to content

fix(jsonview): use terminal rows for startup preload - #165

Closed
markstuart-oai wants to merge 1 commit into
mainfrom
markstuart-oai/c16-explorer-preload-rows
Closed

fix(jsonview): use terminal rows for startup preload#165
markstuart-oai wants to merge 1 commit into
mainfrom
markstuart-oai/c16-explorer-preload-rows

Conversation

@markstuart-oai

Copy link
Copy Markdown
Contributor

Problem and change

The interactive explorer assigns the first term.GetSize result (columns) to its startup preload count. With 24 rows, widening a terminal from 40 to 80 columns therefore increases initial consumption from 40 to 80 items, and can reach an iterator error before the UI appears.

Use the second result (rows) for initial prefetch. Both widths now preload 24 items; a 36-row terminal preloads 36. The existing fallback of 20 on terminal-size errors remains. This does not impose a total item limit: existing lazy loading continues beyond the initial batch. RawJSON handling, retained rows, navigation, and iterator error behavior are unchanged.

Add a Linux PTY regression through ExploreJSONStream for asymmetric dimensions and nonterminal fallback. The test stops at the existing post-preload error check before starting the UI.

Validation

  • New regression failed against unchanged production code (expected 24/24/36, got 40/80/40), then passed after the tuple correction; fallback 20 passed both times.
  • Seven external synthetic Linux PTY runs exercised actual UI startup/quit, both widths at 24 and 36 rows, an item-49 error boundary, and lazy navigation from item 24 through 26. No live API was used.
  • Passed: go test -mod=readonly ./internal/jsonview -count=1, go test -mod=readonly -race ./internal/jsonview -count=1, go test -mod=readonly ./internal/..., go test -mod=readonly ./... -run '^$', go mod verify, and GOFLAGS=-mod=readonly ./scripts/lint (build only).
  • Passed Windows amd64 all-package test cross-compilation and Darwin arm64 jsonview test cross-compilation. These are compile checks, not platform runtime execution; the new PTY regression is Linux-only.
  • After advancing the base to current main, the complete two-file patch remained byte-identical; internal tests and root compile-only checks passed again.
  • Not run locally: the full ./scripts/test mock suite. Verified pinned Steady/Deno setup could not download the JSR manifest in this environment. No network/security protection was bypassed. No native Mac test run is claimed; full mock validation remains for CI.

@markstuart-oai
markstuart-oai requested a review from a team as a code owner September 8, 2026 01:17
Copilot AI lite review requested due to automatic review settings September 8, 2026 01:17
@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-08T01:18:15.587652Z 01fa9c5 PR opened
🔒 Security Review Completed 2026-09-08T01:19:33.758582Z 01fa9c5 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 094a4ab96e8001fa9c580e39. 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 34176149161 --repo openai/openai-cli \
  --name castiron-custom-code-34176149161-1 --dir /tmp/castiron-custom-code-34176149161-1
git apply --stat /tmp/castiron-custom-code-34176149161-1/custom-code.patch
cat /tmp/castiron-custom-code-34176149161-1/custom-code.patch

Or reproduce it from an SDK checkout containing the vendored reporter:

git fetch --no-tags origin 094a4ab96e80c2952c830ae36a9a9f009617e5ec 01fa9c580e39eaef5d9092c5a7cc8f564b55bbb4
python3 scripts/castiron/custom_code_report.py report \
  --base 094a4ab96e80c2952c830ae36a9a9f009617e5ec \
  --head 01fa9c580e39eaef5d9092c5a7cc8f564b55bbb4 --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-01fa9c580e39
cat /tmp/castiron-custom-code-01fa9c580e39/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 Linux preload test mutates global os.Stdout in a package with many t.Parallel() tests, which can introduce race/flakiness under concurrent test execution.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR fixes the JSON interactive explorer’s startup preload logic by using the terminal row count (height) instead of the column count (width), preventing terminal width changes from inadvertently increasing the initial number of prefetched items and triggering iterator errors before the UI starts.

Changes:

  • Correct term.GetSize tuple usage in ExploreJSONStream so the initial preload count is based on terminal rows.
  • Add a Linux-only PTY regression test covering asymmetric terminal dimensions and non-terminal fallback behavior.
File summaries
File Description
internal/jsonview/explorer.go Uses terminal height (rows) rather than width (columns) for initial preload sizing.
internal/jsonview/explorer_preload_linux_test.go Adds Linux PTY tests validating preload sizing by rows and verifying the non-terminal fallback path.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • 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 thread internal/jsonview/explorer_preload_linux_test.go
Comment thread internal/jsonview/explorer_preload_linux_test.go

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed exact head 01fa9c5. term.GetSize returns width then height, so using the second value correctly bounds startup preload by terminal rows. The asymmetric PTY cases cover width invariance, row changes, and non-terminal fallback. The tests do not call t.Parallel, so their temporary os.Stdout swap cannot overlap package parallel tests under Go test scheduling. go test -race ./internal/jsonview, gofmt, go vet, and diff checks pass; hosted CI is green.

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.

3 participants