feat(prs): filter by assignee and assign people on GitHub and GitLab #22381
ClosedTonybynMp4(GitHub profile, opens in a new tab)wants to merge 5 commits into
main fromrefs/pull/22381/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/web/src/components/pullRequest/PullRequestAssigneePicker.tsx lines 109 to 109OutdatedResolvedby TonybynMp4(GitHub profile, opens in a new tab)@@ -0,0 +89,21 @@89+90+ return (91+ <PullRequestCandidatePicker92+ icon={<UserRoundPlusIcon className="size-3.5" />}93+ label="Assign someone"94+ allowed={allowed}95+ disabledReason="Assigning someone needs triage access on this repository"96+ open={open}97+ onOpenChange={setOpen}98+ query={query}99+ onQueryChange={setQuery}100+ searchLabel="Search people who can be assigned"101+ isPending={102+ (candidatesQuery.isPending && candidatesQuery.data === null) ||103+ // Nothing loaded matches yet, and the host has not answered: not a "nobody matches".104+ (candidates.length === 0 &&105+ candidatesQuery.data?.truncated === true &&106+ query.trim().length > 0 &&107+ (searchQuery !== query.trim() || searchResult.isPending))108+ }109+ error={candidatesQuery.data === null ? candidatesQuery.error : null}packages/client-runtime/src/state/pullRequests.ts line 614Resolvedby TonybynMp4(GitHub profile, opens in a new tab)@@ -577,0 +594,21 @@594+ assigneeCandidates,595+ /** The host's search for people past the first page, keyed by what was typed. */596+ assigneeSearch,597+ setAssignees: createEnvironmentRpcCommand(runtime, {598+ label: "environment-data:pull-requests:set-assignees",599+ tag: WS_METHODS.pullRequestsSetAssignees,600+ execute: (input) => routedRequest(WS_METHODS.pullRequestsSetAssignees, input),601+ scheduler: commandScheduler,602+ concurrency: serialPerEnvironment,603+ onSuccess: (target, registry) =>604+ Effect.sync(() => {605+ const { assignees, assigned } = target.input;606+ const candidatesAtom = assigneeCandidates(target);607+ const candidates = Option.getOrNull(AsyncResult.value(registry.get(candidatesAtom)));608+ const ids = new Set(assignees);609+ const selected =610+ candidates?.candidates.filter((candidate) => ids.has(candidate.id)) ?? [];611+ // Both are patched at once and then read again: a GitLab that allows one assignee612+ // replaces the one already there, and somebody found only by the host's search is not613+ // in the candidates to patch.614+ updateCached(
- apps/web/src/components/pullRequest/PullRequestAssigneePicker.tsx line 109OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +89,21 @@89+90+ return (91+ <PullRequestCandidatePicker92+ icon={<UserRoundPlusIcon className="size-3.5" />}93+ label="Assign someone"94+ allowed={allowed}95+ disabledReason="Assigning someone needs triage access on this repository"96+ open={open}97+ onOpenChange={setOpen}98+ query={query}99+ onQueryChange={setQuery}100+ searchLabel="Search people who can be assigned"101+ isPending={102+ (candidatesQuery.isPending && candidatesQuery.data === null) ||103+ // Nothing loaded matches yet, and the host has not answered: not a "nobody matches".104+ (candidates.length === 0 &&105+ candidatesQuery.data?.truncated === true &&106+ query.trim().length > 0 &&107+ (searchQuery !== query.trim() || searchResult.isPending))108+ }109+ error={candidatesQuery.data === null ? candidatesQuery.error : null}apps/web/src/routes/_chat.pull-requests.tsx lines 333 to 335OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -330,3 +330,6 @@330330 ...(typeof raw.author === "string" && raw.author.trim()331331 ? { author: raw.author.trim().slice(0, 200) }332332 : {}),333+ ...(typeof raw.assignee === "string" && raw.assignee.trim()334+ ? { assignee: raw.assignee.trim().slice(0, 200) }335+ : {}),
- apps/web/src/components/pullRequest/PullRequestAssigneePicker.tsx line 59OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +39,21 @@39+ const candidatesQuery = useEnvironmentQuery(40+ open ? pullRequestEnvironment.assigneeCandidates({ environmentId, input: reference }) : null,41+ );42+ // Past the first page the host is asked, since what was loaded cannot answer for the rest.43+ const searchQuery = useDebouncedValue(query.trim(), 250);44+ const searchesHost = candidatesQuery.data?.truncated === true && searchQuery.length > 0;45+ const searchResult = useEnvironmentQuery(46+ open && searchesHost47+ ? pullRequestEnvironment.assigneeSearch({48+ environmentId,49+ input: { ...reference, query: searchQuery },50+ })51+ : null,52+ );53+ const setAssignees = useAtomCommand(pullRequestEnvironment.setAssignees, {54+ reportFailure: false,55+ });56+57+ const candidates = mergeAssigneeCandidates(58+ candidatesQuery.data?.candidates ?? [],59+ searchesHost ? (searchResult.data?.candidates ?? []) : [],
- apps/web/src/components/pullRequest/PullRequestAssigneePicker.tsx line 127OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +107,21 @@107+ (candidatesQuery.isPending && candidatesQuery.data === null) ||108+ // Nothing loaded matches yet, and the host has not answered: not a "nobody matches".109+ (candidates.length === 0 &&110+ candidatesQuery.data?.truncated === true &&111+ query.trim().length > 0 &&112+ (searchQuery !== query.trim() || searchResult.isPending))113+ }114+ error={115+ candidatesQuery.data === null116+ ? candidatesQuery.error117+ : searched && candidates.length === 0118+ ? searchResult.error119+ : null120+ }121+ candidates={candidates}122+ emptyLabel="Nobody can be assigned on this repository."123+ noMatchLabel="Nobody who can be assigned matches that."124+ errorLabel="The people who can be assigned could not be read."125+ truncated={126+ candidatesQuery.data?.truncated === true &&127+ (query.trim().length === 0 || (searched && searchResult.error !== null))packages/source-control-gitlab/src/server/GitLabPullRequestCli.ts line 1341Resolvedby TonybynMp4(GitHub profile, opens in a new tab)@@ -1273,0 +1317,21 @@1317+ }));1318+ const assignedIds = new Set(assigned.map((user) => user.id));1319+ return {1320+ // The assignees lead, and come from the merge request rather than the users page:1321+ // that page stops at a hundred, and somebody missing from it could not be unassigned.1322+ candidates: [1323+ ...assigned,1324+ ...users.candidates.flatMap(({ kind: _kind, isRequested: _isRequested, ...user }) =>1325+ assignedIds.has(user.id) ? [] : [{ ...user, isAssigned: false }],1326+ ),1327+ ],1328+ truncated: users.rawCount >= MAX_PAGE_SIZE,1329+ };1330+ }),1331+ ),1332+1333+ setAssignees: (input) =>1334+ mergeRequestDetail(input).pipe(1335+ Effect.flatMap((mergeRequest) => {1336+ // Like `reviewer_ids`, `assignee_ids` replaces the whole set.1337+ const current = mergeRequest.assigneeIds;
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed