Skip to content

fix(preview): keep BOM-prefixed CSV headers aligned - #356

Closed
AksharP5 wants to merge 1 commit into
thisisgm:mainfrom
AksharP5:fix/csv-bom-headers
Closed

AksharP5 wants to merge 1 commit into
thisisgm:mainfrom
AksharP5:fix/csv-bom-headers

Conversation

@AksharP5

@AksharP5 AksharP5 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

CSV files with a UTF-8 BOM can show values under the wrong headers in Columns preview and Quick Look. A quoted comma splits the first header into two columns; a quoted newline turns part of the header into a data row.

Skip the BOM when the backend finds record boundaries and when the frontend parses the first physical line. Raw protocol lines and U+FEFF in later windows stay intact. The same correction covers TSV and the direct-text preview.

Fixes #355.

For the issue's exact files, in both previews:

File from the issue Before After
comma.csv Three columns; 10 appears under full"; Amount is blank Two columns; 10 appears under Amount
multiline.csv Header continuation becomes row 1; Alice is row 2; count is 2 Header stays together; Alice is row 1; count is 1

The invisible BOM is omitted from the table's before values. These results were checked against the rendered Text items using the shipped preview components and real backend, with identical inputs and settings.

Validation on f21789e5:

  • New regression checks fail on the baseline and pass with the fix.
  • cargo test --locked backend::codereq: 33 passed.
  • ./tests/js.sh csv: 96 checks, zero failures, including retention of U+FEFF at a later window.
  • Existing ./tests/csv-preview.sh: 307 checks, zero failures.
  • Matched offscreen reproduction: 14 checks fail before, all 14 pass after.
  • cargo build --locked, file-budget gate and git diff --check pass.
  • The Clippy gate fails identically on baseline and patch under Rust 1.99.0: the existing fetch_update deprecation in copyread.rs, tracked by Deprecation warning: fetch_update renamed to try_update in src/backend/copyread.rs #334. All 79 finding counts are unchanged.
  • The commit-message checker rejects the contributor identity because it requires GM; the commit retains my configured authorship. Its message checks otherwise pass.

The full repository suite and native compositor interaction were not rerun.

Summary by CodeRabbit

  • Bug Fixes
    • CSV and TSV files with a UTF-8 BOM at the beginning now parse headers without adding an extra column, keeping body cells aligned.
    • BOM bytes remain in returned raw lines, and BOMs on later rows are preserved as cell text.
    • Added coverage for quoted and multiline headers with comma and tab separators.
  • Documentation
    • Clarified how initial UTF-8 BOMs are handled when parsing CSV requests.

Ignore the initial UTF-8 BOM in record and cell parsing so quoted
headers retain their columns and multiline records in both previews.
Keep raw protocol lines and later U+FEFF characters unchanged.
Fixes thisisgm#355.
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 02ca84eb-855d-43bc-ae0d-0f5cbd30b939
📥 Commits

Reviewing files that changed from the base of the PR and between f21789e and 585bb80.

📒 Files selected for processing: 4
  • docs/protocol.md
  • src/backend/csvrange.rs
  • tests/js/csv.js
  • ui/js/Csv.js

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

The backend scanner and frontend table parser now ignore a UTF-8 BOM at the start of a CSV or TSV file. Tests cover quoted headers, multiline headers, and BOM content on a later windowed row. The protocol documentation states that raw lines retain the BOM.

Changes: CSV and TSV BOM parsing

Layer / File(s) Summary
Backend record scanning
src/backend/csvrange.rs
align skips a leading UTF-8 BOM before scanning. Tests cover multiline quoted headers with comma and tab separators, including record counts and first-record ordinals.
Frontend parsing and protocol description
ui/js/Csv.js, tests/js/csv.js, docs/protocol.md
table removes a leading BOM from the first line of the initial block. Tests cover quoted CSV and TSV headers and confirm that a BOM on a later windowed row remains cell text. The protocol documentation states that raw lines retain the BOM.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: thisisgm

Merge Risk: ⚪ Minimal · up to 585bb

No actionable merge-blocking risk is identified in the reviewed change.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the primary change: preserving alignment for BOM-prefixed CSV headers in the preview.
Linked Issues check Passed Issue [#355] requires BOM-prefixed CSV/TSV previews to keep quoted headers together in Columns preview and Quick Look, while preserving later U+FEFF text and raw protocol lines. The change skips the i…
Out of Scope Changes check Passed The changes are limited to the BOM parsing correction, its protocol documentation, and focused regression tests in tests/js/csv.js. These changes directly support issue [#355]. No unrelated product …
Docstring Coverage Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. (1 skipped: 1 u…
Full details: Linked Issues check

Explanation

Issue [#355] requires BOM-prefixed CSV/TSV previews to keep quoted headers together in Columns preview and Quick Look, while preserving later U+FEFF text and raw protocol lines. The change skips the initial BOM in src/backend/csvrange.rs and ui/js/Csv.js. Regression tests cover quoted comma and multiline headers, TSV, direct table parsing, body alignment, later-window U+FEFF retention, and raw-line retention. The reported preview checks and backend tests pass.

Full details: Out of Scope Changes check

Explanation

The changes are limited to the BOM parsing correction, its protocol documentation, and focused regression tests in tests/js/csv.js. These changes directly support issue [#355]. No unrelated product behavior or unrelated files are reported.

Full details: Docstring Coverage

Explanation

Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

🔧 Biome (2.5.15)
tests/js/csv.js

File contains syntax errors that prevent linting: Line 1: Expected a statement but instead found '.'.; Line 1: Expected a semicolon or an implicit semicolon after a statement, but found none; Line 1: Expected a semicolon or an implicit semicolon after a statement, but found none

ui/js/Csv.js

File contains syntax errors that prevent linting: Line 1: Expected a statement but instead found '.pragma library

.'.; Line 3: Expected a semicolon or an implicit semicolon after a statement, but found none; Line 3: Expected a semicolon or an implicit semicolon after a statement, but found none

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thisisgm

thisisgm commented Nov 3, 2026

Copy link
Copy Markdown
Owner

A UTF-8 BOM could split quoted CSV or TSV headers. CSV and TSV previews keep quoted headers aligned after a UTF-8 byte-order mark (da4dac2121, v0.4.0). Thanks @AksharP5! Release.

@thisisgm thisisgm closed this Nov 3, 2026
Jarmoco pushed a commit to Jarmoco/flea that referenced this pull request Nov 6, 2026
Brings the contributor head 585bb80 onto the integration base;
the reviewed correction follows in its own commit.

Co-authored-by: AksharP5 <[email protected]>
Jarmoco pushed a commit to Jarmoco/flea that referenced this pull request Nov 6, 2026
Treat the leading byte-order mark as a file prefix in CSV and TSV previews,
covering quoted and multiline headers while later marks stay cell text.
The QML half and protocol note of PR thisisgm#356 stay as v0.3.12 shipped them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CSV/TSV previews split quoted headers after a UTF-8 BOM

2 participants