Skip to content

Feature: Leave Matrix rooms from chat UI #94

@mjkatgithub

Description

@mjkatgithub

Goal

Let users leave Matrix rooms (channels and group chats under Home) from Decentra, with clear confirmation and immediate UI updates, similar to Element/Discord.

Scope

  • useMatrixClient: leaveRoom(roomId) via matrix-js-sdk (leave / membership leave)
  • Entry point in the active room UI (e.g. room header menu or channel row context action)
  • Confirmation modal before leaving (destructive action)
  • After success: clear selection, refresh sidebar, navigate to a safe view (Home or last room)
  • Show actionable errors when leave is denied (power levels, server policy)
  • English and German strings (i18n)
  • For 1:1 DMs: remove room from m.direct account data when applicable (match existing DM create flow)

Out of scope for this issue:

  • Leaving/kicking other members (moderation)
  • Deleting the room for everyone (requires higher PL / separate feature)
  • Leaving a Space as a whole (only room membership here)

Branch

feature/leave-room

Acceptance Criteria

  • User can leave the currently open room from the chat UI
  • User can leave a room from the channel list without opening it (optional but recommended)
  • Confirmation is required; cancel keeps membership unchanged
  • Left room disappears from Home/space channel lists without full page reload
  • If the left room was selected, chat view shows a neutral state (no stuck empty timeline)
  • Matrix/API errors surface as user-visible messages (not silent failure)
  • DM rooms are cleaned up in m.direct when the local user leaves

Test Checklist

Unit

  • Leave helper calls SDK with correct roomId
  • DM account-data cleanup helper (mocked client)
  • Error mapping for common Matrix failures

Integration

  • Leave group room under Home → room gone from Groups (Cucumber E2E @leave_room)
  • Leave channel inside a space → room gone from space list (Cucumber E2E @leave_room)
  • Leave while room is open → redirects / clears selection (Cucumber E2E @leave_room)

E2E

  • Join or create test room, leave, verify not in sidebar and cannot send messages
  • Leave DM room, verify removed from Personal chats

Notes

  • matrix-js-sdk: MatrixClient.leave(roomId)
  • Timeline already renders m.room.member with membership: leave for others; reuse patterns for local leave
  • Related UX work: invites (# recent), Home room grouping — leaving complements create/invite flows
  • Shipped: Sidebar ellipsis menu (next to notification bell), LeaveRoomConfirmPanel, leaveRoom + removeDirectAccountData in roomsOrDirectory.ts, suppressAutoRoomSelect for neutral view after leave.
  • UX polish: Leave menu item color: error (red); after leave → /chat Home (HOME_SPACE_ID, no room, onboarding panel).
  • Follow-up (#124): General space home / sitemap when a space is selected but no room (e.g. space rail click). After Feature: Space home / sitemap view (space selected, no room) #124, leaving a channel inside a space can land there instead of Home; interim leave always uses Home onboarding.
  • E2E: @leave_room in chat.feature — side seeded room (group), seeded space channel, seeded leave-DM room (E2E_LEAVE_DM_ROOM_ID in runtime-seed-synapse.mjs). Steps in leave-room.steps.mjs; select Home rail before Home sidebar rooms. Run: npm run test:e2e or npx cucumber-js --tags @leave_room (Synapse + preview; stop npm run dev on port 3000).
  • Docs: docs/architecture.md (leave flow, cheat sheet)

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status
    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions