#5302 · Recording export in the native shell
Trusted base: 6d3e82f35dfb10dbf0e05dc87e71c876d2e8759c
PARTIALLY REPRODUCED · Root-cause confidence: medium · Reproduction label: partial-repro
1. TL;DR
The reported symptom is an audio recovery action that produces no saved recording in the native iOS app. A direct source-level probe confirms that export creates a page-local object URL and clicks a download anchor, even with a usable iOS bridge installed; it neither calls native sharing nor Web Share. However, the proposed explanation that the shell always rejects blob navigation is incorrect: the real URL policy allows same-origin blob URLs for root-mounted servers, while prefixed mounts reject them. The existing native share validator rejects both blob and data URLs. This Linux investigation does not reproduce the iOS user-visible failure, toast-dismissal loss, or reload loss on hardware; the verdict deliberately remains partial.
2. Claims vs findings
| Claim | Finding | Evidence |
|---|---|---|
| Failed transcription exposes an audio export action. | Verified | The trusted hook calls downloadBlob; its existing 15-test suite passes, including export after unmount and retry with the same File. |
| Export uses a blob download anchor. | Verified | The probe observes one recording.webm anchor, zero bridge messages, zero Web Share calls, and URL revocation after 60 seconds. |
| The shell always cancels blob navigation. | Refuted as a general explanation | Real isShellNavigation returns true at the same-origin root mount and false with a /bb prefix. The native handler returns true before consulting external schemes. |
| Native sharing can already accept a recording object URL. | Not supported by the current contract | Real bridge parser accepts an HTTPS share URL and rejects blob and data URLs. |
| Nothing is saved on a production iPhone; dismissing or reloading loses the audio. | Unverified on hardware | No iOS device, simulator, native runtime, or production user data was used. A DOM click observation is not a file-save observation. |
| Production web inspection is disabled. | Source verified only | The native screen uses webviewDebuggingEnabled={__DEV__}; the reported USB inspection attempt was not repeated. |
3. Environment
- Public get-bb/bb origin/main, base 6d3e82f35dfb10dbf0e05dc87e71c876d2e8759c; package bb-app version 0.46.0.
- Linux x86_64, Node v22.19.0, pnpm 9.15.0, Vitest 4.1.1, jsdom. Two separate clean detached worktrees at the same base.
- Synthetic audio only. No transcription provider, real microphone, iOS runtime, app server, ports, or application data directory.
- Frozen installs passed in both checkouts. Full base build: 64 successful tasks. Verification app/mobile dependency build: 4 successful tasks (cache restored).
4. Minimal reproduction
- Clone trusted main and detach at the recorded base:
git clone https://github.com/get-bb/bb.git bb-repro cd bb-repro git checkout --detach 6d3e82f35dfb10dbf0e05dc87e71c876d2e8759c pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build
- Copy the complete diagnostic probe embedded below into
apps/app/src/lib/issue-5302.repro.test.ts. - Execute the real export helper, real shell policy, and real share parser, plus the existing voice hook suite:
pnpm exec turbo run test --force --filter=@bb/app -- --run src/lib/issue-5302.repro.test.ts src/hooks/useVoiceInput.test.tsx --silent=false
Expected if a native export existed: recording bytes reach an export-capable native or Web Share path. Actual observed transport: an anchor-only attempt; the probe does not emulate WKWebView or claim a disk save.
{"anchorAttempts":[{"url":"blob:https://qa.example.invalid/recording-id","fileName":"recording.webm"}],"nativeBridgeMessages":0,"webShareCalls":0,"rootMountAllowsBlob":true,"prefixedMountAllowsBlob":false,"externallyOpenable":false,"revokedAfterMs":60000}
{"httpShareAccepted":true,"blobShareAccepted":false,"dataShareAccepted":false}
Test Files 2 passed (2)
Tests 17 passed (17)
These are diagnostic assertions of current behavior, not a red/green fix regression. Synthetic click instrumentation records the browser attempt and does not implement the native behavior being investigated. This is a functional export failure report, not a visual-layout report; no screenshot is claimed.
Complete probe
// @vitest-environment jsdom
import { buildBridgeInjectionScript, parsePageToShellMessage } from "@bb/mobile-bridge";
import { afterEach, expect, it, vi } from "vitest";
import {
isExternallyOpenable,
isShellNavigation,
} from "../../../mobile/src/lib/shell/shell-url";
import { downloadBlob } from "./download-blob";
import { getNativeShell, resetNativeShellForTests } from "./native-shell";
afterEach(() => {
vi.restoreAllMocks();
vi.unstubAllGlobals();
vi.useRealTimers();
resetNativeShellForTests();
});
it("observes the failed-recording export transport and shell URL decisions", () => {
vi.useFakeTimers();
const serverUrl = "https://qa.example.invalid";
const blobUrl = `blob:${serverUrl}/recording-id`;
const audio = new Blob(["synthetic audio"], { type: "audio/webm" });
const createObjectURL = vi.fn(() => blobUrl);
const revokeObjectURL = vi.fn();
vi.stubGlobal("URL", class extends URL {
static createObjectURL = createObjectURL;
static revokeObjectURL = revokeObjectURL;
});
const postMessage = vi.fn();
const share = vi.fn().mockResolvedValue(undefined);
vi.stubGlobal("ReactNativeWebView", { postMessage });
vi.stubGlobal("bb", undefined);
new Function("window", buildBridgeInjectionScript({
bridgeVersion: 1,
appVersion: "0.46.0",
platform: "ios",
profileMode: "direct",
secureContext: true,
safeArea: { top: 0, right: 0, bottom: 0, left: 0 },
capabilities: ["share", "open-external"],
}))(window);
resetNativeShellForTests();
expect(getNativeShell()?.handshake.platform).toBe("ios");
vi.stubGlobal("navigator", { share });
const attempts: { url: string; fileName: string }[] = [];
vi.spyOn(HTMLAnchorElement.prototype, "click").mockImplementation(
function (this: HTMLAnchorElement) {
attempts.push({ url: this.href, fileName: this.download });
},
);
downloadBlob(audio, "recording.webm");
expect(attempts).toEqual([{ url: blobUrl, fileName: "recording.webm" }]);
expect(createObjectURL).toHaveBeenCalledWith(audio);
expect(postMessage).not.toHaveBeenCalled();
expect(share).not.toHaveBeenCalled();
expect(isShellNavigation(attempts[0]!.url, serverUrl)).toBe(true);
expect(isShellNavigation(attempts[0]!.url, `${serverUrl}/bb`)).toBe(false);
expect(isExternallyOpenable(attempts[0]!.url)).toBe(false);
expect(revokeObjectURL).not.toHaveBeenCalled();
vi.advanceTimersByTime(60_000);
expect(revokeObjectURL).toHaveBeenCalledWith(blobUrl);
console.log(JSON.stringify({
anchorAttempts: attempts,
nativeBridgeMessages: postMessage.mock.calls.length,
webShareCalls: share.mock.calls.length,
rootMountAllowsBlob: isShellNavigation(blobUrl, serverUrl),
prefixedMountAllowsBlob: isShellNavigation(blobUrl, `${serverUrl}/bb`),
externallyOpenable: isExternallyOpenable(blobUrl),
revokedAfterMs: 60_000,
}));
});
it("checks whether the existing native share boundary accepts recording URLs", () => {
const request = (url: string) => JSON.stringify({
type: "request",
id: "recording-export",
request: { kind: "share", payload: { url } },
});
const httpResult = parsePageToShellMessage(request("https://qa.example.invalid/audio"));
const blobResult = parsePageToShellMessage(request("blob:https://qa.example.invalid/recording-id"));
const dataResult = parsePageToShellMessage(request("data:audio/webm;base64,YXVkaW8="));
expect(httpResult.ok).toBe(true);
expect(blobResult.ok).toBe(false);
expect(dataResult.ok).toBe(false);
console.log(JSON.stringify({
httpShareAccepted: httpResult.ok,
blobShareAccepted: blobResult.ok,
dataShareAccepted: dataResult.ok,
}));
});
5. Root cause and limits
Verified gap: Failed-audio export only clicks a blob download anchor; there is no native file handoff. Same-origin blob navigation is allowed on root mounts, so the reported universal navigation rejection is not the cause. The native WebView screen has no file-download callback in this path. Which WKWebView callback fires for this action, and whether the native download implementation loses the bytes, remain unmeasured. Missing native handoff is a plausible explanation of the reported iOS symptom, not a fully proven device-level root cause.
- Voice hook: local File and error-toast callbacks. The toast callback captures audioFile; there is no durable save in this branch.
- Export helper: complete implementation.
- Native navigation handler and debug setting.
- URL policy. A same-origin blob URL retains the embedded HTTPS origin; with no server path prefix, the early return admits it. Blob pathname is not /bb, so a prefixed mount fails that check.
- Share boundary validation: only HTTP(S) URL payloads, text, and title; no recording byte/file payload.
- Native share handler forwards accepted share payloads to Share.share.
const OBJECT_URL_REVOKE_DELAY_MS = 60_000;
export function downloadBlob(blob: Blob, fileName: string): void {
const url = URL.createObjectURL(blob);
const anchor = document.createElement("a");
anchor.href = url;
anchor.download = fileName;
document.body.append(anchor);
anchor.click();
anchor.remove();
setTimeout(() => URL.revokeObjectURL(url), OBJECT_URL_REVOKE_DELAY_MS);
}
6. Proposed fix and safety check
First instrument the native iOS WebView download delegate with synthetic audio. Then implement a bounded, capability-negotiated file export with native temporary-file cleanup, completion/error feedback, and retention on failure; do not merely allow more URL schemes. Test native export success, cancellation, failure, and page reload, as well as older shells without the new capability. Retain the recording until export has completed; keep the desktop fallback.
No pull request: the actual iOS download failure is not fully reproduced, and a native byte-transfer repair crosses the app/native bridge protocol, outside this rule's single-subsystem, no-protocol-change simple-fix conditions. No production fix, branch, or pull request was created. No open linked pull request was found in issue timeline metadata or the issue-number search at investigation time.
7. Related issues
Repository metadata confirms #4236 and #5016 are closed. Their summaries address transcription lifecycle and timeout respectively, rather than native recording export.
8. Verification
The same agent repeated the probe in a second initially clean worktree at exactly 6d3e82f35dfb10dbf0e05dc87e71c876d2e8759c. The production source remained unchanged; only the diagnostic test was added. A frozen install and targeted dependency build preceded the run. Turbo test execution was forced, not cache replayed. Both runs emitted the same transport/policy/parser findings and passed 17 tests; the second run also passed all 10 existing shell-URL tests.
pnpm exec turbo run test --force --filter=@bb/app -- --run src/lib/issue-5302.repro.test.ts src/hooks/useVoiceInput.test.tsx --silent=false pnpm exec turbo run test --filter=@bb/mobile -- --run src/lib/shell/shell-url.test.ts
Report correction: rejected the proposed universal blob-navigation cancellation explanation after the first probe, and verified that correction in the second checkout. This is a second run by the same agent, not an independent review.
9. Appendix
Raw artifacts remain in the local report work directory and backup, not in the public repository. The full probe and sanitized run output are embedded here so this report stands alone. Local checkout paths are redacted.
First run output
• turbo 2.10.12
• Packages in scope: @bb/app
• Running test in 1 packages
• Remote caching disabled, using shared worktree cache
@bb/templates:generate:plugin-scaffold: cache miss, executing b7c07615a9060df9
@bb/templates:generate:templates: cache miss, executing 0445486228648688
//:ensure-native-modules: cache bypass, force executing 8b424808ca1453d1
@bb/plugin-build:generate: cache miss, executing 68b5ef906518575c
//:ensure-native-modules:
//:ensure-native-modules: > bb@ ensure-native-modules <checkout>
//:ensure-native-modules: > node scripts/ensure-native-modules.mjs
//:ensure-native-modules:
@bb/templates:generate:templates:
@bb/templates:generate:templates: > @bb/templates@0.0.1 generate:templates <checkout>/packages/templates
@bb/templates:generate:templates: > node ./scripts/generate-templates.mjs
@bb/templates:generate:templates:
@bb/plugin-build:generate:
@bb/plugin-build:generate: > @bb/plugin-build@0.0.1 generate <checkout>/packages/plugin-build
@bb/plugin-build:generate: > node ./scripts/generate-plugin-theme.mjs && node ./scripts/generate-runtime-export-manifest.mjs
@bb/plugin-build:generate:
@bb/templates:generate:plugin-scaffold:
@bb/templates:generate:plugin-scaffold: > @bb/templates@0.0.1 generate:plugin-scaffold <checkout>/packages/templates
@bb/templates:generate:plugin-scaffold: > node ./scripts/generate-plugin-scaffold.mjs
@bb/templates:generate:plugin-scaffold:
@bb/plugin-build:generate: plugin-theme.generated.ts up to date
@bb/plugin-build:generate: wrote <checkout>/packages/plugin-build/src/generated/runtime-export-manifest.generated.ts (react@19.2.4)
@bb/app:test: cache miss, executing 115c80fe657dea6c
@bb/app:test:
@bb/app:test: > @bb/app@0.0.1 test <checkout>/apps/app
@bb/app:test: > node scripts/generate-pwa-icons.mjs --check && vitest run --config vitest.config.ts "--run" "src/lib/issue-5302.repro.test.ts" "src/hooks/useVoiceInput.test.tsx" "--silent=false"
@bb/app:test:
@bb/app:test:
@bb/app:test: RUN v4.1.1 <checkout>/apps/app
@bb/app:test:
@bb/app:test: stdout | src/lib/issue-5302.repro.test.ts > observes the failed-recording export transport and shell URL decisions
@bb/app:test: {"anchorAttempts":[{"url":"blob:https://qa.example.invalid/recording-id","fileName":"recording.webm"}],"nativeBridgeMessages":0,"webShareCalls":0,"rootMountAllowsBlob":true,"prefixedMountAllowsBlob":false,"externallyOpenable":false,"revokedAfterMs":60000}
@bb/app:test:
@bb/app:test: stdout | src/lib/issue-5302.repro.test.ts > checks whether the existing native share boundary accepts recording URLs
@bb/app:test: {"httpShareAccepted":true,"blobShareAccepted":false,"dataShareAccepted":false}
@bb/app:test:
@bb/app:test: ✓ |@bb/app:isolated| src/lib/issue-5302.repro.test.ts (2 tests) 31ms
@bb/app:test: ✓ |@bb/app:isolated| src/hooks/useVoiceInput.test.tsx (15 tests) 288ms
@bb/app:test:
@bb/app:test: Test Files 2 passed (2)
@bb/app:test: Tests 17 passed (17)
@bb/app:test: Start at 23:43:58
@bb/app:test: Duration 4.10s (transform 2.01s, setup 2.62s, import 1.28s, tests 320ms, environment 2.99s)
@bb/app:test:
Tasks: 5 successful, 5 total
Cached: 0 cached, 5 total
Time: 9.587s
Second forced-run output
• turbo 2.10.12
• Packages in scope: @bb/app
• Running test in 1 packages
• Remote caching disabled, using shared worktree cache
@bb/plugin-build:generate: cache bypass, force executing 68b5ef906518575c
//:ensure-native-modules: cache bypass, force executing 8b424808ca1453d1
@bb/templates:generate:plugin-scaffold: cache bypass, force executing b7c07615a9060df9
@bb/templates:generate:templates: cache bypass, force executing 0445486228648688
@bb/templates:generate:templates:
@bb/templates:generate:templates: > @bb/templates@0.0.1 generate:templates <checkout>/packages/templates
@bb/templates:generate:templates: > node ./scripts/generate-templates.mjs
@bb/templates:generate:templates:
@bb/templates:generate:plugin-scaffold:
@bb/templates:generate:plugin-scaffold: > @bb/templates@0.0.1 generate:plugin-scaffold <checkout>/packages/templates
@bb/templates:generate:plugin-scaffold: > node ./scripts/generate-plugin-scaffold.mjs
@bb/templates:generate:plugin-scaffold:
//:ensure-native-modules:
//:ensure-native-modules: > bb@ ensure-native-modules <checkout>
//:ensure-native-modules: > node scripts/ensure-native-modules.mjs
//:ensure-native-modules:
@bb/plugin-build:generate:
@bb/plugin-build:generate: > @bb/plugin-build@0.0.1 generate <checkout>/packages/plugin-build
@bb/plugin-build:generate: > node ./scripts/generate-plugin-theme.mjs && node ./scripts/generate-runtime-export-manifest.mjs
@bb/plugin-build:generate:
@bb/plugin-build:generate: plugin-theme.generated.ts up to date
@bb/plugin-build:generate: wrote <checkout>/packages/plugin-build/src/generated/runtime-export-manifest.generated.ts (react@19.2.4)
@bb/app:test: cache bypass, force executing 115c80fe657dea6c
@bb/app:test:
@bb/app:test: > @bb/app@0.0.1 test <checkout>/apps/app
@bb/app:test: > node scripts/generate-pwa-icons.mjs --check && vitest run --config vitest.config.ts "--run" "src/lib/issue-5302.repro.test.ts" "src/hooks/useVoiceInput.test.tsx" "--silent=false"
@bb/app:test:
@bb/app:test:
@bb/app:test: RUN v4.1.1 <checkout>/apps/app
@bb/app:test:
@bb/app:test: stdout | src/lib/issue-5302.repro.test.ts > observes the failed-recording export transport and shell URL decisions
@bb/app:test: {"anchorAttempts":[{"url":"blob:https://qa.example.invalid/recording-id","fileName":"recording.webm"}],"nativeBridgeMessages":0,"webShareCalls":0,"rootMountAllowsBlob":true,"prefixedMountAllowsBlob":false,"externallyOpenable":false,"revokedAfterMs":60000}
@bb/app:test:
@bb/app:test: stdout | src/lib/issue-5302.repro.test.ts > checks whether the existing native share boundary accepts recording URLs
@bb/app:test: {"httpShareAccepted":true,"blobShareAccepted":false,"dataShareAccepted":false}
@bb/app:test:
@bb/app:test: ✓ |@bb/app:isolated| src/lib/issue-5302.repro.test.ts (2 tests) 31ms
@bb/app:test: ✓ |@bb/app:isolated| src/hooks/useVoiceInput.test.tsx (15 tests) 306ms
@bb/app:test:
@bb/app:test: Test Files 2 passed (2)
@bb/app:test: Tests 17 passed (17)
@bb/app:test: Start at 23:44:32
@bb/app:test: Duration 3.76s (transform 2.65s, setup 2.16s, import 1.25s, tests 338ms, environment 2.77s)
@bb/app:test:
Tasks: 5 successful, 5 total
Cached: 0 cached, 5 total
Time: 8.516s
Existing shell-policy suite output
• turbo 2.10.12 • Packages in scope: @bb/mobile • Running test in 1 packages • Remote caching disabled, using shared worktree cache //:ensure-native-modules: cache bypass, force executing 79573f877ef8b020 @bb/templates:generate:templates: cache miss, executing 3ac419b75b85c1dc @bb/templates:generate:plugin-scaffold: cache miss, executing 98cd2c3534a24aa6 @bb/templates:generate:templates: @bb/templates:generate:templates: > @bb/templates@0.0.1 generate:templates <checkout>/packages/templates @bb/templates:generate:templates: > node ./scripts/generate-templates.mjs @bb/templates:generate:templates: //:ensure-native-modules: //:ensure-native-modules: > bb@ ensure-native-modules <checkout> //:ensure-native-modules: > node scripts/ensure-native-modules.mjs //:ensure-native-modules: @bb/templates:generate:plugin-scaffold: @bb/templates:generate:plugin-scaffold: > @bb/templates@0.0.1 generate:plugin-scaffold <checkout>/packages/templates @bb/templates:generate:plugin-scaffold: > node ./scripts/generate-plugin-scaffold.mjs @bb/templates:generate:plugin-scaffold: @bb/mobile:test: cache miss, executing a5e135523060bb72 @bb/mobile:test: @bb/mobile:test: > @bb/mobile@0.0.1 test <checkout>/apps/mobile @bb/mobile:test: > vitest run --config vitest.config.ts "--run" "src/lib/shell/shell-url.test.ts" @bb/mobile:test: @bb/mobile:test: @bb/mobile:test: RUN v4.1.1 <checkout>/apps/mobile @bb/mobile:test: @bb/mobile:test: ✓ |@bb/mobile| src/lib/shell/shell-url.test.ts (10 tests) 8ms @bb/mobile:test: @bb/mobile:test: Test Files 1 passed (1) @bb/mobile:test: Tests 10 passed (10) @bb/mobile:test: Start at 23:44:16 @bb/mobile:test: Duration 407ms (transform 25ms, setup 0ms, import 48ms, tests 8ms, environment 0ms) @bb/mobile:test: Tasks: 4 successful, 4 total Cached: 0 cached, 4 total Time: 3.305s
All issue content was treated as untrusted claims; no issue-provided scripts, patches, branches, or external links were executed or fetched. Investigation used trusted repository code and locally authored instrumentation only.