lets revuew @docs/EDITOR_UI_REFERENCE.md and the codebase, and lets sketch out a feature design document for a dedicated "CSV viewer" mode for .csv files that will show the rows/cols as a spreadsheet, similar to how tableplus works for databases etc, use librarian to look at how https://github.com/Tablecruncher/tablecruncher is implemented and lets adapt that to work in rust for our csv viewer, it should integrate neatly into our existing codebase and is only relevant for tabular data (csv, tsv, etc), we would need a command to toggle it on/off for the current editor/file and should be able to handle failures (not a csv file, unparsable csv file, etc) and show this as a statusbar message using the existing mechanisms, we need tests for this feature inparticular, we can use a crate for csv parsing , should allow editing of indiviudual cell values while in this mode, and be able to sync the text/csv view when changes are made, should include a benchmark/stress test to ensure we can handle at least 1k,5k, 50k, 500k long csv files (generate them dynamically), and should handle scrolling horizontally when there are too many columns to comfortably fit in view at once, every part of this behaviour must be well documented and specified, data models and how to render it efficiently, sync state and cell values on edit etc, place it in docs/features/csv-editor.md it is fine to split this feature into multiple phases (start with readonly, then add editing support, then incrementally add features etc).
Design CSV viewer mode with spreadsheet UI
Ran todo_write
Explored 2 files
Explored 1 file
Ran todo_write
Explored 11 files
Ran todo_write
Now I have a comprehensive understanding of both the EDITOR_UI_REFERENCE.md, Tablecruncher's architecture, and your codebase structure. Let me create a detailed feature design document.
Created csv-editor.md
+1.9k
Ran todo_write
Created the comprehensive CSV viewer design document at docs/feature/csv-editor.md.
Key design decisions adapted from Tablecruncher:
Memory-efficient storage - Uses delimited-string rows (single
Vec<String>) with0xFAfield delimiter instead ofVec<Vec<String>>Three-phase implementation:
- Phase 1: Read-only viewer with grid rendering and navigation
- Phase 2: Cell editing with document sync
- Phase 3: Performance optimizations and advanced features
Integration approach - CSV mode is a
ViewModevariant onEditorState, sharing the sameDocumentbuffer for undo/redo compatibilityBenchmarks required - Tests for 1K, 5K, 50K, and 500K row files with performance targets
The document covers:
- Data models (
CsvState,CsvData,CellPosition) - Parsing strategy with
csvcrate and delimiter detection - Rendering pipeline for grid, headers, cells, and edit overlay
- Navigation and cell selection
- Bidirectional sync (CSV ↔ text buffer)
- Error handling with status bar messages
- Complete test strategy with unit, integration, and stress tests
- Message types and commands for the Elm architecture