InodeLabs/fern
1
14
Fork
You've already forked fern
2

Vault Assets: internal assets folder & named external asset dirs #5

Closed
opened 2026年03月25日 19:25:51 +01:00 by bugwhisperer · 0 comments

Summary

Fern currently handles only text/markdown files, which leaves users without a good way to store/reference non-text files (images, PDFs, diagrams, etc.) alongside their notes. This issue adds a full asset management layer to the vault and closes the gap between Fern and other PKM tools that allow for mixed-media vaults.

Two complementary mechanisms are introduced:

  1. An internal vault/assets/folder syncs with the vault and uses vault-relative links that remain stable across machine migrations or sync tools.
  2. Named external asset directories let users map a short @namespace alias to any local path, so sensitive files or tool-generated output can be referenced in notes without ever entering the vault.

Both types of assets would be viewable in the sidebar and would be able to be opened via the OS' system viewer.

Conditions of Satisfaction

  • Config and state integrations
  • Asset DB Index
    • Files in assets/ are indexed by the DB with kind = 'asset'
    • DB schema version should be bumped accordingly to auto-rebuilds any existing Vault DBs launch
  • Sidebar Assets section shows up
    • A new SectionAssets entry is added to the sidebar section enum
  • Internal vault/assets/ directory is created on vault init
    • initVault() creates assets/ alongside other top-level folders like notes/, journals/, templates/
  • Named external asset directories with @namespace link syntax
    • Users add external dirs via a palette command ("Assets: Add External Directory") using a two-step name + path prompt
    • Entries are persisted in fern.json state (not fern.conf) as asset_dirs: [{name, path}] so they survive restarts and roam with the vault list
    • Links use [label](@namespace/file.ext) syntax; handleOpenLink detects the @ prefix, resolves the full path via the namespace map, and calls openAssetFile
    • If the namespace is not configured on the current machine, a descriptive cmdbar error is shown instead of attempting file creation
  • Asset link resolution opens files externally rather than in the editor
    • handleOpenLink checks for a file extension first and stats the vault-relative path directly, bypassing the existing .md-only resolver
    • Resolved internal asset paths call openAssetFile, which invokes xdg-open (Linux), open (macOS), or rundll32 (Windows)
    • Dead internal asset links not found on disk fall through to a guard in createAndOpenVaultFile that shows a cmdbar error instead of creating a .md file
  • Palette commands to add and link Assets
    • "Assets: Add File" - copies a file into vault/assets/ and updates the index; shows cmdbar success
    • "Assets: Add File and Insert Link" - copies the file and inserts a formatted [filename](assets/filename.ext) link at the viewer cursor
    • "Assets: Add File and Copy Link" - copies the file and places the formatted link in the internal yank register with a cmdbar confirmation
    • "Assets: Open Asset" - fuzzy-picks from idx.AssetCompletions and opens the selected file externally
    • "Assets: Add External Directory" - two-step input (name, then path);
      • calls cfg.AddAssetDir
      • validates the name and persists to fern.json
      • then refreshes sidebar entries

External Resources

N/A

## Summary Fern currently handles only text/markdown files, which leaves users without a good way to store/reference non-text files (images, PDFs, diagrams, etc.) alongside their notes. This issue adds a full asset management layer to the vault and closes the gap between Fern and other PKM tools that allow for mixed-media vaults. Two complementary mechanisms are introduced: 1. An internal `vault/assets/`folder syncs with the vault and uses vault-relative links that remain stable across machine migrations or sync tools. 2. Named external asset directories let users map a short `@namespace` alias to any local path, so sensitive files or tool-generated output can be referenced in notes without ever entering the vault. Both types of assets would be viewable in the sidebar and would be able to be opened via the OS' system viewer. # Conditions of Satisfaction - [x] Config and state integrations - [x] Asset DB Index - Files in `assets/` are indexed by the DB with `kind = 'asset'` - DB schema version should be bumped accordingly to auto-rebuilds any existing Vault DBs launch - [x] Sidebar Assets section shows up - A new `SectionAssets` entry is added to the sidebar section enum - [x] Internal `vault/assets/` directory is created on vault init - `initVault()` creates `assets/` alongside other top-level folders like `notes/`, `journals/`, `templates/` - [x] Named external asset directories with `@namespace` link syntax - Users add external dirs via a palette command ("Assets: Add External Directory") using a two-step name + path prompt - Entries are persisted in `fern.json` state (not `fern.conf`) as `asset_dirs: [{name, path}]` so they survive restarts and roam with the vault list - Links use `[label](@namespace/file.ext)` syntax; `handleOpenLink` detects the `@` prefix, resolves the full path via the namespace map, and calls `openAssetFile` - If the namespace is not configured on the current machine, a descriptive cmdbar error is shown instead of attempting file creation - [x] Asset link resolution opens files externally rather than in the editor - `handleOpenLink` checks for a file extension first and stats the vault-relative path directly, bypassing the existing `.md`-only resolver - Resolved internal asset paths call `openAssetFile`, which invokes `xdg-open` (Linux), `open` (macOS), or `rundll32` (Windows) - Dead internal asset links not found on disk fall through to a guard in `createAndOpenVaultFile` that shows a cmdbar error instead of creating a `.md` file - [x] Palette commands to add and link Assets - "Assets: Add File" - copies a file into `vault/assets/` and updates the index; shows cmdbar success - "Assets: Add File and Insert Link" - copies the file and inserts a formatted `[filename](assets/filename.ext)` link at the viewer cursor - "Assets: Add File and Copy Link" - copies the file and places the formatted link in the internal yank register with a cmdbar confirmation - "Assets: Open Asset" - fuzzy-picks from `idx.AssetCompletions` and opens the selected file externally - "Assets: Add External Directory" - two-step input (name, then path); - calls `cfg.AddAssetDir` - validates the name and persists to `fern.json` - then refreshes sidebar entries ## External Resources N/A
Sign in to join this conversation.
No Branch/Tag specified
main
v1.5.6
v1.5.5
v1.5.4
v1.5.3
v1.5.2
v1.5.1
v1.5.0
v1.4.1
v1.4.0
v1.3.9
v1.3.8
v1.3.7
v1.3.6
v1.3.5
v1.3.4
v1.3.3
v1.3.2
v1.3.1
v1.3.0
v1.2.1
v1.2.0
v1.1.0-beta
v1.0.3-beta
v1.0.2-beta
v1.0.1-beta
v1.0.0-beta
v0.9.3
v0.9.2
v0.9.1
v0.9.0
v0.8.3
v0.8.2
v0.8.1
v0.8.0
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
InodeLabs/fern#5
Reference in a new issue
InodeLabs/fern
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?