feat: multi-provider pull requests page with in-app reviews #4849
MergedBil0000(GitHub profile, opens in a new tab)merged 223 commits into
main fromrefs/pull/4849/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
- apps/server/src/pullRequest/PullRequestService.ts lines 74 to 79OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +59,21 @@59+}60+61+/** `gh` being absent or logged out disables the whole feature, so it is reported as such62+ * instead of being folded into a single project's error list. */63+function unavailableReason(64+ error: GitHubCli.GitHubCliError,65+): PullRequestUnavailableError["reason"] | null {66+ if (error._tag === "GitHubCliUnavailableError") return "cli-missing";67+ if (error._tag === "GitHubCliAuthenticationError") return "cli-unauthenticated";68+ return null;69+}70+71+function toPullRequestError(72+ operation: string,73+): (error: GitHubCli.GitHubCliError) => PullRequestError {74+ return (error) => {75+ const reason = unavailableReason(error);76+ return reason === null77+ ? new PullRequestOperationError({ operation, detail: error.detail, cause: error })78+ : new PullRequestUnavailableError({ reason, detail: error.detail });79+ };packages/contracts/src/pullRequest.ts lines 755 to 782Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +188,21 @@188+export type PullRequestActionInput = typeof PullRequestActionInput.Type;189+190+export const PullRequestCommentInput = Schema.Struct({191+ ...PullRequestRef.fields,192+ // GitHub rejects comment bodies past 65536 characters; enforcing it here keeps oversized193+ // payloads off the wire and out of subprocess plumbing entirely.194+ body: TrimmedNonEmptyString.check(Schema.isMaxLength(65_536)),195+});196+export type PullRequestCommentInput = typeof PullRequestCommentInput.Type;197+198+export class PullRequestUnavailableError extends Schema.TaggedErrorClass<PullRequestUnavailableError>()(199+ "PullRequestUnavailableError",200+ {201+ reason: Schema.Literals(["cli-missing", "cli-unauthenticated", "provider-unsupported"]),202+ detail: TrimmedNonEmptyString,203+ },204+) {205+ override get message(): string {206+ return this.detail;207+ }208+}apps/server/src/pullRequest/GitHubPullRequestCli.ts lines 139 to 140OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +120,21 @@120+ mergeMethod: PullRequestMergeMethod | undefined,121+): ReadonlyArray<string> {122+ switch (action) {123+ case "merge":124+ return ["merge", `--${mergeMethod ?? "merge"}`];125+ case "ready":126+ return ["ready"];127+ case "draft":128+ return ["ready", "--undo"];129+ case "close":130+ return ["close"];131+ case "reopen":132+ return ["reopen"];133+ }134+}135+136+export const make = Effect.gen(function* () {137+ const github = yield* GitHubCli.GitHubCli;138+139+ const decodeError = (cwd: string, cause: unknown) =>140+ new GitHubCli.GitHubPullRequestDecodeError({ command: "gh", cwd, cause });apps/server/src/pullRequest/GitHubPullRequestCli.ts lines 151 to 151OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +131,21 @@131+ case "reopen":132+ return ["reopen"];133+ }134+}135+136+export const make = Effect.gen(function* () {137+ const github = yield* GitHubCli.GitHubCli;138+139+ const decodeError = (cwd: string, cause: unknown) =>140+ new GitHubCli.GitHubPullRequestDecodeError({ command: "gh", cwd, cause });141+142+ const repositoryArgs = (repository: string) => ["--repo", repository];143+144+ return GitHubPullRequestCli.of({145+ getViewerLogin: (input) =>146+ github.execute({ cwd: input.cwd, args: ["api", "user", "--jq", ".login"] }).pipe(147+ Effect.flatMap((result) => {148+ const login = result.stdout.trim();149+ return login.length > 0150+ ? Effect.succeed(login)151+ : Effect.fail(decodeError(input.cwd, new Error("Empty viewer login.")));
- apps/server/src/pullRequest/gitHubPullRequestJson.ts lines 123 to 127OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +107,21 @@107+ pullRequest: Schema.Struct({108+ reviewThreads: Schema.Struct({109+ totalCount: Schema.optional(Schema.Int),110+ nodes: Schema.Array(111+ Schema.Struct({112+ isResolved: Schema.optional(Schema.Boolean),113+ path: Schema.optional(Schema.NullOr(Schema.String)),114+ comments: Schema.Struct({ nodes: Schema.Array(RawCommentSchema) }),115+ }),116+ ),117+ }),118+ }),119+ }),120+ }),121+});122+123+const RawMergeCapabilitiesSchema = Schema.Struct({124+ mergeCommitAllowed: Schema.optional(Schema.Boolean),125+ squashMergeAllowed: Schema.optional(Schema.Boolean),126+ rebaseMergeAllowed: Schema.optional(Schema.Boolean),127+});apps/server/src/pullRequest/gitHubPullRequestJson.ts lines 224 to 232OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +212,21 @@212+ }213+}214+215+function toLabels(216+ raw: ReadonlyArray<Schema.Schema.Type<typeof RawLabelSchema>> | undefined,217+): ReadonlyArray<PullRequestLabel> {218+ return (raw ?? []).flatMap((label) => {219+ const name = trimmed(label.name);220+ return name === null ? [] : [{ name, color: trimmed(label.color) }];221+ });222+}223+224+/** Team review requests carry a slug instead of a login; both identify a requested reviewer. */225+function toReviewRequestLogins(226+ raw: ReadonlyArray<Schema.Schema.Type<typeof RawReviewRequestSchema>> | undefined,227+): ReadonlyArray<string> {228+ return (raw ?? []).flatMap((request) => {229+ const login = trimmed(request.login) ?? trimmed(request.slug) ?? trimmed(request.name);230+ return login === null ? [] : [login];231+ });232+}apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx lines 127 to 134OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +114,21 @@114+ if (!detail || handoff !== null) return;115+ setHandoff(kind);116+ const prepared = await prepareThread.run({ reference: detail.url, mode: "worktree" });117+ if (prepared._tag === "Failure") {118+ setHandoff(null);119+ toastManager.add({ type: "error", title: "Could not prepare the pull request checkout" });120+ return;121+ }122+ await newThread(scopeProjectRef(environmentId, detail.projectId), {123+ branch: prepared.value.branch,124+ worktreePath: prepared.value.worktreePath,125+ envMode: "worktree",126+ });127+ await writeTextToClipboard(prompt);128+ setHandoff(null);129+ toastManager.add({130+ type: "success",131+ title: "Checkout ready",132+ description: "The prompt is on your clipboard — paste it to start.",133+ });134+ };apps/web/src/components/pullRequest/pullRequestMarkdown.logic.ts line 82OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +62,21 @@62+ const bareVideo = videoUrlFromLine(line);63+ if (bareVideo !== null) {64+ flushMarkdown();65+ segments.push({ id: `video:${segments.length}`, kind: "video", url: bareVideo });66+ continue;67+ }68+69+ if (!/<video\b/iu.test(line)) {70+ markdown.push(line);71+ continue;72+ }73+ // A tag can span lines; consume through its close before looking for the source.74+ let block = line;75+ while (!/<\/video>/iu.test(block) && index + 1 < lines.length) {76+ index += 1;77+ block += `\n${lines[index]!}`;78+ }79+ const source = VIDEO_TAG_SRC_PATTERN.exec(block)?.[1];80+ if (source !== undefined && isPlayableUrl(source)) {81+ flushMarkdown();82+ segments.push({ id: `video:${segments.length}`, kind: "video", url: source });apps/web/src/components/pullRequest/pullRequestMarkdown.logic.ts line 61Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +16,21 @@16+ return parsed.protocol === "https:" || parsed.protocol === "http:";17+ } catch {18+ return false;19+ }20+}21+22+function videoUrlFromLine(line: string): string | null {23+ const bare = BARE_URL_PATTERN.exec(line.trim())?.[1];24+ if (bare === undefined) return null;25+ const isVideo = VIDEO_EXTENSION_PATTERN.test(bare) || GITHUB_ASSET_PATTERN.test(bare);26+ return isVideo && isPlayableUrl(bare) ? bare : null;27+}28+29+/**30+ * Splits a pull request body into markdown runs and the videos embedded in it, which the31+ * markdown renderer has no element for. Two shapes are recognised, both of which GitHub32+ * produces itself: a `<video>` (or `<source>`) tag, and a bare link on its own line to a33+ * video file or an uploaded attachment. Fenced code is copied through untouched so a snippet34+ * that happens to contain a link is never turned into a player.35+ */36+export function splitPullRequestBody(body: string): ReadonlyArray<PullRequestBodySegment> {apps/web/src/components/pullRequest/pullRequestMarkdown.logic.ts line 42OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +22,21 @@22+function videoUrlFromLine(line: string): string | null {23+ const bare = BARE_URL_PATTERN.exec(line.trim())?.[1];24+ if (bare === undefined) return null;25+ const isVideo = VIDEO_EXTENSION_PATTERN.test(bare) || GITHUB_ASSET_PATTERN.test(bare);26+ return isVideo && isPlayableUrl(bare) ? bare : null;27+}28+29+/**30+ * Splits a pull request body into markdown runs and the videos embedded in it, which the31+ * markdown renderer has no element for. Two shapes are recognised, both of which GitHub32+ * produces itself: a `<video>` (or `<source>`) tag, and a bare link on its own line to a33+ * video file or an uploaded attachment. Fenced code is copied through untouched so a snippet34+ * that happens to contain a link is never turned into a player.35+ */36+export function splitPullRequestBody(body: string): ReadonlyArray<PullRequestBodySegment> {37+ const segments: PullRequestBodySegment[] = [];38+ const markdown: string[] = [];39+ let insideFence = false;40+41+ const flushMarkdown = () => {42+ const text = markdown.join("\n").trim();apps/web/src/components/pullRequest/pullRequestDetail.logic.ts lines 90 to 90OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +70,21 @@70+ : `${collapsed.slice(0, FINDING_BODY_MAX_LENGTH - 3)}...`;71+}72+73+/**74+ * Prompt for handing a pull request's review findings to a fresh thread. Everything derived75+ * from the pull request is quoted and explicitly marked untrusted: review bodies and check76+ * output are attacker-controlled on public repositories.77+ */78+export function buildFixFindingsPrompt(input: {79+ readonly number: number;80+ readonly title: string;81+ readonly url: string;82+ readonly headBranch: string;83+ readonly baseBranch: string;84+ readonly comments: ReadonlyArray<PullRequestComment>;85+ readonly checks: ReadonlyArray<PullRequestCheck>;86+ readonly commentsTruncated: boolean;87+}): string {88+ const findings = [89+ ...input.comments90+ .filter((comment) => comment.kind === "review" && comment.body.trim().length > 0)apps/web/src/routes/_chat.pull-requests.tsx line 128OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +108,21 @@108+ [Key in keyof PullRequestsSearch]?: PullRequestsSearch[Key] | undefined;109+ }) =>110+ void navigate({111+ // Rebuilt rather than spread so a cleared field leaves the URL instead of112+ // lingering as an explicit `undefined`.113+ search: (previous: PullRequestsSearch): PullRequestsSearch => {114+ const next = { ...previous, ...patch };115+ return {116+ involvement: next.involvement ?? previous.involvement,117+ state: next.state ?? previous.state,118+ ...(next.repository ? { repository: next.repository } : {}),119+ ...(next.number ? { number: next.number } : {}),120+ ...(next.projectId ? { projectId: next.projectId } : {}),121+ ...(next.q ? { q: next.q } : {}),122+ };123+ },124+ replace: true,125+ });126+127+ // Changing what the list contains must not leave a selection from the previous view open.128+ const clearedSelection = { repository: undefined, number: undefined, projectId: undefined };apps/server/src/pullRequest/GitHubPullRequestCli.ts line 234OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +214,21 @@214+ cwd: input.cwd,215+ args: [216+ "pr",217+ "diff",218+ String(input.number),219+ ...repositoryArgs(input.repository),220+ "--color",221+ "never",222+ "--patch",223+ ],224+ maxOutputBytes: DIFF_MAX_OUTPUT_BYTES,225+ timeoutMs: DIFF_TIMEOUT_MS,226+ })227+ .pipe(228+ Effect.map((result) => ({229+ patch: result.stdout,230+ truncated: result.stdoutTruncated,231+ })),232+ ),233+234+ listReviewThreadComments: (input) => {
- apps/web/src/routes/_chat.pull-requests.tsx line 287OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +267,21 @@267+ </div>268+ <div className="flex items-center gap-2">269+ <PullRequestSearchInput270+ value={search.q ?? ""}271+ onChange={(query) => updateSearch({ q: query || undefined })}272+ />273+ <PullRequestProjectFilter274+ projects={scopedProjects}275+ value={search.projectId}276+ onChange={(projectId) => updateSearch({ ...clearedSelection, projectId })}277+ />278+ </div>279+ </div>280+281+ {listQuery.isPending && listData === null ? (282+ <div className="space-y-1">283+ {Array.from({ length: 7 }, (_, index) => (284+ <Skeleton key={index} className="h-13 w-full rounded-lg" />285+ ))}286+ </div>287+ ) : listQuery.error ? (apps/server/src/pullRequest/PullRequestService.ts line 190OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +170,21 @@170+ if (match.repository.toLowerCase() !== ref.repository.trim().toLowerCase()) {171+ return Effect.fail(172+ new PullRequestOperationError({173+ operation: "resolveRepository",174+ detail: "The pull request does not belong to the selected project.",175+ }),176+ );177+ }178+ return Effect.succeed(match);179+ }),180+ );181+182+ const list: PullRequestService["Service"]["list"] = (input) =>183+ Effect.gen(function* () {184+ const involvement = input.involvement ?? "all";185+ const projects = yield* listGitHubProjects(input.projectId);186+ if (projects.length === 0) {187+ return { viewer: null, entries: [], errors: [], truncated: false };188+ }189+190+ const viewer = yield* githubapps/web/src/components/pullRequest/PullRequestSummaryTab.tsx lines 139 to 147Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +109,21 @@109+ number: detail.number,110+ body: trimmed,111+ },112+ });113+ setPosting(false);114+ if (result._tag === "Failure") {115+ toastManager.add({ type: "error", title: "Could not post the comment" });116+ return;117+ }118+ setBody("");119+ onCommented();120+ };121+122+ return (123+ <div className="mt-3 space-y-2">124+ <Textarea125+ value={body}126+ rows={3}127+ placeholder="Leave a comment"128+ aria-label="Comment on this pull request"129+ onChange={(event) => setBody(event.target.value)}
- apps/web/src/routes/_chat.pull-requests.tsx line 142OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +122,21 @@122+ state: next.state ?? previous.state,123+ ...(next.repository ? { repository: next.repository } : {}),124+ ...(next.number ? { number: next.number } : {}),125+ ...(next.projectId ? { projectId: next.projectId } : {}),126+ ...(next.selectedProjectId ? { selectedProjectId: next.selectedProjectId } : {}),127+ ...(next.q ? { q: next.q } : {}),128+ };129+ },130+ replace: true,131+ });132+133+ // Changing what the list contains must not leave a selection from the previous view open.134+ // The project filter is untouched: it is the user's scope, not part of the selection.135+ const clearedSelection = {136+ repository: undefined,137+ number: undefined,138+ selectedProjectId: undefined,139+ };140+141+ // Page size is view state, not a URL concern: a shared link should open the first page.142+ const filterKey = `${search.state}:${search.involvement}:${search.projectId ?? ""}`;apps/web/src/components/pullRequest/pullRequestMarkdown.logic.ts line 74OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +54,21 @@54+ const lines = body.split("\n");55+ for (let index = 0; index < lines.length; index += 1) {56+ const line = lines[index]!;57+ const fence = FENCE_PATTERN.exec(line)?.[1];58+ if (fence !== undefined) {59+ // A fence closes only on the same marker, at least as long as the one that opened it,60+ // so a ~~~ line cannot end a ``` block and expose its contents to the rules below.61+ if (openFence === null) {62+ openFence = fence;63+ } else if (fence[0] === openFence[0] && fence.length >= openFence.length) {64+ openFence = null;65+ }66+ markdown.push(line);67+ continue;68+ }69+ if (openFence !== null) {70+ markdown.push(line);71+ continue;72+ }73+74+ const bareVideo = videoUrlFromLine(line);packages/contracts/src/pullRequest.ts lines 607 to 610Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +175,21 @@175+export type PullRequestDetail = typeof PullRequestDetail.Type;176+177+export const PullRequestDiffResult = Schema.Struct({178+ patch: Schema.String,179+ truncated: Schema.Boolean,180+});181+export type PullRequestDiffResult = typeof PullRequestDiffResult.Type;182+183+export const PullRequestActionInput = Schema.Struct({184+ ...PullRequestRef.fields,185+ action: PullRequestAction,186+ mergeMethod: Schema.optional(PullRequestMergeMethod),187+});188+export type PullRequestActionInput = typeof PullRequestActionInput.Type;189+190+export const PullRequestCommentInput = Schema.Struct({191+ ...PullRequestRef.fields,192+ // GitHub rejects comment bodies past 65536 characters; enforcing it here keeps oversized193+ // payloads off the wire and out of subprocess plumbing entirely.194+ body: TrimmedNonEmptyString.check(Schema.isMaxLength(65_536)),195+});apps/server/src/pullRequest/gitHubPullRequestJson.ts lines 777 to 782Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +234,21 @@234+ return (raw ?? []).flatMap((request) => {235+ const login = trimmed(request.login);236+ return login === null ? [] : [login];237+ });238+}239+240+function toCheckStatus(raw: Schema.Schema.Type<typeof RawCheckSchema>): PullRequestCheckStatus {241+ // Commit statuses report a single `state`; check runs report `status` plus a `conclusion`242+ // that only exists once the run has completed.243+ const status = raw.status?.trim().toUpperCase();244+ if (status !== undefined && status !== "COMPLETED" && status !== "") {245+ return "pending";246+ }247+ switch ((raw.conclusion ?? raw.state)?.trim().toUpperCase()) {248+ case "SUCCESS":249+ return "success";250+ case "FAILURE":251+ case "ERROR":252+ case "TIMED_OUT":253+ case "STARTUP_FAILURE":254+ return "failure";apps/web/src/components/pullRequest/pullRequestMarkdown.logic.ts lines 57 to 65OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +45,21 @@45+ // indented code block, so trimming a run would silently turn code into prose.46+ const flushMarkdown = () => {47+ const text = markdown.join("\n").replace(/^\n+/u, "").replace(/\s+$/u, "");48+ markdown.length = 0;49+ if (text.trim().length > 0) {50+ segments.push({ id: `markdown:${segments.length}`, kind: "markdown", text });51+ }52+ };53+54+ const lines = body.split("\n");55+ for (let index = 0; index < lines.length; index += 1) {56+ const line = lines[index]!;57+ const fence = FENCE_PATTERN.exec(line)?.[1];58+ if (fence !== undefined) {59+ // A fence closes only on the same marker, at least as long as the one that opened it,60+ // so a ~~~ line cannot end a ``` block and expose its contents to the rules below.61+ if (openFence === null) {62+ openFence = fence;63+ } else if (fence[0] === openFence[0] && fence.length >= openFence.length) {64+ openFence = null;65+ }
- apps/web/src/components/pullRequest/pullRequestMarkdown.logic.ts lines 104 to 107OutdatedResolvedby Bil0000(GitHub profile, opens in a new tab)@@ -0,0 +87,21 @@87+ continue;88+ }89+90+ if (!STANDALONE_VIDEO_TAG_PATTERN.test(line)) {91+ markdown.push(line);92+ continue;93+ }94+ // A tag can span lines; consume through its close before looking for the source.95+ let block = line;96+ let cursor = index;97+ while (!VIDEO_TAG_END_PATTERN.test(block) && cursor + 1 < lines.length) {98+ cursor += 1;99+ block += `\n${lines[cursor]!}`;100+ }101+ const source = VIDEO_TAG_END_PATTERN.test(block)102+ ? VIDEO_TAG_SRC_PATTERN.exec(block)?.[1]103+ : undefined;104+ if (source !== undefined && isPlayableUrl(source)) {105+ flushMarkdown();106+ segments.push({ id: `video:${segments.length}`, kind: "video", url: source });107+ index = cursor;apps/web/src/routes/_chat.pull-requests.tsx line 181Resolvedby Bil0000(GitHub profile, opens in a new tab)@@ -0,0 +77,21 @@77+ : {}),78+ ...(typeof raw.number === "number" && Number.isInteger(raw.number) && raw.number > 079+ ? { number: raw.number }80+ : {}),81+ ...(typeof raw.projectId === "string" && raw.projectId82+ ? { projectId: raw.projectId as ProjectId }83+ : {}),84+ ...(typeof raw.selectedProjectId === "string" && raw.selectedProjectId85+ ? { selectedProjectId: raw.selectedProjectId as ProjectId }86+ : {}),87+ ...(typeof raw.q === "string" && raw.q ? { q: raw.q.slice(0, 200) } : {}),88+ }),89+ component: PullRequestsRouteView,90+});91+92+function PullRequestsRouteView() {93+ const search = Route.useSearch();94+ const navigate = useNavigate({ from: Route.fullPath });95+ const environmentId = usePrimaryEnvironmentId();96+ const projects = useProjects();97+ const scopedProjects = useMemo(apps/server/src/pullRequest/GitHubPullRequestCli.ts line 281OutdatedResolvedby Bil0000(GitHub profile, opens in a new tab)@@ -0,0 +261,21 @@261+ cwd: input.cwd,262+ args: [263+ "pr",264+ "diff",265+ String(input.number),266+ ...repositoryArgs(input.repository),267+ "--color",268+ "never",269+ "--patch",270+ ],271+ maxOutputBytes: DIFF_MAX_OUTPUT_BYTES,272+ timeoutMs: DIFF_TIMEOUT_MS,273+ })274+ .pipe(275+ Effect.map((result) => ({276+ patch: result.stdout,277+ truncated: result.stdoutTruncated,278+ })),279+ ),280+281+ listReviewThreadComments: (input) => {
- apps/web/src/components/pullRequest/pullRequestDetail.logic.ts lines 111 to 112OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +92,21 @@92+ (comment.kind === "review" || comment.kind === "review-comment") &&93+ comment.body.trim().length > 0,94+ )95+ .map((comment) => ({96+ heading: [97+ comment.kind === "review" ? "Review" : "Review comment",98+ comment.path ? `on \`${boundedField(comment.path)}\`` : null,99+ `by ${boundedField(comment.author?.login ?? "ghost")}`,100+ ]101+ .filter(Boolean)102+ .join(" "),103+ body: boundedField(comment.body),104+ })),105+ ...input.checks106+ .filter((check) => check.status === "failure" || check.status === "cancelled")107+ .map((check) => ({108+ heading: "Failing check",109+ body: boundedField(check.description ? `${check.name} — ${check.description}` : check.name),110+ })),111+ ];112+ const included = findings.slice(0, FINDING_LIMIT);apps/web/src/routes/_chat.pull-requests.tsx line 178OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +158,21 @@158+ state: search.state,159+ limit: pageSize,160+ ...(search.projectId ? { projectId: search.projectId } : {}),161+ },162+ }),163+ );164+165+ // Raising the page size targets a different query, which starts empty. Holding the last166+ // result for the same filters keeps the rows on screen so a longer page reads as growth167+ // rather than a reload.168+ const [loaded, setLoaded] = useState<{ key: string; data: PullRequestListResult } | null>(null);169+ useEffect(() => {170+ if (listQuery.data) setLoaded({ key: filterKey, data: listQuery.data });171+ }, [filterKey, listQuery.data]);172+ const listData = listQuery.data ?? (loaded?.key === filterKey ? loaded.data : null);173+ const loadingMore = listQuery.isPending && listData !== null;174+175+ const sentinelRef = useRef<HTMLDivElement>(null);176+ useEffect(() => {177+ const sentinel = sentinelRef.current;178+ if (!sentinel || listData?.truncated !== true || listQuery.isPending) return;apps/server/src/pullRequest/gitHubPullRequestJson.ts lines 303 to 305OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +285,21 @@285+286+function toComments(287+ raw: Schema.Schema.Type<typeof RawDetailSchema>,288+): ReadonlyArray<PullRequestComment> {289+ const issueComments = (raw.comments ?? []).map(290+ (comment): PullRequestComment => ({291+ id: comment.id,292+ kind: "issue-comment",293+ author: toActor(comment.author),294+ body: comment.body ?? "",295+ createdAt: comment.createdAt,296+ url: trimmed(comment.url),297+ path: null,298+ reviewState: null,299+ }),300+ );301+ // Reviews without a body are approvals/dismissals with nothing to read; they already show302+ // up as the review decision, so keeping them here would pad the timeline with empty cards.303+ const reviews = (raw.reviews ?? []).flatMap((review): ReadonlyArray<PullRequestComment> => {304+ const submittedAt = trimmed(review.submittedAt);305+ if (submittedAt === null || (review.body ?? "").trim().length === 0) return [];
- apps/server/src/pullRequest/GitHubPullRequestCli.ts lines 199 to 200OutdatedResolvedby Bil0000(GitHub profile, opens in a new tab)@@ -0,0 +180,21 @@180+ mergeMethod: PullRequestMergeMethod | undefined,181+): ReadonlyArray<string> {182+ switch (action) {183+ case "merge":184+ return ["merge", `--${mergeMethod ?? "merge"}`];185+ case "ready":186+ return ["ready"];187+ case "draft":188+ return ["ready", "--undo"];189+ case "close":190+ return ["close"];191+ case "reopen":192+ return ["reopen"];193+ }194+}195+196+export const make = Effect.gen(function* () {197+ const github = yield* GitHubCli.GitHubCli;198+199+ const readError = (cwd: string, operation: string, cause: unknown) =>200+ new GitHubPullRequestReadError({ command: "gh", cwd, operation, cause });
- apps/server/src/pullRequest/PullRequestProvider.ts lines 154 to 155OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +135,21 @@135+export class PullRequestProviderRegistry extends Context.Service<136+ PullRequestProviderRegistry,137+ {138+ /** Null for a host with no implementation, which the service reports as unsupported. */139+ readonly get: (kind: SourceControlProviderKind) => PullRequestProviderApi | null;140+ readonly kinds: ReadonlyArray<SourceControlProviderKind>;141+ }142+>()("t3/pullRequest/PullRequestProvider/PullRequestProviderRegistry") {}143+144+export function makeRegistry(145+ providers: ReadonlyArray<PullRequestProviderApi>,146+): PullRequestProviderRegistry["Service"] {147+ const byKind = new Map(providers.map((provider) => [provider.kind, provider]));148+ return {149+ get: (kind) => byKind.get(kind) ?? null,150+ kinds: providers.map((provider) => provider.kind),151+ };152+}153+154+/** Convenience for implementations: one place that builds their failures. */155+export function providerError(
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
97da5f22-0528-4dbb-b587-0287e365dd84You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share