Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web,mobile): CSV previews keep a literal leading BOM character in the first cell #45854

Opensaphid(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/45854/headopened View on GitHub

Problem

CSV/TSV table previews drop a literal U+FEFF at the start of the first cell. Every table source first decodes the file: TextDecoder in decodeFilePreviewText, in the server's projects.readFile, in fetch().text(), or in the web worker's own byte read. That consumes the UTF-8 file signature, and then parseDelimitedPreview strips a second U+FEFF by default. The web/desktop worker also re-encodes decoded text input and strips it once more when reading pages back.

Deterministic repro on origin/main (c16ad0ce179d46c0ae335e6547e81d1cc3522fda): create the fixtures in a scratch project:

python3 -c "import zipfile; b=b'\xef\xbb\xbf\xef\xbb\xbfid,name\r\n1,A'; open('data.csv','wb').write(b); zipfile.ZipFile('data.zip','w').writestr('data.csv', b)"

Open each in its table view (use Show table if the source view is showing):

  • mobile, data.zip → data.csv: ZipEntryView → decodeFilePreviewText → parseDelimitedPreview
  • mobile, workspace data.csv: projects.readFile contents → ThreadFilesRouteScreen → parseDelimitedPreview
  • web/desktop, data.csv as a small chat attachment or workspace table: DelimitedTablePreview → LargeTextViewer text → first-screen parse and largeText.worker

Assert on the first header cell's code points, because U+FEFF has no width:

  • Observed: U+0069 U+0064 (id), although the decoded source still starts with U+FEFF.
  • Expected: U+FEFF U+0069 U+0064. The file signature is consumed once and the literal character stays in the cell, matching the source view.

Change

Callers that parse already-decoded text now pass stripBom: false:

  • mobile ZIP entries, attachment documents and workspace files
  • the web LargeTextViewer first-screen parse

The web worker records whether it got raw bytes (src) or decoded text. It skips the byte-level signature, and lets TextDecoder drop it, only for raw bytes. So a fetched file loses its signature exactly once, and decoded text keeps its content. The worker test that treated a leading U+FEFF in text as a file signature now expects it to stay content, because every caller passes decoded text there.

Scope

Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.

Verification

Regression tests, each red on base source and green on head:

  • ZipArchiveView.test.tsx: a real stored-ZIP fixture with the bytes above. Base result: expected [ [ 'id', 'name' ], [ '1', 'A' ] ] to deeply equal [ [ 'id', 'name' ], [ '1', 'A' ] ].
  • ThreadFilesRouteScreen.test.tsx: decoded workspace contents id,name\r\n1,A. Same base failure.
  • largeText.worker.test.ts: raw src bytes EF BB BF + id,name… and decoded text id,name… must page identically. Base passes the raw-byte case and fails the decoded-text case with id.
  • vp run check:changed passes on head cd108f03073: format, lint, knip, typecheck (3 packages), tests (3 files), React Compiler (5 files).

Evidence gist with the byte-to-table code points (base U+0069 U+0064, head U+FEFF U+0069 U+0064), every base failure and the full check:changed summary: https://gist.github.com/saphid/3887e00507e42a0e51c96a52272fd68e

Not shown:

  • No native clipboard or device run. The mobile tests mock DelimitedFilePreview and check the rows the screen passes to it; the real renderer passes each cell unchanged to selectable Text.
  • No screenshots, because U+FEFF has no width and looks the same in both.
  • The web first-screen paint (LargeTextViewer firstScreen) and mobile attachment documents (useAttachmentDocument) have no test of their own. Each is the same one-option change on text that was already decoded.

Authored by Claude Opus 5.5 (Model Hub); reviewed by GPT-6.2 Sol (Codex).

Not shown

  • apps/web/src/components/files/LargeTextViewer.tsx:317 — The worker regression test verifies row data, not the browser’s rendered header after the first-screen-to-worker handoff or selection/copy behavior. Those browser outputs were not exercised.
  • apps/mobile/src/features/files/ZipArchiveView.test.tsx:328 — The ZIP fixture gives a deterministic repro, but no real-client scenarios:prove run captured the selected cell’s code points.
    1. Pusheda075698

    2. The automated pipeline stopped on this pull request and will not merge it:

      the proof was not accepted:

      • The stated bug and fix cover 'web/desktop and mobile previews', and the diff changes three mobile render paths: apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx (workspace CSV), ZipArchiveView.tsx (ZIP-entry CSV) and lib/attachmentDocument.ts (attachment CSV) all gain stripBom:false. No capture shows any mobile path on base or head. The capture's own 'unverified' list admits this. So the captures do not show the claim as stated.
      • The diff also changes web paths that no capture shows: LargeTextViewer.tsx firstScreen (stripBom:false) and the raw-byte branch of largeText.worker.ts (the new signature flag on the streaming decoder and on the byte-skip). Web chat-attachment CSV was not exercised either. Only the web workspace CSV path with already-decoded text is shown.
      • What the captures do show (the web workspace path) is sound. Base 001 and head 001 match in viewport (1280x800), theme (light), data and steps. The table looks identical on both because U+FEFF is invisible, so the defect shows only through a scenario-injected DOM inspector overlay, not through anything the app draws. It counts as wrong data, and the app contradicts itself: on base, its own Copy contents keeps U+FEFF while the table header drops it.
      • Minor: both 001 stills lack the '1 row · 2 columns · 1 KB' status line that 002-failure.png and the video frames show. The stills were taken right after switching back to table mode. This is the same on both sides, so it does not affect the comparison.
      • I did not rebuild the 'after' capture myself.

      It stays open for a person to finish or close.

    3. juliusmarminge added labelstakeover:blocked

    4. juliusmarminge removed labelstakeover:in-progress

Sign in to join this conversation.