Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

fix(console): list no Switch Console chat you are not in on a server this Console runs

raullopez-sandbox4691067625bb
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-filters.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-filters.ts
index 197defb32..c0094a49c 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-filters.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-filters.ts
@@ -70,9 +70,18 @@ export function allReadableRooms(
readable: RemoteRoomSummary[]
): RemoteRoomSummary[] {
const listed = new Set(yours.map((room) => room.id));
- const more = readable.filter(
- (room) => !listed.has(room.id) && (room.bridgeType !== null || room.viewerIsMember)
- );
+ const more = readable.filter((room) => !listed.has(room.id) && !isConsoleChatYouAreNotIn(room));
if (more.length === 0) return yours;
return [...yours, ...more].sort((a, b) => a.name.localeCompare(b.name));
}
+
+/** A Switch Console chat (unbridged, direct or private) the signed-in user is not in: they cannot open it. */
+export function isConsoleChatYouAreNotIn(
+ room: Pick<RemoteRoomSummary, 'bridgeType' | 'channelType' | 'viewerIsMember'>
+): boolean {
+ return (
+ room.bridgeType === null &&
+ (room.channelType === 'direct' || room.channelType === 'channel_private') &&
+ !room.viewerIsMember
+ );
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-rooms-store.test.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-rooms-store.test.ts
index 3ee1fe633..6503b612d 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-rooms-store.test.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-rooms-store.test.ts
@@ -84,6 +84,12 @@ describe('listed rooms', () => {
room('mine', 'user-of-srv-a'),
room('someone-elses', 'user-of-someone-else'),
room('gone', 'user-of-srv-a', { archived: true }),
+ // A Switch Console chat they are not in: the server will not open it to them.
+ room('not-my-chat', 'user-of-someone-else', { channelType: 'channel_private' }),
+ room('my-chat', 'user-of-someone-else', {
+ channelType: 'channel_private',
+ viewerIsMember: true,
+ }),
]
: []
);
@@ -91,7 +97,11 @@ describe('listed rooms', () => {
const store = new SwitchRoomsStore();
await store.loadRoomNames();
- expect(store.listedRoomsInActiveScope.map((r) => r.id)).toEqual(['mine', 'someone-elses']);
+ expect(store.listedRoomsInActiveScope.map((r) => r.id)).toEqual([
+ 'mine',
+ 'my-chat',
+ 'someone-elses',
+ ]);
});
it('lists only rooms owned by that server’s signed-in user, excluding archived ones', async () => {
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-rooms-store.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-rooms-store.ts
index 78c69d2d8..369a1d802 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-rooms-store.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-rooms-store.ts
@@ -9,6 +9,7 @@ import {
type RetireOutcome,
} from '@shared/core/switch-servers/switch-servers';
import { UNBRIDGED_FILTER_VALUE } from '@shared/view-state';
+import { isConsoleChatYouAreNotIn } from './room-filters';
import { serverAvailability } from './server-availability';
import { switchServersStore } from './switch-servers-store';
@@ -184,7 +185,11 @@ export class SwitchRoomsStore {
listedRoomsInWorkspace(workspaceId: string): RemoteRoomSummary[] {
const serverId = workspacesStore.serverIdFor(workspaceId);
const managed = switchServersStore.servers.find((s) => s.id === serverId)?.managed ?? false;
- if (managed) return this.allRoomsByWorkspace.get(workspaceId) ?? [];
+ if (managed) {
+ return (this.allRoomsByWorkspace.get(workspaceId) ?? []).filter(
+ (room) => !isConsoleChatYouAreNotIn(room)
+ );
+ }
const own = this.ownedRoomsByWorkspace.get(workspaceId) ?? [];
const ownIds = new Set(own.map((room) => room.id));
// And the rooms the user's agents are in, managed ones included, by their membership.
diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/your-rooms-view.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/your-rooms-view.test.tsx
index 9d486524e..662c562c9 100644
--- a/console/apps/switch-console-desktop/src/renderer/tests/browser/your-rooms-view.test.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/your-rooms-view.test.tsx
@@ -88,8 +88,9 @@ let root: Root;
beforeEach(() => {
rooms.list = observable({
all: [
- room('bobs-chat', { viewerIsMember: true }),
- room('strangers-chat', {}),
+ room('bobs-chat', { viewerIsMember: true, channelType: 'channel_private' }),
+ room('strangers-chat', { channelType: 'channel_private' }),
+ room('public-room', { channelType: 'channel_public' }),
room('public-slack', { bridgeType: 'slack', bridgeDisplayName: 'Slack' }),
],
});
@@ -123,9 +124,9 @@ it('lists your rooms by default, and drops a chat once you are removed from it',
it('offers All rooms to someone who can read more: bridged rooms, never chats they are not in', async () => {
await render();
await act(async () => toggle('All rooms')!.click());
- expect(names()).toEqual(['#public-slack', 'bobs-chat']);
+ expect(names()).toEqual(['#public-slack', 'bobs-chat', 'public-room']);
await act(async () => runInAction(() => (rooms.list.all[0].viewerIsMember = false)));
- expect(names()).toEqual(['#public-slack']);
+ expect(names()).toEqual(['#public-slack', 'public-room']);
});
it('offers no choice to someone who can read only their own rooms', async () => {