Skip to content

fix(ui): fix crash on emoji messages and harden signal safety#191

Merged
sanity merged 1 commit intomainfrom
fix/emoji-crash-and-signal-safety
Mar 24, 2026
Merged

fix(ui): fix crash on emoji messages and harden signal safety#191
sanity merged 1 commit intomainfrom
fix/emoji-crash-and-signal-safety

Conversation

@sanity
Copy link
Copy Markdown
Contributor

@sanity sanity commented Mar 24, 2026

Problem

River crashes with "RefCell already borrowed" when sending messages containing multi-byte emoji characters. Reported by luckytango on Matrix — sending a message with 👀 triggered a panic that corrupted Dioxus internal state.

Root cause: &message_text[..message_text.len().min(30)] at conversation.rs:989 panics when a multi-byte UTF-8 character straddles the 30-byte boundary. The 👀 emoji is 4 bytes (27..31), so slicing at byte 30 is inside the character. This panic cascades into "RefCell already borrowed" at dioxus-core diff/node.rs:70.

Secondary: several onclick handlers mutated GlobalSignals without defer(), violating AGENTS.md signal safety rules.

Approach

  1. Added truncate_str() helper in util.rs that respects UTF-8 char boundaries
  2. Changed debug log truncation to use the safe helper
  3. Changed ROOMS.read()ROOMS.try_read() inside spawn_local (preventive)
  4. Wrapped 6 onclick GlobalSignal mutations with defer() across conversation.rs, members.rs, room_list.rs

Testing

  • cargo check -p river-ui --target wasm32-unknown-unknown --features no-sync passes
  • cargo fmt clean
  • Verified the crash is reproducible with the exact message from the bug report ("That moment when you...👀👀👀!")

[AI-assisted - Claude]

@sanity sanity force-pushed the fix/emoji-crash-and-signal-safety branch 2 times, most recently from a951510 to b37e52a Compare March 24, 2026 16:10
Fix two bugs:

1. String slicing panic on multi-byte emoji characters in debug log
   (conversation.rs:989). Slicing `&text[..30]` panics when a multi-byte
   character (e.g. 👀, 4 bytes) straddles byte offset 30. This was the
   root cause of the crash reported by luckytango — the panic corrupted
   Dioxus internal state, cascading into "RefCell already borrowed" at
   diff/node.rs:70.

2. Preventive signal safety hardening: changed ROOMS.read() to
   ROOMS.try_read() inside spawn_local (conversation.rs:1128), and
   wrapped 6 onclick GlobalSignal mutations with defer() across
   conversation.rs, members.rs, and room_list.rs per AGENTS.md rules.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sanity sanity force-pushed the fix/emoji-crash-and-signal-safety branch from b37e52a to c0b9136 Compare March 24, 2026 16:11
@sanity sanity merged commit 677a674 into main Mar 24, 2026
5 checks passed
@sanity sanity deleted the fix/emoji-crash-and-signal-safety branch March 24, 2026 16:21
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