feat(db): add wiki-link extraction, resolution, and backlinks
CI / test (pull_request) Successful in 2m27s

[[wiki-links]] in entry bodies are extracted at save time, resolved
to entity IDs (title match first, body substring fallback), and
stored in entity_links junction table. Backlinks surface in TUI
detail view showing entries that link to the current entry.

Schema migration v5 adds entity_links with CASCADE/SET NULL
semantics. Links sync on Create, Update, and Absorb.
This commit is contained in:
2026-05-21 13:34:56 -04:00
parent d24df8432f
commit 1e58433936
10 changed files with 454 additions and 8 deletions
+8
View File
@@ -287,6 +287,12 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.detail.mode = detailPreview
return m, tea.Batch(loadEntities(m.store, m.listParams()), m.setStatus("copied resolved"))
case backlinksLoadedMsg:
if m.detail.entity != nil {
m.detail.backlinks = msg.backlinks
}
return m, nil
case tagsLoadedMsg:
m.filter.setTags(msg.tags)
m.tagRail.setTags(msg.tags)
@@ -865,6 +871,7 @@ func (m model) updateBrowse(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
} else {
m.state = stateDetail
}
return m, loadBacklinks(m.store, e.ID)
}
}
return m, nil
@@ -1212,6 +1219,7 @@ func (m model) selectedEntity() *db.Entity {
func (m model) reloadDetail(id string) tea.Cmd {
return tea.Batch(
loadEntities(m.store, m.listParams()),
loadBacklinks(m.store, id),
func() tea.Msg {
e, err := m.store.Get(context.Background(), id)
if err != nil {