Repository navigation
web: fall back to Blob download without showSaveFilePicker and survive picker cancel - #206
Merged
Merged
Conversation
…e picker cancel Clicking "Save incoming file…" in the browser app unconditionally called showSaveFilePicker, which caused two issues: 1. Safari (macOS/iOS) and Firefox do not implement showSaveFilePicker, so clicking "Save incoming file…" threw ReferenceError, closed conn, left both action buttons disabled, and lost the incoming transfer. Fall back to buffering the stream into a Blob and triggering an <a download="tailcat-download"> when showSaveFilePicker is absent. 2. Where showSaveFilePicker is supported, canceling the save dialog throws AbortError before any bytes have been read from conn (while the sender is still stalled on TCP backpressure), yet the catch handler closed conn and left the buttons disabled. Re-enable the buttons and keep conn open on AbortError so the user can retry or choose "Show as text". Also set dir="auto" on #send-text and .recv-text so right-to-left text renders with natural paragraph direction. Updates tailscale#4 Signed-off-by: Dr. Mohammed Lubbad <engmlubbad@gmail.com>
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.
Problem
In the
web/WebAssembly app (https://tailscale.github.io/tailcat/), clicking Save incoming file… unconditionally calledshowSaveFilePicker(), causing two issues:showSaveFilePickerAPI. Clicking Save incoming file… threwReferenceError: showSaveFilePicker is not defined, enteredcatch (err), closedconn, left both buttons permanently disabled, and lost the incoming stream.AbortError) before reading: On Chromium browsers,showSaveFilePicker()runs beforeconn.read()pulls any bytes (while the sender stalls on TCP backpressure). Dismissing/canceling the file picker threwAbortError, which closedconnand kept both buttons disabled instead of letting the user retry Save incoming file… or choose Show as text.#send-textand.recv-textrendered right-to-left scripts (Arabic, Hebrew, etc.) forced left-to-right withoutdir="auto".Changes
web/app.js:typeof globalThis.showSaveFilePicker === "function", catchAbortErrorfromshowSaveFilePicker()beforeconn.read()starts, re-enable the action buttons, and leaveconnintact.showSaveFilePickeris unavailable (Safari, Firefox), read the incoming stream into aBloband trigger a temporary<a download="tailcat-download">object URL.box.dir = "auto"on.recv-text.web/index.html: Adddir="auto"to<textarea id="send-text">.web/wasm_test.go: AddTestBrowserSaveFileCancelAndFallbackverifying bothAbortErrorrecovery and theBlobfallback SHA-256 integrity end-to-end over a local DERP relay.Verification
GOOS=js GOARCH=wasm go build ./webgo test ./web/ -v -count=1 -timeout 300s --run-headless-browser-tests(5/5 passing, includingTestBrowserSaveFileCancelAndFallback)go vet ./...andmake tidyclean