Skip to content

Keep large CSV previews responsive and add column resizing and links - #25381

Merged
nwparker merged 4 commits into
mainfrom
nwparker/CSV-issues
Oct 5, 2026
Merged

nwparker merged 4 commits into
mainfrom
nwparker/CSV-issues

Conversation

@nwparker

@nwparker nwparker commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1330 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1320
Prod 35 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1740 $\color{#cf222e}{\Huge{\mathbf{−}}}$​455 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1285

ELI5

Large or wide CSVs can exhaust memory because Orca loads and parses the whole file and renders every column. This change loads large CSVs in bounded chunks, renders only visible rows and columns, and adds column resizing and clickable web links.

What Changed

  • CSV/TSV files of at least 1 MiB use a worker-built row index and a bounded page cache. The editor holds a preview descriptor instead of the full file text, and save/draft guards prevent the read-only preview from overwriting the file.
  • Both grid axes use TanStack Virtual. Column edges support dragging, keyboard resizing, and reset; sticky headers and row numbers stay aligned. Row-window controls keep rows beyond Chromium's scroll-height limit reachable.
  • Cells containing an HTTP/HTTPS URL support clicking and keyboard activation through Orca's existing link-routing preference and file ownership rules.
  • Local, SSH, and paired folder-workspace reads stay on the owning host. Local reads retain main's file-access checks and regular-file guard; paired reads reuse the existing chunk RPC and show an update message on unsupported hosts.
  • Small files retain Source editing. Table cell editing, including large-file editing, is outside this PR.

Why

Changing parsers alone still retains the full cell matrix. Paging bounds retained data, while column virtualization also bounds the DOM for wide files. CSV keeps its own plain-text grid because the Markdown table operates on rich-document positions and transactions. No new dependency is added.

Linked Issue

Related to #12915: implements column resizing; leaves the issue open for direct editing and the other requested table operations.

Visual Proof

Same 48-row × 1,024-column fixture in hidden Electron. Before renders the viewer from 8ff6ec9fb1cd; after renders this implementation, with Description resized to 400 px and URLs navigable. The capture checks that the old viewer mounts all 1,024 columns and the new viewer mounts fewer than 40.

Before

CSV before: fixed widths and plain URL text

After

CSV after: resizable columns and clickable URLs

Large-file and horizontal-scroll proof

Final row of a 1,900,100-row CSV:

Final row of large CSV

Final column of a 2,048-column CSV:

Final column of wide CSV

Recovery after a dense file shrinks while its later row window is selected:

dense-after-shrink.png

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

On macOS, 253 focused tests passed across 21 suites; one existing test was skipped. pnpm tc, pnpm run check:code-quality:changed, localization catalog/extraction checks, and the Electron E2E build passed.

All four hidden Electron E2E tests passed: csv-paged-preview.spec.ts verifies final-row/column access, pointer/keyboard resizing, bounded DOM/heap, blocked saves, and a maximum-size first record with a BOM and CRLF; csv-url-links.spec.ts verifies click and Enter navigation in small and paged previews, a dense 600,000-row CSV under 1 MiB, and recovery when a later row window shrinks to three rows. All test windows remained hidden.

The 117 MiB / 1,900,100-row fixture indexed in 4.98 seconds and increased renderer heap by 8.24 MiB after scrolling to the last row. The wide fixture mounted 48 rows and 16 columns. Heap measurement excludes worker memory and total process RSS.

Owner-routing tests cover SSH, paired hosts, folder workspaces, changed/unsupported hosts, and local file-access propagation. Live SSH, Linux, and Windows were not tested locally.

Review

Adversarial review reproduced and fixed the inline findings: dense sub-threshold files remain viewable, a wide viewport no longer evicts itself from the page cache, and record limits exclude the initial BOM and line terminators consistently in the index and parser. Bounded page reads include the BOM and terminator overhead. The cache is bounded independently by 512 Ki cells, 8 MiB of raw page bytes, and 64 pages. Viewport loads check the file snapshot once before and after the batch; abandoned loads stop after their current page. Also fixed shrinking-file row-window recovery, shared the scanner/parser page-cell limit, and verified user-resized widths survive estimate changes. Regression tests cover each case.

Reviewed parser compatibility, worker cancellation, stale file detection, draft/save safety, host ownership, and library sizing/event behavior. Rebased onto main and preserved its file-access rules.

Agent skill upstream boundary

  • Not applicable; no skill-installation or sharing changes.

Notes

Large previews are read-only. Indexing scans the file once before showing the table, including remote transfers. Safety limits reject records above 1 MiB or files above 4,096 columns. Column widths last for the mounted grid and reset on remount. Only whole-cell HTTP/HTTPS URLs are linked.

Checklist

  • This PR is small and focused — the CSV feature spans file loading, rendering, and save guards.
  • I explained what changed and why
  • Before/after screenshots attached
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • Focused local lint/typecheck/tests/build passed; CI covers the full repository checks

@nwparker
nwparker requested a review from brennanb2025 as a code owner October 5, 2026 03:46
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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

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: e450b8ce-83f1-4b6c-8f70-554ef056fbff
📥 Commits

Reviewing files that changed from the base of the PR and between 7ef9196 and 51437df.

📒 Files selected for processing (2)
  • tests/e2e/csv-paged-preview.spec.ts
  • tests/e2e/csv-url-links.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/e2e/csv-url-links.spec.ts
  • tests/e2e/csv-paged-preview.spec.ts

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


📝 Walkthrough

Walkthrough

The change adds bounded filesystem reads and runtime range-read routing. It adds CSV parsing limits, byte indexing, and worker-based page loading. CSV and TSV files at least 1 MiB can use a read-only paged preview. The renderer displays preview data in a virtualized grid with column resizing, row navigation, and HTTP(S) link handling. The change also updates editor state and save behavior for preview-only files, and adds unit and end-to-end tests.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 51437

This incremental change only touches end-to-end tests for the large CSV preview and link behavior. No actionable merge-blocking risk was identified in the supplied evidence.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 36 functions across 47 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 changes: responsive large CSV previews, column resizing, and links.
Description check ✅ Passed The description covers the user impact, changes, rationale, linked issue, visual proof, testing, review notes, and checklist. It provides specific test results and limitations.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@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: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 318b966e-50b5-4f85-b843-dc6d59d298d4
📥 Commits

Reviewing files that changed from the base of the PR and between 3f6225d and 2cb954b.

📒 Files selected for processing (48)
  • src/main/ipc/filesystem/filesystem-chunk-read-handler.ts
  • src/main/ipc/filesystem/filesystem-read-handlers.ts
  • src/main/ipc/filesystem/local-file-range-read.test.ts
  • src/main/ipc/filesystem/local-file-range-read.ts
  • src/main/runtime/orca-runtime-files-ssh-chunk-reads.test.ts
  • src/main/runtime/runtime-file-commands-read-file-explorer-preview.ts
  • src/preload/api/filesystem-api.ts
  • src/preload/api/fs-bridge.ts
  • src/renderer/src/components/editor/CsvCellValue.tsx
  • src/renderer/src/components/editor/CsvColumnResizeHandle.tsx
  • src/renderer/src/components/editor/CsvGrid.test.tsx
  • src/renderer/src/components/editor/CsvGrid.tsx
  • src/renderer/src/components/editor/CsvPagedViewer.tsx
  • src/renderer/src/components/editor/CsvViewer.delimiter.test.tsx
  • src/renderer/src/components/editor/CsvViewer.tsx
  • src/renderer/src/components/editor/EditorEditFileSurface.tsx
  • src/renderer/src/components/editor/EditorPanelHeader.tsx
  • src/renderer/src/components/editor/csv-byte-index.test.ts
  • src/renderer/src/components/editor/csv-byte-index.ts
  • src/renderer/src/components/editor/csv-cell-links.test.tsx
  • src/renderer/src/components/editor/csv-delimiter-detection.ts
  • src/renderer/src/components/editor/csv-link-routing.ts
  • src/renderer/src/components/editor/csv-paged-preview.test.ts
  • src/renderer/src/components/editor/csv-paged-preview.ts
  • src/renderer/src/components/editor/csv-parse-budget.test.ts
  • src/renderer/src/components/editor/csv-parse.ts
  • src/renderer/src/components/editor/csv-preview-save-safety.test.ts
  • src/renderer/src/components/editor/csv-preview-worker-client.ts
  • src/renderer/src/components/editor/csv-preview-worker-protocol.ts
  • src/renderer/src/components/editor/csv-preview.worker.ts
  • src/renderer/src/components/editor/editor-autosave.ts
  • src/renderer/src/components/editor/editor-csv-file-content.ts
  • src/renderer/src/components/editor/editor-lazy-views.ts
  • src/renderer/src/components/editor/editor-panel-content-types.ts
  • src/renderer/src/components/editor/editor-save-queue.ts
  • src/renderer/src/components/editor/useCsvPagedPreview.test.tsx
  • src/renderer/src/components/editor/useCsvPagedPreview.ts
  • src/renderer/src/components/editor/useEditorPanelFileContentLoader.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/runtime/runtime-file-client-test-harness.ts
  • src/renderer/src/runtime/runtime-file-range-client.test.ts
  • src/renderer/src/runtime/runtime-file-range-client.ts
  • src/renderer/src/store/slices/editor/actions/editor-draft-state.ts
  • src/renderer/src/store/slices/editor/actions/open-file-mutations.ts
  • src/renderer/src/store/slices/editor/types/open-file.ts
  • src/renderer/src/web/preload-api/web-filesystem-api.ts
  • tests/e2e/csv-paged-preview.spec.ts
  • tests/e2e/csv-url-links.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 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 — two minor suggestions inline.

Reviewed changes

  • Paged large-CSV preview. CSVs ≥ 1 MiB are admitted as a renderer-only descriptor (content: '' + CsvFilePreview) and rendered from a worker-built byte index with a bounded page cache, instead of loading the full text into the editable buffer.
  • Two-axis virtualization + resizing. CsvGrid virtualizes rows and columns with TanStack Virtual, adds a 500k-row scroll window, and adds pointer/keyboard column resize/reset.
  • Whole-cell HTTP/HTTPS links. CsvCellValue + csv-link-routing open URLs through the existing openHttpLink owner-routing rules; executable/scheme-invalid values stay literal text.
  • Read-only save safety. Transient csvPreviewOnly guards drafts, dirty state, autosave, and the save queue; the loader partitions in-flight reads and refuses to pair a paged preview with an existing draft.
  • Chunked host reads. New fs:readFileChunk IPC and shared readLocalFileRange; the runtime chunk path is refactored onto it; owner/access routing preserved for local, SSH, and paired hosts.

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.

ℹ️ The delta is clean; one prior finding remains open on the byte-index record-length threshold.

Reviewed changes (delta since 2cb954b)

  • Dense sub-threshold CSVs render again. CsvViewer replaces maxCells: 250_000 with CSV_PAGED_PREVIEW_BYTES + 1, which covers the worst case for a file strictly under 1 MiB; regression unit test and a 600k-row e2e added.
  • Bounded page cache. CsvPagedPreview bounds the cache by 64 pages, 512 Ki cells, and 8 MiB of raw bytes, and adds a batched rows() loader that stats once before/after the viewport and aborts after the current page when abandoned; useCsvPagedPreview delegates to it.
  • Row-window shrink recovery. CsvGrid clamps the requested windowStart against the current rowCount, so a refresh that shrinks the file returns to row 0.
  • Shared page-cell limit. CSV_PAGE_CELLS is exported and used by both the index and the worker parser.

ℹ️ Record-length parity at the 1 MiB CRLF/BOM boundary is still open

The previous review flagged that CsvByteIndex.emitRow measures a record's span including its terminator (and the BOM on row 0), so a CRLF row with exactly CSV_RECORD_BYTES - 1 content bytes is rejected by the index while parseCsv accepts it. The new commit does not change that accounting, so the thread below is still open and is the reason this review is not an approval. It is a one-byte, error-path-only gap — not a page-boundary mismatch.

Technical details
# CRLF/BOM record length counts the terminator

## Affected sites
- `src/renderer/src/components/editor/csv-byte-index.ts:82` — `end - this.rowStart > CSV_RECORD_BYTES` includes the CRLF (and BOM) bytes.
- `src/renderer/src/components/editor/csv-byte-index.ts:107` — pending-CR path passes `at + 1` (LF offset + 1).
- `src/renderer/src/components/editor/csv-byte-index.ts:56-60` — `consumePrefix` skips BOM bytes without moving `rowStart`.
- `src/renderer/src/components/editor/csv-parse.ts:48` / `:85-90` — parser measures `end - recordStart` with the CRLF already coalesced, so content only.

## Required outcome
- The byte index and `parseCsv` should agree on the maximum accepted record length, or the gap should be pinned by a test so it is intentional.

## Suggested approach (optional)
- Measure the terminator-exclusive span (pass the CR/LF index rather than LF+1), or add CRLF/BOM-at-limit samples to `csv-byte-index.test.ts` and document the boundary.

Existing thread: #25381 (comment)

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

@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: 4891e91a-cc5a-4294-9f62-95b6ffd0dc70
📥 Commits

Reviewing files that changed from the base of the PR and between e81075d and 7ef9196.

📒 Files selected for processing (7)
  • src/renderer/src/components/editor/csv-byte-index.test.ts
  • src/renderer/src/components/editor/csv-byte-index.ts
  • src/renderer/src/components/editor/csv-paged-preview.test.ts
  • src/renderer/src/components/editor/csv-paged-preview.ts
  • src/renderer/src/components/editor/csv-parse-budget.test.ts
  • src/renderer/src/components/editor/csv-parse.ts
  • tests/e2e/csv-paged-preview.spec.ts

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

Comment thread tests/e2e/csv-paged-preview.spec.ts Resolved

@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 record-length parity finding is fixed in 7ef9196; the delta is correct and well tested.

Reviewed changes (delta since e81075d)

  • Aligned record-length limits across parser and byte index. CsvByteIndex.emitRow now takes a terminator-exclusive contentEnd and consume/finish/consumePrefix pass it, so a lone CR, the CR of a CRLF, and a leading BOM no longer count toward the 1 MiB record limit; parseCsv's limit check skips a terminating CR/LF unless it is inside quotes. The two now agree at the boundary, which closes the prior open finding.
  • Bounded the page-span validation. Added CSV_MAX_PAGE_BYTES = CSV_RECORD_BYTES + 5 (BOM + max content + CRLF) and switched CsvPagedPreview.read's range guard from CSV_RECORD_BYTES to it; the emitRow pre-check isolates an over-length row into its own page, so +5 is the true page-span ceiling.
  • Pinned the behavior with tests. A table-driven csv-byte-index.test.ts case covers both BOMs × four line endings × three at-limit record shapes and asserts index/parser parity plus rejection one byte over; csv-parse-budget.test.ts covers quoted newlines; csv-paged-preview.test.ts reads a max-size BOM+CRLF record in 256 KiB chunks; a new hidden e2e test opens a 1 MiB record with BOM/CRLF and checks the tail row. All 35 focused unit tests pass locally.

I traced the parity paths for lone CR at EOF, CRLF after a closing quote, embedded newlines inside quotes, and escaped quotes; index and parser agree in each. All prior Pullfrog threads on this PR are resolved.

Pullfrog  | 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. The one commit since the prior review is a test-only change, and it is correct.

Reviewed changes (delta since 7ef9196)

  • Guarded the CSV e2e visibility assertions by run mode. csv-paged-preview.spec.ts and csv-url-links.spec.ts now run their isVisible() === false checks only when ORCA_E2E_FORCE_HEADFUL !== '1' and testInfo.project.metadata.orcaHeadful !== true, so an explicit headful/forced-headful run no longer fails these specs while still asserting hidden windows in the default headless project. testInfo is in scope in every guarded test, and the guard matches the established pdf-find-counter.spec.ts:98 / terminal-split-activation-latency.spec.ts:588 pattern.

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

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.

1 participant