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): run a chat load asked for while another is in flight (CHOO-3783)
raullopez-sandbox48fc67018b21
diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/stores/chat-timeline-store.ts b/console/apps/switch-console-desktop/src/renderer/features/chats/stores/chat-timeline-store.tsindex c06eede9a..eb86b6985 100644--- a/console/apps/switch-console-desktop/src/renderer/features/chats/stores/chat-timeline-store.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/stores/chat-timeline-store.ts@@ -104,6 +104,8 @@ export class ChatTimeline {loadError: string | null = null;/** The failure in {@link loadError} was loading earlier messages, not the newest. */olderFailed = false;+ /** A load was asked for while another was in flight; it runs once that one ends. */+ private reloadQueued = false;/** The person is not a member of the room. */notMember = false;/** The person was a member and lost access while the chat was known. */@@ -164,7 +166,10 @@ export class ChatTimeline {}async load(): Promise<void> {- if (this.loading) return;+ if (this.loading) {+ this.reloadQueued = true;+ return;+ }this.loading = true;this.loadError = null;this.olderFailed = false;@@ -195,6 +200,10 @@ export class ChatTimeline {runInAction(() => {this.loading = false;});+ if (this.reloadQueued) {+ this.reloadQueued = false;+ void this.load();+ }}}@@ -219,6 +228,10 @@ export class ChatTimeline {runInAction(() => {this.loading = false;});+ if (this.reloadQueued) {+ this.reloadQueued = false;+ void this.load();+ }}}diff --git a/console/apps/switch-console-desktop/src/renderer/tests/chat-timeline-store.test.ts b/console/apps/switch-console-desktop/src/renderer/tests/chat-timeline-store.test.tsindex 7f0fe8bab..48e1f8cf4 100644--- a/console/apps/switch-console-desktop/src/renderer/tests/chat-timeline-store.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/tests/chat-timeline-store.test.ts@@ -272,4 +272,28 @@ describe('ChatTimeline', () => {expect(asked).toEqual([null, 51, 51]);expect(timeline.loadError).toBeNull();});++ it('loads again when asked during a load, picking up what was posted in between', async () => {+ let head = 1;+ let release!: () => void;+ const first = new Promise<void>((resolve) => {+ release = resolve;+ });+ let calls = 0;+ const { value } = api({+ messages: async () => {+ const seqs = Array.from({ length: head }, (_, i) => i + 1);+ if (calls++ === 0) await first;+ return { messages: seqs.map((seq) => message(seq)), headSeq: head, hasMore: false };+ },+ });+ const timeline = new ChatTimeline('room-1', value);+ const loading = timeline.load();+ head = 2;+ void timeline.load();+ release();+ await loading;+ await vi.waitFor(() => expect(timeline.messages.map((m) => m.seq)).toEqual([1, 2]));+ expect(calls).toBe(2);+ });});