feat(tui): add link picker and navigation history
CI / test (pull_request) Successful in 2m18s

Press [ in detail view to open link picker showing all [[links]]
in the current entry. Enter follows a link, resolving by title
then body substring. Navigation history stack enables esc to pop
back through followed links before returning to list.

Adds Store.ResolveLink() for non-transactional link resolution
from the TUI layer.
This commit is contained in:
2026-05-21 14:03:09 -04:00
parent 8426c2fbc1
commit 2684eb1d24
6 changed files with 201 additions and 0 deletions
+20
View File
@@ -55,6 +55,26 @@ func syncLinks(ctx context.Context, tx *sql.Tx, s *Store, entityID string, body
return nil
}
func (s *Store) ResolveLink(ctx context.Context, linkText string) (*Entity, error) {
lower := strings.ToLower(linkText)
var id string
err := s.db.QueryRowContext(ctx, `
SELECT id FROM entities
WHERE LOWER(title) = ? AND deleted_at IS NULL
ORDER BY created_at DESC LIMIT 1`, lower).Scan(&id)
if err != nil {
err = s.db.QueryRowContext(ctx, `
SELECT id FROM entities
WHERE LOWER(body) LIKE ? AND deleted_at IS NULL
ORDER BY created_at DESC LIMIT 1`, "%"+lower+"%").Scan(&id)
}
if err != nil {
return nil, ErrNotFound
}
return s.Get(ctx, id)
}
func (s *Store) LoadBacklinks(ctx context.Context, entityID string) ([]Backlink, error) {
rows, err := s.db.QueryContext(ctx, `
SELECT e.id, e.title, e.body, el.link_text