Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(thread): show channel reactions and read receipts on messages

Steven Enamakel8750bf50949d
diff --git a/app/src/components/assistant-ui/thread.tsx b/app/src/components/assistant-ui/thread.tsx
index ca9f1b8803..2fa76e1cf9 100644
--- a/app/src/components/assistant-ui/thread.tsx
+++ b/app/src/components/assistant-ui/thread.tsx
@@ -624,6 +624,45 @@ const ThreadScrollToBottom: FC = () => {
return <ScrollAnchor label={t('chat.message.scrollToBottom')} />;
};
+const ChannelMessageActivity: FC = () => {
+ const metadata = useAuiState(state => state.message.metadata?.custom) as
+ | { extraMetadata?: Record<string, unknown> }
+ | undefined;
+ const activity = metadata?.extraMetadata?.channelActivity;
+ if (!activity || typeof activity !== 'object') return null;
+ const value = activity as {
+ reactions?: Array<{ value?: unknown; customEmojiId?: unknown }>;
+ readReceipts?: unknown[];
+ };
+ 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);
+ }
+ const readCount = value.readReceipts?.length ?? 0;
+ if (reactionCounts.size === 0 && readCount === 0) return null;
+ return (
+ <div data-slot="aui_channel-message-activity" className="mt-1 flex flex-wrap gap-1">
+ {[...reactionCounts].map(([reaction, count]) => (
+ <span
+ key={reaction}
+ data-testid="channel-message-reaction"
+ className="bg-muted text-muted-foreground rounded-full px-2 py-0.5 text-xs">
+ {reaction} {count}
+ </span>
+ ))}
+ {readCount > 0 && (
+ <span
+ data-testid="channel-message-read-receipts"
+ aria-hidden="true"
+ className="text-muted-foreground px-1 py-0.5 text-xs">
+ ✓✓ {readCount}
+ </span>
+ )}
+ </div>
+ );
+};
+
const ThreadWelcome: FC = () => {
const { t } = useT();
return (
@@ -1305,6 +1344,7 @@ const AssistantMessage: FC = () => {
<MessageVoiceNote note={voiceNote} withTranscript={false} />
</div>
) : null}
+ <ChannelMessageActivity />
</div>
<div
@@ -1529,6 +1569,7 @@ const UserMessage: FC = () => {
data-slot="aui_user-branch-picker"
className="col-span-full col-start-1 -me-1 justify-end"
/>
+ <ChannelMessageActivity />
</MessagePrimitive.Root>
);
};
diff --git a/app/src/store/threadSlice.ts b/app/src/store/threadSlice.ts
index 6db46c4843..b2dbe0e8a6 100644
--- a/app/src/store/threadSlice.ts
+++ b/app/src/store/threadSlice.ts
@@ -492,7 +492,20 @@ const threadSlice = createSlice({
const rowId = event.openhuman_message_id;
if (!rowId || !event.thread_id) return;
const thread = (state.channelActivityByThreadId[event.thread_id] ??= {});
- const activity = (thread[rowId] ??= { reactions: [], readReceipts: [] });
+ if (!thread[rowId]) {
+ const prior = state.messagesByThreadId[event.thread_id]?.find(message => message.id === rowId);
+ const persisted = prior?.extraMetadata?.channelActivity;
+ const saved = persisted && typeof persisted === 'object' ? persisted : undefined;
+ 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 }))
+ : [],
+ };
+ }
+ const activity = thread[rowId];
const providerEvent = event.channel_event;
if (providerEvent.type === 'reaction_added') {
const reaction = {
@@ -828,6 +841,7 @@ const threadSlice = createSlice({
});
export const {
+ applyChannelEvent,
clearCreateThreadError,
setSelectedThread,
invalidateThreadSelection,