Skip to content

fix(project close): filter projects by open/closed state in interactive prompt#13247

Open
maxbeizer wants to merge 6 commits into
cli:trunkfrom
maxbeizer:fix/project-close-filter-closed
Open

fix(project close): filter projects by open/closed state in interactive prompt#13247
maxbeizer wants to merge 6 commits into
cli:trunkfrom
maxbeizer:fix/project-close-filter-closed

Conversation

@maxbeizer

@maxbeizer maxbeizer commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Summary

When running gh project close interactively (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 prompt
  • gh project close --undo: only shows closed projects in the selection prompt

Changes

  • Added an optional interactive filter to NewProject() in queries.go
  • Updated runClose to pass a filter based on opts.reopen
  • Kept behavior unchanged for all other NewProject() callers
  • Added tests covering interactive filtering behavior

Fixes #10895

…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>
@github-actions github-actions Bot added external pull request originating outside of the CLI core team needs-triage needs to be reviewed labels Apr 20, 2026
maxbeizer and others added 3 commits April 20, 2026 17:41
…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>
@github-actions github-actions Bot removed the needs-triage needs to be reviewed label May 11, 2026
@maxbeizer maxbeizer marked this pull request as ready for review May 26, 2026 15:10
Copilot AI review requested due to automatic review settings May 26, 2026 15:10
@maxbeizer maxbeizer requested a review from a team as a code owner May 26, 2026 15:10
@maxbeizer maxbeizer requested a review from BagToad May 26, 2026 15:10
@github-actions

Copy link
Copy Markdown

Thanks for your pull request! This is a large change (450 lines across 18 files) that doesn't reference a help wanted issue.

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
  1. Include a detailed description of what this PR does
  2. Link to an issue with the help wanted label (use Fixes #123 or Closes #123)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.NewProject with an optional filter func(*Project) bool used when prompting.
  • Update all NewProject call sites to pass nil (no filtering) except project close, which now filters based on close vs reopen.
  • Add unit tests to validate filtering behavior in both queries and project 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

Comment thread pkg/cmd/project/close/close_test.go

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}}}`).
Comment thread pkg/cmd/project/close/close_test.go Outdated
Comment thread pkg/cmd/project/close/close_test.go Outdated
Comment thread pkg/cmd/project/shared/queries/queries.go Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@maxbeizer

Copy link
Copy Markdown
Contributor Author

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 Fixes #10895).\n\nI don’t have permission to apply labels on upstream issues; I tried and got AddLabelsToLabelable permission error when attempting to add help wanted to #10895. If a maintainer is able to apply that label (or confirm this bugfix is acceptable without it), that should satisfy the unmet-requirements check.

@github-actions github-actions Bot closed this May 31, 2026
@maxbeizer

Copy link
Copy Markdown
Contributor Author

@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>
@maxbeizer

Copy link
Copy Markdown
Contributor Author

I pushed follow-up changes to the source branch after reviewing this closed PR. The branch now includes commit ee5d89a (Apply all project selection filters), but GitHub is still showing the closed PR pinned to the earlier head commit rather than reflecting the updated branch tip.

@BagToad BagToad reopened this May 31, 2026
@github-actions github-actions Bot added needs-triage needs to be reviewed and removed needs-triage needs to be reviewed labels May 31, 2026
@github-actions

This comment has been minimized.

@maxbeizer

Copy link
Copy Markdown
Contributor Author

thanks @BagToad ! Looks like it's going to get closed again with out a label applied to the issue tho 😭

@BagToad

BagToad commented May 31, 2026

Copy link
Copy Markdown
Member

@maxbeizer I removed the label. Should be good to go 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team ready-for-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gh project close should present users with a list of open projects, not all projects

4 participants