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): recognize both old and new stop/retry command formats
raullopez-sandbox09674d75c4e9
diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/stop-rows.ts b/console/apps/switch-console-desktop/src/renderer/features/chats/stop-rows.tsindex 46b6fb56d..703cdf284 100644--- a/console/apps/switch-console-desktop/src/renderer/features/chats/stop-rows.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/stop-rows.ts@@ -11,6 +11,9 @@ import type { ChatMessage } from '@shared/core/chats/chats';/** The agent's in-room answer to an interrupt it carried out (core's `_INTERRUPT.ack`). */export const INTERRUPT_ACK_MESSAGE = 'Interrupted my current turn.';+const STOP_REQUESTED_PREFIX = 'Stop requested for ';+const RETRY_REQUESTED_PREFIX = 'Retry requested for ';+type Row = Pick<ChatMessage, 'messageId' | 'threadRootId' | 'body' | 'sender'>;export function isInterruptAck(message: Pick<ChatMessage, 'body' | 'sender'>): boolean {@@ -25,18 +28,28 @@ export function isInterruptAck(message: Pick<ChatMessage, 'body' | 'sender'>): b*/export const RETRY_ACK_MESSAGE = 'Trying that message again.';-/** Each command left out with its acknowledgement, and that acknowledgement. */-const HIDDEN_COMMANDS: [RegExp, string][] = [- [/^Stop requested for /, INTERRUPT_ACK_MESSAGE],- [/^Retry requested for /, RETRY_ACK_MESSAGE],+const SYSTEM_COMMANDS: [RegExp, string][] = [+ [new RegExp(`^${STOP_REQUESTED_PREFIX}`), INTERRUPT_ACK_MESSAGE],+ [new RegExp(`^${RETRY_REQUESTED_PREFIX}`), RETRY_ACK_MESSAGE],+];++const HUMAN_COMMANDS: [RegExp, string][] = [+ [/^!interrupt(\s|$)/, INTERRUPT_ACK_MESSAGE],+ [/^!retry(\s|$)/, RETRY_ACK_MESSAGE],];/** Ids of the Stop and Retry commands and their acknowledgements to leave out of the transcript. */export function hiddenStopRows(messages: readonly Row[]): Set<string> {const hidden = new Set<string>();for (const command of messages) {- if (command.sender.kind !== 'system') continue;- const ack = HIDDEN_COMMANDS.find(([pattern]) => pattern.test(command.body.trim()))?.[1];+ const commands =+ command.sender.kind === 'system'+ ? SYSTEM_COMMANDS+ : command.sender.kind === 'human'+ ? HUMAN_COMMANDS+ : null;+ if (commands === null) continue;+ const ack = commands.find(([pattern]) => pattern.test(command.body.trim()))?.[1];if (ack === undefined) continue;const answers = messages.filter((each) => each.threadRootId === command.messageId && each.sender.kind !== 'human'@@ -50,8 +63,8 @@ export function hiddenStopRows(messages: readonly Row[]): Set<string> {/** An agent's acknowledgement of a Stop or Retry, which the chat leaves out: never where a turn shows. */export function isControlAck(message: Pick<ChatMessage, 'body' | 'sender'>): boolean {+ const allAcks = [...SYSTEM_COMMANDS, ...HUMAN_COMMANDS];return (- message.sender.kind !== 'human' &&- HIDDEN_COMMANDS.some(([, ack]) => message.body.startsWith(ack))+ message.sender.kind !== 'human' && allAcks.some(([, ack]) => message.body.startsWith(ack)));}diff --git a/console/apps/switch-console-desktop/src/renderer/tests/chat-stop-rows.test.ts b/console/apps/switch-console-desktop/src/renderer/tests/chat-stop-rows.test.tsindex dee4b386a..5c6e5e7fc 100644--- a/console/apps/switch-console-desktop/src/renderer/tests/chat-stop-rows.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/tests/chat-stop-rows.test.ts@@ -73,4 +73,23 @@ describe('hiddenStopRows', () => {];expect(hiddenStopRows(messages).size).toBe(0);});++ it('hides old-format human !interrupt command and its acknowledgement', () => {+ const messages = [+ row('$ask', 'fix the build'),+ row('$stop', '!interrupt @coder', human),+ row('$ack', 'Interrupted my current turn.', agent, '$stop'),+ row('$next', 'try again'),+ ];+ expect(hiddenStopRows(messages)).toEqual(new Set(['$stop', '$ack']));+ });++ it('hides old-format human !retry command and its acknowledgement', () => {+ const messages = [+ row('$ask', 'plan a picnic'),+ row('$retry', '!retry @coder $ask', human),+ row('$ack', 'Trying that message again.', agent, '$retry'),+ ];+ expect(hiddenStopRows(messages)).toEqual(new Set(['$retry', '$ack']));+ });});