# Managed attachments Active contributors: Douwe de Vries, vriesd ## Purpose Managed attachments import screenshots and files into app-data storage, store metadata in SQLite, and keep rich editor image references stable. They support paste/upload, preview hydration, clipboard copy, and cleanup when Sessions are deleted. ## Key source files | File | Purpose | | --- | --- | | `crates/qa-scribe-core/src/attachments/mod.rs` | File import, path sanitization, hashing, previews, reconciliation, deletion. | | `crates/qa-scribe-core/src/domain/attachment.rs` | Attachment DTOs. | | `crates/qa-scribe-core/src/services/session_service/attachments.rs` | Attachment persistence operations. | | `src-tauri/src/commands/files.rs` | File and clipboard command handlers. | | `frontend/src/app/attachmentActions.ts` | Paste/upload and materialization workflow. | | `frontend/src/editor/editorHtml.ts` | Managed attachment image HTML and preview hydration. | | `frontend/src/editor/clipboardExport.ts` | Finds screenshot references for clipboard export. | ## How it works ```mermaid graph TD Paste[Paste or upload image] --> Frontend[attachmentActions] Frontend --> Files[src-tauri files command] Files --> Core[attachments module] Core --> Disk[attachments/session-id] Core --> DB[attachments table] DB --> Preview[getAttachmentPreviewDataUrl] Preview --> Editor[hydrated rich editor image] ``` The core stores files under `attachments//` using sanitized relative paths and SHA-256 hashes. Preview reads verify integrity before returning data URLs. Session deletion removes managed attachment files after database rows are cascaded. ## Integration points Managed attachments appear inside [Rich record editing](features--rich-record-editing.md), support [Session capture](features--session-capture.md), and are referenced by generation prompt material in [AI-assisted Testware](features--ai-assisted-testware.md). ## Entry points for modification Change storage behavior in `crates/qa-scribe-core/src/attachments/mod.rs`, command behavior in `src-tauri/src/commands/files.rs`, and editor/paste behavior in `frontend/src/app/attachmentActions.ts`.