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
import { describe, expect, it } from 'vitest';
import { hiddenStopRows } from '@renderer/features/chats/stop-rows';
import type { ChatMessage } from '@shared/core/chats/chats';
const human = { kind: 'human' } as ChatMessage['sender'];
const agent = { kind: 'agent' } as ChatMessage['sender'];
const system = { kind: 'system' } as ChatMessage['sender'];
const row = (
messageId: string,
body: string,
sender = human,
threadRootId: string | null = null
) => ({
messageId,
body,
sender,
threadRootId,
});
describe('hiddenStopRows', () => {
it('hides a Stop command and its acknowledgement', () => {
const messages = [
row('$ask', 'fix the build'),
row('$stop', 'Stop requested for coder by ana', system),
row('$ack', 'Interrupted my current turn. ([Open in Switch Console](x))', agent, '$stop'),
row('$next', 'try again'),
];
expect(hiddenStopRows(messages)).toEqual(new Set(['$stop', '$ack']));
});
it('hides a Stop asked of everyone and each acknowledgement', () => {
const messages = [
row('$stop', 'Stop requested for everyone by ana', system),
row('$ack1', 'Interrupted my current turn.', agent, '$stop'),
row('$ack2', 'Interrupted my current turn.', agent, '$stop'),
];
expect(hiddenStopRows(messages)).toEqual(new Set(['$stop', '$ack1', '$ack2']));
});
it('hides a Stop still waiting for its answer', () => {
expect(hiddenStopRows([row('$stop', 'Stop requested for coder by ana', system)])).toEqual(
new Set(['$stop'])
);
});
it('shows a Stop the agent could not carry out, with its answer', () => {
const messages = [
row('$stop', 'Stop requested for coder by ana', system),
row('$no', "I can't be interrupted — this isn't supported for me.", agent, '$stop'),
];
expect(hiddenStopRows(messages).size).toBe(0);
});
it('leaves other commands and messages alone', () => {
const messages = [
row('$reset', 'Context reset requested for coder by ana', system),
row('$ack', 'Resetting my session.', agent, '$reset'),
row('$talk', '!interrupting cow'),
row('$typed', 'Stop requested for coder'),
row('$quote', 'Interrupted my current turn.'),
];
expect(hiddenStopRows(messages).size).toBe(0);
});
it('hides a Retry and its acknowledgement: the turn it runs again shows under the message', () => {
const messages = [
row('$ask', 'plan a picnic'),
row('$retry', 'Retry requested for coder by ana', system),
row('$ack', 'Trying that message again.', agent, '$retry'),
];
expect(hiddenStopRows(messages)).toEqual(new Set(['$retry', '$ack']));
});
it('shows a Retry the agent could not carry out, with its answer', () => {
const messages = [
row('$retry', 'Retry requested for coder by ana', system),
row(
'$no',
"I couldn't try that again: my current session never worked on that message.",
agent,
'$retry'
),
];
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']));
});
});