mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 15:26:17 +00:00
feat(app): hubs, types and tags UI, themes, key bindings and slash commands
Settings screen (themes incl. Sweet, rebindable shortcuts), rich text escapes, page sidebar with the local graph, sortable All pages, tree view changes and the Type/Tags rows in the page header. Docs updated. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e18fd2c27e
commit
88ef4a97a5
32 files changed
+5431
-375
No files matched your search
+82
-8
@@ -33,7 +33,7 @@ flutter build linux --release # build/linux/x64/release/bundle/
|
||||
flutter run -d <android-device> # or: flutter build apk --release
|
||||
flutter build windows --release # on Windows
|
||||
```
|
||||
The graph lives in the platform app-support dir (`~/.local/share/es.zenvairo.synapse/graph`
|
||||
The graph lives in the platform app-support dir (`~/.local/share/dev.dasemu.synapse/graph`
|
||||
on Linux). Override it with `SYNAPSE_GRAPH=/path/to/graph`.
|
||||
|
||||
## After changing the FFI API
|
||||
@@ -57,27 +57,101 @@ Commit the regenerated `crates/synapse-ffi/src/frb_generated.rs` and `app/lib/sr
|
||||
block, Delete at end pulls the next one in, ↑/↓/←/→ cross block edges, Alt+Shift+↑/↓ move
|
||||
among siblings, Ctrl+↑/↓ collapse/expand, Ctrl+Enter cycles TODO/DONE, Esc leaves editing.
|
||||
- `[[`, `((` auto-pair; `[[`, `#` and `((` open autocomplete (↑/↓, Enter/Tab, Esc).
|
||||
- `/` at the start of a word opens the command menu: `/link` (page link, then the page picker),
|
||||
`/ref`, `/url`, `/image`, `/bold`, `/italic`, `/strike`, `/highlight`, `/code`, `/codeblock`,
|
||||
`/h1`–`/h3`, `/todo`, `/quote`, `/divider`, `/today`, `/tag` (`SlashCommand` in
|
||||
`editor/completion.dart`).
|
||||
- Rich text is Markdown: `**bold**`, `*italic*`, `~~strike~~`, `==highlight==`, `` `code` ``,
|
||||
`[label](url)`, ``. A backslash escapes punctuation (`\*` shows a literal `*`,
|
||||
`\[[` is not a link); the backslash is hidden when the block is not being edited.
|
||||
- Ctrl+B / I / E / L and Ctrl+Shift+S / H wrap the selection (or the caret) in bold, italic,
|
||||
code, page link, strike and highlight; pressing again unwraps.
|
||||
- Drag a bullet onto a row: upper half = before, lower half = after, lower half to the right
|
||||
= first child.
|
||||
- Edits apply locally at once and go to the core through one serial write queue (text saves
|
||||
are debounced 350 ms); after structural edits the outline is re-read and the core's
|
||||
structure wins if they ever disagree.
|
||||
- App shortcuts: Ctrl+K quick switcher, Ctrl+Shift+J journals, Ctrl+Shift+T timeline,
|
||||
Ctrl+\ sidebar, Alt+←/→ back/forward.
|
||||
- App shortcuts (defaults, all rebindable in Settings): Ctrl+K quick switcher, Ctrl+Shift+J
|
||||
journals, Ctrl+Shift+G graph, Ctrl+Shift+T timeline, Ctrl+\ sidebar, Ctrl+Shift+\ graph
|
||||
sidebar, Ctrl+, settings, Alt+←/→ back/forward.
|
||||
|
||||
## Settings, themes and key bindings
|
||||
- Sidebar "Settings" (Ctrl+,): theme cards and the shortcut list. Click a shortcut, press the new
|
||||
combination (Esc cancels); a combo already in use is refused and names its owner; each row
|
||||
and "Reset all" restore defaults.
|
||||
- Themes (`appThemes` in `theme/theme.dart`): System (Paper light/dark by OS), Paper, Paper dark,
|
||||
Sweet (KDE-style indigo and magenta), Sweet light, Nord. A theme is a `SynapseColors` palette.
|
||||
- Preferences live in `app-settings.json` inside the graph directory (`FileSettings`);
|
||||
`Keymap` (`state/keymap.dart`) stores only the overrides, encoded as `ctrl+shift+<keyId>`.
|
||||
|
||||
## Types and tags
|
||||
- **Type** (what a note is): plain names, no page (persona, lugar, empresa, cliente, herramienta,
|
||||
concepto, idea, ...). "Type" under the header opens a picker with the types in use (with count)
|
||||
and seeded suggestions, or type a new name. Stored in `Page.types`.
|
||||
- **Tag** (a topic): a real page of kind `tag`. "Tag" opens a picker over the existing tag pages
|
||||
or creates one by typing a new name (a note used as a tag becomes a tag page; hubs, journals
|
||||
and templates cannot be tags). Tag chips open the tag page, which lists its tagged notes.
|
||||
An inline `#tema` or `[[tema]]` in the text also links to the page. Renaming or deleting a tag
|
||||
page updates its members. Tag pages cannot be tagged themselves.
|
||||
- In the graph a tagged note points at its tag pages with a separate edge kind (TAGGED), apart
|
||||
from page links and inline references.
|
||||
|
||||
## Hubs, namespaces and cleanup
|
||||
- **Hub** (folder icon): a page kind, not a note: no outline, a title, a short description
|
||||
and members (notes and sub-hubs). Membership is stored on the member (its parent hubs), so
|
||||
a page belongs to at most one hub (adding it to another hub moves it); cycles are rejected. **Namespace** (tree icon): `A/B/C`
|
||||
titles; `A/B` is the parent of `A/B/C` even when it does not exist yet.
|
||||
- Hubs never appear in the sidebar's "RECENT" list (they are folders, not pages).
|
||||
- Sidebar "HUBS" (always shown, "+" creates a hub): tree of root hubs, collapsed by default;
|
||||
unfolding a hub lists only its sub-hubs (notes live on the hub screen), above "RECENT";
|
||||
reloads after edits settle.
|
||||
- Hub screen ends with the local graph panel (same as the page sidebar on notes).
|
||||
- Every hub has a template (a hidden note, possibly empty): "Template" on the hub screen opens
|
||||
it for editing, and notes created from "Add" start as a copy of it.
|
||||
- Hub screen: editable title and description (saved on blur), members listed sub-hubs first
|
||||
then by title, "Add" (pick a page, or create a note / sub-hub), × on hover or long-press
|
||||
to remove, `⋯` ▸ "Convert to note" (description and members become blocks and links).
|
||||
- Notes: namespace breadcrumb, "In: ..." chips with a × to leave a hub, and a `⋯` menu
|
||||
with "Convert to hub…" (dialog: shortened title, description, member checklist, optional
|
||||
note that keeps the original outline; title clashes are shown inline) and "Add to hub…".
|
||||
- All pages ▸ "Clean up": dialog listing legacy Logseq pages (`contents`, `hls__...`, pages
|
||||
with `type:: system`, ...) with checkboxes; "Delete (n)" removes only the checked ones
|
||||
and their blocks.
|
||||
|
||||
## Page sidebar and All pages
|
||||
- The sidebar icon next to a note's `⋯` menu toggles a right sidebar (collapsed by default,
|
||||
state in `AppState.pageSidebar`) with the local graph (neighbourhood at depth 1–3) and the
|
||||
related pages; on narrow windows they appear below the content.
|
||||
- All pages lists notes only (hubs are folders, not pages) and can be sorted by edited,
|
||||
created or title, ascending or descending.
|
||||
|
||||
## Graph view
|
||||
One view (sidebar "Graph", Ctrl+Shift+G) with a mode selector:
|
||||
- **Network**: force-directed graph of pages (journals optional). Edges: links, tags,
|
||||
- **Network**: force-directed graph of pages (journals shown by default). Edges: links, tags,
|
||||
property refs, block refs/embeds (aggregated per page) and dashed mentions (unlinked
|
||||
references: a page title appearing as whole words in another page's text). Node size by
|
||||
degree + backlinks, colour by cluster or primary tag. Filters: title, tag, created date
|
||||
degree + backlinks, colour by cluster, primary tag or home hub. Hubs (a page kind: folders of
|
||||
notes) are drawn larger with a ring in every mode including Synapses (one batched draw per
|
||||
size), connected to their members by thin solid "contains" edges (CONTAINS, structural, on by
|
||||
default), both marked in the legend. Filters: title, tag, created date
|
||||
range, min links, orphans, journals, mentions. Drag nodes, hover highlights neighbours,
|
||||
wheel/pinch zoom, tap opens the page.
|
||||
- **Local**: neighbourhood of a page at depth 1–3 (also a side panel on every page).
|
||||
- **Synapses**: `related()` spreading activation from a focus page; brightness/size =
|
||||
activation, edge thickness = Hebbian synapse weight, a pulse travels outward by hops.
|
||||
- **Clusters**: Louvain communities with soft hulls.
|
||||
- **Namespaces**: radial tree of `a/b/c` titles and of tags with their pages.
|
||||
- **Clusters**: soft hulls grouped by "Hubs" (home hub, default when the graph has hubs; hull
|
||||
labelled with the hub title once it is wide enough on screen; layout-only springs pull
|
||||
members to their hub), by "Tags" (each page goes to its most widely used tag page, ties
|
||||
alphabetical; hull labelled with the tag name; springs pull pages to the best connected page
|
||||
of the tag; journals and untagged pages stay out) or by "Communities" (Louvain: groups found
|
||||
automatically from link density, no names). Colours follow group size.
|
||||
- **Tree** (no "Hubs" node: root hubs and the notes that sit in no hub, orphans included,
|
||||
hang straight off the centre): the centre is labelled with the store name (graph directory name); every arm and
|
||||
sub-branch has its own colour (arms evenly spread over the hue circle, children split their
|
||||
parent's sector evenly); drag a node to move it with its branch, drag empty space to pan.
|
||||
Radial tree: hubs (root hubs, then members recursively, cycle-safe,
|
||||
each hub expanded once, folder glyph; membership = CONTAINS edges from the graph data),
|
||||
namespaces (`a/b/c` titles, attached straight to the centre, no "Namespaces" node)
|
||||
and Tags (with their pages).
|
||||
- **Timeline**: the journal timeline.
|
||||
|
||||
Data and layout live in Rust: `SynapseGraph::graph_data()` returns the whole page-level
|
||||
|
||||
@@ -27,6 +27,64 @@ crates may add their own tables to the same database (prefix them: `search_*`, `
|
||||
- **Synapses**: local weighted associations between pages (Hebbian, 30-day half-life).
|
||||
- **Assets**: metadata rows; bytes in the blob store.
|
||||
|
||||
## Tags and types (`synapse-core::{tags, types}`)
|
||||
- **Tags are pages** of kind `tag` (topics such as "tecnología"). A page carries
|
||||
`Page.tags: Vec<String>` (tag page titles; `pages.tags`, schema v5, synced with the page, LWW
|
||||
per page); the derived `page_tags(page_id, tag_key)` index is rewritten on every page write.
|
||||
Setting a tag creates the tag page or converts a note to one; hubs, journals and templates
|
||||
cannot be tags, and tag pages cannot be tagged. Renaming/deleting a tag page rewrites/removes
|
||||
it in its members; opening the graph creates tag pages for tag names that lack one.
|
||||
API: `set_page_tags`, `add_page_tag`, `remove_page_tag`, `pages_with_tag`, `tag_catalog`.
|
||||
The graph has a `TAGGED` edge from each tagged page to its tag pages.
|
||||
- **Types** are plain names saying what a page is: `Page.types` (`pages.types`, no page, no
|
||||
index). API: `set_page_types`, `add_page_type`, `remove_page_type`, `type_catalog` (types in
|
||||
use by count, then the seeded `SUGGESTED_TYPES`).
|
||||
- Both are exported as `synapse-tags::` / `synapse-types::`, and tag pages as
|
||||
`synapse-kind:: tag` (see `history.md`).
|
||||
|
||||
## Hubs and namespaces (`synapse-core::structure`)
|
||||
Two orthogonal ways to organise pages.
|
||||
- **Namespace** (kinship by title, derived): `A/B` is a child of `A` (`namespace_parent`,
|
||||
`Graph::namespace_children`). Parents may not exist as pages (virtual levels).
|
||||
- **Hub** (folder, explicit): a page with `kind = hub` (`PageKind`, schema v3 column
|
||||
`pages.kind`). A hub has a `description` and **no blocks** (`insert_block`/`put_block`/
|
||||
`move_block` into a hub fail with `Error::Invalid`). Created with `create_hub`, or by
|
||||
`convert_to_hub` (manual, from an existing note) and undone with `convert_to_note`.
|
||||
- Membership lives on the **member**: `Page.hubs: Vec<PageId>` (`pages.hubs`, JSON), synced
|
||||
with the page (`UpsertPage`, LWW per page), so no new op exists. A derived local index
|
||||
`page_hubs(page_id, hub_id)` is rewritten on every page write (local or remote) and rebuilt
|
||||
by the v2 → v3 migration.
|
||||
- **One hub per page**: the list holds at most one id (local writes with more are refused;
|
||||
`add_to_hub` moves the page). The wire format stays a list, and readers (index, `structure`)
|
||||
use only its first entry, so data from older replicas converges.
|
||||
- **Template**: every hub owns exactly one page with `kind = template` (member of its hub,
|
||||
possibly empty, an ordinary outline). `create_hub`/`convert_to_hub` create it,
|
||||
`hub_template` returns it (creating one for older hubs). Templates are hidden from
|
||||
`hub_members`, `list_pages` and `structure`, cannot be deleted alone and go with their hub
|
||||
(`convert_to_note` deletes it). `create_page_from_template(hub, title)` makes a note in the
|
||||
hub with a copy of the template's blocks.
|
||||
- API: `set_page_hubs`, `add_to_hub`, `remove_from_hub`, `hub_members` (sub-hubs first, then
|
||||
by title), `hubs_of`. Rules: the target must be a hub, no self-membership, no journals, no
|
||||
cycles (checked locally); duplicates dropped. Readers ignore ids that dangle or point at a
|
||||
page that is no longer a hub. Deleting a hub or converting it to a note removes its id from
|
||||
every member (one `UpsertPage` per member).
|
||||
- `hub_conversion_preview` suggests a title (last namespace segment), a description (first
|
||||
prose block, plain text, <= 280 chars) and members (outline refs, then property and tag
|
||||
refs). `convert_to_hub` applies a `HubConversion` in one transaction: rename (link
|
||||
rewrite), optionally move the outline to a new note (`keep_outline_as`), delete the
|
||||
remaining blocks, set kind/description and add the members.
|
||||
- `Graph::structure()` returns every hub with members and nesting depth, and each page's
|
||||
*home hub* (deepest containing hub; ties: fewer members, then title; a hub is its own
|
||||
home). Cycles created by concurrent edits on two replicas are broken deterministically
|
||||
(edges ordered by the member page's HLC). The graph view adds `CONTAINS` edges hub → member.
|
||||
- Sync limits: `apply_remote` does not enforce "no blocks" (rejecting would break
|
||||
convergence), so a block added on one replica while another converts the page can land in
|
||||
a hub; `convert_to_note` keeps such blocks. Clients older than schema v3 drop `kind`,
|
||||
`description` and `hubs` when they upsert a page, so every client must be on v3.
|
||||
- Logseq built-ins (`contents`, `TODO`, `hls__*`, ...) are recognised by `is_legacy_page`; the
|
||||
app offers to purge them (`legacy_candidates` / `purge_pages` in `synapse-ffi`). The importer
|
||||
only skips a narrower set (see `import.md`).
|
||||
|
||||
## Temporal model
|
||||
- `journal_neighbors(date)` gives the previous/next existing journal (episodic chain).
|
||||
- Pages created from a journal block are born there; other new pages are born in today's
|
||||
|
||||
@@ -12,6 +12,10 @@ works on it (`git --git-dir=<graph>/history log`, `clone`, ...).
|
||||
bullet. Blocks targeted by `((uuid))` get an `id::` property. `collapsed:: true` is kept.
|
||||
- Property values: raw text, or JSON when the value is not a plain string (so numbers/bools
|
||||
survive a restore). Keys are sorted, so output is byte-stable.
|
||||
- Hubs: `synapse-kind:: hub` and `synapse-description::` page properties (hubs have no
|
||||
bullets). A page's tags (tag page titles) are listed in `synapse-tags:: ["a","b"]` and its types in `synapse-types:: [...]`; tag pages carry `synapse-kind:: tag` (all restored with the page). A page in hubs lists their titles in `synapse-hubs:: ["A","B"]`, so renaming a hub
|
||||
re-exports its members. Restore sets kinds first, then memberships (missing hubs or
|
||||
memberships that would now form a cycle are skipped).
|
||||
- `assets.json`: manifest `hash → name/size/mime`, sorted. Asset bytes are **not** committed
|
||||
(the blob store is already content-addressed) unless `HistoryOptions::include_blobs`, which
|
||||
adds `blobs/<hash>`.
|
||||
|
||||
+10
-2
@@ -1,7 +1,7 @@
|
||||
# Logseq import
|
||||
|
||||
Crate `synapse-import`: `import_logseq(src, &graph, &ImportOptions, progress) -> Report`.
|
||||
CLI: `cargo run --release -p synapse-import --example import -- <logseq_dir> <graph_dir> [--skip-existing]`.
|
||||
CLI: `cargo run --release -p synapse-import --example import -- <logseq_dir> <graph_dir> [--skip-existing] [--keep-legacy]`.
|
||||
|
||||
## Pipeline
|
||||
1. **Scan** `pages/`, `journals/` (`.md`, `.org`) and `assets/` (recursive). Settings are read from
|
||||
@@ -22,6 +22,14 @@ CLI: `cargo run --release -p synapse-import --example import -- <logseq_dir> <gr
|
||||
`collapsed:: true` sets the flag.
|
||||
- Assets: `../assets/x%20y.png` → `asset://<blake3>` in place (``; `?`/`#`
|
||||
suffixes kept). Missing files are left as is and reported.
|
||||
- Logseq's organisational files `contents`, `card`, `favorites` and `hls__*` (PDF highlights)
|
||||
are skipped (`ImportOptions::skip_legacy_pages`, default on; `--keep-legacy` in the CLI); other
|
||||
built-in names (`TODO`, `NOW`, ...) import normally. Skipped paths go to
|
||||
`Report::skipped_legacy`, and empty stubs with those titles that refs created *in this import*
|
||||
are removed (pages that existed before are never touched). Purging other legacy pages is a
|
||||
manual action in the app (`legacy_candidates` / `purge_pages`).
|
||||
- Hubs (Synapse-only pages without blocks, see `architecture.md`) are never written by a
|
||||
re-import: the file is skipped with a warning.
|
||||
- `.org` files: one raw root block per top-level heading, no parsing; listed in `Report::org_files`.
|
||||
- Timestamps: page `created_at` = file birth time (≤ mtime), `updated_at` = mtime; blocks inherit
|
||||
them. `origin_journal` = earliest journal referencing the page (aliases resolved), else the
|
||||
@@ -45,7 +53,7 @@ The importer records what it wrote in two local tables (`import_pages`: source f
|
||||
|
||||
## Report / progress
|
||||
`Progress { phase, done, total }` (phases: Scanning, Assets, Parsing, Pages, Blocks) and
|
||||
`Report { pages, journals, blocks, assets, bytes, updated, unchanged, org_files, warnings }`.
|
||||
`Report { pages, journals, blocks, assets, bytes, updated, unchanged, org_files, skipped_legacy, warnings }`.
|
||||
|
||||
## Known limits
|
||||
- Not parsed: org-mode syntax, whiteboards, `draws/`, namespace parent stubs, Logseq queries.
|
||||
|
||||
Reference in new issue
Block a user