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): the chat starter changes its in-flight set in actions
raullopez-sandboxf03dcac9a1d7
diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/stores/direct-chat-starter.ts b/console/apps/switch-console-desktop/src/renderer/features/chats/stores/direct-chat-starter.tsindex 94d1b80f0..d9d968c55 100644--- a/console/apps/switch-console-desktop/src/renderer/features/chats/stores/direct-chat-starter.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/stores/direct-chat-starter.ts@@ -1,4 +1,4 @@-import { observable } from 'mobx';+import { observable, runInAction } from 'mobx';import type { ChatSummary } from '@shared/core/chats/chats';import { chatFailure } from './chat-errors';@@ -48,7 +48,7 @@ export class DirectChatStarter {const key = `${serverId}:${agentId}`;if (this.inFlight.has(key)) return null;- this.inFlight.add(key);+ runInAction(() => this.inFlight.add(key));const requestId = this.retryIds.get(key) ?? this.deps.newId();try {const chat = await this.deps.create({@@ -74,7 +74,7 @@ export class DirectChatStarter {}return null;} finally {- this.inFlight.delete(key);+ runInAction(() => this.inFlight.delete(key));}}}diff --git a/console/apps/switch-console-desktop/src/renderer/tests/direct-chat-starter.test.ts b/console/apps/switch-console-desktop/src/renderer/tests/direct-chat-starter.test.tsindex d083e1fbb..ae4fe0ead 100644--- a/console/apps/switch-console-desktop/src/renderer/tests/direct-chat-starter.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/tests/direct-chat-starter.test.ts@@ -1,3 +1,4 @@+import { autorun, configure } from 'mobx';import { describe, expect, it, vi } from 'vitest';import { DirectChatStarter } from '@renderer/features/chats/stores/direct-chat-starter';import type { ChatSummary } from '@shared/core/chats/chats';@@ -36,6 +37,19 @@ describe('DirectChatStarter', () => {expect(deps.warm).not.toHaveBeenCalled();});+ it('changes whether a chat is starting in actions, as strict mode asks, while a view watches it', async () => {+ configure({ enforceActions: 'observed' });+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});+ const { starter } = setup(async () => chat);+ const seen: boolean[] = [];+ const stop = autorun(() => seen.push(starter.starting));+ await starter.start('s1', 'a1');+ stop();+ expect(seen).toEqual([false, true, false]);+ expect(warn.mock.calls.some((call) => String(call[0]).includes('[MobX]'))).toBe(false);+ warn.mockRestore();+ });+it('ignores a second start for the same agent while one is in flight', async () => {let finish: (value: ChatSummary) => void = () => {};const { deps, starter } = setup(() => new Promise((resolve) => (finish = resolve)));