Skip to content

fix: selection across wrapped rows, hot remount, live scroll wheel and env sync - #5

Closed
mateo-m wants to merge 23 commits into
feat/scrollbarsfrom
fix/selection-remount-automation
Closed

mateo-m wants to merge 23 commits into
feat/scrollbarsfrom
fix/selection-remount-automation

Conversation

@mateo-m

@mateo-m mateo-m commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Contains #4.

What this adds

  • Selection covers the first glyph of a wrapped row. The wash walked visual rows with position_for_index, which reports a soft-wrap boundary on the earlier row, so each continuation row started one glyph late.
  • Events survive a bun --hot remount. The renderer-to-container map now lives on globalThis, so the module instance the native callback holds and the reloaded instance share it. The slot only takes over a value that really is a WeakMap.
  • process.env overrides reach Rust under Bun through a syncEnvVar export. Bun only updates its JS snapshot, so the Rust side never saw a late assignment. The values land in an override map, not in setenv, because setenv races getenv on the dedicated UI thread of Windows and Linux.
  • The automation stdio test runs under the bun runner.
  • Debug builds compile the image crates at opt-level 3. capture_screenshot encodes a png per visual test, and the encoder at opt-level 0 was slow enough that vitest killed the worker.

The live scrollWheel automation method this PR first added now comes from upstream main with modifier support, so this branch dropped its own copy.

What I ran and saw

  • cargo test at this branch: 301 passed, 0 failed.
  • The react suite at this branch: 432 passed, 0 failed. The motion stall the first version of this PR described is gone, fixed in feat: css value styles, linear gradients and motion to auto height #1.
  • The wrapped-row fix has a test that fails without it: the wash misses the first glyph of the continuation row. I reverted the fix, watched the test fail on the missing wash pixels, and put the fix back.

What I did not verify

  • Windows and Linux. Every run above was on macOS. CI builds the other targets.

@mateo-m mateo-m self-assigned this Aug 26, 2026
@mateo-m
mateo-m requested a lite review from Copilot August 26, 2026 19:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

There are correctness and safety concerns around env syncing (flush coverage in the test renderer and potential cross-thread environment mutation in native) that should be addressed before merging.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR improves core runtime ergonomics across GPUIX’s TypeScript/Rust boundary: fixing selection wash coverage on soft-wrapped text, keeping event routing stable across Bun hot reloads, enabling live scroll-wheel automation, and ensuring Bun process.env overrides can be observed from Rust.

Changes:

  • Fix selection wash geometry so wrapped-line continuation rows include the first glyph.
  • Make Bun hot remounts preserve event delivery by sharing renderer→container mappings via globalThis and by making onEvent swappable.
  • Add live automation scroll-wheel dispatch plus a new native syncEnvVar hook (and debug-profile PNG encoder optimization).
File summaries
File Description
packages/react/src/testing.ts Adds env override syncing and exposes scrollIntoView on the JS test renderer.
packages/react/src/reconciler/renderer.ts Routes native events through a hot-reload-stable onEvent slot.
packages/react/src/reconciler/event-registry.ts Persists renderer→container mapping across Bun --hot module reloads.
packages/react/src/automation/client.ts Enables live scrollWheel by calling into native scroll-wheel simulation.
packages/react/src/tests/automation-stdio.test.ts Adjusts rejection assertion to avoid Bun runner stalling behavior.
packages/native/src/text/paint.rs Fixes selection wash rects across wrapped visual rows.
packages/native/src/style/vars.rs Formatting-only test/utility cleanup.
packages/native/src/style/resolve.rs Formatting-only test cleanup.
packages/native/src/style.rs Formatting-only test cleanup.
packages/native/src/renderer/frame.rs Formatting-only refactor of element build dispatch.
packages/native/src/renderer.rs Adds sync_env_var export and production simulate_scroll_wheel dispatch path.
packages/native/src/motion.rs Formatting-only test cleanup.
packages/native/src/color.rs Adds gradient stop easing mapping plus formatting changes.
packages/native/src/automation.rs Implements scroll-wheel event dispatch through the window.
packages/native/index.js Exports syncEnvVar from the native binding.
packages/native/index.d.ts Declares simulateScrollWheel and syncEnvVar in the native TS surface.
packages/native/Cargo.toml Speeds up debug visual tests by compiling PNG/image crates with opt-level 3.
AGENTS.md Documentation tidy-ups and a corrected Zed link.
.changeset/sync-env-overrides-under-bun.md Changeset for Bun env override syncing.
.changeset/survive-a-hot-remount.md Changeset for hot remount event survivability.
.changeset/select-across-wrapped-rows.md Changeset for wrapped-row selection wash fix.
.changeset/live-scroll-wheel.md Changeset for live scroll-wheel automation.
Review details

Suppressed comments (1)

packages/react/src/testing.ts:244

  • syncEnvOverrides() is only invoked when calling TestRenderer.flush(), but most methods in this class call this.native.flush() directly. That means env overrides may not be synced for many render passes (e.g. scrollTo/scrollIntoView/simulation helpers) even though the comment says it runs before every frame flush. One way to ensure coverage without touching all call sites is to wrap this.native.flush once and then call it normally.
  flush(): void {
    syncEnvOverrides()
    this.native.flush()
  }
  • Files reviewed: 21/22 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/react/src/testing.ts
Comment thread packages/react/src/reconciler/event-registry.ts
Comment thread packages/native/src/renderer.rs Outdated
# Conflicts:
#	packages/native/src/renderer/frame.rs
# Conflicts:
#	packages/native/src/renderer/frame.rs
#	packages/react/src/reconciler/event-registry.ts
@mateo-m

mateo-m commented Sep 4, 2026

Copy link
Copy Markdown
Owner Author

Moved to remorses#54.

@mateo-m mateo-m closed this Sep 4, 2026
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.

2 participants