authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-09-05 01:23:45-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-05 01:23:45-07:00
logc059d09b9b585d0c9562527e338e2f95cd2220f0
tree3bc4050c90da0c685cda7e13c36421b34b33c713
parent07fb04dc63694876b531a7bb5492a72b8282009d
signature Signed by PGP key B5690EEEBB952194

refactor(mobile): remove obsolete review list builder (#10039)


2 files changed, 0 insertions(+), 191 deletions(-)

apps/mobile/src/features/review/reviewModel.test.ts-81
......@@ -8,7 +8,6 @@ import {
88} from "@t3tools/contracts";
99
1010import {
11 buildReviewListItems,
1211 buildReviewParsedDiff,
1312 buildReviewSectionItems,
1413 getDefaultReviewSectionId,
......@@ -271,84 +270,4 @@ describe("buildReviewParsedDiff", () => {
271270 actionLabel: "Load diff",
272271 });
273272 });
274
275 it("flattens expanded file rows into virtualized review items", () => {
276 const file = makeRenderableFile({
277 path: "apps/mobile/src/a.ts",
278 rows: [
279 {
280 kind: "hunk",
281 id: "hunk-1",
282 header: "@@ -1,1 +1,2 @@",
283 context: null,
284 },
285 {
286 kind: "line",
287 id: "line-1",
288 change: "add",
289 oldLineNumber: null,
290 newLineNumber: 1,
291 content: "const after = 2;",
292 additionTokenIndex: 0,
293 deletionTokenIndex: null,
294 comparison: null,
295 },
296 ],
297 });
298
299 const items = buildReviewListItems({
300 files: [file],
301 expandedFileIds: [file.id],
302 revealedLargeFileIds: [],
303 });
304
305 expect(items).toEqual([
306 expect.objectContaining({ kind: "file-header", fileId: file.id, expanded: true }),
307 expect.objectContaining({
308 kind: "hunk",
309 fileId: file.id,
310 file,
311 row: file.rows[0],
312 }),
313 expect.objectContaining({
314 kind: "line",
315 fileId: file.id,
316 file,
317 row: file.rows[1],
318 lineIndex: 0,
319 }),
320 ]);
321 });
322
323 it("keeps large diffs collapsed into a placeholder item until revealed", () => {
324 const file = makeRenderableFile({
325 path: "apps/mobile/src/big.ts",
326 rows: Array.from({ length: 401 }, (_, index) => ({
327 kind: "line" as const,
328 id: `line-${index}`,
329 change: "add" as const,
330 oldLineNumber: null,
331 newLineNumber: index + 1,
332 content: `const line${index} = ${index};`,
333 additionTokenIndex: index,
334 deletionTokenIndex: null,
335 comparison: null,
336 })),
337 });
338
339 const items = buildReviewListItems({
340 files: [file],
341 expandedFileIds: [file.id],
342 revealedLargeFileIds: [],
343 });
344
345 expect(items).toEqual([
346 expect.objectContaining({ kind: "file-header", fileId: file.id, expanded: true }),
347 expect.objectContaining({
348 kind: "file-suppressed",
349 fileId: file.id,
350 actionLabel: "Load diff",
351 }),
352 ]);
353 });
354273});
apps/mobile/src/features/review/reviewModel.ts-110
......@@ -58,45 +58,6 @@ export interface ReviewRenderableFile {
5858 readonly rows: ReadonlyArray<ReviewRenderableRow>;
5959}
6060
61export interface ReviewFileHeaderListItem {
62 readonly kind: "file-header";
63 readonly id: string;
64 readonly fileId: string;
65 readonly file: ReviewRenderableFile;
66 readonly expanded: boolean;
67}
68
69export interface ReviewFileSuppressedListItem {
70 readonly kind: "file-suppressed";
71 readonly id: string;
72 readonly fileId: string;
73 readonly message: string;
74 readonly actionLabel: string | null;
75}
76
77export interface ReviewHunkListItem {
78 readonly kind: "hunk";
79 readonly id: string;
80 readonly fileId: string;
81 readonly file: ReviewRenderableFile;
82 readonly row: ReviewRenderableHunkRow;
83}
84
85export interface ReviewLineListItem {
86 readonly kind: "line";
87 readonly id: string;
88 readonly fileId: string;
89 readonly file: ReviewRenderableFile;
90 readonly row: ReviewRenderableLineRow;
91 readonly lineIndex: number;
92}
93
94export type ReviewListItem =
95 | ReviewFileHeaderListItem
96 | ReviewFileSuppressedListItem
97 | ReviewHunkListItem
98 | ReviewLineListItem;
99
10061export type ReviewFilePreviewState =
10162 | {
10263 readonly kind: "render";
......@@ -316,77 +277,6 @@ export function getReviewFilePreviewState(file: ReviewRenderableFile): ReviewFil
316277 return { kind: "render" };
317278}
318279
319// The flattened review list item model is inspired by pierre/diffs' iterator-first
320// virtualization architecture, adapted here for React Native virtualization.
321// Original project: https://github.com/pingdotgg/pierre/tree/main/packages/diffs
322// Reference files:
323// - src/utils/iterateOverDiff.ts
324// - src/components/VirtualizedFileDiff.ts
325export function buildReviewListItems(input: {
326 readonly files: ReadonlyArray<ReviewRenderableFile>;
327 readonly expandedFileIds: ReadonlyArray<string>;
328 readonly revealedLargeFileIds: ReadonlyArray<string>;
329}): ReadonlyArray<ReviewListItem> {
330 const expandedFileIds = new Set(input.expandedFileIds);
331 const revealedLargeFileIds = new Set(input.revealedLargeFileIds);
332 const items: ReviewListItem[] = [];
333
334 input.files.forEach((file) => {
335 const expanded = expandedFileIds.has(file.id);
336 items.push({
337 kind: "file-header",
338 id: `${file.id}:header`,
339 fileId: file.id,
340 file,
341 expanded,
342 });
343
344 if (!expanded) {
345 return;
346 }
347
348 const previewState = getReviewFilePreviewState(file);
349 if (previewState.kind === "suppressed") {
350 if (previewState.reason !== "large" || !revealedLargeFileIds.has(file.id)) {
351 items.push({
352 kind: "file-suppressed",
353 id: `${file.id}:suppressed`,
354 fileId: file.id,
355 message: previewState.message,
356 actionLabel: previewState.actionLabel,
357 });
358 return;
359 }
360 }
361
362 let lineIndex = 0;
363 file.rows.forEach((row, rowIndex) => {
364 if (row.kind === "hunk") {
365 items.push({
366 kind: "hunk",
367 id: `${file.id}:row:${rowIndex}:${row.id}`,
368 fileId: file.id,
369 file,
370 row,
371 });
372 return;
373 }
374
375 items.push({
376 kind: "line",
377 id: `${file.id}:row:${rowIndex}:${row.id}`,
378 fileId: file.id,
379 file,
380 row,
381 lineIndex,
382 });
383 lineIndex += 1;
384 });
385 });
386
387 return items;
388}
389
390280function fallbackHunkHeader(hunk: FileDiffMetadata["hunks"][number]): string {
391281 return `@@ -${hunk.deletionStart},${hunk.deletionCount} +${hunk.additionStart},${hunk.additionCount} @@`;
392282}