diff --git a/docs/adr/0008-underscore-system-properties.md b/docs/adr/0008-underscore-system-properties.md index 44a96425..563a1eb0 100644 --- a/docs/adr/0008-underscore-system-properties.md +++ b/docs/adr/0008-underscore-system-properties.md @@ -27,3 +27,16 @@ As Laputa added more features that store configuration in note frontmatter (pinn - Power users can still access and edit system properties via the raw editor. - Type documents use `_icon`, `_color`, `_order`, `_sidebar_label`, `_pinned_properties`. - Re-evaluation trigger: if the number of system properties grows large enough to warrant a structured sub-object. + +## Normalized system properties + +| Canonical key | Old keys (read with fallback) | Written by | +|---|---|---| +| `_archived` | `Archived`, `archived` | Archive action | +| `_trashed` | `Trashed`, `trashed` | Trash action | +| `_trashed_at` | `Trashed at`, `trashed_at` | Trash action | +| `_favorite` | — | Favorite toggle | +| `_favorite_index` | — | Favorite reorder | + +**Write rule**: always use the canonical `_`-prefixed key. +**Read rule**: accept both canonical and legacy keys (case-insensitive). Do NOT rewrite on read — migration is a separate concern. diff --git a/docs/adr/0041-filekind-all-files-in-vault-scanner.md b/docs/adr/0041-filekind-all-files-in-vault-scanner.md new file mode 100644 index 00000000..c8b29feb --- /dev/null +++ b/docs/adr/0041-filekind-all-files-in-vault-scanner.md @@ -0,0 +1,39 @@ +--- +type: ADR +id: "0041" +title: "fileKind field — scan all vault files, not just markdown" +status: active +date: 2026-04-02 +--- + +## Context + +Laputa vaults often contain non-markdown files alongside notes: images, PDFs, YAML configs, JSON exports, scripts, etc. Previously the vault scanner only indexed `.md` files — all other files were invisible to the app. This made the Folder view incomplete: navigating a folder containing a `config.yml` or `photo.png` showed nothing, even though the file was physically there. + +The need arose when adding a Folder tree view that is meant to mirror the actual filesystem structure. Users expect to see all files in a folder, as any file manager would show. + +## Decision + +**The vault scanner now indexes all files (not just `.md`). Every `VaultEntry` carries a `fileKind` field (`"markdown"`, `"text"`, or `"binary"`) that controls how the frontend renders and opens it.** + +- **`"markdown"`**: full Laputa behavior — frontmatter parsing, BlockNote editor, title sync, type system. +- **`"text"`**: filename as title, no frontmatter, opens in raw CodeMirror editor. Covers `.yml`, `.json`, `.ts`, `.py`, `.sh`, etc. +- **`"binary"`**: filename as title, grayed out, non-clickable. Covers images, PDFs, binaries. +- **Hidden files** (starting with `.`) are skipped regardless of extension. +- **Non-folder views** (All Notes, type sections, Custom Views) still show only `"markdown"` entries. +- **Folder view** shows all file kinds. + +## Options considered + +- **Option A** (chosen): Single `VaultEntry` model with a `fileKind` discriminator. All files go through the same pipeline; rendering is gated by `fileKind`. Simple, incremental — existing code paths untouched for markdown files. +- **Option B**: Separate data model for non-markdown files (e.g. `AssetEntry`). Cleaner type hierarchy, but requires duplicating list/filter/sort logic for two types across the codebase. +- **Option C**: Only scan `.md` + explicitly listed extensions (e.g. `.yml`, `.json`). Simpler initial implementation, but requires ongoing maintenance of an allowlist and still misses user files. Abandoned in favor of a deny-list approach (only `.`-prefixed hidden files are excluded). + +## Consequences + +- Non-markdown files are visible in Folder view — the app now behaves like a file manager in that context. +- All views except Folder view continue to show only markdown files (the `isMarkdown` guard in `filterEntries`). +- `countByFilter` / `countAllByFilter` exclude non-markdown entries to keep sidebar counters accurate. +- The vault cache version was bumped to `11` to force a full rescan after this change. +- Binary files have no click action — clicking does nothing (no editor opened). +- Re-evaluation trigger: if users need to preview or edit binary files (e.g. images), a dedicated preview pane would need a separate ADR. diff --git a/docs/adr/README.md b/docs/adr/README.md index 4c0e7032..b85e179c 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -93,3 +93,7 @@ proposed → active → superseded | [0035](0035-path-suffix-wikilink-resolution.md) | Path-suffix wikilink resolution for subfolder vaults | active | | [0036](0036-external-rename-detection-via-git-diff.md) | External rename detection via git diff on focus regain | active | | [0037](0037-codemirror-language-markdown-highlighting.md) | Language-based markdown syntax highlighting in raw editor | active | +| [0038](0038-frontmatter-backed-favorites.md) | Frontmatter-backed favorites (_favorite, _favorite_index) | active | +| [0039](0039-git-history-for-note-dates.md) | Git history as source of truth for note creation/modification dates | active | +| [0040](0040-custom-views-yml-filter-engine.md) | Custom Views — .laputa/views/*.yml with YAML filter engine | active | +| [0041](0041-filekind-all-files-in-vault-scanner.md) | fileKind field — scan all vault files, not just markdown | active |