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): treat an empty chat load as complete history (CHOO-3783)
raullopez-sandboxf8c37094b24e
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 ce5219e21..644060c51 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@@ -181,7 +181,7 @@ export class ChatTimeline {const fetched = [...page.messages];const newest = page.messages.length? Math.max(...page.messages.map((message) => message.seq))- : held;+ : (held ?? 0);// Page back to the history already complete, so a gap since the last load is not skipped.let oldest = Math.min(...page.messages.map((message) => message.seq));while (held !== null && page.hasMore && page.messages.length && oldest > held) {@@ -191,7 +191,8 @@ export class ChatTimeline {}runInAction(() => {for (const message of fetched) this.apply(message);- if (!this.loaded) this.hasMore = page.hasMore;+ // A catch-up that stopped short of what was held left earlier messages to load.+ if (!this.loaded || (held !== null && oldest > held)) this.hasMore = page.hasMore;this.completeThrough = newest;this.loaded = true;this.notMember = false;diff --git a/console/apps/switch-console-desktop/src/renderer/tests/chats-store.test.ts b/console/apps/switch-console-desktop/src/renderer/tests/chats-store.test.tsindex d48e6646c..6a234b482 100644--- a/console/apps/switch-console-desktop/src/renderer/tests/chats-store.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/tests/chats-store.test.ts@@ -283,6 +283,31 @@ describe('ChatsStore', () => {await vi.waitFor(() => expect(timeline.messages.map((m) => m.seq)).toEqual([1, 2]));});+ it('holds all of an empty room once it is listed again with 130 messages', async () => {+ let head = 0;+ const messages = vi.fn(async (_room: string, before: number | null, limit: number) => {+ const top = Math.min(before ?? head + 1, head + 1);+ const from = Math.max(1, top - limit);+ const seqs = Array.from({ length: Math.max(0, top - from) }, (_, i) => from + i);+ return { messages: seqs.map((seq) => message('r1', seq)), headSeq: head, hasMore: from > 1 };+ });+ const { store } = setup(async () => [summary('r1', 0)], { messages });+ await store.connect('s1');+ const timeline = store.timelines.get('s1', 'r1');+ await timeline.load();+ expect(timeline.messages).toHaveLength(0);+ store.remove('r1', 'unlisted');++ head = 130;+ store.upsert(summary('r1', 130));+ await vi.waitFor(() =>+ expect(timeline.messages.map((m) => m.seq)).toEqual(+ Array.from({ length: 130 }, (_, i) => i + 1)+ )+ );+ expect(timeline.hasMore).toBe(false);+ });+it('revokes a chat unlisted earlier once access is lost', async () => {const { store } = setup(async () => [summary('r1', 1)]);await store.connect('s1');