fix: gh pr/issue/run view drops flags when no identifier given#217
Open
shadowofdoom wants to merge 1 commit intortk-ai:masterfrom
Open
fix: gh pr/issue/run view drops flags when no identifier given#217shadowofdoom wants to merge 1 commit intortk-ai:masterfrom
shadowofdoom wants to merge 1 commit intortk-ai:masterfrom
Conversation
view_pr(), view_issue(), and view_run() all assumed args[0] is an identifier (PR number, issue number, run ID). When users omit the identifier (relying on gh's current-branch default), flags like --json get treated as the identifier, producing broken commands like `gh pr view --json --json fields...`. Replace narrow should_passthrough_run_view() with generic should_passthrough_gh_view() that detects: - First arg is a flag (no identifier given) - Any arg is --json, --log, or --log-failed (output incompatible with rtk's summary filter) Also removes run_passthrough_with_extra() in favor of reusing existing run_passthrough() with prepend_arg() helper. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
view_pr(),view_issue(), andview_run()all assumeargs[0]is an identifier (PR number, issue number, run ID). Butghallows callingviewwithout an identifier — it defaults to the current branch.When users run
gh pr view --json number,title,...(no PR number), the rtk-rewrite hook transforms it tortk gh pr view --json number,title,.... Thenview_pr()takes"--json"as the PR number and appends its own--jsonfields:Result:
Unknown JSON field: "--json"— gh interprets the double--jsonas a field name.Same pattern breaks:
gh pr view --json fields→Unknown JSON field: "--json"gh issue view --json fields→ same errorgh pr view 42 --json custom,fields→ rtk's hardcoded fields override user'sThis is a generalization of the
view_runfix from PR #159, which only handled--log-failed/--log/--jsonafter a run ID but not the no-identifier case.Fix
Replace the narrow
should_passthrough_run_view()with a genericshould_passthrough_gh_view()that detects:--json,--web, etc.) — no identifier given, gh will default to current branch--json,--log, or--log-failed— output incompatible with rtk's summary filterApplied to all three functions:
view_pr(),view_issue(),view_run().Also simplifies the passthrough plumbing: removes
run_passthrough_with_extra()in favor of reusing the existingrun_passthrough()with a smallprepend_arg()helper.Test plan
should_passthrough_gh_view():--jsonas first arg (no identifier) → passthrough--jsonafter identifier → passthrough--log-failedafter identifier → passthrough--logafter identifier → passthrough--webas first arg (no identifier) → passthroughcargo test)cargo fmtandcargo clippycleanrtk gh pr view --json number,titlereturns JSON (no error)rtk gh pr view 42 --json number,titlereturns user-requested JSON🤖 Generated with Claude Code