Entry attachments
Entry attachments let a vault entry keep related files beside its protected fields. The system shows file metadata in the entry detail view while the native side reads, seals, restores, syncs, and removes the file bytes without sending them through the webview.
Attachment model
An attachment is a separate protected file linked to one live vault entry. It is not part of the entry payload, so revealing an entry does not send the file contents to the frontend.
Entry eligibility
Most entry kinds can hold attachments. Environment entries are the exception because their file is the entry content itself. Attachments also require a live entry and a vault key scheme that supports file data.
The entry detail view does not offer attachment actions for archived entries or environment entries. This keeps the file flow separate from the environment-file flow and prevents a file from being attached to a record that cannot accept it.
References: src/…/Body.tsx• L28-37 src/…/drop.ts• L6-19 src-tauri/…/attachments.rs• L246-269
Attachment metadata
The frontend receives a small description for each live attachment. The description supports display and file actions without exposing the file bytes.
| Metadata | Purpose |
|---|---|
| ID and entry ID | Identify the attachment and its owner. |
| Name | Show the original file name and use it as the suggested save name. |
| Size | Show the file size before sealing. |
| MIME hint | Choose a broad file icon when the name gives a known type. |
| Created time | Preserve when the attachment was added. |
Each file is limited to 10 MB. The vault has a shared 128 MB attachment budget that includes archived attachment data, because attachments also travel in vault sync and backup data.
References: src/…/types.ts• L197-214 src-tauri/…/attachments.rs• L22-52
Detail view
The detail view places attachments below the entry fields and above the entry footer. It keeps the surface quiet when no file exists, then shows a labeled list when the first file is attached.
Attachment presentation
Each row shows a file name, a human-readable size, a type-based icon, a save action, and a two-step remove action. Saving restores the file through a native save flow; viewing a file inside the webview is not part of this feature.
The view reads the attachment list and vault usage for the selected entry. It only shows the usage message when the vault is more than 80% full, so normal file lists do not add storage detail that does not need attention.
References: src/…/index.tsx• L12-75 src/…/Row.tsx• L24-89 src/…/useAttachments.ts• L17-41
File selection and drop routing
The attach action opens the native file picker with an attachment purpose. A file dropped on an open, idle entry follows the same attachment path when it is not an image and its name is not an environment-file name.
Drop routing protects other file workflows. Images remain scanner input, environment files remain environment-entry input, and a modal or edit session keeps ownership of the drop. The native side records the user choice and accepts the path only for the matching file purpose.
References: src/…/useAttachments.ts• L50-63 src/…/drop.ts• L9-30 src/…/open.ts• L24-46 src-tauri/…/grants.rs• L35-47
Transfer boundary
The attachment boundary separates UI control from file access. The frontend sends an entry ID and a user-selected path or attachment ID, while Rust owns file reads, encryption, native dialogs, and vault checks.
Frontend attachment API
The frontend API exposes one operation for each stage of the attachment lifecycle:
- List metadata for one entry.
- Add a selected file to an entry.
- Read the vault's current attachment usage.
- Save one attachment to a user-selected destination.
- Delete one attachment.
The add call returns metadata for the new file, not its bytes. The save call returns the chosen destination or no path when the user cancels the dialog. Store actions mark add and remove as vault writes, refresh the open detail view, and schedule sync.
References: src/…/attachments.ts• L1-26 src/…/vault.ts• L234-250
Native command boundary
Rust exposes the attachment operations as registered Tauri commands. Before an add, it checks that the vault is open, the entry is live and eligible, the path came from a user choice, and enough budget remains. It reads and seals the file outside the webview, then returns only the attachment description.
Saving reverses this path without routing plaintext through the frontend: Rust unseals the file and writes it through the native save flow. Session checks discard work when the vault locks or changes while a file is being read or saved.
The command set is part of the shared frontend/native contract. The attachment wrappers and native registration must remain aligned with the general Tauri command bridge.
References: src-tauri/…/attachments.rs• L68-138 src-tauri/…/attachments.rs• L142-243 src-tauri/…/lib.rs• L220-245
Attachment lifecycle
An attachment moves through selection, protected storage, display, optional export, and removal. The same lifecycle also participates in vault key changes and sync, so a file change is a vault change even when the entry fields stay the same.
Add and save flow
When a user adds a file, the frontend first obtains a path from the native picker or an accepted drop. The native side reads the file, applies the per-file and vault limits, seals it under a new attachment ID, and stores it beside the entry.
The frontend then refreshes the list. When a user saves a file, Rust finds it by ID, unseals it, and writes it under a safe file name chosen by the native save flow. A dismissed save dialog has no effect on the vault.
This diagram shows how a selected file becomes protected vault data and how a later save returns it to disk.
flowchart LR
A[Picker or accepted drop] --> B[Frontend attachment call]
B --> C[Native checks and file read]
C --> D[Seal and store beside entry]
D --> E[Return name and size]
E --> F[Detail view list]
F --> G[Save by attachment ID]
G --> H[Native unseal and save dialog]
H --> I[File on chosen disk path]
References: src/…/useAttachments.ts• L50-73 src-tauri/…/attachments.rs• L75-123 src-tauri/…/attachments.rs• L170-204
Removal and vault changes
Remove uses a two-step confirmation in the detail row. A confirmed removal deletes the live attachment, refreshes the open list, and schedules sync. If the parent entry is archived, its attachments leave the live list with it and return when the entry is restored. Permanent entry deletion removes the attachment data with the entry's retained sync shell.
Changing the vault master password also reseals attachment data under the new attachment key. This keeps files readable after the key change without exposing their plaintext to the frontend.
References: src/…/Row.tsx• L41-85 src/…/vault.ts• L240-250 src-tauri/…/engine.rs• L1135-1199 src-tauri/…/auth.rs• L480-533
Sync lifecycle
Attachment rows travel in the same vault sync pack as entry rows. A new or removed file changes the vault digest, so the frontend schedules a sync even when no entry field changed. A sync merge applies entry and attachment changes together, which keeps a file from landing under an entry state that no longer permits it.
Sync uses row-level last-writer-wins behavior with deletion marks. A removal therefore stays removed when an older device still has the file. The open detail view rereads its list after a local write or a sync merge, so another device can change the files while the entry remains selected.
This diagram shows the relationship between a local attachment write, the sync pack, and another device's open entry view.
sequenceDiagram
participant U as User
participant V as Vault UI
participant S as Native vault
participant R as Sync service
participant D as Other device
U->>V: Add or remove file
V->>S: Attachment command
S-->>V: Metadata or success
V->>R: Schedule vault sync
R->>D: Pack with entries and attachments
D->>D: Merge matching rows and deletion marks
D-->>V: Revision changes
V->>S: Reread selected entry files
References: src/…/vault.ts• L236-249 src-tauri/…/engine.rs• L90-100 src-tauri/…/engine.rs• L132-140 src-tauri/…/engine.rs• L458-463 src/…/useAttachments.ts• L9-41
Related workflows
Attachments extend the entry detail experience without changing the entry payload model. For the surrounding vault flow, see Credential management and Credential entry models. For nearby product flows, see Password generation and strength, Secure sharing, and Main workspace interface.
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the attachment metadata shape aligned between src/…/types.ts, the frontend attachment client, and the native DTO. A field mismatch can break list rendering without affecting file storage.
- Keep the five attachment command names, argument shapes, and registration aligned across the frontend client, Tauri handler, and IPC test fake.
- Keep the picker purpose and drop-grant rules aligned with the command that reads the path. A path must not become native file access only because it reached the webview.
- Keep the entry eligibility rule aligned between the detail view, drop routing, and native validation. Environment entries must continue to use their own file flow.
- Keep the per-file cap, vault budget, and sync pack headroom aligned. Raising one limit alone can create files that cannot sync or restore.
- Keep attachment writes on the vault revision and sync paths. A local list refresh without a sync write can leave other devices stale.
- Keep attachment merge, archive, restore, purge, and key-change handling together. Each can change whether the file is live or whether its sealed bytes remain.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A file is larger than 10 MB | The add is refused and the detail view reports the per-file limit. | Native file-size validation runs before the file is stored. |
| A file would exceed the 128 MB vault budget | The file is not added and the user sees that the vault is full. | Native usage checks compare the current total with the remaining budget. |
| A path was not selected or dropped for attachment use | The native read is refused. | Path grants record a purpose and are consumed by the matching command. |
| The vault locks or changes while an add is in progress | The read file is discarded instead of entering the wrong vault session. | The native command checks the session epoch before storing the result. |
| An image or environment file is dropped on an open entry | The file goes to the scanner or environment flow instead of becoming an attachment. | Drop routing reserves those names and types before attachment handling. |
| A removed file is still live on another device | A later sync could restore the old file. | Attachment deletion uses a sync deletion mark and merge rules keep the removal. |
| Attachment commands or DTO fields drift between TypeScript and Rust | Lists, adds, saves, or deletes fail at the bridge or render incomplete rows. | Keep the client, native registration, DTO, and IPC contract together. |
Key files
| File | Why to read it |
|---|---|
| src/…/Body.tsx | Shows where attachments enter the entry read view and which entries can display them. |
| src/…/index.tsx | Shows the user-facing list, attach action, usage warning, and error surface. |
| src/…/useAttachments.ts | Connects list refresh, picker use, store writes, save, remove, and error handling. |
| src/…/drop.ts | Defines which open-entry drops belong to attachments rather than other file flows. |
| src/…/attachments.ts | Defines the frontend attachment command contract. |
| src/…/vault.ts | Shows how attachment writes publish a revision and schedule sync. |
| src-tauri/…/attachments.rs | Defines the native file checks, protected file transfer, limits, and lifecycle commands. |
| src-tauri/…/grants.rs | Defines why a native file path may be read as an attachment. |
| src-tauri/…/engine.rs | Shows how attachment rows and deletion marks move between devices with entries. |
| src-tauri/…/auth.rs | Shows how attachment data follows a vault master-key change. |
| src-tauri/…/lib.rs | Shows the registered native attachment command surface. |