fix(ui): fix crash on emoji messages and harden signal safety#191
Merged
fix(ui): fix crash on emoji messages and harden signal safety#191
Conversation
a951510 to
b37e52a
Compare
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>
b37e52a to
c0b9136
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
truncate_str()helper in util.rs that respects UTF-8 char boundariesROOMS.read()→ROOMS.try_read()inside spawn_local (preventive)defer()across conversation.rs, members.rs, room_list.rsTesting
cargo check -p river-ui --target wasm32-unknown-unknown --features no-syncpassescargo fmtclean[AI-assisted - Claude]