#42

Bookmark tags: editor UI + set_bookmark_tags helper (follow-up to task #18)

Openparzival1lopened 7mo ago

Follow-up notes from the bookmark system landed in PR #43 for kanban task #18. The tags column was added in the same migration (007) to match the pre-declared models.Bookmark shape per task #24's schema/model lockstep rule, but the editor UX was deliberately deferred so the first version of bookmarks (toggle + label + browser) could ship simply. This issue picks up the TUI and helper work that remains.

1. What PR #43 ships vs what it skips

Already in the bookmarks table (migration 007):

  • id, message_uuid (UNIQUE, FK CASCADE → messages), label, tags TEXT NOT NULL DEFAULT '[]', created_at
  • get_bookmark / list_bookmarks decode the JSON column into list[str] before returning, and fall back to an empty list on corrupt payloads so the browser never crashes on a bad write.
  • Toggle via space in selection mode, label prompt via L, browser modal via b
  • Browser filter matches label, message text, project, and custom_name

Deliberately not landed:

  • set_bookmark_tags helper
  • Tag editor UI (no keybind surfaces tag entry anywhere today)
  • Tag rendering in the browser row
  • Tag-scoped filtering (tag:<name> parsing, or matching the JSON payload in the filter OR chain)

So today a bookmark can be pinned and labeled and the column accepts tags if written directly, but no keybind lets the user edit them and no filter path surfaces them.

2. Why tags over labels

The label is a one-off free-text description of a single pin. Tags are different — they're meant to be re-used across many bookmarks so the user can pivot the browser view ("show me every decision bookmark across all sessions"). Label and tags should coexist; a bookmark can have both.

3. UX direction

Capture path

Option A — chord from selection mode: # prompts for comma-separated tags (no spaces inside a tag). Parallel to L for label.

Option B — only from the browser: t in BookmarkBrowserScreen pushes a tags prompt for the highlighted row. Lighter; skips the selection-mode surface entirely.

Option B is probably cleaner for v1 — users haven't asked for mid-transcript tag entry, and the browser is where tag-driven filtering pays off.

Filtering

Browser filter input already passes a substring to db.list_bookmarks. Two extensions:

  • Substring matching the JSON tags column (cheapest: add b.tags LIKE ? to the OR chain; returns any row whose JSON contains the string — good enough for a "show me pins tagged roughly bug" workflow)
  • Filter syntax tag:<name> — parse the leading token out before the LIKE, route to a tighter query that matches the JSON array element exactly (so tag:bug doesn't also match tag:bugfix)

Ship the substring path first; add tag: parsing later if anyone wants it.

Rendering

Add a suffix on the metadata line (or a third line) showing tags as #bug #decision. Keep the row height stable for the common case of zero tags.

4. Action items

  • Add set_bookmark_tags(conn, bookmark_id, tags: list[str]) helper; strip / drop empty entries before JSON-encoding
  • Pick UX path (chord from selection mode vs browser-only) and wire a TagPromptScreen modal (mirror LabelPromptScreen — comma-separated input)
  • Include b.tags LIKE ? in the filter OR chain in list_bookmarks so tag substrings surface in the browser
  • Add tag rendering to BookmarkItem (introduced in PR #43)
  • Optional: parse tag:<name> in the browser filter input for exact matches
  • Add tests: helper round-trip (write → read decode), filter by tag substring, whitespace-only tags collapse

References

  • PR #43 — kanban task #18 (bookmark system) — adds the table, the browser modal, the label editor, and the tags column this issue will build an editor for
  • docs/TASKS.md task #18: "Build bookmark system" — original task bullet lists tags as part of the feature
  • db.py migration 007 (_migration_007_bookmarks) — the migration whose tags column this issue covers
  • models.py — Bookmark model already declares tags: list[str]
  • ADR-001 — rationale for JSON-encoded values in SQLite text columns

Activity

2
parzival1l7mo ago

Tracked against PR #43 (kanban task #18 / bookmark system). That PR ships the bookmarks table, selection-mode toggle, label prompt, and browser modal — this issue picks up the tags column and editor UX as the next pass.

parzival1l7mo ago

Scope shifted after rebasing PR #43 onto docs/adr: the tags column itself lands in PR #43's migration 007 so models.Bookmark stays in lockstep with the schema (task #24 rule). That leaves this issue focused on the editor UX and the set_bookmark_tags helper — the column will already exist by the time anyone picks this up. Issue body updated to match.