← Back to Pull requests

Forms: a submit by email opens a draft in the email app #7835

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

What this changes

Fixes #7693.

A form whose Submit action is a mailto: address no longer ends at "PdfCraft doesn't send form data". Clicking the button (or a script calling this.submitForm("mailto:…")) now opens the existing "open this address?" prompt in an Email this form? form:

  • it shows who gets the message and what it says: To, Cc, Bcc, Subject and Message, read from the address (RFC 6068, percent-decoded; characters that could hide text show as �, except line breaks in the body), and the whole address as before;

  • when the document has unsaved changes, or no file yet, it offers Save and open email app next to Open email app without saving. The email opens only once the save is written (a Save As dialog may take a later frame); a cancelled or failed save opens nothing;

  • the address goes to the email app exactly as the document wrote it, through the same document_url checks every document link gets, so attach=/insert= and encoded words are still refused. PdfCraft adds nothing to it;

  • afterwards the toast says what to attach ("Attach form.pdf to the new email before you send it."), or to save first when the user chose not to.
  • Web (http/https) submissions are unchanged: explained, not sent.

    Headless: a new read-only tool form_submit {doc, field} presses a submit button the same way and returns the draft (email.url/to/cc/bcc/subject/body), unsaved and attach; a web submission returns email: null with the reason, and a refused address is an error. The engine gains links::is_mail_address and links::mail_draft.

    parity/acrobat-features.toml: form.submit-form goes from planned to partial, with notes on what is still missing (attaching the form data or PDF to the message, and any web submission). docs/pdf-spec-parity.md and docs/gaps.md say the same.

    How you verified it

  • cargo fmt --check

  • clippy with -D warnings on the crates I changed

  • tests pass on the crates I changed

  • cargo xtask layers and cargo xtask assets (not run: no crate boundaries or assets touched)
  • Ran locally (macOS, Rust 1.99.1):

  • cargo test -p pdfcraft-engine --lib links:: — 24 passed, including the two new mail_draft tests

  • cargo test -p pdfcraft-automation — form_submit_reads_an_email_submission_and_sends_nothing and tool_table_is_well_formed pass; the only failures are the OCR tests, which need the recognition models I don't have installed here (the text recognition models are not installed), unrelated to this change

  • cargo test -p pdfcraft-ui-egui --test it -- form_email document_links javascript ui:: buttons — 175 passed (8 new in form_email.rs)

  • cargo clippy --no-deps -p pdfcraft-engine -p pdfcraft-automation -p pdfcraft-ui-egui --all-targets -- -D warnings, cargo fmt --all --check, cargo xtask parity, cargo xtask wasm — clean
  • Tests. With the two call sites (canvas/area.rs, workflows/js_ui.rs) reverted to main, 6 of the 7 original form_email tests fail (no prompt, no email); a_web_submission_is_only_explained passes both ways, as it pins the unchanged web notice.

    Never-crash

  • No new unwrap/expect/panic!/unreachable!/todo! outside tests

  • No indexing or slicing with input-derived positions; mail_draft reads with get and splits on ASCII, and its output is never longer than the address (at most 2048 characters after document_url)

  • No unsafe

  • No crash fixed here
  • Provenance

  • No asset from an Adobe product, and no Adobe icon recreated, traced or imitated (the prompt reuses the external-link icon)

  • No font files committed here

  • No GPL/AGPL code copied in

  • Behaviour comes from the specification (ISO 32000-2 §12.7.6.2, RFC 6068) and the issue's description

  • No new asset
  • Security

  • --root confinement still holds; form_submit reads the open document only and reports the file name, not its path

  • MCP and the UI control channel stay opt-in, loopback-only and token-authenticated

  • No new outbound network access: the email app opens a draft the user reviews and sends; PdfCraft sends nothing
  • Parity and reach

  • parity/acrobat-features.toml updated, with notes saying what is still missing

  • Reachable headlessly through form_submit

  • Docs updated (docs/pdf-spec-parity.md, docs/gaps.md)
  • Anything a reviewer should look at first

  • The file is not attached for the user. A mailto: link can't carry an attachment portably, and document_url refuses addresses that try. Once File ▸ Attach to email (#6552) lands, this prompt could hand the saved file to that path instead; I kept the two separate so neither blocks the other.

  • If a subject or body field appears twice in the address, the prompt shows the first; the full address is shown under it as before.

  • I didn't reveal the saved file in the file manager automatically: the toast names it instead. Revealing would open a Finder/Explorer window on every submission, and it has no test seam.

  • New UI strings are English in code; translations belong in craft-i18n.
  • <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Email form submissions now show a confirmation prompt with parsed recipient, subject, and message details. If the PDF needs saving, you can save it before opening your email app.
    Email submissions include instructions for attaching the PDF manually; it is not attached or sent automatically.
    Web form submissions display an explanation and are not sent. Requests requiring local-file attachments are refused.
    Automation can inspect supported form-submit actions and email draft details without sending them.
    Documentation
    * Updated feature references to describe form-submission behavior and PDF/A and PDF/X support.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: mansur-akhmadi Review duration: 17643m
    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 #7835"
    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%