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(email): add references section to side panel (#4221)

teo1820a0b3e167
diff --git a/js/app/packages/block-email/component/sidepanel/EmailSidePanelSections.tsx b/js/app/packages/block-email/component/sidepanel/EmailSidePanelSections.tsx
index 00d18d93bf..a7a6d9b656 100644
--- a/js/app/packages/block-email/component/sidepanel/EmailSidePanelSections.tsx
+++ b/js/app/packages/block-email/component/sidepanel/EmailSidePanelSections.tsx
@@ -1,7 +1,10 @@
import { SidePanel } from '@app/component/side-panel';
import { EntityPropertiesSection } from '@app/component/side-panel/properties';
+import { References } from '@core/component/References';
import type { Property } from '@property/types';
-import { Suspense } from 'solid-js';
+import { useAttachmentReferencesQuery } from '@queries/storage/attachment-references';
+import type { ItemType } from '@service-storage/client';
+import { Show, Suspense } from 'solid-js';
import { useEmailContext } from '../EmailContext';
interface EmailSidePanelSectionsProps {
@@ -45,10 +48,44 @@ export function EmailSidePanelSections(props: EmailSidePanelSectionsProps) {
/>
</Suspense>
</SidePanel.Section>
+ <ReferencesSectionConditional threadId={props.threadId} />
</>
);
}
+// Email threads are stored as the "thread" entity type in the references
+// system (ReferencedShareItemType::EmailThread -> "thread" and the mentions
+// plugin maps email -> thread), so query/render with "thread", not "email".
+const EMAIL_REFERENCE_ENTITY_TYPE = 'thread' as ItemType;
+
+function ReferencesSectionConditional(props: { threadId: string }) {
+ const references = useAttachmentReferencesQuery(
+ () => props.threadId,
+ () => EMAIL_REFERENCE_ENTITY_TYPE
+ );
+
+ const count = () => references.data?.length ?? 0;
+
+ return (
+ <Show when={count() > 0}>
+ <SidePanel.Section
+ id="references"
+ title={<SidePanel.CountTitle label="References" count={count()} />}
+ order={50}
+ >
+ <Suspense fallback={<SidePanel.Loading />}>
+ <div class="text-xs">
+ <References
+ documentId={props.threadId}
+ entityType={EMAIL_REFERENCE_ENTITY_TYPE}
+ />
+ </div>
+ </Suspense>
+ </SidePanel.Section>
+ </Show>
+ );
+}
+
function getEmailMetadataEmptyLabel(property: Property) {
if (!property.isMetadata) return undefined;