Skip to content

fix(cmd): honor item limits in the interactive explorer - #119

Open
edawite wants to merge 1 commit into
anthropics:mainfrom
edawite:codex/explorer-max-items
Open

edawite wants to merge 1 commit into
anthropics:mainfrom
edawite:codex/explorer-max-items

Conversation

@edawite

@edawite edawite commented Oct 18, 2026

Copy link
Copy Markdown

The default terminal explorer ignores --max-items: ShowJSONIterator passes the original iterator to ExploreJSONStream, which preloads and fetches beyond the requested count. The handlers already pass the correct budget, including the --limit fallback.

Wrap only the terminal explorer's iterator with a private lazy cap. It stops before calling the underlying Next() at the limit, leaves negative budgets unlimited, and passes the original items and errors through. No new public API or flags.

Validation on Windows, Go 1.27.2:

  • Built upstream 46211ed and the patched CLI. In an 80x24 ConPTY terminal against a local HTTP fixture serving ten one-item pages, models list --max-items 2 fetched/displayed all ten items before the fix and exactly two afterward. Both exited normally.
  • Zero budget displays no items and makes no additional page requests beyond the Go SDK's eager first-page fetch. Unlimited mode still fetches/displays all ten items.
  • Seven iterator budget cases plus error propagation pass. Existing output, transform and non-terminal fallback tests pass too.
  • go build ./..., Go formatting and git diff --check pass.
  • go test ./... -count=1 completed against the pinned local Steady mock: 685 top-level tests passed; four generated download cases failed because they write to /dev/null on Windows. Each failing command produces the same error on the pristine upstream binary. No tests were disabled or changed to hide these failures.

Related: #83 fixes the separate pager loop; #71 addresses other explorer behavior. Neither enforces the item budget in this terminal branch.

No live Claude API calls were made. Prepared with Codex assistance; the diff and terminal HTTP traces were reviewed.

@edawite
edawite requested a review from a team as a code owner October 18, 2026 20:18

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant