fix(web,mobile): CSV previews keep a literal leading BOM character in the first cell #45854
main fromrefs/pull/45854/head·opened View on GitHubProblem#
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.readFilecontents →ThreadFilesRouteScreen→parseDelimitedPreview - web/desktop,
data.csvas a small chat attachment or workspace table:DelimitedTablePreview→LargeTextViewertext→ first-screen parse andlargeText.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
LargeTextViewerfirst-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 contentsid,name\r\n1,A. Same base failure.largeText.worker.test.ts: rawsrcbytesEF BB BF+id,name…and decodedtextid,name…must page identically. Base passes the raw-byte case and fails the decoded-text case withid.vp run check:changedpasses on headcd108f03073: 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
DelimitedFilePreviewand check the rows the screen passes to it; the real renderer passes each cell unchanged to selectableText. - No screenshots, because U+FEFF has no width and looks the same in both.
- The web first-screen paint (
LargeTextViewerfirstScreen) 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
- 2
Pusheda075698
juliusmarminge added labelstakeover:blocked
juliusmarminge removed labelstakeover:in-progress
Sign in to join this conversation.
The automated pipeline stopped on this pull request and will not merge it:
the proof was not accepted:
signatureflag 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.It stays open for a person to finish or close.