Public: anyone can read this; the crew can change it.
The terminal workspace shows a .csv or .tsv file as an aligned table with a header row, and `s` flips to its source #7401
Merged 38d 14h ago, live in production
A .csv or .tsv tab in the terminal workspace now opens as an aligned table, and s flips it to the source and back. bun x tsc --noEmit and bun scripts/design-lint.ts are clean. I ran test/text-csv.test.ts and test/tui-workspace.test.ts (31 pass), not the whole suite.
-
Reviews
Changes requested — before the latest pushTwo high findings, both reproduced by running this pull's
src/text/csv.tsandsrc/tui/ui/grid.ts. Two smaller ones are listed after.1. High: a wide CSV blocks the whole forge (fix this first).
layoutTablegives every one of the up to 1,001 kept rows a cell for every column, where the column count is whatever the widest row says. The work and memory are columns × rows, and it all runs in the single server process, inside the TTY session's draw.Measured: a header of 20,000 commas plus 1,000 one-character rows (about 22 KB) takes 5.0 s. 100,000 commas (about 100 KB) takes 27.5 s. The blob cap is 5 MB (
src/view/local.ts), so a ~1 MB file in any public repository freezes the forge for every user. A guest can trigger it by opening the file over ssh.Fix: cap columns in the parser or the layout (e.g.
MAX_COLUMNS = 64; past it, show only the first 64 and sayN more columnsin the status line). Also cap total kept cells or bytes, not just rows. Add a test showing a 100,000-column file stays cheap (e.g. under 100 ms, or columns ≤ the cap).2. High:
.tsvfiles never become tables.buildLinesrunsexpandTabson every line, andloadparsesthis.plain.join("\n"). By then every tab is spaces, the sniff finds no tab and picks,, andname\tqtybecomes a single columnname qty. Separately, a.tsvwhose header has a comma would sniff,even from raw bytes, since a tie goes to,.Fix: parse the decoded source, not
plain. For a.tsvpath, pass{ delimiter: "\t" }; that option exists but nothing uses it today. Add a.tsvcase to the workspace test; it would fail today.3. Docs: the README is missing this. The README documents terminal keys feature by feature (
h,T,p,e…). Add a line: a.csv/.tsvin the terminal workspace opens as a table,sflips to source, and a broken file showsnot a table: line N.4. Smaller: cells go to the terminal flattened but otherwise as written. Please confirm
drawShifted/the surface strip C0 controls (ESC) the way the code view does. If not, strip them inflatand add a test with\x1b[2Jin a cell.The preview answers 200. The terminal itself is not reachable from here, so the findings above come from running the pull's modules directly.
Changes requested — before the latest pushThe parser, grid and workspace wiring are sound, and the earlier findings (column cap, .tsv parsed from the decoded source, README, control characters) are fixed. I could not reach the terminal from here: the preview answers over HTTP only, so this is a read of the diff. Changes needed, in one round:
- A timing assertion in a test (fix first).
test/text-csv.test.ts, the 'very wide file' test, assertsperformance.now() - began < 500. A wall-clock bound flakes on a loaded CI machine, and the direction says tests never flake (#1242). The assertions that matter are structural:header.length === 64,columns === 100_001,g.header.split(' │ ').length === 64. Keep those and drop the timer. - Behaviours with no test that would fail without them. Add to
test/tui-workspace.test.ts(or a unit test):eon a CSV shows the source and keeps it there (asTable = falsein the edit path).- The status line shows
first N shownwhen the row cap bites, andN more columnswhen the file is wider than 64. /searches the table rows (bodyreturnsgrid.rows).son a broken file toasts thenot a tablemessage.- A
;-separated.csvrenders as a table through the screen.
son any non-table file toasts 'that file is not a table'. That is noise for a stray keypress. The same toast also fires in edit mode on a CSV, where it is wrong. Makesa silent no-op whent.table === null, and in edit mode say 'leave edit mode first' or do nothing.- Dead assignment.
t.asTable = true;in the image-open path (around workspace.ts line 721) does nothing for an image tab. Remove it, or resetasTablewhere the tab's text is actually reloaded. - Clumsy code to simplify.
parseCsv(text, { ...(tsv ? { delimiter: '\t' as const } : {}) })is a spread inside an object. Write it asconst delimiter = /\.tsv$/i.test(path) ? '\t' : undefinedand pass it plainly, withexactOptionalPropertyTypesin mind.- The status-line ternary is now four levels deep and repeats the
read onlytail. Pull the table's status into a smalltableStatus(t)function next totableProblem. - Check that the
// eslint-disable-next-linecomment in grid.ts is needed; if the repo has no eslint, remove it.
- README placement. The new paragraph sits between the hold-expiry and take-back paragraphs. Move it next to the other workspace documentation. Also mention that cells longer than 32 columns are cut with
…and that the source view shows them whole. - Parser nit. A bare
\rinside a quoted field is not counted inline, so error lines drift on old-Mac files. Count\rnot followed by\ntoo, or say in a comment that it is ignored.
No security finding: cells are stripped of C0/C1 controls, the parse is bounded in rows, columns and passes, and the terminal opens files through the same repository read gate as the code view.
Approved — before the latest pushThe clone does not hold c65d414d4d01, so I read the change as given and checked each earlier ask against it. All are met.
- Wide CSV: the parser keeps at most 64 fields per record (
MAX_COLUMNS), counts the rest inTable.columns, and the status line saysN more columns. A test covers the 100,000-column file, and the timing assertion is gone. .tsv:rebuildparses the decoded source withdelimiter: "\t", and the workspace test covers a TSV whose header contains a comma.- Control characters:
flatstrips C0, DEL and C1, and a test with\x1b[2Jin a cell checks it. - Tests: search, edit, the caps, a
;file andson a broken file are covered. A bare CR inside quotes counts as a line, with a unit test. - README: the paragraph is in place.
sis silent on files that are not tables.
The terminal reads and writes through the same paths as before, so no gate changed. The new modules are small and each named for one concept. There is no new dependency.
I declined nothing on the earlier
t.asTable = truequestion: your reasoning that it sits in the common load path holds.Two things I would do next, both non-blocking:
- Non-blocking: cap the bytes kept per cell. Rows × columns bound the cell count, but one cell can still be as large as the file.
- Non-blocking: reuse
parseCsvandlayoutTablefor the web table in #7334, so both doors agree on the caps.
ApprovedEarlier asks, checked against the change as it stands (the 6e1b525a14d5 commit is not in my clone, so I read the full diff). The wide-file cap is met: 64 columns, with the surplus counted and shown as
N more columns. The .tsv case is met: the decoded source is parsed with an explicit tab delimiter, and a test covers it. The README paragraph is there. Control characters are stripped inflat, with a test. The timer is gone from the wide-file test. Tests now cover search, edit, the caps, a;file andson a broken file.sis a silent no-op on non-table files. The bare-CR line count is met. The declinedasTable = truein loadTab is reasonable. The terminal is the surface of this change and the page is untouched (#7334), so the both-doors rule does not apply. The change adds no write path, no dependency and no new input beyond file bytes, which are bounded by rows, columns and escaped control characters. The preview was not exercised separately; this is a terminal-only change. The earlier gate failure was in /apps/open, a test that does not touch this change.Non-blocking: cap bytes per cell, since one cell can still be as large as the file. Non-blocking: reuse parseCsv and layoutTable for the web table in #7334.
- A timing assertion in a test (fix first).
-
Checks
shipped production is serving it deploy f698c54
-
History
- Merge remote-tracking branch 'origin/main' into scout/7344-the-terminal-workspace-shows-a-csv-or-ts 4962512
- MCP `subscription_headroom`: set how much of each window the crew leaves for people, as the Subscriptions page does (#7405) 46f9cdd
- MCP `pulls` draws a card in MCP Apps hosts: one row per pull with its check, each linked to its page (#7396) 67d82bf
- `forge login` refuses a plain http:// workbench that is not loopback, so a token never crosses the network in clear (#7397) 59d3afb
- Files render in the browser: audio and video play inline, seekable (#7389) 9b36147
- The Claude Code and OpenCode plugins say what the crew is doing on an app and show a run's last lines, through MCP `runs` and `run_log` (#7395) 2e62cec
- While "flow only" is on, a crew pull for a non-flow issue gets no feedback run; it is held with one line saying it waits for the switch (#7393) 9a072d1
- The terminal's People screen marks a person's email verified with `v` and a confirm, as MCP `account_verify` does (#7328) dfe7610
- The terminal's changelog narrows releases by a word with `/`, and Enter on a release lists every pull it carried (#7364) f8a398c
- The terminal's usage screen says what the crew's tokens bought: dollars, runs, changes landed and cost per change, as MCP `returns` does (#7283) b2e06c6
- The terminal's issue screen lets a writer say an issue may go ahead when what it waited for closed as dropped or split, as MCP `confirm_wait` does (#7308) 88aafd3
- The terminal's System screen grants an agent telemetry:read or takes it back with `g` and a confirm, as MCP `telemetry_grant` does (#7361) 990496e
- `forge asks` prints what waits on you, most important first, one line each, as /api/v1/asks answers (#7381) 0866982
- MCP `apps` takes `archived: true` and lists the apps put away, as /apps?archived=1 does (#7363) 76354c0
- MCP `read_file` says whether a JSON, YAML or TOML file parses, and the line and column where it breaks (#7359) 1831a34
- The merge queue re-runs a batch's budget-only reds once, serially, before calling it red — budget tests under gate load are sinking 8-pull batches (#7357) e15cf9e
- The terminal's launcher search ranks like /explore when the line has `kind:` or `sort:` words, with each row's numbers (#7356) e7df551
- CSV table review: no timer in the test, tests for search/edit/caps/semicolon/broken, quiet s, tableStatus, bare CR lines, README placement (#7344) 6e1b525
- CSV table: cap columns, parse .tsv from the decoded source, strip control characters, document it (#7344) c65d414
- The terminal workspace shows a .csv or .tsv as an aligned table with a pinned header, and s flips to the source (#7344) e996303
4 earlier comments
A .csv or .tsv tab in the terminal workspace now opens as an aligned table, and s flips it to the source and back. bun x tsc --noEmit and bun scripts/design-lint.ts are clean. I ran test/text-csv.test.ts and test/tui-workspace.test.ts (31 pass), not the whole suite.
What changed
src/text/csv.ts:parseCsv(text, { maxRows = 1000, delimiter? })returns{ header, rows, more, delimiter, error? }. It handles quoted fields,"", newlines inside quotes, CRLF, a BOM and blank lines. The delimiter (,;or tab) is sniffed from the first line, ignoring quoted text. Rows past the cap are counted inmoreand never built.sniffDelimiteris exported, so #7334 can reuse the module for the web table.src/tui/ui/grid.ts:layoutTablepads each column to its widest cell, capped at 32 columns with….- Table view in
src/tui/screens/workspace.ts:- Opening a CSV draws the table with the header bold and pinned on the top row while the data scrolls under it.
h/lscroll sideways, and/andnsearch the data rows.- The status line shows
N rows, orN rows, first 1000 shownwhen the cap cuts it off.
s:- It toggles table and source, and appears in the key hints only on table files.
- Editing a CSV shows the source until you press
sagain, as markdown does withv. - A file that doesn't parse opens as source, with
not a table: line N, <reason>in the status line. - Pressing
son a broken file shows the same message as a toast.
- Tests:
test/text-csv.test.tscovers each parsing case above, the cap, the error lines and the column layout.- A new test in
test/tui-workspace.test.tsopens a CSV, checks the aligned columns and the pinned header afterG, flips to the source and back, and opens a broken CSV to see the source and the error line.
Left out
- Ragged rows are padded, not reported as errors.
- There are no row numbers or per-column alignment for numbers.
- Only a quote in the wrong place or an unclosed quote counts as a parse error.
- Cells with newlines are flattened to one line in the table, and the source keeps them.
- The web table (#7334) is untouched.
Try it: open a repository in the terminal, open a .csv through the t finder, then press s. The s flip exists only on .csv and .tsv tabs.
🤖 Generated with Claude Code
All four findings are fixed and pushed to the same branch. bun x tsc --noEmit, bun scripts/design-lint.ts and the two test files I touched pass (33 tests); I didn't run the full suite.
- Wide CSV (high):
parseCsvnow keeps at most 64 fields per record (MAX_COLUMNS). Extra fields are counted in a newTable.columnsand never stored, solayoutTableworks on 64 columns at most.- Status line: it shows
N more columnswhen the file is wider than the cap. - Test: a file with 100,000 commas on the header line plus 1,000 rows parses and lays out in under 500 ms, with 64 columns and 100,001 counted.
- Not capped: I did not add a cap on total kept bytes. Rows (1,000) × columns (64) bound the cell count, and a single cell can still be as large as the file.
- Status line: it shows
.tsv(high):rebuildnow parses the decoded source, not the tab-expandedplain, and passes{ delimiter: "\t" }for.tsvpaths. That also fixes a TSV header containing a comma. The workspace test opens a.tsvwhose header contains a comma and checks that it showsname, full │ qty.- README: I added a paragraph on the table view,
s, the row and column caps, andnot a table: line N. - Control characters: I did not check whether
drawShiftedor the surface strips ESC. Insteadflatingrid.tsnow replaces C0, DEL and C1 characters with a space before layout, and a test with\x1b[2Jin a cell confirms none reach the grid.
I've addressed all seven points except #4, which I'm declining; the fixes are pushed to the same branch. bun x tsc --noEmit and bun scripts/design-lint.ts are clean, and test/text-csv.test.ts and test/tui-workspace.test.ts pass (35 tests). I did not run the full suite.
- Timer: removed from the wide-file test. The structural assertions stay (64 header columns,
columns === 100_001, 64 columns in the grid header). - Tests: a new workspace test covers each behaviour you listed:
- Search:
/on a CSV finds a row that was off-screen. - Edit:
ethenescleaves the source showing, andsbrings the table back. - Caps: the status line shows
1100 rows, first 1000 shownand6 more columns. - Semicolons: a
;-separated.csvrenders as a table. - Broken file:
son it showsnot a table: line 2.
- Search:
stoast: it is now a silent no-op on non-table files. In edit modesnever reaches it, because the editor owns the keys.- Dead assignment: declined. The
t.asTable = truenear line 724 is inloadTab, the common load path for every text tab, not an image-only branch. It resets the table view when a tab is re-read withror a ref switch, the same wayt.rendered = truedoes just above it. - Simplifications:
- Delimiter:
delimiteris a plainconstnow, andCsvOptions.delimiteraccepts| undefinedsoexactOptionalPropertyTypesis satisfied. - Status line: the table part moved into
tableStatus(table)next totableProblem, and theread onlytail appears once. - eslint comment: removed, since the repo has no eslint config.
- Delimiter:
- README: the paragraph now sits after the terminal history paragraph, and it says cells wider than 32 columns are cut with
…while the source view shows them whole. There is no dedicated workspace section in the README, so that is the closest fit. - Bare
\r: inside a quoted field it now counts as a line, with a unit test.
The full gate on land was red; the pull is open again. Red tests:
- GET /apps/open names its phases and answers within its budget
The gate's log: /api/v1/repos/trevato/forge/gates/1793134062410-56faf0a92af6/log
Red on top of #7328, #7393, #7395, #7389, #7397, #7396, #7405, which landed first from the same merge-queue candidate: red on its own on that base, or only together with them. Bring this pull up to date with the base and push.
I merged the current origin/main into the branch and pushed it. The merge was clean, with no conflicts and no code changes from me.
I didn't reproduce the GET /apps/open names its phases… failure. That test lives in one of the timing test files and doesn't touch the terminal workspace. My test selection matched 105 files, and all 220 tests pass on the merged branch. They include test/text-csv.test.ts and test/tui-workspace.test.ts, and bun x tsc --noEmit is clean. If the gate goes red on that test again, it is a timing flake or an interaction among the pulls that landed before this one (#7328, #7393, #7395, #7389, #7397, #7396, #7405), not this change.
I did not do juniper's two non-blocking follow-ups:
- Per-cell byte cap: one cell can still be as large as the file, because only rows and columns are capped.
- Web table reuse:
parseCsvandlayoutTableare not yet reused for the web table in #7334.
A
.csvor.tsvtab in the terminal workspace now opens as an aligned table, andsflips it to the source and back.bun x tsc --noEmitandbun scripts/design-lint.tsare clean. I rantest/text-csv.test.tsandtest/tui-workspace.test.ts(31 pass), not the whole suite.What changed
src/text/csv.ts:parseCsv(text, { maxRows = 1000, delimiter? })returns{ header, rows, more, delimiter, error? }. It handles quoted fields,"", newlines inside quotes, CRLF, a BOM and blank lines. The delimiter (,;or tab) is sniffed from the first line, ignoring quoted text. Rows past the cap are counted inmoreand never built.sniffDelimiteris exported, so #7334 can reuse the module for the web table.src/tui/ui/grid.ts:layoutTablepads each column to its widest cell, capped at 32 columns with….src/tui/screens/workspace.ts:h/lscroll sideways, and/andnsearch the data rows.N rows, orN rows, first 1000 shownwhen the cap cuts it off.s:sagain, as markdown does withv.not a table: line N, <reason>in the status line.son a broken file shows the same message as a toast.test/text-csv.test.tscovers each parsing case above, the cap, the error lines and the column layout.test/tui-workspace.test.tsopens a CSV, checks the aligned columns and the pinned header afterG, flips to the source and back, and opens a broken CSV to see the source and the error line.Left out
Try it: open a repository in the terminal, open a
.csvthrough thetfinder, then presss. Thesflip exists only on.csvand.tsvtabs.🤖 Generated with Claude Code
Closes #7344