Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@babakks
Copy link
Member

@babakks babakks commented Sep 5, 2025

This PR adds support for PR number/URL/reference as an argument to agent-task view.

A/C verification (for PR arg support)

Happy paths

Given I have a PR with one session associated with it
When I run gh agent-task view 1234 --repo foo/bar
Then I see some metadata information about that session

Confirmed:
gh-agent-task-view-pr-num

Given I have a PR with more than one session associated with it
When I run gh agent-task view 1234 --repo foo/bar
Then I am prompted for a session to view, and
When I select a session in the list
Then I see some metadata about that session

Confirmed:
gh-agent-task-view-pr-select-session

gh-agent-task-view-pr-select-session-selected

Additional PR formats

Given I have a PR with one session associated with it
When I run gh agent-task view #1234 --repo foo/bar
Then I see some metadata information about that session

Confirmed:
gh-agent-task-view-pr-hash-num

Given I have a PR with one session associated with it
When I run gh agent-task view foo/bar#1234
Then I see some metadata information about that session

Confirmed:
gh-agent-task-view-pr-reference

Given I have a PR with one session associated with it
When I run gh agent-task view https://github.com/foo/bar/pull/1234
Then I see some metadata information about that session

Confirmed:
gh-agent-task-view-pr-url

Prompting requires a TTY

Given I am running without a TTY
When I run gh agent-task view 1234 --repo foo/bar
Then I receive an error message indicating that only session IDs are supported in non-interactive mode

Confirmed:
gh-agent-task-view-pr-nontty

Zero value paths

Given I have a PR with no sessions associated with it
When I run gh agent-task view #1234 --repo foo/bar
Then I see an error message about no sessions being found

Confirmed:
gh-agent-task-view-pr-no-session

Given I have no such PR
When I run gh agent-task view #1234 --repo foo/bar
Then I see an error message about no PR being found

Confirmed:
gh-agent-task-view-pr-not-found

A/C verification (for base repo detection)

Given my CWD is a repository and
Given I have one session for the PR
When I run gh agent-task view 1234
Then I see metadata for that session

Confirmed:
gh-agent-view-base-repo-pr-num

Given my CWD is a repository and
Given I have more than one session for the PR
When I run gh agent-task view 1234
Then I am prompted for a session to select and
When I select a session
Then I see metadata for that session

Confirmed:
gh-agent-view-base-repo-pr-select
gh-agent-view-base-repo-pr-selected

@babakks babakks requested a review from BagToad September 5, 2025 16:07

type ColorFunc func(string) string

func SessionSymbol(cs *iostreams.ColorScheme, state string) string {
Copy link
Member

@BagToad BagToad Sep 5, 2025

Choose a reason for hiding this comment

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

Idea; maybe this could be named IconForSessionState

Copy link
Member Author

Choose a reason for hiding this comment

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

The "symbol" is what is used with gh run commands, so I think we can just keep it. What do you think? I'm fine with either, though.

Copy link
Member

Choose a reason for hiding this comment

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

I guess it's fine then. I only commented because the internal color scheme funcs are named "icon". I don't feel strongly either.

Comment on lines +166 to +170
// TODO(babakks): currently we just fetch a pre-defined number of
// matching sessions to avoid hitting the API too many times, but it's
// technically possible for a PR to be associated with lots of sessions
// (i.e. above our selected limit).
sessions, err := capiClient.ListSessionsByResourceID(ctx, "pull", resourceID, defaultLimit)
Copy link
Member

Choose a reason for hiding this comment

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

I think 60 is quite high - we could probably lower it and still be fine. I think other prompting experience fetch 40 IIRC.

The prompter experience with more items in the list than fit on your terminal isn't great 🤔 at least on my terminal.

I think anything 40-60 like we have is going to be fine so long as we are sorting by most recent.


I was just about to say, if someone has many sessions, they can just run gh agent-task list instead and grab the session ID. But, then I remembered we were talking about dropping the session ID in favour of session name 🤔 If we remove the session ID, we kind of affect this "I have more sessions than what gh agent-task view will prompt but I only have the PR" use-case.

Perhaps this is something we need to think about more.

Copy link
Member

Choose a reason for hiding this comment

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

Another experience to think about is gh run view which has a View all jobs in this run option 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree with 40. Will fix. But for the name-vs-ID, yeah let's discuss.

@babakks babakks marked this pull request as ready for review September 9, 2025 11:14
@babakks babakks requested a review from a team as a code owner September 9, 2025 11:14
@babakks babakks removed the request for review from a team September 9, 2025 11:14
@babakks
Copy link
Member Author

babakks commented Sep 9, 2025

@BagToad, I applied the comments (also those from #11670), and it's ready to review again.

@babakks babakks requested review from BagToad and removed request for BagToad September 9, 2025 11:15
Base automatically changed from babakks/add-agent-task-view-cmd to github-cli-epic-990 September 9, 2025 11:17
Copy link
Member

@BagToad BagToad left a comment

Choose a reason for hiding this comment

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

Looks great! 🚀

@BagToad BagToad merged commit f9617d9 into github-cli-epic-990 Sep 9, 2025
7 of 8 checks passed
@BagToad BagToad deleted the babakks/add-pr-number-arg-support-to-view-cmd branch September 9, 2025 16:44
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.

3 participants