Skip to content

fix(forms): ignore print requests from automatic field scripts - #4166

Open
enriquemelzer-bit wants to merge 5 commits into
storytold:mainfrom
enriquemelzer-bit:fix/field-script-print-requests
Open

enriquemelzer-bit wants to merge 5 commits into
storytold:mainfrom
enriquemelzer-bit:fix/field-script-print-requests

Conversation

@enriquemelzer-bit

@enriquemelzer-bit enriquemelzer-bit commented Oct 23, 2026 •

Copy link
Copy Markdown

What this changes

Fixes #4088. Automatic AcroForm Keystroke, Validate, Calculate and Format scripts can no longer open printing by calling this.print(). The collector ignores those requests and records a JavaScript console diagnostic. Field values, structured alerts, other requests and errors remain intact. Explicit button and console scripts can still request printing, including when they trigger automatic calculations.

Integrated with main f137a289baadefbd29e0e46930899896068cc41d (PdfCraft 0.16.1). Main's ShowPanel/SaveAs filtering, document-error provenance, structured message metadata and module boundaries are preserved. Cargo manifests and Cargo.lock match incoming main exactly, including craft-libs c5a1cbfb5f9049f9270955caffb5bee5997aebf7. This retains the merged craft-libs #366 correction; the temporary dependency adjustment is no longer needed. CI workflows are unchanged relative to main.

How you verified it

Current integration validation — 2026-10-31, Windows x64 / Rust 1.95:

  • Engine and automation suites: 761 passed, 0 failed, 4 existing ignored: 46 automation unit, 307 automation integration, 392 engine unit and 16 engine integration tests passed.
  • Formatting and scoped all-target Clippy with -D warnings passed. cargo xtask layers passed for 37 crates; assets and parity checks passed. Parity retains main's 100 existing headless notices.
  • Scoped engine/automation wasm32-unknown-unknown check passed. Five existing renderer platform warnings and three optional egui patch notices remain.
  • A fresh CLI build and verify4166-main-20261031.py passed all 13 synthetic steps: Qty=4 recalculates Total=8, explicit button/console scripts retain Print requests, and save/render succeeds. The generated filled.png was inspected and shows the values 4 and 8. This is CLI render evidence, not a native printer or UI/GPU-suite qualification.

The three engine regressions and form_fill_cannot_print_but_js_run_can cover all four automatic events, requests emitted before an error, document-error provenance and explicit scripts that trigger calculations. The Rust regression checks the automatic request queue directly, which form_fill JSON does not expose. Static integration review found no lost feature changes.

The current runs used the exact CI font input b076417b5880bd4154bd22f00695b1d28c6bea83, with system fonts disabled, two build jobs, debug symbols omitted and incremental compilation disabled.

Historical evidence, 2026-10-29 only: the previous 0.15 integration recorded 727 engine/automation tests passed, zero failed and four ignored, the scoped verification gates, and a 13-step synthetic CLI exercise with an inspected render. The original regressions had been observed failing with leaked Print requests before the fix. Those results do not validate this 0.16.1 integration.

Never-crash, provenance and security

No new production panic paths, unsafe code, assets, fonts, filesystem/network access or control-channel permissions. Existing JavaScript request limits bound the added diagnostics.

Parity and reach

The existing form.js-security parity entry cites the three engine tests and the automation regression. form_fill and js_run exercise the boundary headlessly. Engine guidance and roadmaps describe the behavior. The contributor's public GitHub-name opt-in was explicitly authorized; only their own entry is added, preserving all incoming credits.

Anything a reviewer should look at first

The production change is the additional Print arm in JsOutput::absorb. Previously documented UI limitations remain outside this fix: literal button-script this.print() classification can skip preceding assignments, and console dialog restoration can hide the Print dialog. Native printer transport is untested.

Summary by CodeRabbit

  • Behavior Changes
    • Print requests from automatic form scripts are ignored and reported in the JavaScript console. These scripts can still update field values, show alerts, and perform other supported actions.
    • Explicit button and console scripts can still request printing. Script errors and console output continue to be preserved.
  • Documentation
    • Updated guidance and feature notes to describe automatic form-script behavior, printing options, and related regression coverage.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between d7870c4 and add4d5b.

Files selected for processing: 5
  • ROADMAP.md
  • contributors/people.toml
  • crates/engine/src/tests.rs
  • docs/roadmap.md
  • parity/acrobat-features.toml
Files skipped from review as they are similar to previous changes: 3
  • parity/acrobat-features.toml
  • docs/roadmap.md
  • ROADMAP.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

Automatic AcroForm field scripts now have Print requests ignored and reported in the JavaScript console. Explicit button and console scripts can still request printing. Tests and project records cover request filtering, preserved script behavior, and error reporting.

Changes: AcroForm printing behavior

Layer / File(s) Summary
Filter automatic-script print requests and verify behavior
crates/engine/src/js.rs, crates/engine/src/tests.rs, crates/automation/src/tests.rs
JsOutput::absorb drops and logs Print requests from automatic field scripts. Tests cover all four automatic field events, retained field values and other script output, error reporting, calculation-triggered requests, and explicit button and console printing.
Document and record printing behavior
crates/engine/README.md, parity/acrobat-features.toml, ROADMAP.md, docs/roadmap.md
The README and parity record describe the request handling and explicit printing. Roadmap entries record the M6 integration and additional milestone updates.

