Commit graph

30 commits

Author SHA1 Message Date
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
ea9dfae3bf Optimize session pull request hydration logic
Replaces linear search with a map for associating sessions with pull requests, improving performance and simplifying code in hydrateSessionPullRequests.
2025-08-29 14:23:43 -06:00
Kynan Ware
5281be467d Refactor error handling in generatePullRequestNodeID
Simplified error handling by inlining the encoder.Encode call and removing redundant comments for improved code clarity.
2025-08-29 14:20:12 -06:00
Kynan Ware
bc1d306c31 Update API query name for session PR fetch
Changed the API query from 'FetchPRs' to 'FetchPRsForAgentTaskSessions' in hydrateSessionPullRequests to match updated backend endpoint.
2025-08-29 14:18:45 -06:00
Kynan Ware
13c293f4cf Refactor variable names in ListSessionsForViewer
Renamed 'Sessions' to 'result' for clarity and consistency in the ListSessionsForViewer method when hydrating session pull requests.
2025-08-29 14:12:33 -06:00
Kynan Ware
48012063df Remove commented-out fields from sessionPullRequest
Cleaned up the sessionPullRequest struct by deleting unused commented-out fields related to Author and MergedBy.
2025-08-29 14:11:47 -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
Kynan Ware
b939188e6d Refactor agent task tests into table-driven format
Consolidates multiple individual test functions into a single table-driven test, improving maintainability and readability. This change makes it easier to add new test cases and ensures consistent test structure for agent task command authentication scenarios.
2025-08-27 17:20:45 -06:00
Kynan Ware
1bc2710c88 Refactor test to use require.Empty assertion
Replaces require.Equal with require.Empty in TestOAuthTokenAccepted for improved clarity when checking for empty output.
2025-08-27 17:07:35 -06:00
Kynan Ware
2128a297b3 Show help on agent-task command execution
Changed the RunE function of the agent-task command to display help output instead of returning nil, improving user guidance when the command is run without arguments.
2025-08-27 17:06:19 -06:00
Kynan Ware
3573f61b86 Add agent-task command with OAuth token validation
Introduces a new `agent-task` command under pkg/cmd/agent with strict OAuth (device flow) token validation. Includes comprehensive tests for token source and host validation, and registers the command in the root command set.
2025-08-27 12:23:01 -06:00