Embed selected native project structures directly in mailbox messages and drafts. - Persist native structure embeds in message metadata and expose their shared types. - Add composer selection, mailbox rendering, previews, and dashboard navigation for linked structures. - Cover metadata persistence and mailbox embed behavior with core and dashboard tests. Files changed: .changeset/fn-8292-mail-native-structure-embeds.md | 7 ++ docs/dashboard-guide.md | 1 + .../message-metadata-native-structures.test.ts | 25 +++++++ .../__tests__/postgres/message-store.pg.test.ts | 21 ++++++ packages/core/src/index.ts | 2 +- packages/core/src/types.ts | 32 +++++++++ packages/core/src/types/messages.ts | 14 ++++ packages/dashboard/app/components/MailboxModal.css | 29 ++++++++ packages/dashboard/app/components/MailboxModal.tsx | 13 +++- .../components/MailboxNativeStructureEmbeds.tsx | 37 ++++++++++ packages/dashboard/app/components/MailboxView.tsx | 14 +++- .../dashboard/app/components/MessageComposer.tsx | 65 ++++++++++++++++-- .../app/components/NativeStructurePreview.tsx | 6 +- .../__tests__/MailboxModal.cache.test.tsx | 8 +-- .../app/components/__tests__/MailboxModal.test.tsx | 9 +++ .../MailboxNativeStructureEmbeds.test.tsx | 42 ++++++++++++ .../app/components/__tests__/MailboxView.test.tsx | 9 +++ .../components/__tests__/MessageComposer.test.tsx | 25 +++++++ .../app/components/dashboard/MainContent.tsx | 78 +++++++++++++++++++++- .../MainContent.mailbox-view-task.test.tsx | 46 ++++++++++++- 20 files changed, 459 insertions(+), 24 deletions(-) Fusion-Task-Id: FN-8292 Fusion-Task-Lineage: ae6cfb9c-a764-407c-bd45-cfd879ccdd3e Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { memo } from "react";
|
|
import type { Message, NativeStructurePreviewResult, NativeStructureRef } from "@fusion/core";
|
|
import { NativeStructurePreview } from "./NativeStructurePreview";
|
|
|
|
export interface MailboxNativeStructureEmbedsProps {
|
|
message: Pick<Message, "metadata">;
|
|
projectId?: string;
|
|
onOpen: (ref: NativeStructureRef, payload: NativeStructurePreviewResult) => void;
|
|
}
|
|
|
|
/**
|
|
* FNXC:NativeStructureEmbed 2026-07-20-12:00:
|
|
* Mail message metadata is the durable home for first-class structure embeds. This thin wrapper
|
|
* deliberately owns no preview behavior: the shared lazy resolver handles live data and missing
|
|
* targets, while this returns no shell for ordinary mail with no structural attachment.
|
|
*/
|
|
export const MailboxNativeStructureEmbeds = memo(function MailboxNativeStructureEmbeds({
|
|
message,
|
|
projectId,
|
|
onOpen,
|
|
}: MailboxNativeStructureEmbedsProps) {
|
|
const embeds = message.metadata?.nativeStructures;
|
|
if (!embeds?.length) return null;
|
|
|
|
return (
|
|
<div className="mailbox-native-structure-embeds" data-testid="mailbox-native-structure-embeds">
|
|
{embeds.map((embed, index) => (
|
|
<NativeStructurePreview
|
|
key={`${embed.kind}:${embed.id}:${index}`}
|
|
ref={{ kind: embed.kind, id: embed.id, projectId: embed.projectId ?? projectId }}
|
|
capturedLabel={embed.label}
|
|
onOpen={onOpen}
|
|
/>
|
|
))}
|
|
</div>
|
|
);
|
|
});
|