authorgravatar for maria@kuuro.netmaria <maria@kuuro.net> 2026-09-02 01:44:25-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-02 01:44:25-04:00
log0681d854994ec0ceed0562ae74549ccf8ef2ec41
treef7bb14a39612d9ff708b47111ff7cf4a6026b0f6
parent80a14b6588f0e856983e6d10002cde9e00e9d3e2
signature Signed by PGP key B5690EEEBB952194

fix(pull-requests): expand code tab diffs by default (#9174)

Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com>

2 files changed, 11 insertions(+), 12 deletions(-)

apps/web/src/components/pullRequest/pullRequestDiff.logic.test.ts+8-8
...@@ -50,9 +50,9 @@ describe("isLineInFileDiff", () => {...@@ -50,9 +50,9 @@ describe("isLineInFileDiff", () => {
50describe("isFileDiffCollapsed", () => {50describe("isFileDiffCollapsed", () => {
51 const NO_TOGGLES: ReadonlySet<string> = new Set();51 const NO_TOGGLES: ReadonlySet<string> = new Set();
5252
53 it("folds every file before the reader has touched anything", () => {53 it("opens every file before the reader has touched anything", () => {
54 expect(isFileDiffCollapsed("a.ts", null, NO_TOGGLES)).toBe(true);54 expect(isFileDiffCollapsed("a.ts", null, NO_TOGGLES)).toBe(false);
55 expect(isFileDiffCollapsed("b.ts", null, NO_TOGGLES)).toBe(true);55 expect(isFileDiffCollapsed("b.ts", null, NO_TOGGLES)).toBe(false);
56 });56 });
5757
58 it("opens every file once the toolbar has asked for it", () => {58 it("opens every file once the toolbar has asked for it", () => {
...@@ -66,12 +66,12 @@ describe("isFileDiffCollapsed", () => {...@@ -66,12 +66,12 @@ describe("isFileDiffCollapsed", () => {
66 expect(isFileDiffCollapsed("b.ts", "folded", NO_TOGGLES)).toBe(true);66 expect(isFileDiffCollapsed("b.ts", "folded", NO_TOGGLES)).toBe(true);
67 });67 });
6868
69 it("keeps a file the reader opened open as the next slice arrives", () => {69 it("keeps a file the reader folded closed as the next slice arrives", () => {
70 // The file keys grow with every slice, so the answer for one already open must not depend on70 // The file keys grow with every slice, so the answer for one already folded must not depend
71 // how many of them there are by then.71 // on how many of them there are by then.
72 const toggled = new Set(["b.ts"]);72 const toggled = new Set(["b.ts"]);
73 expect(isFileDiffCollapsed("b.ts", null, toggled)).toBe(false);73 expect(isFileDiffCollapsed("b.ts", null, toggled)).toBe(true);
74 expect(isFileDiffCollapsed("c.ts", null, toggled)).toBe(true);74 expect(isFileDiffCollapsed("c.ts", null, toggled)).toBe(false);
75 });75 });
7676
77 it("still answers to a toggle after either toolbar press", () => {77 it("still answers to a toggle after either toolbar press", () => {
apps/web/src/components/pullRequest/pullRequestDiff.logic.ts+3-4
...@@ -30,15 +30,14 @@ export type DiffFoldOverride = "expanded" | "folded" | null;...@@ -30,15 +30,14 @@ export type DiffFoldOverride = "expanded" | "folded" | null;
30 * A diff arrives a slice at a time, so the reader's own choices are kept as the difference from30 * A diff arrives a slice at a time, so the reader's own choices are kept as the difference from
31 * what the toolbar last said rather than as the set of folded files: a file that has not loaded31 * what the toolbar last said rather than as the set of folded files: a file that has not loaded
32 * yet cannot be in a set, and would otherwise land expanded moments after the reader folded32 * yet cannot be in a set, and would otherwise land expanded moments after the reader folded
33 * everything. Folded is the starting point whatever the change's size, because laying out every33 * everything. Files start expanded so opening the Code tab immediately shows the change; the
34 * file of it costs the reader the seconds before the tab is usable and buries the file they came34 * reader can still fold individual files or the whole diff from the toolbar.
35 * for among the ones they did not.
36 */35 */
37export function isFileDiffCollapsed(36export function isFileDiffCollapsed(
38 fileKey: string,37 fileKey: string,
39 foldOverride: DiffFoldOverride,38 foldOverride: DiffFoldOverride,
40 toggledFileKeys: ReadonlySet<string>,39 toggledFileKeys: ReadonlySet<string>,
41): boolean {40): boolean {
42 const foldedByDefault = foldOverride !== "expanded";41 const foldedByDefault = foldOverride === "folded";
43 return toggledFileKeys.has(fileKey) ? !foldedByDefault : foldedByDefault;42 return toggledFileKeys.has(fileKey) ? !foldedByDefault : foldedByDefault;
44}43}