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
2 changes: 1 addition & 1 deletion src-tauri/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ pub(crate) async fn get_github_pull_requests(
"--limit",
"50",
"--json",
"number,title,url,updatedAt,headRefName,baseRefName,isDraft,author",
"number,title,url,updatedAt,body,headRefName,baseRefName,isDraft,author",
])
.current_dir(&repo_root)
.output()
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pub(crate) struct GitHubPullRequest {
pub(crate) url: String,
#[serde(rename = "updatedAt")]
pub(crate) updated_at: String,
pub(crate) body: String,
#[serde(rename = "headRefName")]
pub(crate) head_ref_name: String,
#[serde(rename = "baseRefName")]
Expand Down
1 change: 1 addition & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,7 @@ function MainApp() {
gitPullRequestsLoading,
gitPullRequestsError,
selectedPullRequestNumber: selectedPullRequest?.number ?? null,
selectedPullRequest: diffSource === "pr" ? selectedPullRequest : null,
onSelectPullRequest: handleSelectPullRequest,
gitRemoteUrl,
gitRoot: activeGitRoot,
Expand Down
53 changes: 53 additions & 0 deletions src/features/git/components/GitDiffViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { FileDiff, WorkerPoolContextProvider } from "@pierre/diffs/react";
import type { FileDiffMetadata } from "@pierre/diffs";
import { parsePatchFiles } from "@pierre/diffs";
import { workerFactory } from "../../../utils/diffsWorker";
import type { GitHubPullRequest } from "../../../types";
import { formatRelativeTime } from "../../../utils/time";
import { Markdown } from "../../messages/components/Markdown";

type GitDiffViewerItem = {
path: string;
Expand All @@ -16,6 +19,7 @@ type GitDiffViewerProps = {
selectedPath: string | null;
isLoading: boolean;
error: string | null;
pullRequest?: GitHubPullRequest | null;
onActivePathChange?: (path: string) => void;
};

Expand Down Expand Up @@ -110,6 +114,7 @@ export function GitDiffViewer({
selectedPath,
isLoading,
error,
pullRequest,
onActivePathChange,
}: GitDiffViewerProps) {
const containerRef = useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -215,12 +220,60 @@ export function GitDiffViewer({
};
}, [diffs, onActivePathChange, rowVirtualizer]);

const prUpdatedLabel = pullRequest?.updatedAt
? formatRelativeTime(new Date(pullRequest.updatedAt).getTime())
: null;
const prAuthor = pullRequest?.author?.login ?? "unknown";
const prBody = pullRequest?.body?.trim() ?? "";

return (
<WorkerPoolContextProvider
poolOptions={poolOptions}
highlighterOptions={highlighterOptions}
>
<div className="diff-viewer" ref={containerRef}>
{pullRequest && (
<section className="diff-viewer-pr" aria-label="Pull request summary">
<div className="diff-viewer-pr-header">
<div className="diff-viewer-pr-title">
<span className="diff-viewer-pr-number">
#{pullRequest.number}
</span>
<span className="diff-viewer-pr-title-text">
{pullRequest.title}
</span>
</div>
<div className="diff-viewer-pr-meta">
<span className="diff-viewer-pr-author">@{prAuthor}</span>
{prUpdatedLabel && (
<>
<span className="diff-viewer-pr-sep">·</span>
<span>{prUpdatedLabel}</span>
</>
)}
<span className="diff-viewer-pr-sep">·</span>
<span className="diff-viewer-pr-branch">
{pullRequest.baseRefName} ← {pullRequest.headRefName}
</span>
{pullRequest.isDraft && (
<span className="diff-viewer-pr-pill">Draft</span>
)}
</div>
</div>
<div className="diff-viewer-pr-body">
{prBody ? (
<Markdown
value={prBody}
className="diff-viewer-pr-markdown markdown"
/>
) : (
<div className="diff-viewer-pr-empty">
No description provided.
</div>
)}
</div>
</section>
)}
{!error && stickyEntry && (
<div className="diff-viewer-sticky">
<div className="diff-viewer-header diff-viewer-header-sticky">
Expand Down
2 changes: 2 additions & 0 deletions src/features/layout/hooks/useLayoutNodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ type LayoutNodesOptions = {
gitPullRequestsLoading: boolean;
gitPullRequestsError: string | null;
selectedPullRequestNumber: number | null;
selectedPullRequest: GitHubPullRequest | null;
onSelectPullRequest: (pullRequest: GitHubPullRequest) => void;
gitRemoteUrl: string | null;
gitRoot: string | null;
Expand Down Expand Up @@ -513,6 +514,7 @@ export function useLayoutNodes(options: LayoutNodesOptions): LayoutNodesResult {
selectedPath={options.selectedDiffPath}
isLoading={options.gitDiffLoading}
error={options.gitDiffError}
pullRequest={options.selectedPullRequest}
onActivePathChange={options.onDiffActivePathChange}
/>
);
Expand Down
96 changes: 96 additions & 0 deletions src/styles/diff-viewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,102 @@
padding-top: 0;
}

.diff-viewer-pr {
margin: 12px 16px 16px;
padding: 16px;
border-radius: 14px;
border: 1px solid var(--border-subtle);
background: color-mix(in srgb, var(--surface-strong) 84%, transparent);
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

.diff-viewer-pr-header {
display: flex;
flex-direction: column;
gap: 10px;
}

.diff-viewer-pr-title {
display: flex;
flex-wrap: wrap;
gap: 8px;
font-size: 18px;
font-weight: 600;
color: var(--text-strong);
}

.diff-viewer-pr-number {
color: var(--text-faint);
font-variant-numeric: tabular-nums;
}

.diff-viewer-pr-title-text {
color: var(--text-stronger);
}

.diff-viewer-pr-meta {
display: flex;
flex-wrap: wrap;
gap: 8px;
align-items: center;
font-size: 12px;
color: var(--text-muted);
}

.diff-viewer-pr-author {
color: var(--text-strong);
font-weight: 600;
}

.diff-viewer-pr-sep {
color: var(--text-faint);
}

.diff-viewer-pr-branch {
font-family: "SFMono-Regular", "Menlo", "Monaco", monospace;
font-size: 11px;
padding: 2px 6px;
border-radius: 999px;
border: 1px solid var(--border-subtle);
background: var(--surface-control);
color: var(--text-quiet);
}

.diff-viewer-pr-pill {
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
padding: 2px 6px;
border-radius: 999px;
background: rgba(242, 153, 74, 0.16);
color: #f2994a;
border: 1px solid rgba(242, 153, 74, 0.4);
}

.diff-viewer-pr-body {
margin-top: 12px;
padding-top: 12px;
border-top: 1px solid var(--border-subtle);
}

.diff-viewer-pr-markdown {
font-size: 13px;
color: var(--text-stronger);
}

.diff-viewer-pr-markdown :where(h1, h2, h3, h4, h5, h6) {
margin-top: 16px;
}

.diff-viewer-pr-markdown :where(p, ul, ol, pre) {
margin-top: 10px;
}

.diff-viewer-pr-empty {
font-size: 13px;
color: var(--text-muted);
}

.diff-viewer-list {
position: relative;
width: 100%;
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export type GitHubPullRequest = {
title: string;
url: string;
updatedAt: string;
body: string;
headRefName: string;
baseRefName: string;
isDraft: boolean;
Expand Down