The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(thread): handle map-shaped channel activity
Steven Enamakel330dd5137592
diff --git a/app/src/components/assistant-ui/thread.activityGroup.test.tsx b/app/src/components/assistant-ui/thread.activityGroup.test.tsxindex 95fb66173b..8d97746062 100644--- a/app/src/components/assistant-ui/thread.activityGroup.test.tsx+++ b/app/src/components/assistant-ui/thread.activityGroup.test.tsx@@ -69,8 +69,8 @@ describe('activity group', () => {custom: {extraMetadata: {channelActivity: {- reactions: [{ actorId: 'alice', value: '🔥' }],- readReceipts: [{ actorId: 'bob', timestamp: 123 }],+ reactions: { 'reaction-key': { actorId: 'alice', value: '🔥' } },+ readReceipts: { 'receipt-key': { actorId: 'bob', timestamp: 123 } },},},},diff --git a/app/src/components/assistant-ui/thread.tsx b/app/src/components/assistant-ui/thread.tsxindex 2fa76e1cf9..340eadced0 100644--- a/app/src/components/assistant-ui/thread.tsx+++ b/app/src/components/assistant-ui/thread.tsx@@ -631,15 +631,22 @@ const ChannelMessageActivity: FC = () => {const activity = metadata?.extraMetadata?.channelActivity;if (!activity || typeof activity !== 'object') return null;const value = activity as {- reactions?: Array<{ value?: unknown; customEmojiId?: unknown }>;- readReceipts?: unknown[];+ reactions?: Array<{ value?: unknown; customEmojiId?: unknown }> | Record<string, unknown>;+ readReceipts?: unknown[] | Record<string, unknown>;+ };+ const storedItems = (items: unknown): unknown[] => {+ if (Array.isArray(items)) return items;+ if (items && typeof items === 'object') return Object.values(items);+ return [];};const reactionCounts = new Map<string, number>();- for (const reaction of value.reactions ?? []) {- if (typeof reaction.value !== 'string' || reaction.value.length === 0) continue;- reactionCounts.set(reaction.value, (reactionCounts.get(reaction.value) ?? 0) + 1);+ for (const reaction of storedItems(value.reactions)) {+ if (!reaction || typeof reaction !== 'object') continue;+ const item = reaction as { value?: unknown };+ if (typeof item.value !== 'string' || item.value.length === 0) continue;+ reactionCounts.set(item.value, (reactionCounts.get(item.value) ?? 0) + 1);}- const readCount = value.readReceipts?.length ?? 0;+ const readCount = storedItems(value.readReceipts).length;if (reactionCounts.size === 0 && readCount === 0) return null;return (<div data-slot="aui_channel-message-activity" className="mt-1 flex flex-wrap gap-1">diff --git a/app/src/store/threadSlice.ts b/app/src/store/threadSlice.tsindex 813536ed35..dcd17ce9f5 100644--- a/app/src/store/threadSlice.ts+++ b/app/src/store/threadSlice.ts@@ -499,13 +499,31 @@ const threadSlice = createSlice({);const persisted = prior?.extraMetadata?.channelActivity;const saved = persisted && typeof persisted === 'object' ? persisted : undefined;+ const storedItems = (items: unknown): Array<Record<string, unknown>> => {+ if (Array.isArray(items)) {+ return items.filter(item => item && typeof item === 'object');+ }+ if (items && typeof items === 'object') {+ return Object.values(items).filter(item => item && typeof item === 'object');+ }+ return [];+ };thread[rowId] = {- reactions: Array.isArray((saved as ChannelActivity | undefined)?.reactions)- ? (saved as ChannelActivity).reactions.map(item => ({ ...item }))- : [],- readReceipts: Array.isArray((saved as ChannelActivity | undefined)?.readReceipts)- ? (saved as ChannelActivity).readReceipts.map(item => ({ ...item }))- : [],+ reactions: storedItems((saved as ChannelActivity | undefined)?.reactions).map(+ item => ({+ actorId: typeof item.actorId === 'string' ? item.actorId : '',+ value: typeof item.value === 'string' ? item.value : '',+ ...(typeof item.customEmojiId === 'string'+ ? { customEmojiId: item.customEmojiId }+ : {}),+ })+ ),+ readReceipts: storedItems((saved as ChannelActivity | undefined)?.readReceipts).map(+ item => ({+ actorId: typeof item.actorId === 'string' ? item.actorId : '',+ ...(typeof item.timestamp === 'number' ? { timestamp: item.timestamp } : {}),+ })+ ),};}const activity = thread[rowId];