Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

feat(views): show PR diff counts on the sidebar row again (MUL-9997) (#11402)

Jiayuan Zhangb009b192c746
diff --git a/apps/docs/content/docs/github-integration.fr.mdx b/apps/docs/content/docs/github-integration.fr.mdx
index 2932aa15f1..1c4e296f57 100644
--- a/apps/docs/content/docs/github-integration.fr.mdx
+++ b/apps/docs/content/docs/github-integration.fr.mdx
@@ -90,7 +90,7 @@ Une fois associées, les PR apparaissent dans le bloc **Pull requests** du déta
- le dépôt, le numéro, le titre et l'auteur ;
- l'état `Ouverte`, `Brouillon`, `Fusionnée` ou `Fermée` ;
-- le nombre de lignes ajoutées et supprimées, et le nombre de fichiers modifiés, au survol de la ligne ;
+- le nombre de lignes ajoutées et supprimées, juste après le numéro, par exemple `#19 · +48 −12` ; le nombre de fichiers modifiés s'affiche au survol de la ligne ;
- le statut CI : toutes les vérifications ont réussi (avec leur nombre), certaines sont en échec (avec le nom des vérifications concernées) ou certaines sont en cours ; les PR sans vérification configurée n'affichent pas cet élément, et « aucune vérification » n'est jamais considéré comme une réussite ;
- la possibilité de fusion : « Prête à fusionner » (uniquement lorsque GitHub signale un état de fusion propre), « Conflits de fusion », « Bloquée » ou « En retard sur la base ».
diff --git a/apps/docs/content/docs/github-integration.ja.mdx b/apps/docs/content/docs/github-integration.ja.mdx
index 0db070d5e1..6c051988e1 100644
--- a/apps/docs/content/docs/github-integration.ja.mdx
+++ b/apps/docs/content/docs/github-integration.ja.mdx
@@ -88,7 +88,7 @@ Resolves MUL-123
- リポジトリ、番号、タイトル、作成者
- `Open`、`Draft`、`Merged`、`Closed` の状態
-- 追加行数、削除行数、変更ファイル数(行にカーソルを合わせると表示)
+- 追加行数と削除行数(番号のすぐ後ろ。例: `#19 · +48 −12`)。変更ファイル数は行にカーソルを合わせると表示
- CI の状態: すべて成功した check の件数、失敗した check の名前、実行中の check の件数。check が 1 つも設定されていない PR ではこの項目を表示せず、「check なし」を成功として扱いません。
- マージ可能性: GitHub がマージ状態を clean と報告した場合だけマージ可能。ほかに競合、blocked、behind を表示します。
diff --git a/apps/docs/content/docs/github-integration.ko.mdx b/apps/docs/content/docs/github-integration.ko.mdx
index dcf979669b..fb07a02adf 100644
--- a/apps/docs/content/docs/github-integration.ko.mdx
+++ b/apps/docs/content/docs/github-integration.ko.mdx
@@ -88,7 +88,7 @@ Resolves MUL-123
- 저장소, 번호, 제목, 작성자
- `Open`, `Draft`, `Merged`, `Closed` 상태
-- 추가 및 삭제한 줄 수와 변경한 파일 수(행에 마우스를 올리면 표시)
+- 번호 바로 뒤의 추가 및 삭제한 줄 수(예: `#19 · +48 −12`). 변경한 파일 수는 행에 마우스를 올리면 표시
- CI 상태: 모두 통과(개수 표시), 일부 실패(실패한 check 이름 표시), 일부 진행 중. 설정된 check가 없는 PR에는 이 항목을 표시하지 않으며 "check 없음"을 통과로 간주하지 않습니다.
- merge 가능 여부: merge 가능(GitHub가 merge 상태를 clean으로 보고한 경우만), conflict 있음, blocked, behind
diff --git a/apps/docs/content/docs/github-integration.mdx b/apps/docs/content/docs/github-integration.mdx
index e770b5caf1..7279ca17a4 100644
--- a/apps/docs/content/docs/github-integration.mdx
+++ b/apps/docs/content/docs/github-integration.mdx
@@ -90,7 +90,7 @@ Once linked, PRs appear in the **Pull requests** block of issue detail. Each ent
- repository, number, title, and author;
- `Open`, `Draft`, `Merged`, or `Closed` state;
-- added and deleted lines and the number of changed files, when you hover the row;
+- added and deleted lines after the number, such as `#19 · +48 −12`; hover the row for the number of changed files;
- CI status: all passed (with a count), some failed (naming the failing checks), or some in progress; PRs with no checks configured don't show this item, and "no checks" is never treated as passing;
- mergeability: mergeable (only when GitHub reports a clean merge state), conflicting, blocked, or behind.
diff --git a/apps/docs/content/docs/github-integration.zh-Hant.mdx b/apps/docs/content/docs/github-integration.zh-Hant.mdx
index 8e8d0f5cb8..e285726516 100644
--- a/apps/docs/content/docs/github-integration.zh-Hant.mdx
+++ b/apps/docs/content/docs/github-integration.zh-Hant.mdx
@@ -90,7 +90,7 @@ Resolves MUL-123
- 倉庫、編號、標題和作者;
- `Open`、`Draft`、`Merged` 或 `Closed` 狀態;
-- 新增、刪除行數和改動檔案數(懸停這一列時顯示);
+- 新增、刪除行數,緊跟在編號後面,例如 `#19 · +48 −12`;改動檔案數在懸停這一列時顯示;
- CI 狀態:全部透過(帶計數)、若干個失敗(點名失敗的 check),或若干個進行中;沒有配置任何 check 的 PR 不顯示這一項,"沒有 check"不會被當成透過;
- 可合併性:可合併(僅當 GitHub 報告合併狀態為 clean)、有衝突、blocked 或 behind。
diff --git a/apps/docs/content/docs/github-integration.zh.mdx b/apps/docs/content/docs/github-integration.zh.mdx
index 1b5c683cb5..0048940314 100644
--- a/apps/docs/content/docs/github-integration.zh.mdx
+++ b/apps/docs/content/docs/github-integration.zh.mdx
@@ -90,7 +90,7 @@ Resolves MUL-123
- 仓库、编号、标题和作者;
- `Open`、`Draft`、`Merged` 或 `Closed` 状态;
-- 新增、删除行数和改动文件数(悬停这一行时显示);
+- 新增、删除行数,紧跟在编号后面,例如 `#19 · +48 −12`;改动文件数在悬停这一行时显示;
- CI 状态:全部通过(带计数)、若干个失败(点名失败的 check),或若干个进行中;没有配置任何 check 的 PR 不显示这一项,"没有 check"不会被当成通过;
- 可合并性:可合并(仅当 GitHub 报告合并状态为 clean)、有冲突、blocked 或 behind。
diff --git a/packages/views/issues/components/pull-request-list.test.tsx b/packages/views/issues/components/pull-request-list.test.tsx
index 5b007a368f..0f0f5c7c76 100644
--- a/packages/views/issues/components/pull-request-list.test.tsx
+++ b/packages/views/issues/components/pull-request-list.test.tsx
@@ -329,7 +329,7 @@ describe("PullRequestList sidebar rows", () => {
await waitForRender();
expect(screen.getByText("#42")).toBeInTheDocument();
expect(screen.getByText("#43")).toBeInTheDocument();
- expect(screen.queryByText("widget#42")).not.toBeInTheDocument();
+ expect(screen.queryByText("widget")).not.toBeInTheDocument();
});
it("shows the repo and number without the owner when the PRs span repos", async () => {
@@ -339,23 +339,51 @@ describe("PullRequestList sidebar rows", () => {
];
renderList();
await waitForRender();
- expect(screen.getByText("widget#42")).toBeInTheDocument();
- expect(screen.getByText("gadget#7")).toBeInTheDocument();
+ const [a, b] = screen.getAllByTestId("pull-request-row");
+ expect(a).toHaveTextContent("widget#42");
+ expect(b).toHaveTextContent("gadget#7");
+ expect(screen.queryByText(/acme\//)).not.toBeInTheDocument();
+ });
+
+ it("truncates only the repo name, never the number", async () => {
+ mockPRs = [
+ makePR({ id: "a", number: 42 }),
+ makePR({ id: "b", number: 7, repo_name: "gadget" }),
+ ];
+ renderList();
+ await waitForRender();
+ expect(screen.getByText("widget")).toHaveClass("truncate");
+ expect(screen.getByText("#42")).toHaveClass("shrink-0");
});
it("hides the diff size when all stats are 0 (legacy backend)", async () => {
mockPRs = [makePR()];
renderList();
await waitForRender();
+ expect(screen.queryByTestId("pull-request-diff")).not.toBeInTheDocument();
expect(screen.queryByText(/^\+0/)).not.toBeInTheDocument();
});
- it("leaves the diff size to the tooltip", async () => {
+ it("shows the diff size after the number, compacted and coloured", async () => {
mockPRs = [makePR({ additions: 6743, deletions: 6, changed_files: 119 })];
renderList();
await waitForRender();
- expect(screen.getByTestId("pull-request-row")).not.toHaveTextContent("+6.7k");
- expect(screen.queryByText("−6")).not.toBeInTheDocument();
+ const diff = screen.getByTestId("pull-request-diff");
+ expect(diff).toHaveClass("shrink-0");
+ expect(within(diff).getByText("+6.7k")).toHaveClass("text-success");
+ expect(within(diff).getByText("−6")).toHaveClass("text-destructive");
+ expect(screen.getByTestId("pull-request-row")).not.toHaveTextContent("119 files");
+ });
+
+ it.each([
+ ["checks are running", { checks_rollup: "pending" as const, checks_total: 4, checks_running: 2 }],
+ ["the snapshot is stale", { snapshot_stale: true, snapshot_fetched_at: new Date(Date.now() - 3_600_000).toISOString() }],
+ ["the PR is merged", { state: "merged" as const, merged_at: new Date(Date.now() - 3_600_000).toISOString() }],
+ ])("keeps the diff size while %s", async (_, overrides) => {
+ mockPRs = [makePR({ additions: 48, deletions: 12, ...overrides })];
+ renderList();
+ await waitForRender();
+ expect(within(screen.getByTestId("pull-request-diff")).getByText("+48")).toBeInTheDocument();
});
// --- Collapse behaviour --------------------------------------------------
diff --git a/packages/views/issues/components/pull-request-list.tsx b/packages/views/issues/components/pull-request-list.tsx
index 8a0b6d617d..7754e76b9a 100644
--- a/packages/views/issues/components/pull-request-list.tsx
+++ b/packages/views/issues/components/pull-request-list.tsx
@@ -22,6 +22,7 @@ import {
import {
issuePullRequestsOptions,
derivePullRequestVerdict,
+ formatPullRequestDiffCount,
shouldShowPullRequestStats,
stripIssueKeyFromTitle,
useLinkIssuePullRequest,
@@ -450,12 +451,27 @@ function PullRequestRow({
{stripIssueKeyFromTitle(pr.title, identifier)}
</p>
<div className="mt-1 flex items-center gap-2">
- {/* The number and the pill never yield. Everything after the dot
- is one unit: short of room, it wraps whole onto the clipped
- second line instead of being cut mid-word. */}
+ {/* The number, the diff and the pill never yield; short of room,
+ only the repo name truncates. The trailing meta is one unit:
+ it wraps whole onto the clipped second line instead of being
+ cut mid-word. */}
<p className="flex h-lh min-w-0 flex-1 flex-wrap items-center gap-x-1.5 overflow-hidden whitespace-nowrap text-caption text-muted-foreground tabular-nums">
- <span className="min-w-0 truncate">
- {showRepo ? pr.repo_name : null}#{pr.number}
+ <span className="inline-flex min-w-0 items-center gap-1.5">
+ <span className="inline-flex min-w-0 items-center">
+ {showRepo ? <span className="min-w-0 truncate">{pr.repo_name}</span> : null}
+ <span className="shrink-0">#{pr.number}</span>
+ </span>
+ {showStats ? (
+ <span data-testid="pull-request-diff" className="inline-flex shrink-0 items-center gap-1.5">
+ <span aria-hidden="true" className="text-faint-foreground">
+ ·
+ </span>
+ <span className="inline-flex items-center gap-1">
+ <span className="text-success">+{formatPullRequestDiffCount(pr.additions ?? 0)}</span>
+ <span className="text-destructive">−{formatPullRequestDiffCount(pr.deletions ?? 0)}</span>
+ </span>
+ </span>
+ ) : null}
</span>
{meta ? (
<span className="inline-flex min-w-0 items-center gap-1.5">