The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 24, 09:00 UTC
refactor(mobile): remove obsolete native diff token stream (#10062)
Julius Marminge committed
Sep 5, 2026 at 01:50 UTC
d524eb96936090bd2b8a96449784155ad4af9591
2 files changed
+1
-106
apps/mobile/src/features/diffs/nativeReviewDiffHighlighter.test.ts
+1
-22
@@ -2,11 +2,7 @@ import { afterEach, describe, expect, it, vi } from "vite-plus/test";
2
3
import type { NativeReviewDiffRow } from "./nativeReviewDiffSurface";
4
import type { NativeReviewDiffFile } from "./nativeReviewDiffTypes";
5
-import {
6
- highlightNativeReviewDiffVisibleRows,
7
- streamNativeReviewDiffTokens,
8
- type NativeReviewDiffTokenChunk,
9
-} from "./nativeReviewDiffHighlighter";
5
+import { highlightNativeReviewDiffVisibleRows } from "./nativeReviewDiffHighlighter";
6
7
const tokenization = vi.hoisted(() => ({
8
calls: [] as string[],
@@ -340,21 +336,4 @@ describe.each(["native", "javascript"] as const)("%s highlighting budgets", (eng
336
expect(result.rowCount).toBe(0);
337
expect(result.tokensByRowId).toEqual({});
338
});
343
-
344
- it("applies the same long-line guard to streamed token chunks", async () => {
345
- const content = "x".repeat(10_000);
346
- const chunks: NativeReviewDiffTokenChunk[] = [];
347
-
348
- await streamNativeReviewDiffTokens({
349
- rows: [line(1, content)],
350
- files: [TYPESCRIPT_FILE],
351
- scheme: "dark",
352
- engine,
353
- onChunk: (chunk) => chunks.push(chunk),
354
- });
355
-
356
- expect(chunks).toHaveLength(1);
357
- expect(chunks[0]?.tokensByRowId["line-1"]).toEqual([{ content, color: null, fontStyle: null }]);
358
- expect(tokenization.calls).toHaveLength(0);
359
- });
339
});
apps/mobile/src/features/diffs/nativeReviewDiffHighlighter.ts
-84
@@ -65,26 +65,6 @@ interface IndexedNativeReviewDiffLineRow {
65
readonly rowIndex: number;
66
}
67
68
-export interface NativeReviewDiffTokenChunk {
69
- readonly chunkIndex: number;
70
- readonly fileId: string;
71
- readonly filePath: string;
72
- readonly language: NativeReviewDiffLanguage;
73
- readonly lineCount: number;
74
- readonly durationMs: number;
75
- readonly tokensByRowId: Record<string, ReadonlyArray<NativeReviewDiffToken>>;
76
-}
77
-
78
-export interface StreamNativeReviewDiffTokenInput {
79
- readonly rows: ReadonlyArray<NativeReviewDiffRow>;
80
- readonly files: ReadonlyArray<NativeReviewDiffFile>;
81
- readonly scheme: NativeReviewDiffHighlightScheme;
82
- readonly engine?: NativeReviewDiffHighlightEngine;
83
- readonly chunkSize?: number;
84
- readonly signal?: AbortSignal;
85
- readonly onChunk: (chunk: NativeReviewDiffTokenChunk) => void;
86
-}
87
-
68
export interface HighlightNativeReviewDiffVisibleRowsInput {
69
readonly rows: ReadonlyArray<NativeReviewDiffRow>;
70
readonly files: ReadonlyArray<NativeReviewDiffFile>;
@@ -98,7 +78,6 @@ export interface HighlightNativeReviewDiffVisibleRowsInput {
78
readonly signal?: AbortSignal;
79
}
80
101
-const NATIVE_REVIEW_DIFF_HIGHLIGHT_CHUNK_SIZE = 500;
81
const NATIVE_REVIEW_DIFF_VISIBLE_OVERSCAN_ROWS = 160;
82
const NATIVE_REVIEW_DIFF_VISIBLE_MAX_ROWS = 360;
83
const NATIVE_REVIEW_DIFF_TOKENIZE_MAX_LINE_LENGTH = 1_000;
@@ -423,20 +402,6 @@ function canShareGrammarContext(
402
);
403
}
404
426
-function groupLineRowsByFileId(rows: ReadonlyArray<NativeReviewDiffRow>) {
427
- const rowsByFileId = new Map<string, NativeReviewDiffLineRow[]>();
428
- for (const row of rows) {
429
- if (!isHighlightableLineRow(row)) {
430
- continue;
431
- }
432
-
433
- const fileRows = rowsByFileId.get(row.fileId) ?? [];
434
- fileRows.push(row);
435
- rowsByFileId.set(row.fileId, fileRows);
436
- }
437
- return rowsByFileId;
438
-}
439
-
405
function createFileMap(files: ReadonlyArray<NativeReviewDiffFile>) {
406
return new Map(files.map((file) => [file.id, file]));
407
}
@@ -561,52 +526,3 @@ export async function highlightNativeReviewDiffVisibleRows(
526
durationMs: Math.round(performance.now() - startedAt),
527
};
528
}
564
-
565
-export async function streamNativeReviewDiffTokens(
566
- input: StreamNativeReviewDiffTokenInput,
567
-): Promise<NativeReviewDiffHighlightEngine> {
568
- const highlighter = await getNativeReviewDiffHighlighter(input.engine ?? "native");
569
- const rowsByFileId = groupLineRowsByFileId(input.rows);
570
- const theme = NATIVE_REVIEW_DIFF_THEME_NAME_BY_SCHEME[input.scheme];
571
- const chunkSize = input.chunkSize ?? NATIVE_REVIEW_DIFF_HIGHLIGHT_CHUNK_SIZE;
572
- let chunkIndex = 0;
573
-
574
- for (const file of input.files) {
575
- const fileRows = rowsByFileId.get(file.id) ?? [];
576
- for (let startIndex = 0; startIndex < fileRows.length; startIndex += chunkSize) {
577
- if (input.signal?.aborted) {
578
- return highlighter.engine;
579
- }
580
-
581
- const startedAt = performance.now();
582
- const chunkRows = fileRows.slice(startIndex, startIndex + chunkSize);
583
- const code = chunkRows.map((row) => row.content).join("\n");
584
- const tokenLines = await highlighter.tokenize(code, {
585
- lang: file.language,
586
- theme,
587
- signal: input.signal,
588
- });
589
- if (input.signal?.aborted) return highlighter.engine;
590
- const tokensByRowId: Record<string, ReadonlyArray<NativeReviewDiffToken>> = {};
591
-
592
- chunkRows.forEach((row, rowIndex) => {
593
- tokensByRowId[row.id] = tokenLines[rowIndex] ?? makePlainTokenFallback(row);
594
- });
595
-
596
- input.onChunk({
597
- chunkIndex,
598
- fileId: file.id,
599
- filePath: file.path,
600
- language: file.language,
601
- lineCount: chunkRows.length,
602
- durationMs: Math.round(performance.now() - startedAt),
603
- tokensByRowId,
604
- });
605
-
606
- chunkIndex += 1;
607
- await waitForNextFrame();
608
- }
609
- }
610
-
611
- return highlighter.engine;
612
-}