Skip to content

feat: emit system messages for channel renames - #5818

Open
thesid42 wants to merge 2 commits into
block:mainfrom
thesid42:fix/5618-channel-rename-system-message
Open

feat: emit system messages for channel renames#5818
thesid42 wants to merge 2 commits into
block:mainfrom
thesid42:fix/5618-channel-rename-system-message

Conversation

@thesid42

Copy link
Copy Markdown

Summary

  • emit a kind-40099 name_changed system event when a channel's canonical display name changes
  • include the actor, previous name, and new name while retrieving the stored previous name atomically with the update
  • render channel rename events in Desktop and mobile timelines, with fallback copy when the previous name is unavailable
  • add focused relay, integration, Desktop, and mobile coverage

Related issue

Fixes #5618

Testing

  • cargo fmt --all -- --check
  • cargo clippy -p buzz-relay -p buzz-db --all-targets -- -D warnings
  • cargo test -p buzz-relay channel_name_change --lib
  • cargo test -p buzz-test-client --test e2e_relay test_channel_rename_emits_persistent_system_message -- --ignored --exact --nocapture
  • cd desktop && node --experimental-strip-types --test src/features/messages/lib/systemEventCopy.test.mjs
  • cd desktop && tsc --noEmit
  • cd desktop && pnpm lint
  • cd 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.dart
  • cd mobile && flutter analyze lib/features/channels/timeline_message.dart test/features/channels/channel_detail_page_test.dart test/features/channels/timeline_message_test.dart
  • cd mobile && flutter test test/features/channels/timeline_message_test.dart test/features/channels/channel_detail_page_test.dart
  • manually created and renamed a channel through the native Desktop app, verified the live timeline row, reloaded the app, and confirmed the persistent kind-40099 event in Postgres

@thesid42
thesid42 requested a review from a team as a code owner August 14, 2026 00:25
Copilot AI lite review requested due to automatic review settings August 14, 2026 00:25
Signed-off-by: thesid42 <siddharthbhat44@gmail.com>

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.

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_changed system messages on successful kind-9002 channel rename edits.
  • DB: add an atomic update_channel_name helper 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.

Comment thread crates/buzz-db/src/channel.rs Outdated
@thesid42
thesid42 force-pushed the fix/5618-channel-rename-system-message branch from b20355f to cbfed0a Compare August 14, 2026 00:31
Signed-off-by: thesid42 <siddharthbhat44@gmail.com>

@Chessing234 Chessing234 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

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.

feat: emit a system message when a channel is renamed

3 participants