feat: emit system messages for channel renames - #5818
Conversation
Signed-off-by: thesid42 <siddharthbhat44@gmail.com>
There was a problem hiding this comment.
Pull request overview
Adds a new relay-emitted kind-40099 system event (name_changed) for channel renames, propagating it through the DB update path and rendering it in both Desktop and mobile timelines with targeted coverage across layers.
Changes:
- Relay: emit
name_changedsystem messages on successful kind-9002 channel rename edits. - DB: add an atomic
update_channel_namehelper returning(previous_name, name)to support accurate system/audit messaging. - Clients/tests: parse + render rename system messages in Desktop and mobile, with unit/widget/E2E coverage.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| mobile/test/features/channels/timeline_message_test.dart | Adds parsing + description tests for name_changed system events (including no-previous-name fallback). |
| mobile/test/features/channels/channel_detail_page_test.dart | Widget coverage ensuring name_changed renders correctly in the channel timeline UI. |
| mobile/lib/features/channels/timeline_message.dart | Adds nameChanged to SystemEvent parsing and human-readable copy for timeline rendering. |
| desktop/src/features/messages/ui/SystemMessageRow.tsx | Renders name_changed by mapping payload fields to a dedicated copy helper. |
| desktop/src/features/messages/lib/systemEventCopy.ts | Introduces describeChannelNameChange(previousName, name) copy helper. |
| desktop/src/features/messages/lib/systemEventCopy.test.mjs | Unit tests covering rename copy with and without previous_name. |
| crates/buzz-test-client/tests/e2e_relay.rs | E2E test validating live delivery + persistence of the relay-signed name_changed system message. |
| crates/buzz-relay/src/handlers/side_effects.rs | Emits the name_changed system message after a successful DB rename and adds focused unit tests for content helpers. |
| crates/buzz-db/src/lib.rs | Exposes Db::update_channel_name API for relay use. |
| crates/buzz-db/src/channel.rs | Implements transactional update_channel_name with SELECT ... FOR UPDATE to return stable previous/new names. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
b20355f to
cbfed0a
Compare
Signed-off-by: thesid42 <siddharthbhat44@gmail.com>
Chessing234
left a comment
There was a problem hiding this comment.
the no-op rename path is the one thing that isn't really covered. it's reachable — canonical_channel_name means a client resending " ###foo " against a stored "foo" lands there — but should_emit_channel_name_change is just != and its test asserts !("same-name" != "same-name"), so nothing exercises the guard through handle_edit_metadata. the e2e only covers the renamed path; an assertion that a same-name kind:9002 emits zero 40099s is the one that could actually fail.
rest looks right to me — checked that this is the only rename call site so the FOR UPDATE pair really is atomic, that create_channel canonicalizes too so there's no spurious first-rename event, and that both clients drop unknown system types so older builds are unaffected.
Summary
name_changedsystem event when a channel's canonical display name changesRelated issue
Fixes #5618
Testing
cargo fmt --all -- --checkcargo clippy -p buzz-relay -p buzz-db --all-targets -- -D warningscargo test -p buzz-relay channel_name_change --libcargo test -p buzz-test-client --test e2e_relay test_channel_rename_emits_persistent_system_message -- --ignored --exact --nocapturecd desktop && node --experimental-strip-types --test src/features/messages/lib/systemEventCopy.test.mjscd desktop && tsc --noEmitcd desktop && pnpm lintcd mobile && dart format --output=none --set-exit-if-changed lib/features/channels/timeline_message.dart test/features/channels/channel_detail_page_test.dart test/features/channels/timeline_message_test.dartcd mobile && flutter analyze lib/features/channels/timeline_message.dart test/features/channels/channel_detail_page_test.dart test/features/channels/timeline_message_test.dartcd mobile && flutter test test/features/channels/timeline_message_test.dart test/features/channels/channel_detail_page_test.dart