Replies: 3 comments 5 replies
|
@designermonkey: Here are many questions. Not all need answer, but I guess it is a good starting point. |
|
I've been investigating a few things, including what's in this discussion so far, and have done some research in the codebase to see what should be implemented in what order. I have more detailed information on these to share at a later date, but for now here's some really high-level insight. I'm unsure how you want to handle dependency collision, so I thought it best to figure out what affects what before making any decisions. 1. Frontmatter (
|
Here's a plan for links and assets:Plan: Canonical Link Format — LeafWikiDate: 2026-07-31 ProblemHTTP-style absolute paths in markdown ( Assets (images, PDFs, etc.) placed manually alongside wiki pages are linked via relative paths that work in editors but 404 in the web app — browser resolves them against the page URL, and the server doesn't serve arbitrary filesystem paths. Design Constraints
Proposed Link FormatsFormat 1: Relative markdown paths (primary recommendation)Store links as tree-relative paths. Works everywhere — editors, git web, LeafWiki web. [Page](../target-page.md)
[Section](../../other/target-page.md#section-heading)Key principle: storage ≠ rendering.
Format 2:
|
| Task | Files |
|---|---|
Add /wiki/ static route serving <storageDir>/root/ |
internal/wiki/assets/routes.go or new |
Auth-gate same as /assets/ |
internal/wiki/assets/routes.go |
| Path traversal protection | Route handler |
Update MarkdownImage to resolve relative paths via resolveWikiLinkPath() |
ui/.../MarkdownImage.tsx |
Update MarkdownImage to route non-asset images to /wiki/ |
ui/.../MarkdownImage.tsx |
Update MarkdownLink to detect file refs (not pages) and route to /wiki/ |
ui/.../MarkdownLink.tsx |
| Update link pipeline to skip indexing for file refs | internal/links/helpers.go |
Phase 2: Add leafwiki:// resolution
| Task | Files |
|---|---|
Add ResolveLeafWikiURI() to LinkService |
internal/links/link_service.go |
Add leafwiki:// detection in render path |
Frontend markdown renderer |
Store leafwiki:// as link format in "Copy link" dialog |
internal/wiki/links/use_cases.go |
Render leafwiki:// as resolved route path in HTML |
ui/.../MarkdownPreview.tsx |
Phase 3: Relative path storage
Convert stored links from HTTP absolute to tree-relative in markdown files.
| Task | Files |
|---|---|
| Convert link storage from HTTP absolute to tree-relative | internal/links/helpers.go |
| Add rewrite pass for existing absolute links | internal/links/link_refactor.go |
| Update link extraction to preserve relative format | internal/links/helpers.go |
| Validate relative links in external editors | Manual test |
Phase 4: Default [[Title]] linking
| Task | Files |
|---|---|
"Link to page" dialog defaults to [[Title]] |
ui/.../editor/... |
"Copy link" copies [[Title]] or leafwiki:// |
internal/wiki/links/use_cases.go |
Auto-suggest [[Title]] on [[ typing |
ui/.../editor/... |
Open Decisions
-
leafwiki://user-visible or internal? — Visible. Enables cross-workspace links. Users can copy/paste between wikis. -
Hash fragments on
leafwiki://? — Not needed initially.leafwiki://idresolves to page, browser handles#headingon the resolved URL. -
Phase ordering? — Phase 1 (file serving) is a prerequisite for relative paths working in web app. Phases 2-4 can be reordered depending on priority.
-
wikilink:sentinel prefix? — Keep it. Disambiguates title-based links from path-based links in the DB.
Uh oh!
There was an error while loading. Please reload this page.
Current State
LeafWiki is designed to be reconstructable from the files stored in a workspace.
Markdown files are the primary source of truth. LeafWiki-specific metadata such as
leafwiki_id,leafwiki_pinned, and related properties is stored in the Markdown frontmatter and read when the application starts.In addition to the Markdown files, a LeafWiki workspace currently contains:
assetsdirectory for attachments and other file-based resources.leafwikidirectory for revisions and internal application dataBecause LeafWiki relies heavily on Markdown files, bidirectional synchronization with Git repositories or external filesystem-based tools could be a valuable feature.
However, this also introduces several architectural questions and potential problems.
Git and Bidirectional Synchronization
A bidirectional Git integration would allow users to edit files both through LeafWiki and through external tools.
The main concern is merge conflicts.
Conflicts may occur when:
leafwiki_id.leafwikidiverge from the current file stateWe need to determine how LeafWiki should detect and resolve these situations.
Some open questions are:
Currently, files can be rescanned through the maintenance window. This may work as a manual recovery mechanism, but it may not be sufficient for continuous bidirectional synchronization.
Filesystem Agent Systems
Filesystem agents and other external automation tools introduce similar challenges, even without Git.
An external process may:
LeafWiki must decide how it handles changes that happen while the application is running.
Important questions include:
The filesystem is currently the source of truth, but external agents make it necessary to define clearer ownership and consistency rules.
Linking
Another area that requires attention is the linking system.
LeafWiki currently represents links as HTTP-style addresses. This may cause problems when linking documents locally or when a workspace is moved, cloned, or opened on another machine.
For example, links may need to work across:
Possible approaches could include:
leafwiki_idWe should also define what happens when:
Main Components Affected
The main areas that would likely need to be reviewed are:
node_storetree_serviceThe
node_store,tree_service, and Markdown package currently read and reconstruct data from the filesystem. These components would need clear responsibilities around:The links subsystem would need a consistent model for resolving links independently of whether a document is accessed through HTTP, Git, or the local filesystem.
Scope
MCP support is planned, but it is outside the scope of this discussion.
For now, the main questions are:
Feedback, architectural ideas, and examples from similar systems are very welcome.
All reactions