Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.
Python agent-orchestrationaiai-agentschatopsdiscordlangchainmcpmicrosoft-teamsmulti-agentopen-sourceopenaiself-hostedslack
fix(console): block Reset/Compact per agent and report failed targets
raullopez-sandbox67ff024f14b5
diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-composer.tsx b/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-composer.tsxindex aa3646ee2..3b5772e0e 100644--- a/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-composer.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-composer.tsx@@ -7,6 +7,7 @@ import { switchServersStore } from '@renderer/features/switch-servers/switch-serimport { workspacesStore } from '@renderer/features/workspaces/workspaces-store';import { AgentAvatar } from '@renderer/lib/components/agent-avatar';import { isEditableTarget } from '@renderer/lib/hooks/use-arrow-key-navigation';+import { toast } from '@renderer/lib/hooks/use-toast';import { useFeatureFlags } from '@renderer/lib/hooks/useFeatureFlags';import { rpc } from '@renderer/lib/ipc';import { modalStore } from '@renderer/lib/modal/modal-store';@@ -120,6 +121,8 @@ const CONTROL_LABEL: Record<ControlRequest['command'], string> = {compact: 'Compact',};+const CONTEXT_BLOCKED = 'Waiting for the previous command to be sent.';+/*** Where each Stop, Reset or Compact sent from here stands: being posted,* posted and waiting for the agent, or the agent's answer, which it threads@@ -521,22 +524,40 @@ export const ChatComposer = observer(function ChatComposer({const status = stopping ? 'sending' : hasRunningAgent && !hasContent ? 'running' : 'idle';const showSeparateStop = hasRunningAgent && hasContent;// Not blocked while working: a turn whose host died stays running in the feed, and Reset is the way out.- const contextBlocked = activities.some((activity) => activity.pendingControl)- ? 'Waiting for the previous command to be sent.'- : null;- const runContext = (command: 'reset' | 'compact', targets: AgentActivity[]) => {+ const blocked = (targets: AgentActivity[]) =>+ targets.some((activity) => activity.pendingControl) ? CONTEXT_BLOCKED : null;+ // A group opens the menu while any one agent is free; the agent list blocks each one.+ const contextBlocked =+ activities.length > 0 && activities.every((activity) => activity.pendingControl)+ ? CONTEXT_BLOCKED+ : null;+ const runContext = async (command: 'reset' | 'compact', targets: AgentActivity[]) => {setContextOpen(false);setContextStep(null);- for (const activity of targets) void activity.control(command);+ const results = await Promise.allSettled(targets.map((activity) => activity.control(command)));+ // control() records a failed post on the agent instead of rejecting, so check both.+ const failed = targets.filter(+ (activity, index) =>+ results[index]!.status === 'rejected' ||+ activity.controls.some(+ (each) =>+ each.command === command && (each.state === 'failed' || each.state === 'unknown')+ )+ );+ if (failed.length)+ toast({+ title: `${CONTROL_LABEL[command]} failed for ${failed.map(labelOf).join(', ')}.`,+ variant: 'destructive',+ });};const pickContext = (command: 'reset' | 'compact') => {if (group) setContextStep({ command, targets: null });else if (command === 'reset') setContextStep({ command, targets: activities });- else runContext(command, activities);+ else void runContext(command, activities);};const choose = (targets: AgentActivity[]) => {if (contextStep?.command === 'reset') setContextStep({ command: 'reset', targets });- else runContext('compact', targets);+ else void runContext('compact', targets);};const resetTargets = contextStep?.command === 'reset' ? contextStep.targets : null;@@ -802,8 +823,8 @@ export const ChatComposer = observer(function ChatComposer({</Button><Buttonsize="sm"- disabled={contextBlocked !== null}- onClick={() => runContext('reset', resetTargets)}+ disabled={blocked(resetTargets) !== null}+ onClick={() => void runContext('reset', resetTargets)}>Start fresh</Button>@@ -813,7 +834,7 @@ export const ChatComposer = observer(function ChatComposer({<><Buttonvariant="ghost"- disabled={contextBlocked !== null}+ disabled={blocked(activities) !== null}className="justify-start px-2"onClick={() => choose(activities)}>@@ -825,7 +846,7 @@ export const ChatComposer = observer(function ChatComposer({<Buttonkey={activity.agentId}variant="ghost"- disabled={contextBlocked !== null}+ disabled={blocked([activity]) !== null}className="justify-start gap-2 px-2"onClick={() => choose([activity])}>@@ -841,8 +862,8 @@ export const ChatComposer = observer(function ChatComposer({</Button>);})}- {contextBlocked && (- <p className="text-xs text-foreground-muted">{contextBlocked}</p>+ {blocked(activities) && (+ <p className="text-xs text-foreground-muted">{blocked(activities)}</p>)}</>) : (diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/chat-composer-group-controls.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/chat-composer-group-controls.test.tsxindex e0be67732..9aa0ed387 100644--- a/console/apps/switch-console-desktop/src/renderer/tests/browser/chat-composer-group-controls.test.tsx+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/chat-composer-group-controls.test.tsx@@ -11,6 +11,8 @@ vi.mock('@renderer/lib/ipc', () => ({events: { on: () => () => {} },rpc: { chats: { commands: async () => [] } },}));+const toast = vi.hoisted(() => vi.fn());+vi.mock('@renderer/lib/hooks/use-toast', () => ({ toast }));vi.mock('@renderer/lib/hooks/useFeatureFlags', () => ({useFeatureFlags: () => ({ group_chats: true }),}));@@ -31,6 +33,7 @@ let container: HTMLDivElement | null = null;let root: Root | null = null;afterEach(async () => {+ toast.mockClear();if (root) await act(async () => root!.unmount());container?.remove();container = null;@@ -67,8 +70,8 @@ const runningTurn: ChatActivityItem = {updatedAt: '2026-01-01T00:00:00Z',};-async function render() {- const control = vi.fn<ActivityApi['control']>(async (input) => `cmd-${input.requestId}`);+async function render(post: ActivityApi['control'] = async (input) => `cmd-${input.requestId}`) {+ const control = vi.fn<ActivityApi['control']>(post);const api: ActivityApi = {resolve: async () => ({ kind: 'none' }) as never,reasoning: async () => null,@@ -196,3 +199,36 @@ it('shows Stop next to Send when agent is working and user has attached a file',await click('Stop reply');expect(sent(control)).toEqual([['agent-b', 'interrupt']]);});++it('names the agent a command failed for when all agents are picked', async () => {+ const control = await render(async (input) => {+ if (input.agentId === 'agent-a') throw new Error('offline');+ return `cmd-${input.requestId}`;+ });+ await click('Context actions');+ await click(/^Compact context/);+ await click('All agents');+ expect(sent(control)).toEqual([+ ['agent-a', 'compact'],+ ['agent-b', 'compact'],+ ]);+ await vi.waitFor(() =>+ expect(toast).toHaveBeenCalledWith(+ expect.objectContaining({ title: 'Compact failed for Alpha.', variant: 'destructive' })+ )+ );+});++it('blocks only the agent whose command is still being sent', async () => {+ await render((input) =>+ input.agentId === 'agent-a' ? new Promise(() => {}) : Promise.resolve(`cmd-${input.requestId}`)+ );+ await click('Context actions');+ await click(/^Compact context/);+ await click(/Alpha$/);+ await click('Context actions');+ await click(/^Compact context/);+ expect(button(/Alpha$/)?.disabled).toBe(true);+ expect(button('All agents')?.disabled).toBe(true);+ expect(button(/Beta$/)?.disabled).toBe(false);+});