lbg #
A native, KDE-integrated interface to a directory of Markdown notes, inspired by the Logseq experience. Comfortable reading, searching, and writing come first.
Agreed direction #
- Markdown files are the source of truth. Any directory layout works, recursively. Opening or reading a folder never moves, renames, or rewrites its notes.
- Preserve Logseq-style nested blocks. Each block can contain full Markdown, including headings, paragraphs, lists, quotes, code fences, tables, and images.
- Ordinary Markdown documents open as one large block, retaining their source. Converting them into an outline will be an explicit action.
- In the editor, the active block shows Markdown source; inactive blocks render it.
- Preserve ordinary newlines as visible line breaks when rendering a block.
- Follow the user's KDE colors, fonts, icons, and native control styling.
- Keep the implementation small and straightforward. Optimize when a real issue warrants it; there are no benchmark targets.
- The reusable core owns notes, parsing, search, and eventually editing operations. Desktop, future TUI/mobile interfaces, and the agent share that core.
- A deeply integrated LLM agent remains part of the intended product. Develop the main reading/writing experience first. Notes can continue to sync via Nextcloud.
Iteration 1: note browser #
Open a folder, list its Markdown notes, search filenames/paths/content, and read
them with Markdown formatting. Preserve nested lists in outlines and treat other
documents as a single document block. Support Logseq's ^^highlight^^ syntax in
rendered text, keeping code, escaped carets, and original source intact.
Provide a read-only source view, keyboard
navigation, and an explicit refresh for externally changed notes.
Use a Qt-free Rust lbg-core and a Qt Widgets desktop frontend in lbg-gui.
Qt Widgets gives this desktop iteration the standard KDE controls. Future mobile
UI can be a separate consumer of the core. A small CXX bridge joins Rust and C++.
Markdown parsing uses pulldown-cmark; Qt's native text document renders the result.
Search uses an in-memory snapshot; refreshing rebuilds it from the files.
The notes panel sorts by file modification time, newest first, with path order for
equal timestamps. Saving updates the order while preserving selection and editing.
Search retains recency order within its filename/path and content-only groups.
Completion means the app opens /home/roller/Documents/lbg test, including its
unusual nested paths, renders outlines and prose, searches across all its notes,
and leaves every note byte-for-byte intact. Then stop for user review.
Page references #
Current addition: treat #page, #[[page with spaces]], and [[page]] as page
references. Show linked references grouped by source note at the bottom of the
reader. Ignore code and escaped hashes when extracting tags. Clicking a missing
reference creates and opens an empty Markdown page, as does activating the explicit
Create choice in search. Typing or selecting that choice only previews creation.
Search shows filename/path matches, then Create, then content-only matches, so Enter
can create a referenced page even when its name appears inside other notes.
New pages live at the folder root, or at the corresponding path for qualified names
such as projects/idea. Existing notes are never overwritten. Ambiguous basenames
require a qualified path. Ordinary relative Markdown links also contribute backlinks.
Iteration 2: block editing and saving #
Clicking a block edits its Markdown source; other blocks stay rendered. Typing authorizes autosave after a short pause, and Ctrl+S saves immediately. Enter splits an outline block into siblings; Shift+Enter adds a newline within a block. Ordinary document blocks use normal newlines. Undo and redo cover text and block creation.
The block editor has no frame. Tab indents an outline block under its preceding sibling; Shift+Tab outdents it after its parent's remaining children. Its subtree moves with it, focus stays on the block, and undo/redo includes these moves. Quotes render with a vertical bar and a subtle background; code blocks use a darker background. Derive these colors from the native theme.
Continue using the existing Markdown representation. Unordered list items are blocks, nested unordered lists are children, and other block Markdown belongs to the enclosing block. For example:
- # A heading
A paragraph with **formatting**.
> A quote
- A child block
- A sibling block
Editing replaces only the selected block's source region. Preserve frontmatter, untouched siblings/children, bullet style, and line endings. If a parent has prose after its child list, treat the page as one document block to preserve the ordering. No file format conversion or whole-outline canonicalization occurs automatically.
Save through an atomic temporary-file replacement, preserving file permissions. Compare against the last saved source before replacing the file. External edits or deletion stop saving and keep the draft; navigation must not lose that draft. The full Markdown source viewer includes the draft and remains available to copy. Refreshing or closing offers an explicit discard choice if saving fails.
Completion means normal browsing still leaves real notes intact, and scratch-note checks demonstrate active-block editing, children/sibling preservation, new blocks, undo/redo, autosave, explicit save, and external-change protection. Stop for review.
Then develop journals, tasks, and other workflows in reviewed steps.
Block folding #
Native disclosure arrows fold/unfold a block's children. Ctrl+. toggles the focused block, or its nearest parent if it has no children. Parents remain editable while folded; nested fold state is retained when reopening an ancestor. Opening an editor or following an anchor inside a hidden block reveals its ancestors.
Store folded state in local app settings per canonical notebook and relative page, with no metadata added to Markdown files. Restore only uniquely matching subtrees using their content and internal hierarchy, not row numbers. External changes to hidden content and ambiguous identical subtrees reopen expanded. Known local edits keep an edited parent's fold attached to it. This state is per-device.
Check persistence, nested folding, keyboard control, editing, note/notebook isolation, external changes, and file preservation. Then stop for user review.
Today and Journals #
Today opens the local date's entry ready to write. Reuse a unique existing dated
file anywhere in the notebook; a new day explicitly opened through Today creates
an empty journals/YYYY-MM-DD.md. Recognize valid YYYY-MM-DD and YYYY_MM_DD
filename stems for both Markdown extensions. Duplicate dates remain separate;
Today offers a choice when several files match rather than choosing arbitrarily.
Journals is a scrollable newest-first feed of existing entries, loading seven at a time with a visible Show older entries button. Browsing never creates a day. Reuse block rendering, editing, folding, references, and safe saving within the feed. Only one block is active at a time; switching days saves before leaving the current entry. Each day also has an Open page button for the regular note view. Today and Journals have labeled sidebar buttons and Ctrl+T / Ctrl+J shortcuts.
Check browsing without writes, existing paths, explicit creation, editing across days, outer scrolling, links, and external-change protection. Verify the real test folder remains intact, then stop for screenshot review.
Tasks: inline checkboxes #
Tasks have only checked/unchecked states. Recognize Markdown list-item markers
[ ], [x], [X], and the shorthand [], followed by whitespace or end of line.
Markers in ordinary prose, links/images, escaped text, or code remain ordinary
Markdown. Opening a note never normalizes its task markers.
Render native clickable checkboxes inside both outline blocks and ordinary
document checklists, including in Journals. Space toggles a focused checkbox.
An explicit toggle authorizes saving and replaces only that marker with standard
[x] or [ ]. Keep every other byte, fold state, and the existing external-change
save guard. Undo/redo includes toggles; toggling itself keeps the block rendered.
Check source preservation, shorthand and Markdown boundaries, native mouse and keyboard toggles, undo/redo, folding, journal isolation, and conflicts. Stop for review before adding the Tasks overview.
Block keyboard navigation #
Clicking a bullet selects its rendered block; Esc or Ctrl+Enter finishes editing and selects that block. Show selection with a subtle native-theme highlight. Up/down selects the preceding/following visible block, skipping folded descendants and continuing between loaded journal entries. Enter or F2 edits the selection; typing starts editing and appends the typed text without losing the first character. Left/right on a selection starts editing at the beginning/end of the block.
Inside the editor, retain ordinary caret movement and text selection. At the first/last visual line, up/down continues into the adjacent visible block while retaining the cursor column. Left/right crosses blocks only at the beginning/end. Keep the existing save guard when navigation crosses journal days.
Backspace deletes a genuinely empty outline block. Preserve children by promoting them one level; preserve other source bytes and line endings. Focus the previous visible block, retaining editing or selection mode. Removing the last empty bullet leaves an editable empty page and preserves frontmatter. Empty child bullets must remain blocks rather than becoming Markdown heading underlines. Ordinary document editing keeps standard text behavior. Deletion participates in autosave and undo; history restores the block, selection, and folds.
Check native arrows, selected-block typing and composition, empty deletion, undo/redo, folded children, journal navigation, and external changes. Verify real notes remain intact. Then stop for user review.
Tasks overview and calendar #
Tasks opens a list of checklist items across the notebook, grouped by note. Hide completed tasks by default, with a Show completed toggle and task search. Space or a checkbox toggles the original task; Enter or Open in note opens its source block. Include undo/redo and the same external-change save guard.
Provide List, Month, and Week views. Month shows filtered task counts by day. Week is a table with seven day columns and task blocks stacked in rows, without hour labels. Cells wrap task text and show native checkboxes and source paths. Day headers open their journals. Resize rows to fit their contents; retain keyboard selection, scheduling, and opening a selected task in its note. Clicking a calendar day or a week header opens that journal ready to write, creating an empty dated Markdown file only if needed. Keyboard activation also opens a day. Month/week navigation, filters, and selection never create files. Reuse dated files anywhere in the notebook; offer a choice for duplicate dates.
A task's first valid dated wiki link, such as [[2026-10-08]], schedules it from any note. Accept qualified paths and underscore date stems as well. Ignore dates in code, escaped links, frontmatter, or child items. Additional dated links remain ordinary references. Tasks without a dated link inherit their journal filename's date, if present; other tasks are unscheduled and stay in List.
Schedule opens a native date picker. Acceptance replaces the first dated link or appends one to the task's first line, preserving other bytes. Cancellation writes nothing. Scheduling does not create a journal; explicitly opening the dated link or calendar day does. Bare dated links reuse the same journal resolution as Today. No recurring tasks, priorities, reminders, or extra task states in this iteration.
Check list/calendar browsing, task toggles, scheduling/rescheduling, undo/redo, opening source blocks, explicit journal creation/reuse, keyboard activation, and external edits. Verify the real test folder remains intact; stop for user review.
Page graph #
Graph is a separate view of pages and their Markdown links/tags, using the same reference extraction and resolution as backlinks. Include existing notes even when disconnected. Combine repeated links and tags into one undirected connection; ignore self-links, code, escaped references, images, external links, and ambiguous basenames. Preserve qualified identities and ordinary relative Markdown links.
Show referenced missing pages as faint ghost nodes with dotted outlines, with a Show ghost pages toggle. Selection, search previews, layout, panning, and zooming never write files. Clicking a node or explicitly opening it with Enter/Open page opens the note; opening a ghost creates its empty Markdown file through the existing page-opening rules. Dragging a node moves it without opening it. Resolve dated journal links consistently, and never recreate an externally deleted solid node merely because the graph snapshot still contains it.
Offer Whole notebook and Current note views. Current note includes that page and its direct incoming/outgoing neighbors. Use native palette colors and labeled controls for finding a page, opening it, zooming, and fitting the view. Arrows select nodes geometrically; Enter opens. Settle the layout on loading, then leave nodes still until the user moves them. Refresh reloads external changes while staying in the graph. Draft/save protection also applies when entering this view. Graph layout is ephemeral; no graph metadata or extra dependencies in this pass.
Arrange connected components independently with repulsion between nodes and attraction along links, then leave room between disconnected groups. Scale node circles with zoom so fitting a large notebook does not pile fixed-size circles onto one another; give well-connected pages a slightly larger circle. Use muted native palette colors, retaining accent colors for selection and the current page, and dotted ghost outlines. Labels remain readable at their normal font size and appear only where there is space. Prioritize hovered/selected pages and hubs; zooming in reveals less-connected and unlinked page labels. Refresh keeps existing node positions and camera settings, including a ghost becoming an existing page.
Check reference identity, read-only browsing, ghosts, local scope, mouse/keyboard navigation, drag-versus-open, zoom/pan, explicit creation, refresh, notebook isolation, and draft protection. Verify real note bytes and stop for user review.
Desktop preferences #
Settings → Configure lbg opens a native dialog, also available through Ctrl+,. Group controls into Startup, Fonts, Tasks & Calendar, and Graph. Include Apply, OK, Cancel, and Restore defaults; previews and pending defaults do not persist until Apply/OK. Cancel leaves any previously applied changes in place.
Startup can reopen the last folder and start in Notes, Journals, Tasks, or Graph. Explicit folder arguments still open when automatic reopening is disabled. Startup only browses existing pages and never creates a journal or ghost page. Notes is the default starting view.
Provide note font/family size and a separate monospace font/size for rendered code blocks, inline code, and Markdown source editing. Both default to their system fonts. Restrict the code font selector to monospace fonts. Apply fonts to existing notes and journal readers while keeping active source text, cursor, selection, folds, undo history, and the external-change save guard intact. Font previews change only inside the dialog until applied. Controls retain KDE fonts/colors.
Task defaults select List/Month/Week and completed-task visibility, with List and hidden completed tasks retained as defaults. Calendar week start can follow the system locale or explicitly use Monday/Sunday, consistently in Month and Week. Graph defaults select Whole notebook/Current note and ghost visibility. A local graph with no current note falls back to the whole notebook. Defaults apply on entering a view; temporary view controls do not change preferences. Refresh retains temporary choices. Applying a changed default updates that view.
Store preferences in device-local Qt settings, alongside existing last-folder and fold state, without touching Markdown or adding notebook files. Restoring preference defaults retains folder/fold state. Verify dialog controls, persistence, fonts in actual rendered code, safe startup, calendar consistency, and conflicting draft preservation with native checks. Verify real notes remain intact; stop for user review.
Automatic file refresh #
Enable automatic refresh by default, with an Automatically refresh notes toggle in Settings → Configure lbg → Startup. Disabling it leaves F5 available; enabling it catches up on changes made while disabled. Preference previews never change watching before Apply/OK.
The core supplies the directory/Markdown watch paths using normal traversal rules, including arbitrary nested and empty folders and unreadable Markdown. Exclude .git and symlink trees. The native desktop watches those paths, groups short bursts of events, and rebuilds the read-only notebook snapshot. Reattach watches after atomic replacements and moved/recreated notebook roots. Switching notebooks drops the previous watches. No periodic indexing loop or added dependencies.
Automatic refresh never invokes saving, discard prompts, or missing-page creation. Update added, changed, renamed, and removed notes, search results, references, tasks/calendars, graph data, and loaded journals. Preserve temporary view options, selection/scrolling, graph node positions and zoom, and already loaded journal entries. Defer replacing view items until a mouse click/drag finishes.
Keep active editors and pending drafts intact, including cursor/selection, folds, and history. When the current file changes or disappears, show an inline notice with Copy draft and Reload from disk controls. Copying changes only the clipboard; reloading uses the existing explicit discard confirmation for unsaved edits. Keep the existing byte-comparison save guard. An idle removed note becomes unavailable and is never recreated. A deleted active journal remains visible until the user resolves it. An unavailable root retains the view/draft and recovers when it returns, with clear status feedback.
Check nested arrivals, repeated atomic replacement, idle edits/deletion, filtered search/tasks, graph arrangement, journal/editor preservation, conflicts, toggling, notebook isolation, and moved/replaced root recovery. Verify actual note bytes remain intact; stop for user review.
Local images and file links #
Standard Markdown images render inline in documents, outline blocks, and journals. Resolve relative image paths from the containing note's directory; absolute local paths and file URLs also work, including images outside the notebook. Support percent-encoded paths and Markdown angle-bracket destinations for spaces and non-ASCII filenames. Large images shrink to the available reading width and keep their proportions as the window/sidebar is resized. Small images retain their natural size. This applies to documents, nested blocks, and journals, without resizing source image files or changing Markdown. Reading images never copies or changes them. Remote image downloading and attachment insertion controls remain outside this pass.
Standard Markdown links to local files work inside or outside the notebook. Existing Markdown files inside the notebook open as exact note paths, retaining the normal draft/save guard; missing Markdown pages inside the notebook retain explicit creation behavior. Other files, outside Markdown, and symlinked paths open through the desktop's normal file association. Resolve relative links from the note's directory and preserve absolute file URLs, including filenames with spaces, Unicode, and escaped '#'. Previewing/reading never launches files; only explicit link activation does. Outside links never create or import note files.
Check actual image resources in normal notes and nested journal blocks, link activation/routing, notebook boundaries, and original image/note bytes. Then stop for user review.
Draft recovery #
Keep an atomic, device-local recovery copy whenever a user edit produces an unsaved draft, before the autosave delay. Store the full Markdown and the exact source it was based on, with its canonical notebook/path and editing position. Use local application data outside the notebook; add no files or metadata to notes. Remove the copy after a successful save, undo back to the saved source, or explicit discard. Keep separate editing sessions/notebooks independent. An unreadable or incomplete recovery record must not hide other drafts or be deleted silently.
On reopening, show a notice for available drafts. File → Recover Drafts opens a native review dialog, available even without a notebook open or with folder reopening disabled. Preview recovered Markdown beside the current note on disk; offer Restore into editor, Copy draft, Discard with confirmation, and Close. Previewing, copying, cancellation, and restoration never write note files.
Restoring reopens the source editor for review, without restarting autosave. Ctrl+S explicitly saves, or a fresh edit resumes normal autosave. Keep the original source expectation: externally changed files cannot be overwritten and deleted files cannot be recreated by recovery. Missing folders keep their recovery copies available to preview/copy until the folder returns. A copy already saved to disk can be cleared on explicit restoration without rewriting the note.
When saving fails or a recovered draft awaits review, closing offers Keep draft and close, Discard, or Cancel. Only offer keeping when the latest recovery write has succeeded. Reload from disk retains explicit discard confirmation and clears the discarded copy. Persistence failures must be visible; never claim a failed copy is protected across restart.
Check abrupt process termination before autosave, restoration without writes, explicit save and autosave cleanup, conflicts, normal close/reopen, deletion, missing roots, copying/discard confirmation, and notebook isolation. Verify real note bytes remain intact, then stop for user review before discussing LLM work.
The backed-up spec is reference material. This shorter spec and the current conversation define the restart's scope.