Commit graph

36 commits

Author SHA1 Message Date
Max Beizer
c5c107aa8b Polish --json support for agent-task list
- Fix empty results returning error instead of [] when --json is used
- Rename 'status' field to 'state' for consistency with struct and UI
- Add missing JSON fields: completedAt, user, pullRequestTitle, pullRequestState
- Add test for empty results with --json
- Add test for nil PullRequest with --json

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-01 09:08:18 -06:00
Max Beizer
0d9e6af3da Add --json support to gh agent-task list
Add --json, --jq, and --template flags to `gh agent-task list`,
consistent with the pattern used by `gh pr list --json`,
`gh issue list --json`, etc.

This implements the ExportData interface on capi.Session and defines
SessionFields for the available JSON fields:
id, name, status, repository, createdAt, updatedAt,
pullRequestNumber, pullRequestUrl.

Closes https://github.com/cli/cli/issues/12805 (partial)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-28 09:20:13 -06:00
Andy Feller
e85877dd75 Remove extra flag default from help usage
Fixes #12153
2025-11-17 10:09:17 -05:00
Babak K. Shandiz
4a0c32ef9f
fix(agent-task list): show capitalised session state
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-18 12:34:27 +01:00
Babak K. Shandiz
7d163eaf27
docs(agent-task list): add "(preview)" note to cmd docs
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-18 12:20:34 +01:00
Babak K. Shandiz
5f73d3b438
refactor(agent-task list): remove unused BaseRepo from ListOptions
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-18 12:00:54 +01:00
Kynan Ware
680ebade59
Remove repo-scoped session listing and related code
This commit removes support for listing agent sessions scoped to a specific repository, including the ListSessionsForRepo method and related tests. The list command now always lists the latest sessions for the viewer, simplifying the code and user experience. Test and mock code have been updated accordingly.
2025-09-18 12:00:50 +01:00
Babak K. Shandiz
ab7e4039da
refactor: move Copilot Agents home URL to capi
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-10 11:05:28 +01:00
Kynan Ware
bbf7586578 Show session name instead of ID in agent-task list
Updated the agent-task list command to display the session name instead of the session ID in the table output and header. Adjusted tests to reflect this change by using the Name field for display and updating expected outputs accordingly.
2025-09-09 11:06:53 -06:00
Babak K. Shandiz
476b636810
test(agent-task list): remove unused stubs
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-05 12:44:22 +01:00
Babak K. Shandiz
7824b43f8a
refactor(agent-task list): simplify cmd initialisation
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-04 21:06:38 +01:00
Babak K. Shandiz
3762d97894
test(agent-task list): apply test args anyway
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-04 20:12:57 +01:00
Babak K. Shandiz
c708e58f69
test(agent-task list): use CapiClientMock
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-04 20:12:57 +01:00
Babak K. Shandiz
27d9a0d5fc
test(agent-task list): update TestNewCmdList
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-04 20:12:57 +01:00
Babak K. Shandiz
f3c3797d5c
refactor(agent-task list): use shared CapiClientFunc
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-04 20:12:53 +01:00
Kynan Ware
2a99dcd2ce Add pager support to agent-task list output
Introduces pager functionality to the agent-task list command output for improved readability. If the pager fails to start, an error message is printed to stderr. Aligns with implementations in other commands.
2025-09-02 17:13:43 -06:00
Kynan Ware
c5f7be9adb Replace panic with require.FailNow in test
Updated the test to use require.FailNow instead of panic when CapiClient is called with --web, improving test failure reporting and consistency.
2025-09-02 13:14:37 -06:00
Kynan Ware
c4c0ddc8c2 Add test for web mode with repo flag in listRun
Added a test case to ensure that web mode in listRun uses the global URL even when the --repo flag is set. This improves coverage for scenarios where both web mode and repo are specified.
2025-09-02 13:13:35 -06:00
Kynan Ware
93f7e9847f Add comment on web dashboard filtering limitation
Added a comment explaining that the web GUI does not currently support filtering by repo, so the agents dashboard is opened without arguments. Notes future improvement if repo filtering becomes available.
2025-09-02 13:11:10 -06:00
Kynan Ware
51aa033b2e Add test case for negative limit in list command
Introduces a test to verify that passing a negative value to the --limit flag in the agent-task list command returns the expected error message.
2025-09-02 13:09:12 -06:00
Kynan Ware
163eb7e7c8 Return NoResultsError when no agent tasks found
Replaces plain output with a NoResultsError in listRun when no agent tasks are found. Updates related tests to expect the error instead of output, improving error handling consistency.
2025-09-02 13:04:27 -06:00
Kynan Ware
227f0bd01d Add comment explaining error handling in listRun
Added a comment to clarify why the error from opts.BaseRepo() is ignored in listRun. This provides context for handling cases when the current working directory is not a repo and --repo is not set.
2025-09-02 12:55:03 -06:00
Kynan Ware
4a07cdf940 Simplify time calculation in listRun test
Replaces explicit duration parsing with direct multiplication for calculating a timestamp 6 hours ago in Test_listRun, improving code clarity.
2025-09-02 12:52:52 -06:00
Kynan Ware
97da7fc1d2 Simplify BaseRepo assignment in list command
Removes unnecessary nil check for Factory before assigning BaseRepo in the agent-task list command. This streamlines the code since Factory is always expected to be non-nil.
2025-09-02 12:50:15 -06:00
Kynan Ware
61c8b5ef09
Merge branch 'kw/1003-gh-agent-task-list-respects--l--limit' into kw/1004-gh-agent-task-list-respects--w--web 2025-08-29 19:14:52 -06:00
Kynan Ware
ffc8792260
Merge branch 'kw/1002-gh-agent-task-list-respects-cwd-repo-and---repo-flag' into kw/1003-gh-agent-task-list-respects--l--limit 2025-08-29 19:14:37 -06:00
Kynan Ware
3197193e42 Handle repo resolution errors gracefully in agent-task list
Updated listRun to ignore errors from BaseRepo resolution and proceed when possible. Adjusted tests to reflect that repo resolution errors no longer surface, improving robustness when repo information is ambiguous.
2025-08-29 19:13:35 -06:00
Kynan Ware
a2d75d12f6 Add --web flag to agent-task list command
Introduces a --web flag to the agent-task list command, allowing users to open the agent tasks page in their browser. Updates tests to cover the new flag and browser interaction.
2025-08-29 18:21:47 -06:00
Kynan Ware
83c597ff53 Show default limit in agent-task list flag help
Updates the help text for the --limit flag in the agent-task list command to display the default value, improving clarity for users.
2025-08-29 17:56:04 -06:00
Kynan Ware
a49994defa Add limit flag to agent-task list command
Introduces a --limit flag to control the maximum number of agent tasks fetched. Validates that the limit is greater than zero and updates tests to cover custom and invalid limit scenarios.
2025-08-29 17:52:27 -06:00
Kynan Ware
e750e71288 Add repo-scoped agent session listing support
Introduces ListSessionsForRepo to CapiClient and CAPIClient, enabling listing agent sessions for a specific repository. Updates the list command and tests to support repo override and repo-scoped session queries, including error handling and test coverage for repo resolution.
2025-08-29 17:27:04 -06:00
Kynan Ware
4fd6ae6e3a Refactor session state color logic to shared package
Moved the session state color selection logic from list.go to a new shared/display.go file as ColorFuncForSessionState. This improves code reuse and maintainability by centralizing the color mapping for session states.
2025-08-29 15:23:40 -06:00
Kynan Ware
7b71b5f21b Refactor agent-task list command client initialization
Moves CAPI client initialization to a deferred function in ListOptions, simplifying command setup and improving testability. Updates tests to use the new client initialization pattern and adds more comprehensive test cases for session listing.
2025-08-29 14:09:45 -06:00
Kynan Ware
0a5b78a510 Refactor session filtering in listRun function
Simplifies logic for filtering sessions to only include those with valid pull request and repository data. This reduces nested conditionals and improves code readability.
2025-08-29 08:25:00 -06:00
Kynan Ware
0de5cf24f0 Fix import alias for shared package in agent-task list
Renames the import of the shared package to 'prShared' and updates its usage in list.go to avoid naming conflicts and improve code clarity.
2025-08-29 08:19:37 -06:00
Kynan Ware
dd424d85fd Add agent task listing command and CAPI client
Introduces a new 'list' subcommand under agent-task for listing agent tasks. Implements a Copilot API client for fetching agent sessions and hydrating them with pull request data. Updates PullRequest and PRRepository types to support new fields. Adds dependencies for msgpack and tagparser.

Co-Authored-By: Babak K. Shandiz <babakks@github.com>
2025-08-28 22:00:35 -06:00