← Back to Pull requests

feat: let extensions take over files the browser tab downloads #4223

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 10, 2026 23:52 UTC
Author

Description

  • Adds BrowserDownloadExtension to Beutl.Extensibility, so an extension can take over a file that a page in the browser tab offers and add it to the editor in its own way. The first consumer is the text-to-speech extension: Yukkuri voice sites synthesize speech in the page and hand it over as a blob:/data: URL whose file name does not carry the spoken line, so the extension has to read the line from the page and place the speech with its character and caption.

  • When a page offers a file, the browser asks each BrowserDownloadExtension in turn through Claim(BrowserDownloadOffer). A claim can carry a PageScript, a JavaScript expression the browser evaluates in the offering page at once (also for a file held back behind another prompt, so it reads that file's own page; a file that a frame of a page still loading offers is claimed once that page is on display), and a Description, which the download prompt shows in place of the file name.

  • A claimed file still needs the user's confirmation in the prompt; a page cannot add anything on its own. Once confirmed, the browser saves it to the project's resources/downloads without the download options and calls ImportAsync with the file, the offer and the page data. The browser wraps the expression in an envelope of its own, so PageData is the page's string exactly on WebView2 and WebKit alike; a failing or silent page gives null after five seconds. ImportAsync returns false to fall back to the usual single-element import, an exception shows the existing "saved, but timeline import failed" message, and canceling in the prompt reports a cancellation.

  • Offers reach extensions only while the editor can add files to a saved scene in a saved project. Retrying from the download history and the toolbar's download button keep the options flow.

  • EditViewModel now also answers IExtensionProvider, so editor components can offer work to extensions through the lease-backed interface.

  • Adds the authoring guide docs/extension-authoring/browser-downloads.md.
  • Screenshots / Render output

    Nothing changes without a BrowserDownloadExtension. With one that claims the offer, the second line of the download prompt shows the claim's description instead of the file name (the file name moves to that line's tooltip), and confirming skips the download options panel. The extension's own UI is shown in the text-to-speech extension's PR linked below.

    Affected areas

  • Beutl.Engine (rendering / scene / track)

  • Beutl.ProjectSystem (project / document persistence)

  • UI (Beutl.Editor, Beutl.Editor.Components, Beutl.Controls)

  • Beutl.Extensibility (plugin abstractions)

  • Beutl.NodeGraph (node editor)

  • Beutl.FFmpegIpc / Beutl.FFmpegWorker (media IPC boundary)

  • Beutl.Api (server API client)

  • Build / CI / docs only
  • Breaking changes

    None. The extension kind, its records and the IExtensionProvider editor service are additions.

    Raises the format floor?

    No.

    Test plan

  • tests/Beutl.HeadlessUITests/BrowserDownloadExtensionTests.cs: a claimed generated file is read from its page when offered (WebView2's quoted envelope, WebKit's plain one, a string that is itself quoted, the string null, and a value that is not a string), shows the claim's description, skips the options, lands in resources/downloads and reaches ImportAsync with its offer and page data; a declined import falls back to one element; an offer no extension claims keeps the options; a scene that was never saved offers nothing to extensions; a failing import and a failing page script are reported while the file stays; a file held behind an earlier prompt keeps the data its own page showed; a file from a frame of the next page is not claimed for the page being left, and one from a frame of a page still loading is claimed for that page once it is shown; canceling during the import reports a cancellation and keeps the file.

  • tests/Beutl.PublicApiContractTests/BrowserDownloadExtensionAuthoringContractTests.cs: a plugin-authored extension claims, imports, and has its arguments checked.

  • Ran BrowserDownloadExtensionTests, WebBrowserDownloadTests, EditViewModelServicesTests and BrowserReviewLifecycleTests (151 passed) and the new contract tests (3 passed) on macOS.

  • A local pack of this branch (2.99.99-browserdownload.1) runs the text-to-speech extension's import tests, which place real speech with a PsdTachie character and a caption.

  • Not yet tried against the live sites: their synthesis sits behind a Cloudflare Turnstile check that needs a person.
  • Fixed issues / References

  • Consumer: b-editor/Beutl.Extensions.Voice#43 places speech from Yukkuri voice sites with this API.
  • <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Browser extensions can now claim eligible downloads, show a description during confirmation, and import saved files into the project. If an extension declines or cannot import a file, the existing download flow remains available.
    Documentation
    Added a guide explaining how to create browser download extensions, including offer eligibility, confirmation, page data, and import behavior.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: greptile-apps[bot] Review duration: 20m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.52) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #4223"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 29.7% · Safe to merge
    29.7%
    Repository