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): show Stop next to Send when agent is working with draft

raullopez-sandbox38eb4c09ddf3
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.tsx
index 070c9d331..aa3646ee2 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
@@ -1,5 +1,5 @@
import { useQuery } from '@tanstack/react-query';
-import { ChevronDown, Minimize2, Plus, RotateCcw, RotateCw, X } from 'lucide-react';
+import { ChevronDown, Minimize2, Plus, RotateCcw, RotateCw, SquareIcon, X } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import { type KeyboardEvent as ReactKeyboardEvent, useEffect, useRef, useState } from 'react';
import { reportBuddyMessage } from '@renderer/features/switch-buddy/buddy-telemetry';
@@ -513,11 +513,13 @@ export const ChatComposer = observer(function ChatComposer({
onClearReply();
};
- const showStop = stopActivities.length > 0 && !draft.trim() && !files.length;
+ const hasRunningAgent = stopActivities.length > 0;
+ const hasContent = draft.trim() !== '' || files.length > 0;
const stopping = stopActivities.some(
(activity) => activity.pendingControl?.command === 'interrupt'
);
- const status = stopping ? 'sending' : showStop ? 'running' : 'idle';
+ 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.'
@@ -725,6 +727,25 @@ export const ChatComposer = observer(function ChatComposer({
}}
/>
</div>
+ {showSeparateStop && (
+ <PromptInputButton
+ tooltip={
+ stopActivities.some((activity) => activity.pendingControl) ? 'Sending…' : 'Stop'
+ }
+ variant="ghost"
+ size="icon-sm"
+ className="h-8 min-w-8 rounded-xl border-none bg-(--composer-send-bg) text-(--composer-send-fg) hover:bg-(--composer-send-bg-hover) active:bg-(--composer-send-bg-active) disabled:opacity-50"
+ disabled={
+ disabled !== null || stopActivities.some((activity) => activity.pendingControl)
+ }
+ onClick={() => {
+ for (const activity of stopActivities) void activity.control('interrupt');
+ }}
+ aria-label="Stop reply"
+ >
+ <SquareIcon className="size-3 fill-current" />
+ </PromptInputButton>
+ )}
<PromptInputSubmit
status={status}
className="h-8 min-w-8"
@@ -734,7 +755,7 @@ export const ChatComposer = observer(function ChatComposer({
stopDisabledReason={
stopActivities.some((activity) => activity.pendingControl) ? 'Sending…' : null
}
- disabled={disabled !== null || (!showStop && !draft.trim() && !files.length)}
+ disabled={disabled !== null || (!hasRunningAgent && !draft.trim() && !files.length)}
/>
</div>
</PromptInput>
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.tsx
index b94298dec..e0be67732 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
@@ -155,3 +155,44 @@ it('compacts every agent when all are picked', async () => {
['agent-b', 'compact'],
]);
});
+
+it('shows Stop next to Send when agent is working and user has typed a draft', async () => {
+ const control = await render();
+ const textarea = document.querySelector('textarea');
+ expect(textarea).toBeDefined();
+ await act(async () => {
+ Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value')!.set!.call(
+ textarea,
+ 'test message'
+ );
+ textarea!.dispatchEvent(new Event('input', { bubbles: true }));
+ });
+ await vi.waitFor(() => {
+ const stopButton = button('Stop reply');
+ const sendButton = button('Send');
+ expect(stopButton).toBeDefined();
+ expect(sendButton).toBeDefined();
+ });
+ await click('Stop reply');
+ expect(sent(control)).toEqual([['agent-b', 'interrupt']]);
+});
+
+it('shows Stop next to Send when agent is working and user has attached a file', async () => {
+ const control = await render();
+ const fileInput = document.querySelector('input[type="file"]');
+ expect(fileInput).toBeDefined();
+ const file = new File(['content'], 'test.txt', { type: 'text/plain' });
+ await act(async () => {
+ Object.defineProperty(fileInput, 'files', {
+ value: [file],
+ writable: false,
+ });
+ fileInput!.dispatchEvent(new Event('change', { bubbles: true }));
+ });
+ const stopButton = button('Stop reply');
+ const sendButton = button('Send');
+ expect(stopButton).toBeDefined();
+ expect(sendButton).toBeDefined();
+ await click('Stop reply');
+ expect(sent(control)).toEqual([['agent-b', 'interrupt']]);
+});