feat(filters): add 'Has PR' task sidebar filter (#713)

Co-authored-by: Kandev Agent <agent@kandev.dev>
This commit is contained in:
João Salavisa
2026-04-27 18:28:40 +01:00
committed by GitHub
parent d961d1b430
commit 2a3df653f7
4 changed files with 30 additions and 0 deletions
@@ -52,6 +52,14 @@ export const DIMENSION_METAS: DimensionMeta[] = [
defaultOp: "is",
defaultValue: true,
},
{
dimension: "hasPR",
label: "Has PR",
valueKind: "boolean",
ops: ["is", "is_not"],
defaultOp: "is",
defaultValue: true,
},
{
dimension: "state",
label: "State",
+20
View File
@@ -21,6 +21,26 @@ describe("applyFilters — basics", () => {
});
});
describe("applyFilters — hasPR", () => {
it("filters by hasPR is true (task with linked PR)", () => {
const tasks = [task({ id: "a", prInfo: { number: 1, state: "Open" } }), task({ id: "b" })];
const out = applyFilters(tasks, [C({ dimension: "hasPR", op: "is", value: true })]);
expect(out.map((t) => t.id)).toEqual(["a"]);
});
it("filters by hasPR is false (task without linked PR)", () => {
const tasks = [task({ id: "a", prInfo: { number: 1, state: "Open" } }), task({ id: "b" })];
const out = applyFilters(tasks, [C({ dimension: "hasPR", op: "is", value: false })]);
expect(out.map((t) => t.id)).toEqual(["b"]);
});
it("supports is_not negation on hasPR", () => {
const tasks = [task({ id: "a", prInfo: { number: 1, state: "Open" } }), task({ id: "b" })];
const out = applyFilters(tasks, [C({ dimension: "hasPR", op: "is_not", value: true })]);
expect(out.map((t) => t.id)).toEqual(["b"]);
});
});
describe("applyFilters — per-dimension", () => {
it("filters by isPRReview is true (watcher-created task)", () => {
const tasks = [task({ id: "a", isPRReview: true }), task({ id: "b" })];
+1
View File
@@ -46,6 +46,7 @@ const dimensionExtractors: Record<FilterDimension, DimensionExtractor> = {
const ds = t.diffStats;
return !!ds && (ds.additions > 0 || ds.deletions > 0);
},
hasPR: (t) => !!t.prInfo,
isPRReview: (t) => t.isPRReview === true,
isIssueWatch: (t) => t.isIssueWatch === true,
titleMatch: (t) => t.title ?? "",
@@ -6,6 +6,7 @@ export type FilterDimension =
| "executorType"
| "repository"
| "hasDiff"
| "hasPR"
| "isPRReview"
| "isIssueWatch"
| "titleMatch";