Skip to content

Commit 5b9089d

Browse files
committed
Fix type errors
1 parent b48ffae commit 5b9089d

File tree

9 files changed

+724
-104
lines changed

9 files changed

+724
-104
lines changed

AGENTS.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# pulldash
2+
3+
Pulldash is the fastest way to review pull requests.
4+
5+
## Development
6+
7+
Use `bun` for everything - package management, tests.
8+
9+
## Principles
10+
11+
- Performance is P1. If things feel laggy or are not smooth, it is of the utmost importance to fix. Pulldash exists because GitHub's PR review is slow.
12+
- Tests should primarily occur at the data-layer, and the frontend should mostly dummily render the data.
13+
14+
## Testing
15+
16+
Tests should be minimal, not conflict with each other, and not be race-prone.
17+
18+
Good:
19+
20+
- `import { test } from "bun:test"`
21+
22+
Bad:
23+
24+
- `import { it } from "bun:test"`
25+
- Any form of timing-based test (e.g. `setTimeout`, `setImmediate`, etc)
26+
- Deep nesting of tests

src/browser/components/file-header.tsx

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
import { Check, FileCode, ChevronLeft, ChevronRight } from "lucide-react";
1+
import {
2+
Check,
3+
FileCode,
4+
ChevronLeft,
5+
ChevronRight,
6+
Columns2,
7+
AlignJustify,
8+
} from "lucide-react";
29
import { cn } from "../cn";
310
import { Keycap } from "../ui/keycap";
411
import type { PullRequestFile } from "@/api/types";
512
import { memo } from "react";
13+
import type { DiffViewMode } from "../contexts/pr-review";
614

715
interface FileHeaderProps {
816
file: PullRequestFile;
@@ -12,6 +20,8 @@ interface FileHeaderProps {
1220
totalFiles?: number;
1321
onPrevFile?: () => void;
1422
onNextFile?: () => void;
23+
diffViewMode?: DiffViewMode;
24+
onToggleDiffViewMode?: () => void;
1525
}
1626

1727
export const FileHeader = memo(function FileHeader({
@@ -22,6 +32,8 @@ export const FileHeader = memo(function FileHeader({
2232
totalFiles,
2333
onPrevFile,
2434
onNextFile,
35+
diffViewMode,
36+
onToggleDiffViewMode,
2537
}: FileHeaderProps) {
2638
const fileStatusBadge = (() => {
2739
switch (file.status) {
@@ -92,19 +104,55 @@ export const FileHeader = memo(function FileHeader({
92104
)}
93105
</div>
94106

95-
<button
96-
onClick={onToggleViewed}
97-
className={cn(
98-
"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors shrink-0",
99-
isViewed
100-
? "bg-green-500/20 text-green-500 hover:bg-green-500/30"
101-
: "bg-muted hover:bg-muted/80 text-muted-foreground"
107+
<div className="flex items-center gap-2">
108+
{/* Split/Unified toggle */}
109+
{onToggleDiffViewMode && (
110+
<div className="flex items-center rounded-md border border-border bg-muted/30 p-0.5">
111+
<button
112+
onClick={() =>
113+
diffViewMode !== "unified" && onToggleDiffViewMode()
114+
}
115+
className={cn(
116+
"flex items-center gap-1 px-2 py-1 text-xs rounded transition-colors",
117+
diffViewMode === "unified"
118+
? "bg-background text-foreground shadow-sm"
119+
: "text-muted-foreground hover:text-foreground"
120+
)}
121+
title="Unified view"
122+
>
123+
<AlignJustify className="w-3.5 h-3.5" />
124+
<span className="hidden sm:inline">Unified</span>
125+
</button>
126+
<button
127+
onClick={() => diffViewMode !== "split" && onToggleDiffViewMode()}
128+
className={cn(
129+
"flex items-center gap-1 px-2 py-1 text-xs rounded transition-colors",
130+
diffViewMode === "split"
131+
? "bg-background text-foreground shadow-sm"
132+
: "text-muted-foreground hover:text-foreground"
133+
)}
134+
title="Split view"
135+
>
136+
<Columns2 className="w-3.5 h-3.5" />
137+
<span className="hidden sm:inline">Split</span>
138+
</button>
139+
</div>
102140
)}
103-
>
104-
<Check className={cn("w-4 h-4", isViewed && "text-green-500")} />
105-
{isViewed ? "Viewed" : "Mark as viewed"}
106-
<Keycap keyName="v" size="xs" className="ml-1" />
107-
</button>
141+
142+
<button
143+
onClick={onToggleViewed}
144+
className={cn(
145+
"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors shrink-0",
146+
isViewed
147+
? "bg-green-500/20 text-green-500 hover:bg-green-500/30"
148+
: "bg-muted hover:bg-muted/80 text-muted-foreground"
149+
)}
150+
>
151+
<Check className={cn("w-4 h-4", isViewed && "text-green-500")} />
152+
{isViewed ? "Viewed" : "Mark as viewed"}
153+
<Keycap keyName="v" size="xs" className="ml-1" />
154+
</button>
155+
</div>
108156
</div>
109157
);
110158
});

src/browser/components/pr-overview.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import {
6969
type ReactionContent,
7070
type TimelineEvent,
7171
type ReviewThread,
72+
type PullRequest,
7273
} from "../contexts/github";
7374
import { useCanWrite } from "../contexts/auth";
7475
import { useTelemetry } from "../contexts/telemetry";
@@ -208,7 +209,7 @@ export const PROverview = memo(function PROverview() {
208209
(run: { conclusion: string | null }) =>
209210
run.conclusion === "action_required"
210211
)
211-
.map((run: { id: number; name: string; html_url: string }) => ({
212+
.map((run: { id: number; name?: string | null; html_url: string }) => ({
212213
id: run.id,
213214
name: run.name || "Workflow",
214215
html_url: run.html_url,
@@ -1017,7 +1018,7 @@ export const PROverview = memo(function PROverview() {
10171018
key={`comment-${comment.id}`}
10181019
user={comment.user}
10191020
createdAt={comment.created_at}
1020-
body={comment.body}
1021+
body={comment.body ?? null}
10211022
reactions={reactions[`comment-${comment.id}`]}
10221023
onAddReaction={
10231024
canWrite

0 commit comments

Comments
 (0)