From c0bf0eec2aaee9822129f3b39ba3b3aaca1d6720 Mon Sep 17 00:00:00 2001 From: Peter Schilling Date: Tue, 17 Mar 2026 16:57:50 -0700 Subject: [PATCH 1/2] feat: add --label filter to issue list --- src/commands/issue/issue-list.ts | 11 +++ src/utils/linear.ts | 13 ++++ .../__snapshots__/issue-link.test.ts.snap | 16 ----- .../__snapshots__/issue-list.test.ts.snap | 10 +++ test/commands/issue/issue-list.test.ts | 67 ++++++++++++++++++- 5 files changed, 100 insertions(+), 17 deletions(-) diff --git a/src/commands/issue/issue-list.ts b/src/commands/issue/issue-list.ts index 1b31cf3f..6688826e 100644 --- a/src/commands/issue/issue-list.ts +++ b/src/commands/issue/issue-list.ts @@ -94,6 +94,11 @@ export const listCommand = new Command() "--milestone ", "Filter by project milestone name (requires --project)", ) + .option( + "-l, --label ", + "Filter by label name (can be repeated for multiple labels)", + { collect: true }, + ) .option( "--limit ", "Maximum number of issues to fetch (default: 50, use 0 for unlimited)", @@ -120,6 +125,7 @@ export const listCommand = new Command() projectLabel, cycle, milestone, + label: labels, limit, pager, }, @@ -229,6 +235,10 @@ export const listCommand = new Command() milestoneId = await getMilestoneIdByName(milestone, projectId) } + const labelNames = labels && labels.length > 0 + ? labels.flat() + : undefined + const { Spinner } = await import("@std/cli/unstable-spinner") const showSpinner = shouldShowSpinner() const spinner = showSpinner ? new Spinner() : null @@ -246,6 +256,7 @@ export const listCommand = new Command() cycleId, milestoneId, projectLabel, + labelNames, ) spinner?.stop() const issues = result.issues?.nodes || [] diff --git a/src/utils/linear.ts b/src/utils/linear.ts index a93b2610..dffa846e 100644 --- a/src/utils/linear.ts +++ b/src/utils/linear.ts @@ -423,6 +423,7 @@ export async function fetchIssuesForState( cycleId?: string, milestoneId?: string, projectLabel?: string, + labelNames?: string[], ) { const sort = sortParam ?? getOption("issue_sort") as "manual" | "priority" | undefined @@ -472,6 +473,18 @@ export async function fetchIssuesForState( filter.projectMilestone = { id: { eq: milestoneId } } } + if (labelNames && labelNames.length > 0) { + if (labelNames.length === 1) { + filter.labels = { some: { name: { eqIgnoreCase: labelNames[0] } } } + } else { + filter.labels = { + and: labelNames.map((name) => ({ + some: { name: { eqIgnoreCase: name } }, + })), + } + } + } + const query = gql(/* GraphQL */ ` query GetIssuesForState($sort: [IssueSortInput!], $filter: IssueFilter!, $first: Int, $after: String) { issues(filter: $filter, sort: $sort, first: $first, after: $after) { diff --git a/test/commands/issue/__snapshots__/issue-link.test.ts.snap b/test/commands/issue/__snapshots__/issue-link.test.ts.snap index 96b772ff..45a57a97 100644 --- a/test/commands/issue/__snapshots__/issue-link.test.ts.snap +++ b/test/commands/issue/__snapshots__/issue-link.test.ts.snap @@ -25,22 +25,6 @@ stderr: "" `; -snapshot[`Issue Link Command - link URL to issue 1`] = ` -stdout: -"✓ Linked to ENG-123: org/repo#42 -" -stderr: -"" -`; - -snapshot[`Issue Link Command - link URL with custom title 1`] = ` -stdout: -"✓ Linked to ENG-456: Design document -" -stderr: -"" -`; - snapshot[`Issue Link Command - invalid URL shows error 1`] = ` stdout: "" diff --git a/test/commands/issue/__snapshots__/issue-list.test.ts.snap b/test/commands/issue/__snapshots__/issue-list.test.ts.snap index d971ea8c..aa7ca0fa 100644 --- a/test/commands/issue/__snapshots__/issue-list.test.ts.snap +++ b/test/commands/issue/__snapshots__/issue-list.test.ts.snap @@ -24,6 +24,7 @@ Options: --project-label - Filter by project label name (shows issues from all projects with this label) --cycle - Filter by cycle name, number, or 'active' --milestone - Filter by project milestone name (requires --project) + -l, --label