Skip to content

fix(transform): #764 — module-init State() no longer breaks stateOnChange (v0.5.910)#766

Open
proggeramlug wants to merge 1 commit into
mainfrom
worktree-issue-764-reactive-text
Open

fix(transform): #764 — module-init State() no longer breaks stateOnChange (v0.5.910)#766
proggeramlug wants to merge 1 commit into
mainfrom
worktree-issue-764-reactive-text

Conversation

@proggeramlug
Copy link
Copy Markdown
Contributor

Summary

Test plan

  • cargo test --release -p perry-transform — 23/0/0, includes the 4 new gate tests.
  • Full workspace tests (excluding cross-host UI crates per CLAUDE.md) — exit 0.
  • test_issue_763_reactive_textfield.ts — AppleScript validation on macOS: typing into the TextField AND clicking the "set hello world" button both reactively update the standalone Text(\current state for text: ${text.value}`)` widget.
  • test_issue_764_state_at_module_init.ts — CLI smoke: stateOnChange callback fires on every cell.set(...).
  • perry/ui: TextField in non-initially-active NavStack route doesn't accept geisterhand /type after screen.set #640 NavStack regression: test_issue_640_navstack_textfield.ts still routes A↔B correctly.
  • Windows path (the user's Reactive state in textfield not working #763 platform) — not yet validated here; the fix is purely in the platform-agnostic HIR transform layer so the symptom should resolve there too if the underlying cause matched. Worth a follow-up confirmation from the reporter.

Notes

  • Version bump 0.5.909 → 0.5.910. CLAUDE.md + Cargo.toml + Cargo.lock + CHANGELOG entry included.
  • New TS fixtures need --target macos to link perry-ui-macos, so they join test_issue_640_navstack_textfield in the compile-smoke SKIP_TESTS list.
  • Auto-bind reactive template literals in Text/TextField labels to perry_ui_state_bind_text_template #764 was originally filed as a "wire Text(\…${state.value}…`)toperry_ui_state_bind_text_template" feature request, but investigation showed the IIFE-based auto-bind has shipped since v0.5.112 — the user-visible failure in #763 is actually this separate module-init regression. The runtime-side perry_ui_state_bind_text_template` consolidation is left as a future architectural improvement.

…Change (v0.5.910)

Gate `state_desugar` so it only rewrites a `State(...)` / `state(...)`
binding to the synthetic `__state_*` keyed runtime when *no* handle-based
state API (stateOnChange / stateBindTextfield / stateBindToggle /
stateBindSlider / stateBindVisibility / stateBindTextNumeric) consumes
that binding anywhere in the module — including function bodies and class
methods, which is where the #763 reactive-Text desugar emits its
`stateOnChange(cell, ...)` calls.

Pre-fix, `const cell = State(""); stateOnChange(cell, cb); cell.set("v")`
at module-init level updated `cell.value` correctly but never fired `cb`
because the desugar replaced `cell`'s init with `Undefined` while leaving
`stateOnChange(cell, ...)` untouched — handle-based FFI saw garbage and
the subscriber registry stayed empty. NavStack / ForEach / `.set` /
`.value` / `.get` / `.text` rewrites are unchanged (they have full
keyed-side implementations); lowercase `state(...)` flows through #535
exactly as before when used purely keyed-API.

Includes 4 unit tests in state_desugar.rs covering the gate (uppercase
+ stateOnChange skipped, lowercase + stateBindTextfield skipped, pure
keyed-API still rewritten, handle use inside function body still gates
module-init binding) and two integration fixtures under `test-files/`:
- `test_issue_763_reactive_textfield.ts` — user's original UI repro
  (validated via AppleScript: typing and button click both update
  the standalone reactive Text widget).
- `test_issue_764_state_at_module_init.ts` — CLI parity (stateOnChange
  callback fires correctly when State is at module-init).

Both new TS fixtures need `--target macos` to link perry-ui-macos, so
they join `test_issue_640_navstack_textfield` in the compile-smoke
SKIP_TESTS list. NavStack regression check: #640 still routes A↔B.
`cargo test --release -p perry-transform` 23/0/0; full workspace tests
green.

Refs #763.
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.

Auto-bind reactive template literals in Text/TextField labels to perry_ui_state_bind_text_template

1 participant