Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Export Selection Range as CSV Command
This is a draft that I'd like some feedback and support on.
This exports table rows to a CSV file based off of the selection range.
SUPPORT NEEDED ON:
Feature Demo
This writes ~100k lines to a CSV file from the selection without crashing the app or lagging out main usage.
Screencast.from.11-10-2025.11_39_42.AM.mp4
Why A Command vs UI Integration?
People have lots of opinions about UI. I wanted verification on the core functionality before building out UI.
Algorithm
I kept it simple.
The function exports table data to a CSV file within a selected time range.
It retrieves column headers, resolves start and end indices for that range, and opens a writable CSV stream.
It then requests rows from the server in fixed-size batches, prefetching the next batch while writing the previous one to disk.
The process repeats until all rows have been written, after which the file stream is closed.
Fixed memory usage (1k lines)
No FE -> BE data pipline (lots of code overhead / slow JSON RPC)
A diagram if it helps:
sequenceDiagram participant App participant API participant FS as "File" %% Setup phase App->>API: "Fetch column headers" API-->>App: "Header list" App->>API: "Fetch start index for START_TIME" API-->>App: "Start index" App->>API: "Fetch end index for END_TIME" API-->>App: "End index" App->>FS: "Open CSV stream and write header" %% Prime first fetch App->>API: "Fetch batch 1 (startIndex, count)" Note over App,API: "ongoing = promise for first batch" %% Batched pipelined loop loop "while rowsLeft > 0" App->>API: "Await previous fetch (batch N)" API-->>App: "Return lines (batch N)" App->>API: "Start next fetch (batch N+1)" App->>FS: "Build and write CSV batch (await drain if needed)" App->>App: "Update progress and decrement rowsLeft" end %% Final flush App->>API: "Await final fetch (batch N+1)" API-->>App: "Final lines" App->>FS: "Write final batch" App->>FS: "End stream and wait for finish"