feat(mobile): filter inbox reports by priority (port #2176)#2497
feat(mobile): filter inbox reports by priority (port #2176)#2497Gilbert09 wants to merge 2 commits into
Conversation
Ports the desktop "filter inbox signal reports by priority" feature to the mobile app. - Add `priorityFilter` (P0–P4) state to the inbox filter store, with `togglePriority` / `setPriorityFilter` actions; persisted and cleared on reset, mirroring the existing status/source/reviewer filters. - Add a `buildPriorityFilterParam` helper that returns a deduped comma-separated string, or `undefined` when empty. - Pass the selected priorities to the signal reports query as a `priority` param via `useInboxReports` and the API client. - Add a Priority section (P0–P4 toggle rows with colored dots) to the filter sheet. - Unit tests for the store actions and the param builder. Generated-By: PostHog Code Task-Id: bf3907c8-72ee-420f-97e7-8f3e176f6eaa
|
| describe("buildPriorityFilterParam", () => { | ||
| it("returns undefined for an empty selection", () => { | ||
| expect(buildPriorityFilterParam([])).toBeUndefined(); | ||
| }); | ||
|
|
||
| it("joins selected priorities with commas", () => { | ||
| expect(buildPriorityFilterParam(["P0", "P2"])).toBe("P0,P2"); | ||
| }); | ||
|
|
||
| it("dedupes repeated priorities", () => { | ||
| expect(buildPriorityFilterParam(["P1", "P1", "P3"])).toBe("P1,P3"); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
The three
buildPriorityFilterParam cases are pure input/output pairs that fit naturally into it.each, consistent with how the sibling toSuggestedReviewerWriteContent and reviewerMatchesAvailable tests are written in the same file.
| describe("buildPriorityFilterParam", () => { | |
| it("returns undefined for an empty selection", () => { | |
| expect(buildPriorityFilterParam([])).toBeUndefined(); | |
| }); | |
| it("joins selected priorities with commas", () => { | |
| expect(buildPriorityFilterParam(["P0", "P2"])).toBe("P0,P2"); | |
| }); | |
| it("dedupes repeated priorities", () => { | |
| expect(buildPriorityFilterParam(["P1", "P1", "P3"])).toBe("P1,P3"); | |
| }); | |
| }); | |
| describe("buildPriorityFilterParam", () => { | |
| it.each([ | |
| { name: "returns undefined for an empty selection", input: [], expected: undefined }, | |
| { name: "joins selected priorities with commas", input: ["P0", "P2"] as const, expected: "P0,P2" }, | |
| { name: "dedupes repeated priorities", input: ["P1", "P1", "P3"] as const, expected: "P1,P3" }, | |
| ])("$name", ({ input, expected }) => { | |
| expect(buildPriorityFilterParam(input)).toBe(expected); | |
| }); | |
| }); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/mobile/src/features/inbox/utils.test.ts
Line: 233-245
Comment:
The three `buildPriorityFilterParam` cases are pure input/output pairs that fit naturally into `it.each`, consistent with how the sibling `toSuggestedReviewerWriteContent` and `reviewerMatchesAvailable` tests are written in the same file.
```suggestion
describe("buildPriorityFilterParam", () => {
it.each([
{ name: "returns undefined for an empty selection", input: [], expected: undefined },
{ name: "joins selected priorities with commas", input: ["P0", "P2"] as const, expected: "P0,P2" },
{ name: "dedupes repeated priorities", input: ["P1", "P1", "P3"] as const, expected: "P1,P3" },
])("$name", ({ input, expected }) => {
expect(buildPriorityFilterParam(input)).toBe(expected);
});
});
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Include `priorityFilter` in `buildInboxViewedProperties` so the `has_active_filters` analytics flag is true when a priority filter is the only active filter; previously priority-only filtering was reported as no active filters. Thread `priorityFilter` through the inbox screen's INBOX_VIEWED call site and add coverage for the priority-only case. Also fold the `buildPriorityFilterParam` cases into `it.each`, matching the sibling table-driven tests in the file. Generated-By: PostHog Code Task-Id: bf3907c8-72ee-420f-97e7-8f3e176f6eaa
Ports the desktop filter inbox signal reports by priority feature (#2176) to the PostHog Code mobile app.
What changed
inboxFilterStore.ts): addedpriorityFilter: SignalReportPriority[](empty = no filter), withtogglePriorityandsetPriorityFilteractions. Persisted and cleared inresetFilters, matching the existingstatusFilter/sourceProductFilter/suggestedReviewerFilterpatterns.utils.ts): addedbuildPriorityFilterParam, returning a deduped comma-separated string orundefinedwhen empty (equivalent to desktop's helper, sibling tobuildSuggestedReviewerFilterParam).useInboxReports.ts+api.ts+types.ts): the selected priorities flow into the reports query as apriorityrequest param.FilterSheet.tsx): added a Priority section with P0–P4 toggle rows and colored dots (P0 red, P1/P2 amber-orange, P3/P4 gray), reusing the existingOptionRow/SectionHeaderprimitives and theme colors.Tests
inboxFilterStore.test.ts: toggle on/off, accumulation, dedupe onsetPriorityFilter, and clear-on-reset.utils.test.ts:buildPriorityFilterParamfor empty (undefined), join, and dedupe.Mobile inbox tests, biome lint, and typecheck all pass.
No desktop (
apps/code) code was modified.