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): a chat's add field stays open under Participants for a manager

raullopez-sandboxaab05b0afa33
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-configuration-panel.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-configuration-panel.tsx
index 754d27657..cf7950287 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-configuration-panel.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-configuration-panel.tsx
@@ -131,7 +131,6 @@ const ChatParticipantsSection = observer(function ChatParticipantsSection({
queryKey: membersKey,
queryFn: () => rpc.chats.members(serverId, roomId),
});
- const [adding, setAdding] = useState(false);
const [removing, setRemoving] = useState<string | null>(null);
const [error, setError] = useState<string | null>(null);
const people = members.data ?? [];
@@ -181,8 +180,9 @@ const ChatParticipantsSection = observer(function ChatParticipantsSection({
<Button
variant="outline"
size="sm"
- aria-expanded={adding}
- onClick={() => setAdding((v) => !v)}
+ aria-controls={ADD_PARTICIPANT_INPUT}
+ // Focusing the field opens its results.
+ onClick={() => document.getElementById(ADD_PARTICIPANT_INPUT)?.focus()}
>
<Plus className="size-3.5" />
Add participants
@@ -190,7 +190,7 @@ const ChatParticipantsSection = observer(function ChatParticipantsSection({
)}
</div>
- {adding && (
+ {chat.canManage && (
<ChatAddParticipantPanel
serverId={serverId}
workspaceId={workspaceId}
@@ -241,6 +241,8 @@ export async function addToChat(
};
}
+const ADD_PARTICIPANT_INPUT = 'chat-add-participant';
+
/**
* The New room dialog's participant field, adding each pick at once: an agent
* the workspace shows (the server decides who may use which) or a person on
@@ -293,8 +295,8 @@ const ChatAddParticipantPanel = observer(function ChatAddParticipantPanel({
return (
<div className="flex flex-col gap-2 pt-1">
<ParticipantPicker
- inputId="chat-add-participant"
- autoFocus
+ inputId={ADD_PARTICIPANT_INPUT}
+ autoFocus={false}
busy={adding !== null}
overlay
candidates={candidates}
diff --git a/console/apps/switch-console-desktop/src/renderer/tests/chat-configuration.test.ts b/console/apps/switch-console-desktop/src/renderer/tests/chat-configuration.test.ts
index 44a19cec9..98b09ed32 100644
--- a/console/apps/switch-console-desktop/src/renderer/tests/chat-configuration.test.ts
+++ b/console/apps/switch-console-desktop/src/renderer/tests/chat-configuration.test.ts
@@ -70,7 +70,7 @@ describe('RoomConfigurationPanel for a group chat', () => {
expect(html).toContain('Helper');
expect(html).toContain('1 agent · 2 people');
expect(html).toContain('Add participants');
- expect(html).not.toContain('Add agent');
+ expect(html).not.toMatch(/>\s*Add agent\s*</);
expect(html).not.toContain('Add person');
expect(html).not.toContain('From a template');
expect(html).toContain('aria-label="Remove Helper"');
@@ -78,10 +78,19 @@ describe('RoomConfigurationPanel for a group chat', () => {
expect(html).not.toContain('aria-label="Remove Alice"');
});
+ it('keeps the add field open under the header, above the cards, with the invite line under it', () => {
+ const html = render(true);
+ const field = html.indexOf('id="chat-add-participant"');
+ expect(field).toBeGreaterThan(html.indexOf('Add participants'));
+ expect(html.indexOf('Don&#x27;t see someone?')).toBeGreaterThan(field);
+ expect(html.indexOf('aria-label="Remove Helper"')).toBeGreaterThan(field);
+ });
+
it('shows the participants without controls to someone who cannot manage', () => {
const html = render(false);
expect(html).toContain('Bob');
expect(html).not.toContain('Add participants');
+ expect(html).not.toContain('id="chat-add-participant"');
expect(html).not.toContain('aria-label="Remove');
});
});