Repository navigation
Description
Problem
A .csv file opens as raw text: csv sits in textExtensions and falls through to the text preview kind (files.ts:49,75), which the README documents as designed ("a .csv opens as text"). But CSV is the most common plain-data interchange format a reader imports — exports, logs, datasets — and as raw text it wraps or scrolls sideways with no column alignment, no way to scan a row, and no sheet tabs.
The asymmetry is sharper because the product already owns the right machinery: the spreadsheet grid (xlsx-reader, virtualized rows, sheet tabs, column letters) and the assistant's structure-aware sheet tools (features/agent/xlsx/ — sheet inventory with extents, read by A1 range) both consume the same Worksheet[] model from core/xlsx.ts. An xlsx gets all of that; a csv gets neither — the assistant reads it as flat lines with no range tools, and the human reads wrapped commas.
Proposal
- Parse CSV into the existing
Worksheet[]model (comma-delimited UTF-8, BOM tolerated, quoted and multiline fields per RFC 4180) and map it to the spreadsheet grid preview. - Keep CSV's current editing capability: unlike xlsx (read-only by nature), CSV today is an editable text document with a Source panel — the grid must not remove it. Give CSV the preview-plus-Source shape SVG already has.
- Degrade safely: a CSV that fails structured parsing (odd encodings, exotic delimiters) falls back to today's text preview rather than an error.
- The assistant's sheet tools apply to CSV workbooks unchanged, since they already operate on
Worksheet[].
Goal
After this, importing a CSV opens the same grid an xlsx gets — sheet tab, aligned columns, row numbers — with Source editing preserved and the assistant reading sheets and ranges instead of flat text; unparsable files still open as text.
Verification
grep -q "extension === 'csv'" ui-packages/web/src/core/files.ts
pnpm --filter @gamma-reader/web test --silent
pnpm checkRefs
- ui-packages/web/src/core/files.ts:49,75 — csv in
textExtensions, falls totextkind - ui-packages/web/src/features/reader/xlsx-reader/index.tsx — existing grid consuming
Worksheet[] - ui-packages/web/src/features/agent/xlsx/tools.ts — sheet tools consuming the same model
- ui-packages/web/src/core/xlsx.ts —
readSpreadsheet/Worksheetto extend - README.md "Document support" — Excel row ("search, and read by sheet and A1 range") vs the csv-as-text note
Activity
bencode commentedon Sep 30, 2026
Independent review — posted by the scheduled issue-reviewer loop (a session separate from the one that files these issues), under the maintainer's standing instruction to evaluate, sharpen, or retire
source:scheduledproposals.Evidence audit (against
main@d28fe0b): core claims confirmed.csvsits intextExtensionsand falls through to thetextpreview kind (files.ts:49,75) — exactly as cited; README line 67 confirms "a.csvopens as text" is by design.readSpreadsheetreturnsWorksheet[](core/xlsx.ts:127), consumed by both the grid andfeatures/agent/xlsx/tools.TextDocumentWorkspace(text-document-workspace/index.tsx:49-64,sourceOpen/synchronizeSource).lintpassed;verifyfails today as it should → stays open.Verdict: valid, keep open. Strong asymmetry argument (the machinery exists and serves xlsx only), and the safe-degrade clause is well chosen.
One factual correction (should be fixed, non-blocking): the Proposal says "Give CSV the preview-plus-Source shape SVG already has" — SVG has no such shape.
svgroutes to theimagepreview kind (files.ts:46) andimage-reader.tsxhas no Source wiring; the preview-plus-Source shape belongs to text documents viaTextDocumentWorkspace. Since CSV is currently a text document, the correct precedent is "the shape text documents already have" (which is also what "Source editing preserved" in the Goal actually requires). The sentence as written points an implementer at the wrong template.bencode commentedon Sep 30, 2026
Correction to my earlier review above. I flagged "the preview-plus-Source shape SVG already has" as a factual error, citing that
svgroutes to theimagepreview kind with no Source wiring. That was wrong:files.tsrouting is overridden at the tab level —document-tabs.tsx:42-50gives.svga dedicatedTextReaderDefinition(SvgReaderpreview +sourceLanguage: 'plain'), which is exactly the preview-plus-Source shape. The issue's sentence stands as written; the rest of my audit (including the verdict: valid, keep open) is unaffected. An implementer can use the SVG reader definition as the template the issue implies.bencode commentedon Oct 1, 2026
Close audit — posted by the scheduled issue-reviewer loop (independent of the authoring session), under the maintainer's standing instruction to maintain
source:scheduledproposals.Auto-closed by the merge of #51 (
7108d78), bypassing the relay close gate. Audit atmain@fe2c123:core/csv.ts— quoted/multiline fields, BOM, CRLF, plus delimiter sniffing for;/\texports the proposal never asked for),CsvReaderreusing the grid via the extracted sharedsheet-grid.tsx, and Source editing preserved through theTextReaderDefinitionshape (document-tabs.tsx:44,53). Safe degrade shipped asisTabular— a single-column file (prose named.csv) falls back to text reading. README note updated (f393022).extension === 'csv'incore/files.ts, but the implementation routed at the tab level (the same pattern SVG uses) and never touchedfiles.ts—csvstill sits intextExtensions. The gate would have refused a correct close. Recording this as the concrete failure mode of implementation-shaped anchors: the goal was met by a different, equally defensible route.Action: added
state:needs-verificationto normalize the lifecycle. Maintainer: swap tostate:verifiedafter opening a CSV in person (grid + Source + a semicolon-delimited export if handy), or reopen if it misses.