Skip to content

feat(dev-tools): add rotate-sessions developer tool#670

Open
Just-Insane wants to merge 2 commits intoSableClient:devfrom
Just-Insane:feat/devtool-rotate-sessions
Open

feat(dev-tools): add rotate-sessions developer tool#670
Just-Insane wants to merge 2 commits intoSableClient:devfrom
Just-Insane:feat/devtool-rotate-sessions

Conversation

@Just-Insane
Copy link
Copy Markdown
Contributor

Description

Adds a "Rotate Sessions" button to the Developer Tools settings panel. Triggering it re-creates all active Matrix sessions (logs out and back in all devices) so that developers can quickly cycle sessions without leaving the app.

Fixes #

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

AI disclosure:

  • Partially AI assisted (clarify which code was AI assisted and briefly explain what it does).

The new RotateSessions section in DevelopTools.tsx — renders a confirmation-gated button that calls the existing logout/re-login flow for each session in the session list. The surrounding structure (loading state, error boundary, layout) was scaffolded with AI assistance and then reviewed and verified.

@Just-Insane Just-Insane requested review from 7w1 and hazre as code owners April 12, 2026 16:12
@Just-Insane Just-Insane force-pushed the feat/devtool-rotate-sessions branch from 2e2766c to 86701ca Compare April 14, 2026 04:24
Copilot AI review requested due to automatic review settings April 14, 2026 04:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 Developer Tools action to rotate outbound room encryption sessions from within the app, along with a changeset entry for release notes.

Changes:

  • Add an “Encryption” section with a “Rotate Encryption Sessions” button and async UI states (loading/success/error).
  • Implement session discard across joined encrypted rooms and trigger key-sharing preparation.
  • Add a patch changeset for the new developer tool.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
src/app/features/settings/developer-tools/DevelopTools.tsx Adds async “Rotate Encryption Sessions” UI and logic to discard Megolm outbound sessions across encrypted rooms.
.changeset/devtool-rotate-sessions.md Records the new dev-tool feature for release notes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

import { useCallback, useState } from 'react';
import { Box, Text, Scroll, Switch, Button } from 'folds';
import { Box, Text, Scroll, Switch, Button, Spinner, color } from 'folds';
import { KnownMembership } from 'matrix-js-sdk/lib/types';
Comment on lines +150 to +156
<SettingTile
focusId="rotate-encryption-sessions"
title="Rotate Encryption Sessions"
description="Discard current Megolm sessions and begin sharing new keys with all room members. Key delivery happens in the background — send a message in each affected room to confirm the bridge has received the new keys."
after={
<Button
onClick={rotateAllSessions}
Comment on lines +46 to +54
await Promise.all(encryptedRooms.map((room) => crypto.forceDiscardSession(room.roomId)));
const rotated = encryptedRooms.length;

// Proactively start session creation + key sharing with all devices
// (including bridge bots). fire-and-forget per room.
encryptedRooms.forEach((room) => crypto.prepareToEncrypt(room));

return { rotated, total: encryptedRooms.length };
}, [mx])
Comment on lines +46 to +47
await Promise.all(encryptedRooms.map((room) => crypto.forceDiscardSession(room.roomId)));
const rotated = encryptedRooms.length;
default: patch
---

Add rotate-sessions developer tool to force session rotation for testing
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.

2 participants