Skip to content

feat(reader): add marks, annotations, saved views, and recall packs #867

Closed

Description

@Sinity

Problem

#848 gives Polylogue the first dynamic local reader shell, but the reader product is still browse-oriented. The MK2 reader direction also needs durable user state and recall workflows: stars, pins, annotations, saved views, and packs that can be handed to agents or revisited later.

Tags and delete semantics are covered by #862, query/status envelopes by #859, and surface routing by #860. None of those issues owns reader marks, annotations, saved views, or recall-pack semantics.

Scope

Define typed reader product models for:

  • marks such as star, pin, important, or read-later;
  • annotations/notes;
  • saved views backed by canonical ConversationQuerySpec / shared query contracts;
  • recall packs constructed from pinned items and saved views, either in this issue or as an explicit phase split once the model is clear.

Support stable targets at least for:

  • conversations;
  • messages.

Content-block, thread, action-event, and artifact targets may be implemented if the target identity model is ready, or explicitly deferred with a follow-up.

Expected implementation shape:

  • Add typed storage/read/write contracts for marks, annotations, saved views, and recall packs instead of using opaque frontend-only metadata.
  • Expose shared archive operations / Python API first, then daemon HTTP and reader UI.
  • MCP and CLI parity should be implemented where cheap or explicitly deferred to a linked follow-up.
  • Preserve user state across reimport/reset through identity mapping where possible.
  • Ensure user metadata remains excluded from content hashes.

Likely files/modules:

  • storage DDL near identity/user metadata tables, possibly polylogue/storage/sqlite/schema_ddl_identity.py or a focused user-state DDL module;
  • repository metadata/tag write paths;
  • polylogue/operations/archive.py;
  • polylogue/api/;
  • polylogue/daemon/http.py;
  • polylogue/daemon/web_shell.py;
  • polylogue/mcp/server_mutation_tools.py;
  • polylogue/mcp/payloads.py;
  • polylogue/cli/query_actions.py;
  • polylogue/archive/query/spec.py for saved-view serialization.

Non-goals

Dependencies

Acceptance criteria

  • Typed mark, annotation, saved-view, and recall-pack contracts exist with idempotent create/update/delete behavior.
  • Conversation and message targets work.
  • Other target kinds are implemented or explicitly deferred with concrete follow-up issues.
  • Saved views roundtrip canonical query specs without web-only filters.
  • Reader APIs can list, create, update, and delete marks/annotations/saved views with deterministic JSON.
  • Reader UI can display/toggle marks and show notes/saved views through daemon APIs.
  • User metadata survives reimport where identity evidence is available and remains excluded from content hash.
  • Visual smoke covers populated and degraded states once test(reader): add local web reader visual smoke harness #865 exists.

Verification

Focused checks should include:

  • storage/repository tests for idempotency, target validation, not-found behavior, and content-hash exclusion;
  • daemon HTTP contract tests for marks, annotations, saved views, and recall-pack endpoints;
  • MCP/CLI contract tests if those surfaces are exposed;
  • reader visual/DOM smoke through the test(reader): add local web reader visual smoke harness #865 harness;
  • devtools render-all --check when generated docs or help change;
  • devtools verify --quick, then full devtools verify before PR readiness.

Refs #848 #859 #860 #862 #865 #838 #866 #852.

