fix(project close): filter projects by open/closed state in interactive prompt#13247
fix(project close): filter projects by open/closed state in interactive prompt#13247maxbeizer wants to merge 6 commits into
Conversation
…ve prompt When running `gh project close` interactively (without --number), only show open projects in the selection list. When running with --undo (reopen), only show closed projects. This prevents user confusion from being shown projects in the wrong state. Adds a filter parameter to NewProject() so callers can pass an optional predicate to restrict which projects appear in the interactive prompt. All other callers pass nil (no filtering, preserving existing behavior). Fixes cli#10895 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…e` command When running `gh project close` interactively (no project number given), the selection prompt showed all projects regardless of whether they were already closed. Similarly, `gh project close --undo` showed all projects including ones that were already open. Add an optional filter predicate to NewProject() that is applied when building the interactive prompt list. The close command passes a filter that selects only open projects when closing (reopen=false) and only closed projects when reopening (reopen=true). All other callers pass nil, preserving existing behavior. Fixes cli#10895 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When a user has projects but none match the filter (e.g., all projects are already closed when trying to close), return a distinct 'no matching projects found' message instead of the generic 'no projects found' message. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Thanks for your pull request! This is a large change (450 lines across 18 files) that doesn't reference a Large feature PRs require prior discussion in an issue before implementation — this helps the team assess whether the feature aligns with the project's direction before significant effort is invested. Please open an issue to discuss this feature first. This PR will be automatically closed in 2 days if requirements are not met. Full contribution requirements
|
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds an optional project filter to NewProject so interactive selection can be constrained (e.g., only open vs only closed projects), and updates commands/tests to use the new signature.
Changes:
- Extend
Client.NewProjectwith an optionalfilter func(*Project) boolused when prompting. - Update all
NewProjectcall sites to passnil(no filtering) exceptproject close, which now filters based on close vs reopen. - Add unit tests to validate filtering behavior in both
queriesandproject close.
Show a summary per file
| File | Description |
|---|---|
| pkg/cmd/project/shared/queries/queries.go | Adds filter parameter and applies it to interactive project selection. |
| pkg/cmd/project/shared/queries/queries_test.go | Updates signature usage and adds tests for open-only / closed-only / no-filter prompting. |
| pkg/cmd/project/close/close.go | Uses filter to show only open projects when closing and only closed projects when reopening. |
| pkg/cmd/project/close/close_test.go | Adds prompt-level tests asserting filtered options for close vs reopen flows. |
| pkg/cmd/project/view/view.go | Updates NewProject call to include nil filter. |
| pkg/cmd/project/unlink/unlink.go | Updates NewProject call to include nil filter. |
| pkg/cmd/project/mark-template/mark_template.go | Updates NewProject call to include nil filter. |
| pkg/cmd/project/link/link.go | Updates NewProject call to include nil filter. |
| pkg/cmd/project/item-list/item_list.go | Updates NewProject call to include nil filter. |
| pkg/cmd/project/item-delete/item_delete.go | Updates NewProject call to include nil filter. |
| pkg/cmd/project/item-create/item_create.go | Updates NewProject call to include nil filter. |
| pkg/cmd/project/item-archive/item_archive.go | Updates NewProject call to include nil filter. |
| pkg/cmd/project/item-add/item_add.go | Updates NewProject call to include nil filter. |
| pkg/cmd/project/field-list/field_list.go | Updates NewProject call to include nil filter. |
| pkg/cmd/project/field-create/field_create.go | Updates NewProject call to include nil filter. |
| pkg/cmd/project/edit/edit.go | Updates NewProject call to include nil filter. |
| pkg/cmd/project/delete/delete.go | Updates NewProject call to include nil filter. |
| pkg/cmd/project/copy/copy.go | Updates NewProject call to include nil filter. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 18/18 changed files
- Comments generated: 5
|
|
||
| gock.New("https://api.github.com"). | ||
| Post("/graphql"). | ||
| BodyString(`{"query":"mutation CloseProjectV2.*"variables":{"afterFields":null,"afterItems":null,"firstFields":0,"firstItems":0,"input":{"projectId":"closed-project-ID","closed":false}}}`). |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Thanks for the nudge. I pushed commit d5607a1 to reduce PR surface area significantly (now 4 files touched, no cross-command call-site churn). This is a bug fix for #10895 (already linked with |
|
@BagToad may I submit this for re-opening/review when y'all have a moment please? |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
I pushed follow-up changes to the source branch after reviewing this closed PR. The branch now includes commit ee5d89a ( |
This comment has been minimized.
This comment has been minimized.
|
thanks @BagToad ! Looks like it's going to get closed again with out a label applied to the issue tho 😭 |
|
@maxbeizer I removed the label. Should be good to go 👍 |
Summary
When running
gh project closeinteractively (without specifying--number), users are currently shown all projects regardless of their open/closed state. This is confusing - when closing a project you'd see already-closed projects, and when reopening (--undo) you'd see already-open ones.This PR adds a filter predicate to
NewProject()so that:gh project close(no flags): only shows open projects in the selection promptgh project close --undo: only shows closed projects in the selection promptChanges
NewProject()inqueries.gorunCloseto pass a filter based onopts.reopenNewProject()callersFixes #10895