Skip to content

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

fix(threads): match provider reactions when custom emoji id is absent

Steven Enamakel22a9b81c048d
diff --git a/app/src/store/__tests__/threadSlice.test.ts b/app/src/store/__tests__/threadSlice.test.ts
index 384f735075..8297f4e921 100644
--- a/app/src/store/__tests__/threadSlice.test.ts
+++ b/app/src/store/__tests__/threadSlice.test.ts
@@ -5,6 +5,7 @@ import { threadApi } from '../../services/api/threadApi';
import { CoreRpcError } from '../../services/coreRpcClient';
import type { Thread, ThreadMessage } from '../../types/thread';
import threadReducer, {
+ applyChannelEvent,
addInferenceResponse,
addMessageLocal,
clearAllThreads,
@@ -86,6 +87,42 @@ describe('threadSlice synchronous reducers', () => {
expect(state.isLoadingMessages).toBe(false);
});
+ it('applies provider reactions only to the exact OpenHuman row and persists read state in metadata', async () => {
+ const store = createStore();
+ const message = makeMessage({ id: 'user:row-42' });
+ mockedThreadApi.getThreadMessages.mockResolvedValueOnce({ messages: [message], count: 1 });
+ await store.dispatch(loadThreadMessages('channel:telegram/alice/room-1'));
+
+ const event = {
+ event: 'channel_event',
+ client_id: 'channel-runtime',
+ thread_id: 'channel:telegram/alice/room-1',
+ request_id: 'event-9',
+ openhuman_message_id: 'user:row-42',
+ channel_event: {
+ version: 2,
+ eventId: 'event-9',
+ channel: { id: 'telegram', accountId: 'bot-1' },
+ conversation: { kind: 'group', id: 'room-1' },
+ type: 'reaction_added',
+ messageId: 'provider-message-42',
+ actor: { id: 'alice', altIds: [], name: null, isBot: false, roles: [] },
+ reaction: { value: '🔥', customEmojiId: null },
+ },
+ } as Parameters<typeof applyChannelEvent>[0];
+ store.dispatch(applyChannelEvent(event));
+
+ expect(
+ store.getState().thread.messagesByThreadId['channel:telegram/alice/room-1']?.[0]
+ ?.extraMetadata.channelActivity
+ ).toEqual({
+ reactions: [{ actorId: 'alice', value: '🔥' }],
+ readReceipts: [],
+ });
+ expect(store.getState().thread.messagesByThreadId['channel:telegram/alice/room-1']?.[0]?.id)
+ .toBe('user:row-42');
+ });
+
// [#1123] setWelcomeThreadId is now a true no-op — kept for TS compat but
// state.welcomeThreadId must never be mutated by this action.
it('setWelcomeThreadId is a no-op — state.welcomeThreadId stays null', () => {
diff --git a/app/src/store/threadSlice.ts b/app/src/store/threadSlice.ts
index 14b6c728af..2106fdf666 100644
--- a/app/src/store/threadSlice.ts
+++ b/app/src/store/threadSlice.ts
@@ -530,7 +530,7 @@ const threadSlice = createSlice({
item =>
item.actorId !== providerEvent.actor.id ||
item.value !== providerEvent.reaction.value ||
- item.customEmojiId !== providerEvent.reaction.customEmojiId
+ item.customEmojiId !== (providerEvent.reaction.customEmojiId ?? undefined)
);
} else if (providerEvent.type === 'read_receipt') {
const receipt = {
diff --git a/crates/openhuman-core/src/channels/host/adapters.rs b/crates/openhuman-core/src/channels/host/adapters.rs
index 6af8525e74..b896ac3863 100644
--- a/crates/openhuman-core/src/channels/host/adapters.rs
+++ b/crates/openhuman-core/src/channels/host/adapters.rs
@@ -388,7 +388,9 @@ async fn project_channel_event(
}))
}
-fn channel_event_target_message_id(event: &tinychannels_bus::ChannelEvent) -> Option<&str> {
+pub(super) fn channel_event_target_message_id(
+ event: &tinychannels_bus::ChannelEvent,
+) -> Option<&str> {
use tinychannels_bus::ChannelEventKind as Kind;
match &event.event {
Kind::ReadReceipt { message_id, .. }