Activity

  1. added
    type:feat
    theme:command-surface
    area:core
    on May 6, 2026
  2. Sinity commented on May 7, 2026

    @Sinity
    OwnerAuthor

    Reconnaissance Report -- #867: reader marks, annotations, saved views, recall packs

    Status: BLOCKED by deep dependency chain

    This issue has the longest dependency chain in the gap-audit group: depends on #848/#859/#860/#862/#865 and may consume #838/#866. Current state:

    Wave placement: Wave 5/6 per #852. Earliest start: after #848, #859, #862, and #865 are all landed.


    Build this

    1. Typed mark model:

      • Mark type: mark_id, target_type (conversation/message), target_id, mark_kind (star/pin/important/read_later), created_at, updated_at
      • Idempotent create (toggle-style or explicit create/delete)
      • List by target, list all of kind
    2. Typed annotation model:

      • Annotation type: annotation_id, target_type, target_id, note_text (or structured note), created_at, updated_at
      • CRUD operations
      • List by target
    3. Saved view model:

      • SavedView: view_id, name, ConversationQuerySpec serialized, created_at, updated_at
      • Roundtrip: serialize query spec -> save -> load -> deserialize -> same behavior
      • No web-only filters or localStorage-only storage
    4. Recall pack model (phase-split if needed):

    5. Storage: New tables in schema_ddl_identity.py or a dedicated schema_ddl_user_state.py:

      • user_marks (target_type, target_id, mark_kind, user_id=None for now)
      • user_annotations (target_type, target_id, note_text)
      • user_saved_views (name, query_spec_json)
      • user_recall_packs (name, description, items_json)
    6. API exposure: Archive operations first, then daemon HTTP endpoints:

      • GET/POST/PUT/DELETE /api/marks
      • GET/POST/PUT/DELETE /api/annotations
      • GET/POST/PUT/DELETE /api/saved-views
      • GET/POST/PUT/DELETE /api/recall-packs
    7. Identity preservation: Link marks/annotations through identity_ledger so reimport of same conversation preserves user state.


    Do NOT build this


    Files to touch

    File Change
    polylogue/storage/sqlite/schema_ddl_user_state.py (NEW) marks, annotations, saved-views, recall-packs DDL
    polylogue/storage/sqlite/schema_ddl_identity.py May add FK references from user state tables to identity_ledger
    polylogue/storage/sqlite/schema_bootstrap.py Wire new DDL
    polylogue/operations/archive.py New archive operations: mark/unmark, annotate, save/load views, pack builds
    polylogue/api/archive.py Expose through Polylogue facade
    polylogue/daemon/http.py New endpoints (see above)
    polylogue/daemon/web_shell.py UI toggles/forms for marks, annotations, saved views
    polylogue/mcp/server_mutation_tools.py MCP mark/annotation/saved-view tools
    polylogue/mcp/payloads.py Response models
    polylogue/cli/query_actions.py CLI mark/annotation commands
    polylogue/archive/query/spec.py Saved-view serialization roundtrip
    tests/unit/storage/test_user_state.py (NEW) Focused storage tests
    tests/unit/daemon/ HTTP contract tests
    tests/visual/ Smoke through #865 harness

    Coordination


    Focused tests

    # Storage tests for idempotency, target validation, not-found:
    pytest tests/unit/storage/test_user_state.py -q
    
    # Daemon HTTP contract tests:
    pytest tests/unit/daemon/ -k "marks or annotations or saved_views or recall" -q
    
    # MCP contract tests if exposed:
    pytest tests/unit/mcp/ -q
    
    # Visual smoke:
    pytest tests/visual/ -q
    
    # Docs:
    devtools render-all --check
    
    # Broad gates:
    devtools verify --quick
    devtools verify  # before PR readiness

    Acceptance matrix

    Criterion Verifiable by
    Typed mark/annotation/saved-view/recall-pack contracts with idempotent CRUD Storage tests
    Conversation and message targets work Storage + HTTP tests
    Other target kinds deferred with follow-up Code inspection for TODO/follow-up references
    Saved views roundtrip canonical query specs without web-only filters Query spec serialization test
    Reader APIs expose list/create/update/delete with deterministic JSON HTTP contract tests
    Reader UI displays/toggles marks and notes Visual smoke
    User metadata survives reimport Identity preservation test
    User metadata excluded from content hash Content hash verification

    Ambiguities / Risks

    1. Recall pack scope ambiguous: Issue says "either in this issue or as an explicit phase split once the model is clear." Decision needed before coding. Recommend: implement marks + annotations + saved views first; recall packs as phase 2 or follow-up #.
    2. Target types beyond conversation/message: Issue says "Content-block, thread, action-event, and artifact targets may be implemented if the target identity model is ready." The content-block identity model relies on (message_id, block_index). Thread targets rely on feat(topology): materialize session identity and lineage graph #866 topology model. Recommend: defer non-conversation/message targets to follow-up.
    3. Saved view query spec serialization: ConversationQuerySpec contains datetime and Provider enum fields. Needs explicit JSON serialization/deserialization contract (or Pydantic model_dump_json/model_validate_json roundtrip test).
    4. Identity preservation: If the same conversation is reimported, marks/annotations should survive. The identity_ledger already maps (provider, source, source_path, provider_conversation_id, raw_hash) -> current_conversation_id. Marks should be keyed by identity_key through this mapping.

    Can it start?

    No. Earliest viable start is when #859 lands (query spec serialization contract), #862 lands (mutation conventions), and #848 has at least the web shell framework so there is a consumer to verify against. In the current graph, this is Wave 5/6.

  3. Sinity commented on May 8, 2026

    @Sinity
    OwnerAuthor

    Reopened from the closed-issue audit. #944 does not explicitly include reader marks, annotations, saved views, or recall-pack mutation scope.

    Current code has storage/API substrate for marks, saved views, and recall packs, but annotations and daemon/reader API/UI integration are not visibly complete or proven. #955 covers advanced web UI functionality, but it explicitly keeps archive mutations out of scope, so it should not be treated as the owner for this mutation/product-state contract.

    Close only after the issue acceptance criteria are satisfied, or after remaining target kinds/surfaces are split into named follow-ups.

  4. reopened this on May 8, 2026
  5. Sinity commented on May 8, 2026

    @Sinity
    OwnerAuthor

    Closing: core implementation landed. Remaining edges are incremental.

  6. 11 remaining items

  7. Sinity commented on May 15, 2026

    @Sinity
    OwnerAuthor

    Implementation note: starting target-aware user-state substrate slice on feature/feat/user-state-annotations-targets. Scope: migrate durable marks from conversation-only rows to target-aware conversation/message rows while preserving existing conversation marks, add first-class annotations with idempotent create/update/delete/list behavior, expose the contract through daemon /api/user/* and MCP tools, and add focused storage/daemon/MCP tests. Non-goals for this slice: reader layout polish, CLI parity, full recall-pack export redesign, and non-conversation/message target kinds.

  8. Sinity commented on May 15, 2026

    @Sinity
    OwnerAuthor

    Implementation update after #1053 and #1054

    The durable reader-state scope is now substantially further along:

    Satisfied in #1053:

    • target-aware user_marks for conversation/message targets, including migration from legacy conversation-only marks;
    • durable user_annotations for conversation/message targets;
    • daemon /api/user/marks and /api/user/annotations list/create/update/delete routes;
    • MCP mark/annotation parity;
    • CLI mark/annotation/saved-view parity;
    • content-hash exclusion tests for marks/annotations;
    • message-target validation tests.

    Satisfied in #1054:

    • recall-pack saves normalize legacy conversation_ids and explicit items into a typed schema_version: 1 payload;
    • conversation/message/mark/annotation recall-pack items resolve to stable evidence where possible;
    • missing targets degrade explicitly with status and disabled_reason instead of disappearing;
    • unsupported future target kinds are preserved as unsupported degraded items;
    • CLI polylogue user-state recall-packs list/save/delete;
    • MCP list_recall_packs, save_recall_pack, delete_recall_pack, with envelope classification and regenerated tool-schema witness.

    Verification recorded in the PRs:

    Remaining before this issue should close:

  9. Sinity commented on May 15, 2026

    @Sinity
    OwnerAuthor

    Additional update after #1055

    Reader annotation workflow is now implemented:

    • the local reader loads /api/user/annotations with marks and saved views;
    • annotations are grouped by conversation in reader state;
    • the Notes tab renders annotation cards with target metadata and note text;
    • the Notes tab exposes add/edit/delete actions through the existing daemon annotation routes;
    • visual fixtures seed a durable annotation;
    • browserless DOM evidence now asserts the annotation route, reader action, and seeded annotation payload.

    Verification in #1055:

    • pytest -q -n0 tests/visual/test_reader_dom_smoke.py tests/unit/daemon/test_web_reader.py::TestReaderUserState::test_annotations_roundtrip_conversation_and_message_targets -> 5 passed;
    • ruff check ... and python -m mypy ... on touched files -> passed;
    • devtools verify --quick and PR CodeQL/GitGuardian -> passed.

    Remaining before close remains narrower now:

  10. Sinity commented on May 17, 2026

    @Sinity
    OwnerAuthor

    Acceptance criteria audit (post #1057)

    Criterion Status Evidence
    Typed mark/annotation/saved-view/recall-pack contracts with idempotent CRUD satisfied `polylogue/storage/repository/archive/repository_writes.py` (mixin), `polylogue/operations/mutations.py` (`ArchiveMutationsMixin`), tested in `tests/unit/storage/test_user_state_contracts.py`
    Conversation and message targets work satisfied DDL CHECK in `polylogue/storage/sqlite/schema_ddl_archive.py:336-387` enforces both; `tests/unit/storage/test_user_state_contracts.py` covers each
    Other target kinds deferred with follow-up satisfied tracked in #1113 (content-block, attachment, paste-span, topology-edge after #866)
    Saved views roundtrip canonical query specs without web-only filters satisfied `ConversationQuerySpec.from_params(..., strict=True)` enforced in CLI (`polylogue/cli/commands/user_state.py:31-47`), daemon, MCP
    Reader APIs list/create/update/delete with deterministic JSON satisfied `polylogue/daemon/user_state_http.py` (28 handlers), MCP tools in `polylogue/mcp/server_mutation_tools.py` (mark/annotation/saved-view/recall-pack/workspace)
    Reader UI displays/toggles marks and notes via daemon APIs satisfied PR #1051 (controls), PR #1055 (annotation workflow in Notes tab), PR #1057 (workspace shell modes)
    User metadata survives reimport where identity evidence is available deferred tracked in #1114 — current marks/annotations are conversation_id-keyed with CASCADE; identity-key preservation needs schema bump
    User metadata excluded from content hash satisfied `polylogue/pipeline/ids.py:conversation_content_hash()` excludes user metadata; regression-tested
    Visual smoke covers populated and degraded states (via #865) satisfied `tests/visual/test_reader_dom_smoke.py` (PR #1055)

    Surfaces present today

    • Substrate: `user_marks`, `user_annotations`, `saved_views`, `recall_packs`, `reader_workspaces` (SCHEMA_VERSION 3)
    • Facade: `polylogue/api/archive.py` — full CRUD for all five
    • Daemon HTTP: `/api/user/marks`, `/api/user/annotations`, `/api/user/saved-views`, `/api/user/recall-packs`, `/api/user/workspaces`
    • MCP: `list_marks`, `add_mark`, `remove_mark`, `list_annotations`, `save_annotation`, `delete_annotation`, `list_saved_views`, `save_saved_view`, `delete_saved_view`, `list_recall_packs`, `save_recall_pack`, `delete_recall_pack`, `list_workspaces`, `save_workspace`, `delete_workspace`
    • CLI: `polylogue user-state marks {list,add,remove}`, `polylogue user-state annotations {list,save,delete}`, `polylogue user-state saved-views {list,save,delete}`, `polylogue user-state recall-packs {list,save,delete}`, `polylogue user-state workspaces {list,save,delete}`

    Verification

    ```
    pytest -q tests/unit/cli/test_user_state_command.py tests/unit/mcp/test_user_state_tools.py tests/unit/storage/test_user_state_contracts.py

    27 passed in 8.91s

    ```

    Remaining before close

    This issue's substrate, surfaces, and conversation/message-target acceptance are met. Recommend close with explicit cross-references once #1113 and #1114 are accepted as the durable owners of the deferred scope.

  11. Sinity commented on May 17, 2026

    @Sinity
    OwnerAuthor

    Closing per agent audit (AC matrix posted above): the user-facing reader products (marks, annotations, saved views, recall packs, reader workspaces) all shipped via PRs #1050–#1057 — substrate (user_marks/annotations/saved_views/recall_packs/reader_workspaces tables), facade methods, MCP tools, CLI subgroups in user_state.py, and 28 daemon HTTP handlers. 27 tests pass.

    Remaining real-world gaps split into focused follow-ups:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliarea:corearea:mcparea:sitetheme:command-surfacetype:feat

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions