Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
fix(attachments): link media to source memos
boojackc4221c6dfe51
diff --git a/web/src/components/AttachmentLibrary/AttachmentMediaGrid.tsx b/web/src/components/AttachmentLibrary/AttachmentMediaGrid.tsxindex 37cf475ea..6c7463ccd 100644--- a/web/src/components/AttachmentLibrary/AttachmentMediaGrid.tsx+++ b/web/src/components/AttachmentLibrary/AttachmentMediaGrid.tsx@@ -4,7 +4,7 @@ import { Badge } from "@/components/ui/badge";import VideoPoster from "@/components/VideoPoster";import type { AttachmentLibraryMediaItem, AttachmentLibraryMonthGroup } from "@/hooks/useAttachmentLibrary";import { useTranslate } from "@/utils/i18n";-import { AttachmentMetadataLine, AttachmentOpenButton } from "./AttachmentLibraryPrimitives";+import { AttachmentMetadataLine, AttachmentOpenButton, AttachmentSourceChip } from "./AttachmentLibraryPrimitives";interface AttachmentMediaGridProps {groups: AttachmentLibraryMonthGroup[];@@ -60,12 +60,12 @@ const AttachmentMediaCard = ({ item, onPreview }: { item: AttachmentLibraryMedia)}</div>+ <AttachmentMetadataLine+ className="min-w-0"+ items={[item.fileTypeLabel, item.createdLabel !== "—" ? item.createdLabel : undefined]}+ /><div className="flex items-center justify-between gap-2">- <AttachmentMetadataLine- className="min-w-0 flex-1"- items={[item.fileTypeLabel, item.createdLabel !== "—" ? item.createdLabel : undefined]}- />-+ <AttachmentSourceChip memoName={item.memoName} /><AttachmentOpenButton href={item.sourceUrl} /></div></div>diff --git a/web/src/hooks/useAttachmentLibrary.ts b/web/src/hooks/useAttachmentLibrary.tsindex e475b93b2..a9679c59d 100644--- a/web/src/hooks/useAttachmentLibrary.ts+++ b/web/src/hooks/useAttachmentLibrary.ts@@ -37,6 +37,7 @@ export interface AttachmentLibraryMediaItem extends AttachmentVisualItem {createdAt?: Date;createdLabel: string;fileTypeLabel: string;+ memoName?: string;}export interface AttachmentLibraryMonthGroup {@@ -96,6 +97,7 @@ const toLibraryMediaItem = (item: AttachmentVisualItem, locale: string, livePhotcreatedAt,createdLabel: formatCreatedAt(createdAt, locale),fileTypeLabel: item.kind === "motion" ? livePhotoLabel : fileTypeLabel,+ memoName: primaryAttachment.memo,};};diff --git a/web/tests/attachment-library-source-link.test.tsx b/web/tests/attachment-library-source-link.test.tsxnew file mode 100644index 000000000..2f9619692--- /dev/null+++ b/web/tests/attachment-library-source-link.test.tsx@@ -0,0 +1,65 @@+import { create } from "@bufbuild/protobuf";+import { fireEvent, render, screen } from "@testing-library/react";+import { MemoryRouter } from "react-router-dom";+import { describe, expect, it, vi } from "vitest";+import AttachmentMediaGrid from "@/components/AttachmentLibrary/AttachmentMediaGrid";+import type { AttachmentLibraryMonthGroup } from "@/hooks/useAttachmentLibrary";+import { AttachmentSchema } from "@/types/proto/api/v1/attachment_service_pb";++vi.mock("@/utils/i18n", () => ({ useTranslate: () => (key: string) => key }));++describe("<AttachmentMediaGrid>", () => {+ it("links a media attachment to its source memo without replacing the direct file action", () => {+ const attachment = create(AttachmentSchema, {+ name: "attachments/photo",+ filename: "photo.jpg",+ type: "image/jpeg",+ memo: "memos/source-memo",+ });+ const groups: AttachmentLibraryMonthGroup[] = [+ {+ key: "2026-07",+ label: "Jul 2026",+ items: [+ {+ id: attachment.name,+ kind: "image",+ filename: attachment.filename,+ posterUrl: "/file/attachments/photo/photo.jpg?thumbnail=1",+ sourceUrl: "/file/attachments/photo/photo.jpg",+ attachmentNames: [attachment.name],+ attachments: [attachment],+ previewItem: {+ id: attachment.name,+ kind: "image",+ filename: attachment.filename,+ sourceUrl: "/file/attachments/photo/photo.jpg",+ },+ mimeType: attachment.type,+ primaryAttachment: attachment,+ createdLabel: "Jul 29, 2026",+ fileTypeLabel: "JPEG",+ memoName: attachment.memo,+ },+ ],+ },+ ];+ const onPreview = vi.fn();++ render(+ <MemoryRouter>+ <AttachmentMediaGrid groups={groups} onPreview={onPreview} />+ </MemoryRouter>,+ );++ const memoLink = screen.getByRole("link", { name: "attachment-library.labels.memo" });+ expect(memoLink).toHaveAttribute("href", "/memos/source-memo");++ const fileLink = screen.getByRole("link", { name: "attachment-library.actions.open" });+ expect(fileLink).toHaveAttribute("href", "/file/attachments/photo/photo.jpg");+ expect(fileLink).toHaveAttribute("target", "_blank");++ fireEvent.click(memoLink);+ expect(onPreview).not.toHaveBeenCalled();+ });+});