Skip to content

feat(mobile): edit suggested reviewers on inbox report detail (port #2481)#2482

Open
Gilbert09 wants to merge 2 commits into
mainfrom
posthog-code/mobile-edit-suggested-reviewers
Open

feat(mobile): edit suggested reviewers on inbox report detail (port #2481)#2482
Gilbert09 wants to merge 2 commits into
mainfrom
posthog-code/mobile-edit-suggested-reviewers

Conversation

@Gilbert09
Copy link
Copy Markdown
Member

Ports desktop PR #2481 (feat(inbox): edit suggested reviewers from the report detail pane) to the mobile app. The suggested-reviewers list on an inbox signal report is now editable from the report detail screen — previously it was display-only.

What changed

API (features/inbox/api.ts)

  • New updateSignalReportArtefact(reportId, artefactId, content)PUT-replaces the suggested_reviewers artefact content with a SuggestedReviewerWriteEntry[]. The server canonicalizes each entry to a lowercase github_login, with user_uuid winning when both are supplied.

Hook (features/inbox/hooks/useInboxReports.ts)

  • New useUpdateSuggestedReviewers(reportId) — optimistic full-replacement mutation. onMutate patches the cached artefacts list immediately, onError rolls back, and onSettled invalidates so the optimistic guess is reconciled with the server-resolved reviewer data (user records, commits, canonical login).

UI

  • SuggestedReviewers.tsx is now editable: existing reviewers render as chips with a remove (✕) control (tap the chip to open the GitHub profile), plus an Add button that opens a searchable picker.
  • New EditReviewersSheet.tsx — a bottom sheet (consistent with ReviewerFilterSheet / DismissReportSheet) listing the org's available reviewers with a search box; assigned reviewers show a check and tapping toggles add/remove.
  • Extracted a shared ReviewerOptionRow reused by both the add picker and the existing ReviewerFilterSheet, plus shared reviewer-option and write-shape helpers in utils.ts.

Analytics (lib/analytics.ts)

  • Added add_suggested_reviewer / remove_suggested_reviewer action types and suggested_reviewer_login / suggested_reviewer_uuid properties, fired via the existing inbox engagement tracker.

Reuse

Reuses existing mobile inbox infrastructure: the available-reviewers query (useAvailableSuggestedReviewers), inbox query keys, the sheet/modal patterns, and the engagement-tracker analytics layer.

Testing

  • Unit tests for toSuggestedReviewerWriteContent, reviewerMatchesAvailable, and buildReviewerOptions (write-shape mapping + reviewer matching).
  • vitest run src/features/inbox — 17 passing.
  • Biome lint and tsc clean on the touched files.

…2481)

Makes the suggested reviewers on an inbox signal report editable from the
report detail screen, porting desktop PR #2481 to the mobile app.

- New `updateSignalReportArtefact` API method (PUT-replaces artefact content).
- New `useUpdateSuggestedReviewers` mutation hook with an optimistic
  full-replacement update that patches the cached artefacts and reconciles
  with server-canonicalized data on settle.
- `SuggestedReviewers` becomes editable: removable reviewer chips plus an
  "Add" affordance opening a searchable picker (`EditReviewersSheet`) over the
  org's available reviewers.
- Extracted a shared `ReviewerOptionRow` reused by the add picker and the
  existing `ReviewerFilterSheet`, and shared reviewer-option / write-shape
  helpers in `utils.ts`.
- Fires `add_suggested_reviewer` / `remove_suggested_reviewer` analytics with
  `suggested_reviewer_login` / `suggested_reviewer_uuid`.
- Unit tests for the write-shape mapping and reviewer matching helpers.

Generated-By: PostHog Code
Task-Id: a3560a8b-5ba2-46b2-bfe5-d0a9f93db8e2
@Gilbert09 Gilbert09 requested a review from a team June 4, 2026 10:47
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 4, 2026

Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
apps/mobile/src/features/inbox/components/SuggestedReviewers.tsx:120-125
The "Add" button and the sheet's toggle callback are not guarded against a pending mutation, while the ✕ remove button is correctly `disabled={isPending}`. If a user opens the sheet and taps while an earlier mutation is still in-flight, `onMutate` for the second call captures the *optimistic* state from the first as its rollback snapshot. If the first mutation then fails and rolls back, it reverts to the state before both mutations, temporarily erasing the second mutation's optimistic update. `onSettled`'s refetch eventually heals the UI, but there's a visible flicker and a brief window of incorrect state.

```suggestion
        <Pressable
          onPress={() => setEditOpen(true)}
          disabled={isPending}
          accessibilityLabel="Add suggested reviewer"
          hitSlop={6}
          className="flex-row items-center gap-1 rounded-full border border-gray-6 px-2.5 py-1 active:opacity-70 disabled:opacity-50"
        >
```

### Issue 2 of 2
apps/mobile/src/features/inbox/utils.test.ts:173-220
**Prefer parameterised tests**

The three cases under `toSuggestedReviewerWriteContent` and the three under `reviewerMatchesAvailable` are each a fixed input → expected output table and would be more concise and easier to extend as `it.each` blocks. The project convention is to always prefer parameterised tests.

Reviews (1): Last reviewed commit: "feat(mobile): edit suggested reviewers o..." | Re-trigger Greptile

Comment thread apps/mobile/src/features/inbox/components/SuggestedReviewers.tsx
Comment thread apps/mobile/src/features/inbox/utils.test.ts
Address review feedback on the suggested reviewers UI:
- Disable the "Add" button and short-circuit toggleReviewer while a
  mutation is in-flight so overlapping optimistic updates can't flicker
  or roll back to a stale snapshot.
- Convert toSuggestedReviewerWriteContent and reviewerMatchesAvailable
  tests to it.each parameterised cases per project convention.

Generated-By: PostHog Code
Task-Id: 4b8dd76e-7ba9-453b-8cb8-c9441a47b3dc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants