Skip to content

feat(csv-viewer): detect semicolon-separated CSVs - #19894

Merged
nwparker merged 9 commits into
stablyai:mainfrom
kbsali:feat/csv-viewer-semicolon-delimiter
Oct 4, 2026
Merged

nwparker merged 9 commits into
stablyai:mainfrom
kbsali:feat/csv-viewer-semicolon-delimiter

Conversation

@kbsali

@kbsali kbsali commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Semicolon-separated CSV files render as columns, and you can choose the separator when automatic detection guesses wrong. Decimal values such as 1,50 stay in one cell.

What Changed

The viewer offers Auto, Comma, Semicolon, and Tab in its footer. Auto shows the detected separator. An explicit choice bypasses detection and the .tsv extension rule, using the existing parser and virtualized table.

For ambiguous headerless data such as 1,50;coffee\n2,75;tea, Auto still guesses comma. Choosing Semicolon displays the decimal values and labels in separate columns. Quoted separators, escaped quotes, and multiline fields retain their values. The choice affects the view and leaves the file bytes intact. It stays selected through content refreshes while that viewer is mounted; a newly mounted file starts in Auto.

The bounded consistency scanner now follows the parser's rule for opening a quoted field. A literal quote in 6" bolts therefore stays literal instead of hiding later commas and rows from detection. Five matching English labels are declared in the existing catalog.

Why

Some text is valid under more than one separator, so automatic detection cannot always infer the author's intent. Keeping Auto as the default and offering an explicit choice resolves those cases through the existing Label and Select components. The consistency scanner uses the existing parser's quote rule and retains its existing record and scan limits.

Linked Issue

Context: #19893. This continues @kbsali's contribution in #19894.

Visual Proof

The delimiter choice menu is shown open below at current head 88b1915. It offers Auto, Comma, Semicolon and Tab. Auto displays the detected separator; selecting Semicolon explicitly overrides automatic detection. These fresh hidden Electron captures use the same file and viewport, with the three-column table unchanged behind the menu. The rendered check verifies all four choices and both checkmarks.

Auto selected Semicolon selected manually
Open delimiter menu with Auto selected Open delimiter menu with Semicolon selected

Fresh hidden Electron screenshots on macOS, captured through Playwright CDP at the same 1280×800 viewport. Before uses main snapshot 8cd9751963b3046e8393f2007c9104a56a63fa84; after uses current 88b19155af379d7f7c2370c5009bcf36b2fdc101. Both show the identical european-sales.csv file bytes. The baseline displays one column containing semicolons; the current viewer automatically displays Product, Quantity and RevenueEUR as three columns.

Before: one column After: automatic semicolon detection
Baseline semicolon file displayed as one column Current viewer detects three semicolon-separated columns

The following pair shows the new choice on the same final branch, rather than another pre-change baseline. For the unchanged 1,50;coffee\n2,75;tea file, Auto guesses Comma. Choosing Semicolon preserves 1,50 and 2,75 as complete cell values.

Auto: comma guess After choosing Semicolon
Auto comma guess splits the decimal values Manual semicolon selection preserves decimal commas

Both fresh hidden-app tests passed with no retries. Each screenshot follows exact table assertions and two completed animation frames. File bytes, source and compiled output stayed unchanged; the two owned apps exited and disposable profiles were removed.

Earlier additional rendered cases remain available: quoted multiline values, comma override for a misnamed TSV, and literal quotes with Auto.

Testing

  • Manually tested locally in a hidden Electron renderer through Playwright CDP.
  • Automated tests added/updated.

45 focused tests pass: 40 parser/detection controls and five actual viewer/selector tests. Literal-quote comma and tab cases fail before the scanner repair. Three private mutations independently demonstrate that the boundary/EOF tests catch unsafe partial-record corroboration.

The freshly rebuilt native rendered test passes all four file cases using the real virtualized table and keyboard-operated selector. It asserts exact headers/cells, switches back to Auto, checks that fixture files retain their exact bytes, and confirms every Electron window stays hidden.

Localization extraction, catalog validation, coverage, Node/CLI/renderer typechecks, lint, formatting, and changed-code quality pass. Validation uses existing installed tools directly with ORCA_BACKGROUND_LAUNCH=1; native dependencies retain their bytes and modification times.

Rerun focused tests:

ORCA_BACKGROUND_LAUNCH=1 node node_modules/vitest/vitest.mjs run --config config/vitest.config.ts src/renderer/src/components/editor/csv-parse.test.ts src/renderer/src/components/editor/CsvViewer.delimiter.test.tsx

AI Disclosure

Original contribution assisted by Claude Opus 5 via Claude Code, as disclosed by @kbsali. Follow-up adaptation and validation assisted by Codex.

Review

Independent review covered the selector, five catalog entries, and scanner repair at their exact committed versions. The original contribution and its author/coauthor metadata remain in the branch history. The earlier literal-quote and weak-boundary review findings are addressed by this follow-up.

Agent skill upstream boundary

  • Not applicable; no agent skill code is changed.

Notes

Auto remains a guess for inherently ambiguous data. A manual choice lasts while the viewer remains mounted; it is not a persistent per-file preference. Existing first-row-as-header behavior remains. Native rendered validation covers macOS; Linux and Windows rendered checks were not run locally.

Required CI passes for the current head. All six feature files match the actual CI checkout. The preceding catalog failure was reproduced and repaired; earlier CI results remain historical.

Checklist

  • Small and focused.
  • ELI5, user-visible behavior, mechanism, and alternatives explained.
  • Rendered comparison and additional screenshots attached.
  • Self-review and independent source review completed.
  • Cross-platform, folder workspace, and SSH implications considered.
  • Current-head required CI complete.

@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1293d677-5a61-485d-af5d-8b178b08f47a
📥 Commits

Reviewing files that changed from the base of the PR and between f07f384 and 0100448.

📒 Files selected for processing (3)
  • src/renderer/src/components/editor/CsvViewer.delimiter.test.tsx
  • src/renderer/src/components/editor/CsvViewer.tsx
  • src/renderer/src/components/editor/csv-delimiter-picker.tsx

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


📝 Walkthrough

Walkthrough

The CSV delimiter detector now counts semicolons alongside commas and tabs. When semicolons exceed both, it checks up to eight records for consistent existing comma or tab columns. If the counts are consistent and semicolon counts vary, it retains the existing delimiter; otherwise, it selects semicolon. CsvViewer adds automatic and manual delimiter selection. Tests cover detection, parsing, and viewer selection behavior.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 01004

Some comma-delimited files containing literal quotes can display incorrectly in Auto mode. Readers can select Comma manually, so this is a bounded issue that can be accepted for merge with a follow-up fix.

Architecture Summary

Architecture risk: 🟡 Medium · up to 96147

The change affects 1 system.

Changed systems: src

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (ui) was modified; 2 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in src/renderer/src/components/editor/csv-parse.test.ts: Adds tests expecting semicolon detection for decimal-comma exports and verifies parsing preserves decimal commas and quoted commas.
  • observed — Modified behavior in src/renderer/src/components/editor/csv-parse.test.ts: Adds delimiter-detection expectations for semicolons inside quoted fields, tab-over-semicolon precedence, .tsv files, existing comma/tab precedence cases, and semicolon detection after a BOM and whitespace-only lines.
  • observed — Modified behavior in src/renderer/src/components/editor/csv-parse.test.ts: Adds a parsing test for semicolon-delimited input containing a BOM, escaped quotes, a quoted separator, and an embedded newline; expects two columns and preserved field contents.
  • observed — Modified behavior in src/renderer/src/components/editor/csv-parse.test.ts: Adds expectations for comma and tab detection when semicolons occur as field content, semicolon detection despite varying unquoted comma counts, ignoring punctuation in multiline quoted fields, and retaining first-line inference for ambiguous or ragged rows.

Reliability and maintainability

  • inferred — Risk-relevant change factors for src: blast_radius_1; direct_dependents_1
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: semicolon-separated CSV detection in the CSV viewer.
Description check ✅ Passed The description covers the required sections, links the related issue, provides visual proof and testing details, and completes the relevant checklist items.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed detectCsvDelimiter gaining a semicolon candidate and four new tests covering the sniffing behavior.

  • Semicolon sniffing — adds a semicolons count and a branch returning ; only when semicolons strictly beat commas and at least tie tabs, preserving comma as the RFC 4180 default and every prior tab/comma outcome for semicolon-free files.
  • Tests — four new cases: a semicolon export with comma decimals (asserting both delimiter and parsed rows), semicolons confined to quotes not winning, tab dominating semicolon, and the .tsv short-circuit.

The tie-break is deliberate and defensible: ; ties/beats tab because a semicolon export can carry tabs inside cells while a TSV rarely carries semicolons, and detection reads only the first non-empty line. I ran vitest run src/renderer/src/components/editor/csv-parse.test.ts locally — 19/19 pass — and the toBe(';') assertion is a genuine regression guard (it fails against the pre-PR implementation). The added pass is bounded by CSV_DELIMITER_SNIFF_SCAN_CODE_UNITS and uses index access, so the existing charCodeAt budget and no-split guarantees still hold.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@kbsali

kbsali commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

up

kbsali and others added 2 commits October 2, 2026 04:56
Spreadsheet apps running a comma-decimal locale export `;` as the list
separator, so a large share of real-world CSVs are semicolon-separated.
The viewer only sniffed tab vs comma, so those files rendered as a single
column of raw text.

Add semicolon as a third sniffing candidate. A candidate only wins when it
strictly beats comma, so comma remains the RFC 4180 default on ties and for
files with no delimiter at all, and existing tab/comma behaviour is
unchanged. Semicolon is checked ahead of tab because a semicolon export can
legitimately contain tabs inside cells, while a TSV rarely contains
semicolons. The `.tsv` extension still short-circuits to tab.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ByGxbX82uLxMRhKHUBxz8h
Require semicolons to strictly outnumber both commas and tabs on the
bounded first non-empty line. Keep the existing precedence on ties and
reuse quote-aware counting and the existing delimiter-parameterized parser.

Cover decimal commas, quoted separators, escaped quotes, embedded newlines,
BOM and leading blanks, extension overrides, ties and scan limits. Record
the unavoidable ambiguity of comma headers containing unquoted semicolons.

Adapted from Kevin Saliou (kbsali) in PR stablyai#19894; the preceding commit retains
his original authorship and coauthor credit.
@nwparker
nwparker force-pushed the feat/csv-viewer-semicolon-delimiter branch from 8d26d30 to 5bd8103 Compare October 2, 2026 12:06

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Re-reviewed the commits landed since pullfrog's previous review (8d26d30). The delta is the semicolon tie-break rework plus a substantially expanded test suite.

  • Tab ties preserved — detectCsvDelimiter now returns ; only when semicolons strictly outnumber tabs (> was >=), so a first line where semicolons and tabs tie keeps the pre-PR tab choice; the strategy comment was condensed to match.
  • Precedence table — a new it.each covers six comma/tab/semicolon combinations, including a;b\tc pinned to \t, locking in the tab-tie behavior.
  • Edge coverage — added cases for escaped quotes inside a quoted field, .TSV case-insensitivity, BOM/leading whitespace-only lines, quoted separators with escaped quotes and embedded newlines, the ambiguous unquoted-semicolon header, and the first-line scan boundary.

I reran pnpm test src/renderer/src/components/editor/csv-parse.test.ts — 29/29 pass — and traced countDelimiterOutsideQuotes against the new tie cases by hand; the strict > comparison matches every table row. Reversing the earlier >= rationale is deliberate and documented in the PR body, and the tab-tie row is now a genuine regression guard for it.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Check a bounded sample before overriding an existing delimiter with semicolons. Keep the first-line choice when the sample remains ambiguous, and preserve TSV handling.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fd56129f-92d6-49bf-89fa-e929ba4c7f04
📥 Commits

Reviewing files that changed from the base of the PR and between 613e117 and 96147a9.

📒 Files selected for processing (2)
  • src/renderer/src/components/editor/csv-parse.test.ts
  • src/renderer/src/components/editor/csv-parse.ts

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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — minor suggestions inline.

Reviewed changes

Re-reviewed the two commits pushed since the prior pullfrog review (5bd8103): a behavior change to the semicolon tie-break plus substantially expanded coverage.

  • Consistent-column corroboration — when semicolons strictly win the first line, detectCsvDelimiter now scans up to eight logical records and keeps the existing comma/tab choice if those columns are consistent while semicolon counts vary, so a comma header carrying stray semicolons (notes;one;two,value) no longer flips the parse to ;.
  • Tests — replaced the ambiguous-header expectation and added cases for consistent comma/tab columns, varying unquoted commas, a multiline quoted field, the 8-record corroboration cap, the scan boundary, and CRLF plus escaped quotes/quoted newline.

The two findings below are low-stakes; I ran the file (36/36 pass) and reproduced both against the checked-out branch.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The new delimiter picker references five localization keys that are not declared in en.json, so this head fails the required localization checks.

Reviewed changes

Re-reviewed the commit pushed since pullfrog's prior review (96147a9): a manual delimiter picker layered on the existing semicolon detection.

  • Delimiter picker — added csv-delimiter-picker.tsx, a Select over Auto / Comma / Semicolon / Tab that shows the currently detected delimiter in the Auto label.
  • Viewer state — CsvViewer now holds the choice in local state and parses with either the detected or the explicitly chosen delimiter; a different file remounts (via the caller's existing key={activeFile.id}) and resets to Auto.
  • Interaction tests — five happy-dom cases: ambiguous decimal data, quoted multiline records, a .tsv forced to comma, choice persistence across a content refresh, and reset on file identity change.

I confirmed this commit leaves csv-parse.ts and parseCsv untouched, verified tc:web and the new test file pass, and reproduced the localization-gate failure locally. The two earlier inline threads remain open and unchanged, so they are not re-raised.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker requested a review from brennanb2025 as a code owner October 4, 2026 02:11

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found — the prior localization blocker is resolved.

Reviewed changes

Re-reviewed the commit pushed since pullfrog's prior review (0100448): a catalog-only follow-up that declares the picker's English strings.

  • English delimiter labels — added the five delimiter* keys under auto.components.editor.CsvViewer in en.json, completing the labels csv-delimiter-picker.tsx already references and clearing the required localization check.
  • No code surface — the follow-up touches only en.json; every picker, parser, and test byte is unchanged from 0100448.

I confirmed pnpm run verify:localization-catalogs and pnpm run verify:localization-extraction both pass at this head, and oxfmt --check is clean on the file. The two earlier inline threads (hasConsistentExistingCsvColumns quote model, the non-falsifiable boundary case) remain open and were not touched by this follow-up, so they are not re-raised.

Pullfrog  | Fix it ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Re-reviewed the commit pushed since pullfrog's prior review (b52dc5f): a fix that aligns the delimiter scanner's quote handling with parseCsv, plus the boundary coverage called out in the prior review.

  • Scanner quote model — hasConsistentExistingCsvColumns now tracks fieldIsEmpty and opens a quoted field only at field start, matching parseCsv's field === '' rule, so a literal quote in an unquoted field (6" bolts) no longer hides later commas and records from corroboration.
  • Literal-quote coverage — a new keeps literal quotes inside unquoted %j fields case asserts both the detected delimiter and the parsed rows for comma and tab; it fails when the quote rule is reverted to an unconditional toggle.
  • Boundary / EOF guards — the existing quoted-boundary case now seeds the unfinished record with a pre-quote comma (plain,") so it is falsifiable, and two cases (partial unquoted record at the scan boundary, unfinished quoted record at EOF) were added. All three fail when the flush guard is dropped.

I ran the focused suite at this head — 45/45 pass — plus tc:web, and confirmed each new guard by mutation. Both earlier inline threads (scanner quote model, non-falsifiable boundary case) are addressed and resolved.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit f62bd7d into stablyai:main Oct 4, 2026
32 checks passed
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.

2 participants