Commit Graph

8 Commits (490a3dd6241cfaed6fba37e6750d8643dec5031b)

Author SHA1 Message Date
mirivlad fec35f55b8 Notes: sync templates, fix Create layout, repair direct children, ListItems+ListNotes merge
=== Breaking ===
- CreateNote for unsupported parents (file/note/action/secret/worklog/link) -> error
- EnsureNotesFolder validates parent supports notes before creating Notes/

=== Templates (system_templates.json) ===
- folder.default: +notes module, +Notes folder in default_folders
- document.default: +notes module, +Notes folder, +Overview.md default file
- recipe.default: +Notes folder in default_folders
All container types now consistently declare notes support.

=== CreateNodeFromTemplate layout fix ===
- DefaultFolders created BEFORE DefaultFiles (so Notes/ exists)
- DefaultFile nodes now parented inside Notes folder, not the container
- File path, file record, notes record all canonical: Notes/Overview.md
- No root-level Overview.md created

=== ListItems (Files tab) ===
- bindings_files.go: ListItems now includes TypeNote (not just TypeFolder+TypeFile)
- Notes folder visible in Files tab tree
- Overview.md inside Notes shown with type='note', Mime='text/markdown'

=== ListNotes merge ===
- Collects from both Notes folder (canonical) and direct TypeNote children (compat)
- Duplicates excluded via seen set
- Canonical layout takes priority

=== RepairNotesLayout ===
- Moves direct TypeNote children into Notes folder via nodes.Move
- Updates files.path/files.filename for moved notes
- Skips non-container parents (file/note/etc)

=== Tests ===
- note_repair_test.go: 37 tests (24 old + 13 new)
  - SupportsNotes for containers/non-containers
  - EnsureNotesFolder rejects for unsupported parents
  - Create for file/note parent -> error, no state leak
  - Repair: skips non-containers, creates Notes folder, moves notes
  - Files tab: Notes folder visible, Overview content preserved after repair
- vault_layout_notes_files_test.go: 3 new ListItems/repair tests
  - ListItems shows Notes folder
  - ListItems inside Notes shows Overview with FileID
  - Repair moves direct children, ListItems reflects new layout
- Updated: suggest_test.go, trash_test.go, vault_layout_test.go expectations

=== Misc ===
- nodes/repository.go: ListByType helper for test use
- bindings_files.go: TypeNote in ListItems, Mime=text/markdown
2026-06-15 17:24:56 +08:00
mirivlad 0fdf77ce03 fix: stabilize markdown notes — internal link modal, rename UI, trash integration
- Replace broken ObjectPickerModal with simple inline modal (Label+URL fields)
- Insert internal link at cursor position in textarea
- Add rename button in note editor header and note cards
- Add delete button on note cards with confirm dialog
- Integrate DeleteNote with shared trash (.verstak/trash/) via files.TrashFile()
- Remove hidden .verstak/trash/notes/ folder — notes use unified trash now
- Fix purgeTrashNode to clean file-record-based trash entries (notes/files)
- Add activity + sync ops to DeleteNote binding
- Add files.TrashFile() public method
- Update i18n keys for note.rename, note.deleteConfirm, internal link modal
- AssertContained: symlink-aware path containment check
- Update tests: shared trash, file record missing flag, collision on rename
- All go test ./... pass, frontend build passes, GUI binary built
2026-06-15 09:19:26 +08:00
mirivlad e2aad19cc4 fix: avoid outgoing ops during remote template apply 2026-06-04 03:36:44 +08:00
mirivlad 9d14ba50af test: restore vault and worklog test baseline 2026-06-04 03:25:04 +08:00
mirivlad a31f5fd702 fix: third stabilization pass — template children as nodes, atomicity, fs_path validation, sync_apply compat, smoke test 2026-06-03 02:05:53 +08:00
mirivlad 7b2a1da529 fix: note/file move ops, rename/move atomicity, importDir folder creation
- importDir: create physical folder for imported directories
- RenameNode/MoveNode: os.Rename before DB updates (atomicity)
- RenameNode note/file: fail if physical file missing
- MoveNode: file renames before DB updates
- applyRemoteNoteOp: handle OpMove for notes/files
- applyRemoteNodeMove: handle notes/files with empty FsPath
- MoveNode sync payload: no fs_path for notes/files
- Add 7 tests covering all fixes
2026-06-03 01:32:47 +08:00
mirivlad 20a05569ac fix: второй стабилизационный pass vault layout — sync payload, bindings, vaultPath, tests
sync_apply.go:
- applyRemoteNodeCreate: полный payload (template_id/fs_path/sort_order/archived),
  INSERT сохраняет все поля, для folder-like создаётся физическая папка.
- applyRemoteNodeUpdate: принимает fs_path/template_id/archived,
  физическое переименование папки при изменении title/fs_path.
- applyRemoteNodeMove: принимает fs_path, обновляет parent_id+fs_path,
  физически перемещает папку (folder-like) или file record (note/file).

bindings_nodes.go:
- MoveNode: node.FsPath = newFsPath после UpdateFsPath;
  sync.RecordOp отправляет новый fs_path; note/file move to root — файл в vault root.
- RenameNode: EntityFile для file, EntityNote для note;
  коллизия → генерация уникального имени; файл переименовывается только после os.Rename.
- DeleteNode: единый вызов a.files.DeleteNodeAndChildren(), дублирование удалено.
- Исправлен deadlock с SetMaxOpenConns(1) — Query/Exec больше не конфликтуют.

files.Service.vaultPath: filepath.Rel-based проверка,
  sibling-prefix escape (/tmp/vault vs /tmp/vault_evil) отклоняется.

VaultCheck: SQL JOIN с n.deleted_at IS NULL, чтобы удалённые узлы
  не показывались как missing files.

Добавлены тесты: RenameFileNodeUsesEntityFile, MoveNoteToRoot,
  DeleteFolderLeavesVaultCheckHealthy, SyncNodeCreatePreservesFields,
  VaultPathSiblingPrefixEscape.
2026-06-02 17:03:05 +08:00
mirivlad 4f01f2de2e fix: complete vault layout transition — fs_path everywhere, no more spaces/
- notes.Create(): .md files stored in parent node's fs_path folder
- files.CopyIntoVault/CreateEmptyFile/Duplicate: use parent fs_path
- files.AddPathCopy/AddPathLink: use parent fs_path, set folder fs_path
- files.DeleteNodeAndChildren: move physical folder to .verstak/trash
- UpdateFsPathRecursive: use SafeDisplayNameToPathSegment(child.Title)
- sync_apply.go note ops: use fs_path instead of spaces/
- internal/gui/server.go file upload: use n.FsPath instead of nodeSlug
- VaultCheck diagnostic: walk nodes/files, verify paths on disk
- Tests: create/rename/move/delete/name-conflict/vault-check all pass
2026-06-02 15:43:40 +08:00