Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: PR Checks

on:
pull_request:

concurrency:
group: pr-checks-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.15.0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run lint
run: pnpm lint

typecheck:
name: Type Check
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.15.0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run type check
run: pnpm check-types
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ import {
import { vercelDark, vercelLight } from "@diffkit/ui/lib/shiki-themes";
import { cn } from "@diffkit/ui/lib/utils";
import type { SelectedLineRange } from "@pierre/diffs";
import type { DiffLineAnnotation } from "@pierre/diffs/react";
import type { DiffLineAnnotation, PatchDiffProps } from "@pierre/diffs/react";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { createFileRoute, Link } from "@tanstack/react-router";
import { useTheme } from "next-themes";
import {
type ComponentType,
type LazyExoticComponent,
lazy,
Suspense,
useCallback,
Expand Down Expand Up @@ -57,14 +59,15 @@ import { useRegisterTab } from "#/lib/use-register-tab";
// Lazy-load PatchDiff so @pierre/diffs (which bundles all shiki language grammars)
// is excluded from the server bundle, keeping it under the CF Workers 3 MiB limit.
// During SSR, return a no-op component to avoid stubbed-shiki runtime errors.
const PatchDiff = lazy(() =>
type ReviewPatchDiffComponent = ComponentType<PatchDiffProps<ReviewAnnotation>>;

const PatchDiff: LazyExoticComponent<ReviewPatchDiffComponent> = lazy(() =>
import.meta.env.SSR
? Promise.resolve({
// biome-ignore lint: SSR placeholder for the lazy-loaded PatchDiff
default: (() => null) as any,
default: (() => null) as ReviewPatchDiffComponent,
})
: import("@pierre/diffs/react").then((mod) => ({
default: mod.PatchDiff,
default: mod.PatchDiff as ReviewPatchDiffComponent,
})),
);

Expand Down Expand Up @@ -114,6 +117,7 @@ type PendingComment = {
body: string;
};

type ReviewAnnotation = PullReviewComment | PendingComment;
type ReviewEvent = "APPROVE" | "REQUEST_CHANGES" | "COMMENT";

type FileTreeNode = {
Expand Down Expand Up @@ -779,9 +783,7 @@ function FileDiffBlock({

// Combine existing review comments and pending comments into annotations
const allAnnotations = useMemo(() => {
const result: DiffLineAnnotation<PullReviewComment | PendingComment>[] = [
...annotations,
];
const result: DiffLineAnnotation<ReviewAnnotation>[] = [...annotations];

for (const pending of pendingComments) {
result.push({
Expand Down Expand Up @@ -877,7 +879,9 @@ function FileDiffBlock({
options={diffOptions}
selectedLines={selectedLines}
lineAnnotations={allAnnotations}
renderAnnotation={(annotation) => {
renderAnnotation={(
annotation: DiffLineAnnotation<ReviewAnnotation>,
) => {
const data = annotation.metadata as
| PendingComment
| PullReviewComment
Expand Down
Loading