feat(outline): outline type + outliner — S3 (#109)
CI / ci (push) Canceled after 0s

Dedicated block surface (ADR-0013, #105 variant B): OutlineTree
parses/serializes plain nested-bullet markdown leniently and
normalizes on save; the outliner promotes one NSTextView over the
focused row with LogSeq-style keys (Tab/⇧Tab, ⌥↑/⌥↓ subtree move,
↑/↓ hop, ⇧↑/⇧↓ block selection, ⌘↑/⌥↓ fold, Enter split), folds
session-scoped by runtime node UUID. New Outline ⇧⌘N stages a
type: outline draft through the existing autosave/conflict
machinery; reading renders the serialized markdown unchanged.

Outline rows use the body face at its natural line box — the prose
CSS-1.8 lineHeightMultiple grew the focused row and detached the
bullet (test-pinned). Finish-audit fixes included: paste-multiline
sanitizing at setText, dead Enter disjunct, dead Row.path.

Closes #109
This commit is contained in:
AlexKucera committed 2026-10-15 13:09:31 +02:00
1 parent e55747e7fe
commit c23ee0f62f
21 files changed
+1809 -21

No files matched your search

+32 -2
View File
@@ -16,9 +16,17 @@ import Observation
/// The New Post draft: body text only, no folder until first save (#62).
/// #107: remembers the project the piece will land in when first saved.
/// #109: remembers the content type too (post default; .outline for New
/// Outline) so saveDraft stamps the right frontmatter.
struct PostDraft {
var text = "# Untitled\n\n"
let project: String
var type = Post.ContentType.post
/// Mount identity: bumped on every stage (newPost/newOutline) so the
/// editor view REMOUNTS per draft — the outliner's one-shot seed
/// (`guard loadedGeneration < 0`) would otherwise keep a stale tree
/// when a new draft replaces the old without a hierarchy change.
let mountID = UUID()
}
/// Recursive FSEvents stream on one or more directories (#61): file-level
@@ -108,9 +116,14 @@ final class PostsModel {
/// presents (the pendingImportURLs pattern, #94).
private(set) var askNewProject = false
/// #109: the just-saved outline draft's afterglow — the posts list
/// lags one rescan (the FSEvents window), so the freshly-opened
/// session can't read its type from the scan yet and would flash the
/// prose editor. True only between saveDraft and the next selection.
private(set) var lastDraftWasOutline = false
/// Last failed-op message surfaced in the editor (nil = clean).
private(set) var lastError: String?
/// Home the watcher is bound to; also the rescan target.
private var watchedHome: URL?
private var watcher = PostsWatcher()
@@ -204,6 +217,20 @@ final class PostsModel {
session?.teardown(flushFirst: true) // #64: selection change flushes
session = nil
draft = PostDraft(project: target)
lastDraftWasOutline = false // #109: the afterglow died with the draft
selectedPostID = nil
}
/// #109: New Outline — newPost's draft path with an outline draft instead:
/// body seeds one empty root node ("- "), the outline surface parses it.
/// Title keeps prose semantics (raw first line).
func newOutline() {
let target = targetProject
dismissExternal()
session?.teardown(flushFirst: true)
session = nil
draft = PostDraft(text: "- ", project: target, type: .outline)
lastDraftWasOutline = false // #109: a new draft resets the afterglow
selectedPostID = nil
}
@@ -223,7 +250,8 @@ final class PostsModel {
func saveDraft(home: URL) {
guard let draft else { return }
do {
let post = try PostStore.writeNew(body: draft.text, project: draft.project, home: home)
let post = try PostStore.writeNew(body: draft.text, project: draft.project, type: draft.type, home: home)
lastDraftWasOutline = draft.type == .outline // #109: covers the lagging rescan
self.draft = nil
pendingProject = nil // #108: the explicit target landed with the draft
selectedPostID = post.id
@@ -251,6 +279,7 @@ final class PostsModel {
// #108: abandoning the draft kills its explicit project target too —
// a later New Post must not silently land in the abandoned project.
pendingProject = nil
lastDraftWasOutline = false // #109: opening a post is a fresh context
selectedPostID = id
wireSession()
}
@@ -475,6 +504,7 @@ final class PostsModel {
session = nil
draft = nil
pendingProject = nil // #108 audit: the draft died here too — its target dies with it
lastDraftWasOutline = false // #109: same death, same clearing
externalSession = EditorSession(target: .externalFile(target))
if externalSession?.loadFailed == true {
lastError = "Couldn't read \(target.lastPathComponent) — not UTF-8 text or unreadable. Nothing was changed."