Skip to content

fix(wasm): preserve TextField callback strings on web - #8621

Closed
proggeramlug wants to merge 2 commits into
PerryTS:mainfrom
proggeramlug:fix/8584-web-textfield-value
Closed

fix(wasm): preserve TextField callback strings on web#8621
proggeramlug wants to merge 2 commits into
PerryTS:mainfrom
proggeramlug:fix/8584-web-textfield-value

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Preserve browser text input values as strings when invoking Perry WASM closures. The WASM bridge now performs the JS-value-to-i64 conversion exactly once, avoiding NaN payload canonicalization that made TextField callbacks receive numeric NaN.

Changes

  • Pass plain DOM strings from TextField, SecureField, and TextArea into callWasmClosure.
  • Remove the same premature boxing from other WASM closure bridge call sites.
  • Document the bridge contract and add a regression test that rejects pre-boxed callback arguments.

Related issue

Fixes #8584

Test plan

  • cargo fmt -p perry-codegen-wasm -- --check
  • cargo test -p perry-codegen-wasm
  • Compiled the issue's exact reproduction with cargo run -p perry --no-default-features --features backend-wasm -- compile /tmp/perry-8584-repro.ts --target web -o /tmp/perry-8584-web.html
  • Confirmed the generated web runtime passes el.value directly and contains no fromJsValue(el.value) call
  • ./scripts/test_affected_crates.sh --base upstream/main (1,026 tests pass; the unrelated codegen_env_vars_are_build_cache_inputs test fails because current upstream/main does not classify its new PERRY_OUTLINE_ENTRY* variables)
  • ./scripts/pre-tag-check.sh --quick (all non-format quick gates pass; current upstream/main has a pre-existing rustfmt mismatch in module_global_typed_array_read.rs)
  • Added a #[test] in the affected crate
  • No CLI, stdlib, or runtime API documentation change required

Checklist

  • I have NOT bumped the workspace version or edited CLAUDE.md / CHANGELOG.md
  • My commits follow the repository's conventional prefix style
  • I've read CONTRIBUTING.md and agree to the Code of Conduct

@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 84a4b6f5-b762-4ab4-bd20-1bf362262f07

📥 Commits

Reviewing files that changed from the base of the PR and between 73df2a6 and 8ab8dbb.

📒 Files selected for processing (3)
  • changelog.d/8621-web-textfield-callback-strings.md
  • crates/perry-codegen-wasm/src/lib.rs
  • crates/perry-codegen-wasm/src/wasm_runtime.js

Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

Web callback paths now pass browser values directly to callWasmClosure. TextField, SecureField, and TextArea callbacks preserve entered strings. Related state, dialog, file, and media callbacks use the same conversion path. A test verifies the text-input call sites.

Changes

WASM callback conversion

Layer / File(s) Summary
Direct callback values
crates/perry-codegen-wasm/src/wasm_runtime.js, crates/perry-codegen-wasm/src/lib.rs, changelog.d/8621-web-textfield-callback-strings.md
TextField, SecureField, and TextArea pass raw values to callWasmClosure. State, dialog, file, and media callbacks also remove redundant fromJsValue conversion. A test verifies the three text-input call sites and the absence of pre-boxing. The changelog documents string-valued Web callbacks.

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

Merge Risk: ⚪ Minimal · up to 8ab8d

This localized WASM bridge change preserves text input values as strings for callbacks, with targeted regression coverage and no actionable merge-blocking risk remaining beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 2 files. (1 skipped: 1 unsupported.) Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address issue #8584 by preserving Web TextField callback strings and adding regression coverage for single-value conversion.
Out of Scope Changes check ✅ Passed The changelog, bridge consistency updates, and regression test support the stated WASM callback conversion fix without unrelated changes.
Title check ✅ Passed The title clearly and concisely identifies the WASM fix for preserving TextField callback strings on the web.
Description check ✅ Passed The description includes the required summary, changes, issue reference, test plan, and checklist with relevant verification details.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

proggeramlug added a commit that referenced this pull request Aug 22, 2026
* fix(wasm): preserve text input callback strings

* test(link): guard prebuilt stdlib HTTP isolation (#8587)

* docs(changelog): note web text callback fix

* docs: add the missing changelog fragment for #8622

---------

Co-authored-by: Ralph Küpper <ralph@skelpo.com>
@proggeramlug

Copy link
Copy Markdown
Contributor Author

Landed via #8626, which carries this branch's commits plus #8622's missing changelog.d fragment.

Validated on the combined tree: cargo check --workspace --all-targets exit 0, perry-runtime --lib 2636 passed, all seven ratchets and cargo fmt --check clean, with the ratchets re-run against the current baseline immediately before merge.

@proggeramlug
proggeramlug deleted the fix/8584-web-textfield-value branch August 22, 2026 20:53
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.

Perry/ui TextField works on Linux but not on Web target

1 participant