Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat: channel messages multi hit content matches + fix channel goToLocationFromParams (#549)

gbirmanb74dc81a0017
diff --git a/js/app/packages/block-channel/component/Channel.tsx b/js/app/packages/block-channel/component/Channel.tsx
index efa59a1fc8..b511aabc0d 100644
--- a/js/app/packages/block-channel/component/Channel.tsx
+++ b/js/app/packages/block-channel/component/Channel.tsx
@@ -124,13 +124,15 @@ export function Channel(props: { data: Required<ChannelData> }) {
createMethodRegistration(blockHandle, {
goToLocationFromParams: async (params: Record<string, any>) => {
- if (params.thread_id) {
- setActiveThreadId(params.thread_id);
+ const threadId = params[URL_PARAMS.thread];
+ const messageId = params[URL_PARAMS.message];
+ if (threadId) {
+ setActiveThreadId(threadId);
}
- if (params.message_id) {
+ if (messageId) {
setTargetMessage({
- messageId: params.message_id,
- threadId: params.thread_id,
+ messageId,
+ threadId,
});
}
},
diff --git a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
index 0beb498a73..b7514c30a1 100644
--- a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
+++ b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
@@ -858,7 +858,9 @@ function DirectMessageIcon(props: { entity: EntityData }) {
const userId = useUserId();
const participantId = () =>
props.entity.type === 'channel'
- ? (props.entity.particpantIds ?? []).filter((id) => id !== userId()).at(0)
+ ? (props.entity.participantIds ?? [])
+ .filter((id) => id !== userId())
+ .at(0)
: undefined;
const Fallback = () => <EntityIcon targetType="directMessage" />;
diff --git a/js/app/packages/macro-entity/src/components/UnifiedInfiniteList.tsx b/js/app/packages/macro-entity/src/components/UnifiedInfiniteList.tsx
index e8b5545002..7ba28b6a99 100644
--- a/js/app/packages/macro-entity/src/components/UnifiedInfiniteList.tsx
+++ b/js/app/packages/macro-entity/src/components/UnifiedInfiniteList.tsx
@@ -44,6 +44,7 @@ import { Entity } from './Entity';
* - Uses service entity as base
* - Falls back to local nameHighlight if service doesn't have one
* - Falls back to local contentHighlights if service doesn't have any
+ * - Preserves 'local' source if either entity is local (for stable ordering)
*/
const mergeSearchEntities = <T extends EntityData>(
first: WithSearch<T>,
@@ -51,11 +52,14 @@ const mergeSearchEntities = <T extends EntityData>(
): WithSearch<T> => {
const serviceEntity = first.search.source === 'service' ? first : second;
const localEntity = first.search.source === 'local' ? first : second;
+ const hasLocal =
+ first.search.source === 'local' || second.search.source === 'local';
return {
...serviceEntity,
search: {
...serviceEntity.search,
+ source: hasLocal ? 'local' : 'service',
nameHighlight:
serviceEntity.search.nameHighlight || localEntity.search.nameHighlight,
contentHitData: serviceEntity.search.contentHitData?.length
diff --git a/js/app/packages/macro-entity/src/queries/channel.ts b/js/app/packages/macro-entity/src/queries/channel.ts
index de4e66187c..3d8a1df77c 100644
--- a/js/app/packages/macro-entity/src/queries/channel.ts
+++ b/js/app/packages/macro-entity/src/queries/channel.ts
@@ -42,7 +42,7 @@ export function createChannelsQuery(options?: {
frecencyScore: channel.frecency_score,
createdAt: Date.parse(channel.created_at),
updatedAt: Date.parse(channel.updated_at),
- particpantIds: channel.participants.map((p) => p.user_id),
+ participantIds: channel.participants.map((p) => p.user_id),
viewedAt: channel.viewed_at
? Date.parse(channel.viewed_at)
: channel.interacted_at
diff --git a/js/app/packages/macro-entity/src/queries/search.ts b/js/app/packages/macro-entity/src/queries/search.ts
index 5b765356a3..b9db054c5d 100644
--- a/js/app/packages/macro-entity/src/queries/search.ts
+++ b/js/app/packages/macro-entity/src/queries/search.ts
@@ -272,6 +272,9 @@ const useMapSearchResponseItem = () => {
updatedAt: result.metadata?.updated_at,
channelType: result.channel_type as ChannelType,
interactedAt: result.metadata?.interacted_at ?? undefined,
+ participantIds: channelWithLatest?.participants?.map(
+ (p) => p.user_id
+ ),
search,
};
}
diff --git a/js/app/packages/macro-entity/src/types/entity.ts b/js/app/packages/macro-entity/src/types/entity.ts
index 784566f657..76f42ab7d9 100644
--- a/js/app/packages/macro-entity/src/types/entity.ts
+++ b/js/app/packages/macro-entity/src/types/entity.ts
@@ -23,7 +23,7 @@ export type ChannelEntity = EntityBase & {
type: 'channel';
channelType: 'direct_message' | 'private' | 'organization' | 'public';
interactedAt?: number;
- particpantIds?: string[];
+ participantIds?: string[];
latestMessage?: {
content: string;
senderId: string;