#5503 · Native download navigation lacks a file handoff
Trusted base: e5651418281c98e841d390eba5364e16f42bee40, fetched from main and checked against the target repository's main commit.
Verdict: PARTIALLY REPRODUCED · Root-cause confidence: medium · Reproduction label: partial-repro
1. TL;DR
The issue describes downloads replacing the iOS app or opening an unauthenticated system browser. Two clean source checkouts reproduce the routing decisions that permit those outcomes: a generated Tasks download URL is admitted as an ordinary page on a root-mounted profile, but selected for external browsing on a prefixed profile. The page uses an ordinary download anchor, while the native shell has no file-download handler or native file-transfer request. This investigation ran the actual URL builder, navigation predicates, and bridge parser, not an iOS WebView. Raw-byte rendering, Safari cookie behavior, the displayed filename, and recovery by force-quitting therefore remain unverified here.
2. Claims vs findings
| Claim | Status | Evidence |
|---|---|---|
| A root-mounted download can be admitted as a page navigation. | Verified at the policy boundary | The real Tasks URL builder and shell predicates produce inWebView: true in both runs. |
| The same root-absolute download URL is sent outside a prefixed profile. | Verified at the policy boundary | The predicates produce inWebView: false, inExternalBrowser: true; the actual screen calls Linking.openURL on that branch. |
| The iOS screen displays ZIP/PDF bytes and cannot recover without a restart. | Unverified | No iOS runtime, simulator, or native screenshot was available on this Linux host. Back/forward gestures are disabled in source, but that alone does not prove the full recovery claim. |
| Safari loses the authenticated session and chooses a different filename. | Unverified | No authenticated native-to-Safari download was performed. The routing decision is reproduced; the subsequent OS behavior is not. |
| Download controls do not perform a native file handoff. | Verified by source inspection | File preview and Tasks use download anchors. The screen installs neither onFileDownload nor onOpenWindow. |
| The current share bridge cannot directly accept blob/data file URLs. | Verified dynamically | The actual parser accepts an HTTPS share URL and rejects both blob and data URLs. Share text is bounded to 4,000 characters; other request kinds have different bounds. |
| The server returns correct bytes and download headers. | Partially checked | The Tasks handler sets content type, disposition, and length in source. No live file request or cookie test was made in this investigation. |
| All file-download sites and full prefixed hosting fail identically. | Unverified generalization | The executable reproduction covers Tasks URL generation and shared navigation policy, not every control, blob preview, router redirect, or proxy configuration. |
3. Environment
- Public target repository
get-bb/bb; trusted main commit recorded above. - Linux x86_64; Node v22.19.0; pnpm 9.15.0; Vitest 4.1.1.
- Two newly created detached checkouts, named
BASEandVERIFYbelow. Both had clean tracked source before adding the investigator-authored test. - Frozen installs succeeded in both checkouts. Full Turbo build in BASE: 66/66 tasks successful. Relevant dependency build in VERIFY: 3/3 tasks successful.
- The repository pins react-native-webview 13.16.1. Its installed iOS implementation was inspected, not executed.
- No app instance, listening port, database, user session, provider call, or production runtime data was needed. Synthetic
example.comURLs are parsed locally and never requested. - No iOS simulator or screenshots: this is a policy-level partial reproduction, not a visual/native confirmation.
4. Minimal reproduction
- Create a fresh checkout of the trusted commit:
git clone https://github.com/get-bb/bb.git BASE cd BASE git checkout --detach e5651418281c98e841d390eba5364e16f42bee40 pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build
- Save the complete investigator-authored test below as
apps/mobile/src/lib/shell/issue-5503.repro.test.ts. No production code changes are required. - Run the owning package through Turbo:
pnpm exec turbo run test --filter=@bb/mobile -- src/lib/shell/issue-5503.repro.test.ts
The two safety assertions intentionally fail on the unchanged implementation. They express the required invariant that a file download must not replace the page or be delegated to a different browser session. They do not assert that simply denying a navigation would implement file saving.
import { describe, expect, it } from "vitest";
import { parsePageToShellMessage } from "@bb/mobile-bridge";
import { attachmentDownloadUrl } from "../../../../../plugins/tasks/shared/attachments";
import { isExternallyOpenable, isShellNavigation } from "./shell-url";
describe("issue 5503 download navigation safety", () => {
it.each([
{ mount: "root", serverUrl: "https://example.com" },
{ mount: "prefixed", serverUrl: "https://example.com/bb" },
])("keeps a $mount download out of page and external navigation", ({ serverUrl }) => {
const downloadUrl = new URL(
attachmentDownloadUrl("fixture"),
`${serverUrl}/plugins/tasks`,
).href;
const inWebView = isShellNavigation(downloadUrl, serverUrl);
const inExternalBrowser = !inWebView && isExternallyOpenable(downloadUrl);
expect({ inWebView, inExternalBrowser }).toEqual({
inWebView: false,
inExternalBrowser: false,
});
});
it("characterizes the existing share bridge rather than assuming file support", () => {
const shareRequest = (url: string) => JSON.stringify({
type: "request",
id: "fixture",
request: { kind: "share", payload: { url } },
});
expect(parsePageToShellMessage(shareRequest("https://example.com/file.zip")).ok).toBe(true);
expect(parsePageToShellMessage(shareRequest("blob:https://example.com/fixture")).ok).toBe(false);
expect(parsePageToShellMessage(shareRequest("data:application/zip;base64,UEs=")).ok).toBe(false);
});
});
Expected vs actual
The generated URL is https://example.com/api/v1/plugins/tasks/http/attachments/download?attachmentId=fixture for both profiles. The path prefix is not retained because the builder returns a root-absolute path.
Verbatim assertion excerpts from the first run, with only the Turbo log prefix removed:
keeps a 'root' download out of page and external navigation
- Expected
+ Received
{
"inExternalBrowser": false,
- "inWebView": false,
+ "inWebView": true,
}
keeps a 'prefixed' download out of page and external navigation
- Expected
+ Received
{
- "inExternalBrowser": false,
+ "inExternalBrowser": true,
"inWebView": false,
}
Test Files 1 failed (1)
Tests 2 failed | 1 passed (3)
5. Root cause
File actions are treated as ordinary navigation without a native file handoff. The Tasks builder returns a root-absolute API endpoint. The shell first admits any URL within its profile scope, and otherwise externally opens HTTP(S) URLs. There is no download-specific branch.
return `/api/v1/plugins/tasks/http/attachments/download?attachmentId=${encodeURIComponent(attachmentId)}`;
Actual screen navigation callback, lines 342–348:
if (isShellNavigation(request.url, profile.serverUrl)) return true;
if (isExternallyOpenable(request.url)) {
void Linking.openURL(request.url).catch(() => undefined);
}
return false;
Scope predicate, lines 28–43: an empty prefix admits every same-origin path; a non-empty prefix admits only that subtree. External URL predicate, lines 57–65: HTTP(S) and mailto are externally openable. The test invokes both actual functions in exactly the screen's branch order; it does not mount the screen or invoke the native linking API.
File preview Download, lines 1303–1307, and Tasks attachment anchor, lines 191–193, use ordinary anchors with a download attribute. The screen WebView configuration has no file-download/new-window handler and disables back/forward gestures.
The locally installed pinned iOS WebView implementation, apple/RNCWebViewImpl.m:1461, recognizes attachment disposition or a non-displayable MIME response. It cancels and emits a download event only when _onFileDownload is set. This is supporting source evidence for the missing interception, not a demonstration that WebKit renders every file as text.
Bridge schema, lines 15–56, has no file-save request and accepts only HTTP(S) share URLs. The share handler, lines 72–94, forwards share content to the native share API, not an authenticated file transfer.
Prefix handling is broader than this one helper: the web API client, lines 4–12, uses window.location.origin and returns pathname/search URLs. Correcting only the Tasks link would not provide a native download implementation. The Tasks response, lines 540–552, already sets download metadata; this investigation does not establish an additional server-response defect.
6. Proposed fix and safety gate
Introduce a capability-negotiated native file-save operation shared by web download sites, with bounded payload handling, explicit filename/MIME metadata, cancellation, and temporary-file cleanup. Network downloads need the correct profile session and URL scope; blob data must be transferred from the page rather than opened in Safari. Add WebView download and new-window interception for pages without the new capability, ensuring that unhandled downloads cannot replace the shell. Do not weaken the origin/prefix navigation boundary or forward credentials to arbitrary URLs.
Validate root/prefixed profiles, authenticated responses, blob files, user cancellation, and old/new bridge combinations on an actual iOS simulator or device. First capture a native before/download/after sequence to settle the raw-byte display and recovery claims.
No fix PR was attempted. A complete root-cause fix crosses web/native bridge contracts and authenticated file handling, which fails the autopilot's single-subsystem/no-protocol-or-security-boundary-change conditions. The native symptom was also only partially reproduced. Silently blocking downloads is not a substitute for saving files. No linked open PR was present in the issue timeline or the open-PR search at review time.
7. Verification
The same investigator created a second clean detached checkout at the identical trusted commit; this is a repeated check, not independent review. git status --porcelain was empty and git rev-parse HEAD returned the full base SHA before adding the same investigator-authored test. A second frozen install and the relevant Turbo dependency build succeeded.
cd VERIFY pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build --filter=@bb/mobile... pnpm exec turbo run test --filter=@bb/mobile -- src/lib/shell/shell-url.test.ts src/lib/shell/shell-share.test.ts # Copy the identical test shown above into the same relative path. pnpm exec turbo run test --filter=@bb/mobile -- src/lib/shell/issue-5503.repro.test.ts
| Check | Result |
|---|---|
| BASE, 19:08:22 UTC | 2 safety failures / 1 bridge characterization pass; exit 1; root WebView=true, prefixed external=true. |
| VERIFY, 19:08:46 UTC | Same 2 failures / 1 pass; exit 1. Turbo executed the failing test; it was not replayed from cache. |
| Existing shell URL/share tests in VERIFY | 15/15 passed; no baseline failure in those suites. |
| Existing mobile bridge suite in BASE | 37/37 passed across message, injection, and version tests. |
| Tracked source changes | None in either checkout. Only the new reproduction test was added. Both tracked diffs passed git diff --check. |
The repeated run required no correction to the policy findings. The report deliberately limits the verdict to PARTIALLY REPRODUCED because neither run exercised iOS, Safari, cookies, file bytes, save sheets, or deep-link recovery. No screenshot was fabricated. Reproduction source and exact assertion results are embedded above; raw local artifacts are not published, following this reports repository's policy.
8. Related issues
#5302 is a narrower voice-recording failure reported in the same mobile area. This investigation does not establish that every recording path has the same cause or that a recording-only remedy fixes general file downloads.
9. Appendix
Investigation used read-only GitHub metadata, trusted-main source inspection, frozen installs, Turbo builds/tests, and tracked diff checks. Issue content was treated only as untrusted claims; no issue command, external issue link, script, patch, or PR branch was executed. The reproduction was designed from the repository's actual URL builder and shell policy.
BASE build:
Tasks: 66 successful, 66 total
VERIFY dependency build:
Tasks: 3 successful, 3 total
VERIFY existing mobile shell tests:
Test Files 2 passed (2)
Tests 15 passed (15)
BASE and VERIFY reproduction, each:
Test Files 1 failed (1)
Tests 2 failed | 1 passed (3)
BASE existing mobile bridge tests:
Test Files 3 passed (3)
Tests 37 passed (37)
Additional recorded command: pnpm exec turbo run test --filter=@bb/mobile-bridge. No runtime was started, so there are no test ports, native sessions, or application data directories to clean up.
> AGENT GENERATED