gh pr edit: new interactive prompt for assignee selection, performance and accessibility improvements#12526
gh pr edit: new interactive prompt for assignee selection, performance and accessibility improvements#12526BagToad merged 23 commits intotrunkcli/cli:trunkfrom github-cli-1070-multi-select-with-search-ccrcli/cli:github-cli-1070-multi-select-with-search-ccrCopy head branch name to clipboard
gh pr edit: new interactive prompt for assignee selection, performance and accessibility improvements#12526Conversation
25ce0f4 to
2a50965
Compare
gh pr editgh pr edit with assignees
Updated the Prompt interface in survey.go to include parameter names for all methods, improving code readability and clarity.
Initial implementation of MultiSelectWithSearch: - Implement by survey and accessible prompters. They use the same internal func under the hood. - Implement in `gh preview prompter` for initial testing and demonstration - Implement interface changes across the codebase and mocks to satisfy compiler. - Implement tests for new MultiSelectWithSearch prompter
Introduces SuggestedAssignableActors API query and wires up a dynamic assignee search function in the PR edit command. Updates Editable and EditPrompter interfaces to support search-based multi-select for assignees, improving the user experience when assigning users to pull requests.
The assigneeSearchFunc now receives the editable struct to update its Metadata.AssignableActors field with suggested assignable actors. This change ensures that the editable struct has the necessary actor metadata for later PR updates.
Added a comment explaining how to enable logging in expect-based tests by using expect.WithLogger. This helps developers debug by printing characters read to stdout.
Refactored the MultiSelectWithSearch function and related interfaces to use a MultiSelectSearchResult struct instead of multiple return values. This change improves clarity and extensibility of the search function signature, and updates all usages, mocks, and tests accordingly.
Updated test mocks and logic to consistently use lowercase 'monalisa' for login names and display names for user assignees. Improved handling of dynamic assignee fetching in interactive flows by relying on searchFunc and metadata population, and clarified logic in FetchOptions to fetch assignees only when necessary. These changes ensure more accurate simulation of interactive assignment and better test coverage for actor assignee features.
Updated the TODO comment to specify wiring up the reviewer search function if or when it exists, providing clearer intent for future development.
Co-authored-by: Babak K. Shandiz <babakks@github.com>
Co-authored-by: Babak K. Shandiz <babakks@github.com>
Simplifies SuggestedAssignableActors by no longer including the viewer in the returned actors list when the query is blank. Removes related logic and variables for viewer handling.
Refactored the construction of the variables map by directly assigning the 'query' key, removing the conditional logic for nil assignment.
Added detailed comments to the assigneeSearchFunc explaining its purpose and the importance of updating assignable actors metadata for later ID resolution when mutating assignees with the GraphQL API.
f3c2378 to
e3a3a01
Compare
gh pr edit with assigneesgh pr edit with assignees
gh pr edit with assigneesgh pr edit: new interactive prompt for assignee selection, performance and accessibility improvements
Deleted the Viewer struct from the responseData type in SuggestedAssignableActors as it was not being used.
Introduces a test case to verify that the interactive edit flow on GitHub Enterprise Server uses the legacy assignee selection without search, ensuring correct behavior when editing pull request assignees.
Introduces a test case to verify that errors returned from the MultiSelectWithSearch search function are properly propagated to the caller.
Updated SuggestedAssignableActors to return the total count of available assignees in the repository. Modified assigneeSearchFunc to use this count to calculate and display the number of additional assignees beyond the current results.
There was a problem hiding this comment.
Pull request overview
Adds an interactive multi-select prompt with on-demand search for assignee selection in gh pr edit, aiming to avoid loading large org member lists upfront and to improve accessibility.
Changes:
- Introduces
MultiSelectWithSearchin the prompter layer (survey + accessible) and extends mocks/tests to support it. - Wires assignee search into
gh pr editwhenActorIsAssignableis available, plus a preview command to exercise the new prompt. - Adds a new GraphQL helper (
SuggestedAssignableActors) intended to back dynamic assignee search.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/cmd/preview/prompter/prompter.go | Adds a preview entry point for the new multi-select-with-search prompt. |
| pkg/cmd/pr/shared/survey.go | Extends shared survey prompt interface to include MultiSelectWithSearch. |
| pkg/cmd/pr/shared/editable.go | Adds assignee search hook to the editable model and uses MultiSelectWithSearch when available. |
| pkg/cmd/pr/edit/edit.go | Wires assignee search function into gh pr edit for Actor assignees and updates fetch behavior. |
| pkg/cmd/pr/edit/edit_test.go | Updates PR edit tests for the new Actor assignee flow and metadata handling. |
| pkg/cmd/issue/edit/edit_test.go | Updates issue edit test fixtures for actor login casing changes. |
| internal/prompter/prompter.go | Adds MultiSelectWithSearch implementation and supporting types. |
| internal/prompter/accessible_prompter_test.go | Adds accessible prompter tests covering the new search flow. |
| internal/prompter/test.go | Extends mock prompter helpers to stub MultiSelectWithSearch. |
| internal/prompter/prompter_mock.go | Extends generated mock to support MultiSelectWithSearch calls. |
| api/queries_pr.go | Adds SuggestedAssignableActors GraphQL query helper. |
Comments suppressed due to low confidence (2)
internal/prompter/prompter.go:394
- The search sentinel uses an empty-string key (
optionKeys = append(optionKeys, "")). IfdefaultValues,persistentValues, orsearchFuncresults ever contain an empty key, it will collide with the sentinel and can drop selections or create duplicates. Filter out empty keys (and/or use a reserved non-empty sentinel key).
// 1. Search sentinel.
optionKeys = append(optionKeys, "")
if moreResults > 0 {
optionLabels = append(optionLabels, fmt.Sprintf("Search (%d more)", moreResults))
} else {
pkg/cmd/pr/edit/edit.go:386
MoreResultsis set toavailableAssigneesCount(repo-wide assignable user total), butmultiSelectWithSearchdisplays this as "Search (%d more)", which implies “more results for this search”. Either compute an actual remaining-results count (if available) or adjust the label/semantics so the number isn’t misleading.
return prompter.MultiSelectSearchResult{
Keys: logins,
Labels: displayNames,
MoreResults: availableAssigneesCount,
Err: nil,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| searchResultKeys := searchResult.Keys | ||
| searchResultLabels := searchResult.Labels | ||
| moreResults := searchResult.MoreResults | ||
|
|
There was a problem hiding this comment.
multiSelectWithSearch indexes searchResultLabels[i] for each key without validating slice lengths. If a searchFunc returns mismatched Keys/Labels lengths, this will panic. Validate lengths and return a clear error (or use a slice of {Key, Label} pairs).
| if len(searchResultLabels) != len(searchResultKeys) { | |
| return nil, fmt.Errorf("failed to search: mismatched result lengths: %d keys, %d labels", len(searchResultKeys), len(searchResultLabels)) | |
| } |
There was a problem hiding this comment.
I think I'd rather see the panic error
Cleaned up obsolete TODO comments related to assignee and reviewer selection logic in the MetadataSurvey function.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Deleted a comment about the query variable being passed as null when empty, as it is no longer relevant or necessary.
Description
Implements multiselect with search for
gh pr editassignees, addressing performance and accessibility issues in large organizations. Part of larger work to improve the reviewer and assignee experience ingh.Key changes
MultiSelectWithSearchprompter: Adds a search sentinel option to multiselect lists, allowing dynamic fetching of assignees via API search rather than loading all org members upfrontSuggestedAssignableActorsAPI: New GraphQL query to fetch suggested actors for an assignable (Issue/PR) node with optional search filteringgh pr editassignee flow: Wires up the new prompter for interactive assignee selection whenActorIsAssignablefeature is detectedsurveyPrompterandaccessiblePrompterimplement the new method, with full test coveragemulti-select-with-searchtogh preview prompterfor testingNotes for reviewers
gh pr edit; reviewers will follow in a subsequent PR