From 1d4ebe0d9150bb54b7ac64173d0a6877e199d228 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Thu, 16 Jul 2026 17:12:47 -0700 Subject: [PATCH] fix(review): trim comments to AGENTS.md's one/two-line why-only rule Comments in mobile-diff-image-preview.ts and mobile-file-tab-doc.ts ran 3-6 lines and narrated mechanism instead of stating only the non-obvious reason, per AGENTS.md's "Code Comments: Document the Why, Briefly" rule. Co-authored-by: Orca --- mobile/src/files/mobile-diff-image-preview.ts | 15 ++++----------- mobile/src/files/mobile-file-tab-doc.ts | 5 ++--- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/mobile/src/files/mobile-diff-image-preview.ts b/mobile/src/files/mobile-diff-image-preview.ts index bb5908d7fca..ff98c31c108 100644 --- a/mobile/src/files/mobile-diff-image-preview.ts +++ b/mobile/src/files/mobile-diff-image-preview.ts @@ -1,10 +1,7 @@ import { buildImageDataUri } from '../../../src/shared/image-data-uri' -// A git.diff result for a binary file. The host (git.diff) already sends base64 -// image bytes plus isImage/mimeType for previewable formats, so mobile can render -// image diffs instead of falling back to "Binary preview unavailable". The -// originalIsBinary/modifiedIsBinary flags tell a deletion (modified side absent) -// apart from a modify whose bytes the host couldn't inline (relay/size-capped). +// originalIsBinary/modifiedIsBinary distinguish a genuine deletion from a modify +// whose bytes the host couldn't inline (relay/size-capped). export type MobileBinaryDiffResult = { kind: 'binary' originalContent?: string @@ -15,12 +12,8 @@ export type MobileBinaryDiffResult = { mimeType?: string } -// Builds a data URI for a binary image diff, preferring the modified (post-change) -// bytes. Only falls back to the original for a genuine deletion — when the modified -// side is absent (not binary). Returns null for non-previewable binaries and when -// the modified side IS a binary image but arrives empty (e.g. a relay working-tree -// read or a >size-cap file), since showing the pre-change image there would be -// silently stale rather than the current content. +// Falls back to the original bytes only for a genuine deletion; a size-capped/relay +// modify returns null instead of the stale pre-change image. export function mobileDiffImageDataUri(result: MobileBinaryDiffResult): string | null { if (result.isImage !== true) { return null diff --git a/mobile/src/files/mobile-file-tab-doc.ts b/mobile/src/files/mobile-file-tab-doc.ts index d4ed498afd2..78977b5fd30 100644 --- a/mobile/src/files/mobile-file-tab-doc.ts +++ b/mobile/src/files/mobile-file-tab-doc.ts @@ -21,9 +21,8 @@ export type MobileFileTabDocRequest = { diffSource?: 'staged' | 'unstaged' | 'branch' | 'commit' } -// Loads the previewable doc for a session file tab: git diffs (text or image), -// previewable images, HTML source, or plain text. Throws 'binary_file', -// 'file_too_large', or the RPC error message; callers map those to error docs. +// Throws 'binary_file'/'file_too_large'/the RPC error message; callers map those +// to error docs. export async function resolveMobileFileTabDoc( client: FileTabDocClient, request: MobileFileTabDocRequest