Commit graph

5685 commits

Author SHA1 Message Date
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
Babak K. Shandiz
08e4aa892e
test(cache delete): combine test cases for invalid/non-existent refs
Also note that the API never returns HTTP 422 for invalid refs.

Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-08-28 11:07:49 +01:00
Babak K. Shandiz
d1a404a060
test(cache delete): replace HTTP 204 with 200 to match API behaviour
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-08-28 11:06:58 +01:00
Babak K. Shandiz
02d50700b5
docs(cache delete): explain different API responses
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-08-28 11:05:28 +01:00
Babak K. Shandiz
d457a1bce0
test(cache delete): add test case for key arg and --all
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-08-28 10:12:19 +01:00
Babak K. Shandiz
2dd54ae921
refactor(cache delete): simplify error handling
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-08-28 10:08:04 +01:00
Babak K. Shandiz
842d3449b4
refactor(cache delete): simplify condition
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-08-28 10:02:03 +01: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
Lucas
926327ce6d
fix(cache): validate --ref flag usage with cache ID
* Ensure that the `--ref` flag cannot be used in conjunction with a cache ID.
* Update error handling to provide clear feedback when this condition is violated.
* Add tests to cover scenarios involving the `--ref` flag and cache ID.
2025-08-27 19:54:19 +02:00
Lucas
1a19918581
fix(cache): prevent using --ref flag with cache ID
* Added validation to ensure that the `--ref` flag cannot be used when a cache ID is provided.
* Updated error message to include the reference when a cache is not found with the specified `--ref`.
2025-08-27 19:38:01 +02:00
Lucas
5c292286cf
refactor(cache): extract cache ID parsing logic
* Replaced direct conversion of cache ID string to int with a dedicated `parseCacheID` function.
* Improved readability and maintainability of the `deleteCaches` function.
2025-08-27 19:37:39 +02:00
Lucas
047326fcb4
fix(cache): update error message for missing cache key with --ref flag
* Changed the error message from "--ref cannot be used without cache key/ID" to "must provide a cache key" for clarity.
* Updated corresponding test case to reflect the new error message.
2025-08-27 04:56:48 +02:00
Lucas
3ba82b58a9
chore(cache): improve help text for --ref flag in cache deletion
* Clarified the description of the `--ref` flag to specify its purpose more accurately.
* Ensures users understand that it narrows down deletion by cache key and ref.
2025-08-27 04:56:48 +02:00
Lucas
bfb1354e51
test(cache): add tests for --ref flag in cache deletion
* Implemented test cases for handling the `--ref` flag in cache deletion commands.
* Added validation for using `--ref` with cache key and ID.
* Ensured proper error messages are returned for invalid usage of `--ref`.
2025-08-27 04:56:48 +02:00
Lucas
aff2bfaa5c
feat(cache): add support for --ref flag in cache deletion
- Introduced `--ref` flag to narrow down cache deletion to a specific branch or PR reference.
- Updated command examples to include usage of `--ref`.
- Added validation to ensure `--ref` cannot be used with `--all` and must accompany a cache key/ID.
2025-08-27 04:56:46 +02:00
minxinyi
21b08bdd20
refactor: use slices.Equal to simplify code (#11364)
Signed-off-by: minxinyi <minxinyi6@outlook.com>
2025-08-26 15:29:19 -06:00
Kynan Ware
e1a1040f37
Merge branch 'trunk' into auth-status-json-output-8635 2025-08-25 10:00:43 -06:00
Andrey
4e1318eb2a
feat: gh auth Automatically copy one-time OAuth code to clipboard (#11518)
* feat: add ability to copy one-time OAuth code while authenticating

Signed-off-by: Andrey <andrekabatareika@gmail.com>

* fix(docs): wrong example for gh auth refresh

* chore(authflow): update message to include one-time code to it

Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>

* chore(authflow): improve message when copied one-time code

Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>

* chore(authflow): don't early return error when could not copy OAuth code

Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>

* refactor(authflow): make code for working with OAuth code more readable

* Adjust language in `gh auth` help for clipboard

---------

Signed-off-by: Andrey <andrekabatareika@gmail.com>
Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>
2025-08-25 09:52:51 -06:00
Andrey
204536cdd0
docs(release create): difference --generate-notes and --notes-from-tag (#11534)
* docs(release create): distinguish difference between '--generate-notes' and '--notes-from-tag'

Signed-off-by: Andrey <andrekabatareika@gmail.com>

* Clarify release notes behavior for unannotated tags

Updated help text to specify that if a git tag is not annotated, the release notes will use the commit message instead of the tag annotation.

---------

Signed-off-by: Andrey <andrekabatareika@gmail.com>
Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>
2025-08-25 15:20:21 +00:00
Andrey
89512590ad
Add --force flag to gh run cancel (#11513)
* feat: add --force flag to run cancel command

Signed-off-by: Andrey <andrekabatareika@gmail.com>

* docs: use less prescriptive docs for --force flag

Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>

* chore: remove short flag

Signed-off-by: Andrey <andrekabatareika@gmail.com>

---------

Signed-off-by: Andrey <andrekabatareika@gmail.com>
Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>
2025-08-21 12:45:12 -06:00
Benjamin Levesque
78675e73e1
fix show token when using json 2025-08-20 21:01:31 +02:00
Benjamin Levesque
48bc79a291
fix exit code 2025-08-20 20:26:27 +02:00
Benjamin Levesque
085f31fed8
revert showToken change 2025-08-20 20:07:57 +02:00
Benjamin Levesque
c937e0275d
mutually exclusive flags 2025-08-20 20:02:41 +02:00
Benjamin Levesque
faa0e2c26b
flag duplicate check 2025-08-20 20:02:00 +02:00
Benjamin Levesque
6e6c09e6b1
add ExpectCommandToSupportJSONFields 2025-08-20 19:36:09 +02:00
Copilot
5eddf8d523
Merge pull request #11536 from cli/copilot/fix-11535
Fix `gh repo delete --yes` safety issue when no repository argument provided
2025-08-20 11:03:44 -06:00
Benjamin Levesque
3d02e248c0
do not export authState 2025-08-20 17:50:29 +02:00
Benjamin Levesque
96755eec83
handle -t conflict 2025-08-20 09:05:20 +02:00
Benjamin Levesque
3ffe199ef3
do not fetch scope if not necessary 2025-08-20 01:04:09 +02:00
Benjamin Levesque
8b553d66cc
json flags 2025-08-20 00:27:31 +02:00