Repository navigation
feat(webview): Web Share API with files in the Android web container (slock #15772) - #5120
Closed
stamp-build[bot] wants to merge 6 commits into
Closed
stamp-build[bot] wants to merge 6 commits into
stamp-build[bot] wants to merge 6 commits into
Conversation
stamp-build Bot
pushed a commit
that referenced
this pull request
Nov 20, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
stamp-build Bot
pushed a commit
that referenced
this pull request
Nov 20, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
stamp-build
Bot
force-pushed
the
agent/lagoon/webview-share
branch
from
November 20, 2026 05:59
4dd68e1 to
6ada248
Compare
…(slock #15772) Android's WebView has no navigator.share. A document-start shim (the page's own origin) gives the page a synchronous navigator.canShare and a Promise-returning navigator.share that posts the files in base64 chunks to the origin-bound download port; the app writes them under its FileProvider share folder and opens the system share sheet (ACTION_SEND / SEND_MULTIPLE; text-only shares send text), then resolves the Promise once the sheet is shown or rejects it (AbortError / DataError). iOS WKWebView already has Web Share level 2 (WebKit WebShareEnabled / WebShareFileAPIEnabled on for Cocoa), so the shim steps aside wherever the page has the API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review findings on #5120: - each chunk is parsed, decoded and appended to its file on one background thread, acknowledged before the page reads the next; no file is held in memory, and pending shares end with the port, on eviction, or after two silent minutes (AbortError) - a share is staged in its own <uuid> entry of slock-share-files, under the attachment share's age and count rules, not in a web-share/ parent - the shim rejects without user activation (NotAllowedError), while a share is in flight (InvalidStateError), and is not installed in subframes - sizes are bounded one by one with a checked sum; ids and file names are validated (RaftShareFileName.sanitize); the intent type is normalised Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
stamp-build
Bot
force-pushed
the
agent/lagoon/webview-share
branch
from
November 20, 2026 10:08
6ada248 to
93740c3
Compare
Second review of #5120: - the expiry check comes back while a share is still being received, so one whose last message was handled late still ends - a session whose port is gone takes no more messages - a share message is told by its leading kind, so a download read can never be detoured past its own chunks - the data URL is split at its last comma - tests assert the acknowledged chunk rather than any non-null result Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Contributor
Author
|
Merged by Stamp in batch |
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.
What / why
Builds on #5108 (its port and download-name hook). For slock #15772 (#proj-workspace:#346): the Artifact viewer's ⋯ › Share appears only when
navigator.canShare({ files: [file] })is true and callsnavigator.share({ files, title })synchronously in the click. Android's WebView has no Web Share API, so Share never showed in the app.navigator.canShareandnavigator.share; the app receives the files and opens the system share sheet.WebShareEnabled/WebShareFileAPIEnabledare on for Cocoa; the app's target is iOS 15.0). The shim also steps aside wherever the page already hasshareandcanShare.Design
Shim (
raftWebViewShareShimScript,RaftWebViewShare.kt)window.top !== window→ not installed), because the app takes the port's messages from the main frame alone.canShareis synchronous: files must be Blobs, at most 64 files and 100 MB together; or aurl/text/titlestring.sharereturns a Promise and rejects in the Web Share order:InvalidStateErrorwhile an earlier share of this page is in flight,NotAllowedErrorwhennavigator.userActivation.isActiveis false,TypeErrorfor data it cannot share.raftDownloadPort, one chunk at a time: the next is read only after the app acknowledges the last (__raftShareAck), so neither side holds more than a chunk.{"k":"share-…); the app tells a share message from a download read by that exact prefix.Receiver (
RaftWebViewShareReceiver, common code)[A-Za-z0-9_]{1,64}), file count, each size non-negative and within the cap, a checked running sum, chunk order, announced sizes.RaftShareFileName.sanitize(one path component, 200 bytes) and are made unique within the share.DataError), or aborted (AbortError: evicted by a fifth concurrent share, silent for 2 minutes, or the port removed).Android (
RaftSandboxWebView.android.kt)cache/slock-share-files/<uuid>/<name>entry, the same root and naming as attachment shares (existing FileProvider path). There is noweb-share/parent.androidAppand cannot be called from the shared module, so the rule is duplicated asraftWebViewShareStaleStagingEntries; the two must be kept in step (noted onsweepAndroidAttachmentShareStaging).removeDownloadSupportcloses the session: pending shares are aborted, their partial files deleted, and later messages for that session are ignored.ACTION_SEND/ACTION_SEND_MULTIPLEwith read grants; text-only istext/plain. The intent type is the files' normalised common type (RaftShareFileName.resolveMimeType), elsemajor/*, else*/*.AbortErrorif it could not open.Checks
RaftWebViewShareTest(common): shim strings (canShare, port, caps, top-frame / in-flight / activation guards, ack, kind-first messages, last-comma split); settle and ack scripts; streaming two files with duplicate names; chunk order (skipped, repeated, wrong file, too many bytes, bad base64, empty); negative and overflowing sizes; file-count cap; hostile names (../x, 300-byte, empty,.., case clash); invalid and empty ids; eviction, expiry, abort, restart, write failure; intent type; staging sweep rule.Device checks needed
Android, with slock #15772 on staging, in the Artifact viewer ⋯ › Share:
File.name, and a target app receives it intact;canSharefalse) and nothing is staged;iOS: ⋯ › Share shows and the native share sheet opens from WKWebView in the viewer (confirms native level 2 in our WKWebView configuration).
Known limits
Requirement Challenge
🤖 Generated with Claude Code