Contributor metadata

Layer / File(s) Summary
Add contributor synchronization entry
contributors/people.toml
Adds the enriquemelzer-bit contributor entry with GitHub-name synchronization enabled.

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: dylanmtaylor, aiongg

Merge Risk: Minimal · up to add4d

Automatic field-script printing is suppressed while explicit printing remains available. No merge-blocking risk is identified.

Architecture risk: Low · up to add4d

The change affects 5 systems.

Changed systems: crates, contributors, docs, parity, ROADMAP.md

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — crates (service) was modified; 4 changed files map to changed impact.
  • observed — contributors (service) was modified; 1 changed file maps to changed impact.
  • observed — docs (service) was modified; 1 changed file maps to changed impact.
  • observed — parity (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in crates/engine/README.md: Added documentation of automatic AcroForm script execution and request handling: Print, ShowPanel, and SaveAs requests are ignored with a console diagnostic; field values, alerts, and other requests are retained; explicit button and console scripts can request printing.
  • observed — Modified behavior in crates/automation/src/tests.rs: Added a test exercising print requests from form-validation scripts versus explicit js_run: form filling is expected to preserve the field value and console output while yielding no print request or errors, whereas explicit script execution is expected to return a print request.
  • observed — Modified behavior in crates/engine/src/js.rs: The absorb documentation now includes print requests among the requests noted on the console and dropped.
  • observed — Modified behavior in crates/engine/src/js.rs: The comment now says only explicit button or console scripts may print, show, or hide a side panel, or open Save As. Automatic field-script Request::Print requests are now dropped with a console message directing users to a button or the JavaScript console; previously they were passed through to requests.
Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Out of Scope Changes check Warning The supplied whole-PR summary identifies a new [people.enriquemelzer-bit] entry with sync_github_name = true in contributors/people.toml. Contributor credit does not implement or support the Pri… Remove the [people.enriquemelzer-bit] contributor entry and its sync_github_name = true setting from this pull request. Move the contributor credit to a separate maintenance pull request.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: ignoring print requests from automatic field scripts.
Description check Passed The description covers the change, verification results, regression tests, never-crash, provenance, security, parity, reach, and reviewer considerations. It is complete and directly related to the pul…
Linked Issues check Passed Issue #4088 requires suppression of Print requests from automatic AcroForm Keystroke, Format, Validate, and Calculate scripts, with a JavaScript console diagnostic. It requires Print to remain availab…
Full details: Description check

Explanation

The description covers the change, verification results, regression tests, never-crash, provenance, security, parity, reach, and reviewer considerations. It is complete and directly related to the pull request.

Full details: Linked Issues check

Explanation

Issue #4088 requires suppression of Print requests from automatic AcroForm Keystroke, Format, Validate, and Calculate scripts, with a JavaScript console diagnostic. It requires Print to remain available to button Mouse Up scripts. The JsOutput::absorb diff adds a Request::Print filter and the required diagnostic in the automatic field-script path. The supplied change summary reports engine and automation tests for all four events, preserved values and errors, and explicit button and console printing. The implementation meets the coding requirements in #4088.

Full details: Out of Scope Changes check

Explanation

The supplied whole-PR summary identifies a new [people.enriquemelzer-bit] entry with sync_github_name = true in contributors/people.toml. Contributor credit does not implement or support the Print suppression required by #4088. The engine change, tests, parity entry, and documentation are connected to the issue.

Resolution

Remove the [people.enriquemelzer-bit] contributor entry and its sync_github_name = true setting from this pull request. Move the contributor credit to a separate maintenance pull request.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@enriquemelzer-bit
enriquemelzer-bit marked this pull request as ready for review October 23, 2026 04:09

@ahmadmuj ahmadmuj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked f948111 with engine, automation and headless UI tests. Automatic K/V/C/F printing stays suppressed through repeated edits and save/reopen, with values and errors retained.

Two existing UI limits affect the explicit-printing claim:

  • A button running getField('greeting').value=6; this.print(); opens Print but skips the assignment. button_script classifies it as Named(Print); the bracket-call fixture this['print']() runs the assignment and opens Print.
  • Console Run dispatches Print, but dialog rendering then restores JsConsole, so the print dialog does not appear.

Both paths are unchanged from the base; these are not regressions from this filter. Could the description qualify the UI coverage? Native printer transport remains untested.

@enriquemelzer-bit
enriquemelzer-bit force-pushed the fix/field-script-print-requests branch from f948111 to cadf570 Compare October 24, 2026 07:47
@enriquemelzer-bit

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@enriquemelzer-bit

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@enriquemelzer-bit

Copy link
Copy Markdown
Author

@coderabbitai resume

@enriquemelzer-bit

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Action performed

Reviews resumed. No new commits to review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forms JavaScript: a field's own AcroForm scripts can open the print dialog unasked

2 participants