fix: save bucket exports from the WebView instead of dropping them - #229
Open
0xbrayo wants to merge 4 commits into
Open
fix: save bucket exports from the WebView instead of dropping them#2290xbrayo wants to merge 4 commits into
0xbrayo wants to merge 4 commits into
Conversation
The web UI fetches /export successfully, then saves via a blob <a download> which Android WebView does not persist. Intercept those downloads and write them through the Storage Access Framework picker. Fixes ActivityWatch#228
Greptile SummaryThe PR adds native handling for dashboard blob and loopback export downloads, persists export payloads in cache, and serializes Storage Access Framework save requests across fragment recreation.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Sequence DiagramsequenceDiagram
participant UI as Dashboard Web UI
participant Hook as Export JS Hook
participant Bridge as WebAppInterface
participant Queue as ExportSaveQueue
participant Picker as Save-to Picker
participant Storage as ContentResolver
UI->>Hook: Click blob export link
Hook->>Bridge: beginExport(name, MIME)
loop 256 KiB chunks
Hook->>Bridge: appendExport(chunk)
end
Hook->>Bridge: finishExport()
Bridge->>Queue: Persist cache file and enqueue
Queue->>Picker: Launch CreateDocument
Picker-->>Queue: Return destination URI
Queue->>Storage: Copy cached payload
Storage-->>Queue: Save result
Queue->>Queue: Delete cache and launch next
Reviews (4): Last reviewed commit: "address greptile review feedback (greplo..." | Re-trigger Greptile |
Queue overlapping exports so a later save cannot replace the picker payload, and drop captured blobs on send or URL.revokeObjectURL.
Member
Author
Persist queued exports to cache files and restore the Save-to queue after fragment recreation so a picker result cannot drop the payload.
Member
Author
Resume waiting exports in onStart after recreation during an async write, when the restored queue has items but no in-flight picker.
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #228.
The bucket Export button fetched
/api/0/buckets/.../exportsuccessfully (~39 ms in the report), then the bundled web UI saved the result with ablob:+<a download>click. Android WebView does not persist that, and the existingDownloadListeneronly firedACTION_VIEWon the URL — so the bytes were discarded with no file, picker, toast, or crash.Changes:
DownloadListenerforblob:and loopback HTTP exports if the WebView does surface themVerified with
./gradlew :mobile:testDebugUnitTest(including new hook / filename / chunk-reassembly tests). Not device-tested.