feat(buckets): use server-side CSV export endpoint - #997
Conversation
Replace the client-side PapaParse approach with a direct request to the
new server endpoint GET /api/0/buckets/{id}/export/csv.
In a regular browser (including Android WebView), an anchor navigation
is used so the browser handles the download natively — no events ever
enter JS memory and headers arrive immediately, fixing the apparent hung
connection on large buckets.
In Tauri (where <a download> is not supported), the CSV text is fetched
via the API client and saved through the native file dialog.
Removes the papaparse import from this file.
Git-Session-Id: cdc6
|
timeout: 0 was added for the Tauri fallback path but the existing test (added in ActivityWatch#993) explicitly verifies no timeout: 0 remains. The server-side CSV streaming endpoint is fast to start (headers sent before serialization), so 5 minutes matches the large-event-JSON path and is sufficient. Git-Session-Id: 70d5
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #997 +/- ##
=======================================
Coverage 57.66% 57.66%
=======================================
Files 51 51
Lines 3231 3231
Branches 794 794
=======================================
Hits 1863 1863
- Misses 1291 1352 +61
+ Partials 77 16 -61 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The browser path used a bare <a> navigation, which drops Authorization and cannot report 4xx/network failures. Use the same path as JSON export: Android native URL download, then an authenticated blob GET with the 5-minute timeout. downloadBlob still handles Tauri. Git-Session-Id: d11ab6e2-235d-55ab-8e68-e80e65a02e47
|
Pushed 3eba796 to address the Greptile 4/5 findings:
The earlier CI failure ( |
|
@greptileai review |
Restore <a> navigation for local installs so the server-side CSV endpoint can stream. Keep the authenticated blob path for Tauri and Bearer-token deployments, which cannot attach Authorization to a navigation download. Git-Session-Id: 92d2be57-41cd-59e0-8f80-fc2b1a31d6af
|
@greptileai review |
|
Merged by Erik ( Leaving #995 open until that endpoint lands. Master webui now calls |
Summary
Replace the client-side PapaParse CSV export with a direct call to the new server-side streaming endpoint
GET /api/0/buckets/{id}/export/csv(ActivityWatch/aw-server-rust#722).The problem: The existing
export_csvmethod fetches all events as JSON, builds a PapaParse CSV in JavaScript, and creates a Blob. For buckets with 500k+ events on Android WebView this causes OOM or a connection that looks hung — there's no response at all until the full payload is ready.The fix:
200 OKheaders immediately (before serialization begins), so the WebView sees a live response right away. Events never enter JS memory.<a download>is unsupported): fetch the CSV text via the existing API client, then save via the native file dialog — same as today but with server-side CSV generation.Also removes the
import Papa from 'papaparse'that is no longer needed.Related