Skip to content

fix: Re-render components when use_mount dirties state#27

Merged
BinaryMuse merged 2 commits into
mainfrom
mkt/fix-mount-state-rerender
Apr 14, 2026
Merged

fix: Re-render components when use_mount dirties state#27
BinaryMuse merged 2 commits into
mainfrom
mkt/fix-mount-state-rerender

Conversation

@BinaryMuse

Copy link
Copy Markdown
Member

Summary

  • Mount effects that mutate component state via use_mount were not triggering a re-render, causing the component to display stale default state until an unrelated event forced a rebuild.
  • Root cause: rebuild() unconditionally cleared needs_refresh after reconcile_children(), wiping the flag that fire_mount set during reconciliation. Additionally, fire_mount itself wasn't setting needs_refresh at all.
  • Fix: clear needs_refresh before reconciliation so mount effects can set it back, and check the dirty flag after each mount handler fires.

Reproduction

cargo run --example mount_rerender — a component sets its label in use_mount. Before this fix, the label shows [mount has not fired yet] until an external event triggers a re-render. After this fix, it correctly shows Mounted with: hello from mount immediately.

Test plan

  • All 259 existing tests pass
  • New mount_rerender example demonstrates the fix visually
  • Verified in Atuin AI's SessionContinue component (the original trigger for this bug)

Mount effects that mutate component state via use_mount were not
triggering a re-render. Two issues combined to cause this:

1. fire_mount did not set needs_refresh after running mount handlers
   that dirtied state, so refresh_dirty_views never ran for them.

2. rebuild() unconditionally cleared needs_refresh *after*
   reconcile_children(), wiping any flag set by fire_mount during
   the reconciliation pass.

Fix: clear needs_refresh before reconciliation so mount effects can
set it back, and check the dirty flag after each mount handler fires.

Adds a reproduction example (mount_rerender) that exercises the bug.
@greptile-apps

greptile-apps Bot commented Apr 14, 2026

Copy link
Copy Markdown

Greptile Summary

Fixes a bug where use_mount state mutations didn't trigger a re-render because rebuild() cleared needs_refresh after reconciliation, wiping the flag set by mount handlers. The fix is minimal and correct: clear the flag before reconciliation, then check dirty state after each mount handler fires.

Confidence Score: 5/5

Safe to merge — targeted two-line ordering fix with no side effects on existing behavior.

Both changes are minimal and correct. Moving the flag clear before reconciliation is safe, and the dirty check after mount handlers is additive. No regressions expected.

No files require special attention.

Important Files Changed

Filename Overview
crates/eye_declare/src/renderer.rs Two-part fix: clear needs_refresh before reconciliation (not after), and check dirty state after each mount handler fires to set needs_refresh back.
crates/eye_declare/examples/mount_rerender.rs New example demonstrating the use_mount re-render fix; straightforward repro case.

Reviews (1): Last reviewed commit: "cargo format" | Re-trigger Greptile

@BinaryMuse BinaryMuse merged commit 7d29d89 into main Apr 14, 2026
5 checks passed
@BinaryMuse BinaryMuse deleted the mkt/fix-mount-state-rerender branch April 14, 2026 19:55
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.

1 participant