Repository navigation
feat: expose reader user-state APIs - #1050
Conversation
Problem: #867 had durable mark, saved-view, and recall-pack substrate, but the daemon reader surface still reported annotation/user-state actions as unavailable and exposed no deterministic API for the existing user-state tables. The existing write helpers also did not commit across ordinary request-scoped connections, so read-after-write behavior failed across HTTP requests.\n\nWhat changed: add daemon /api/user routes for conversation marks, saved views, and recall packs; validate saved-view query params with the strict ConversationQuerySpec contract; move the transport helpers into a focused daemon module to keep http.py within file budgets; commit user-state writes in the existing SQLite helpers; and extend reader smoke coverage for idempotent mark CRUD, saved-view roundtrips, invalid query rejection, and recall-pack references.\n\nRemaining #867 scope: annotations, message/range targets, UI controls, CLI parity, and MCP parity remain open.\n\nVerification:\n- ruff format --check polylogue/daemon/http.py polylogue/daemon/user_state_http.py polylogue/storage/sqlite/queries/conversations_identity.py tests/unit/daemon/test_web_reader.py\n- ruff check polylogue/daemon/http.py polylogue/daemon/user_state_http.py polylogue/storage/sqlite/queries/conversations_identity.py tests/unit/daemon/test_web_reader.py\n- mypy polylogue/daemon/http.py polylogue/daemon/user_state_http.py polylogue/storage/sqlite/queries/conversations_identity.py tests/unit/daemon/test_web_reader.py\n- pytest -q tests/unit/daemon/test_web_reader.py -k 'UserState or marks or saved_views or recall_packs'\n- pytest -q tests/unit/daemon/test_web_reader.py\n- pytest -q tests/visual\n- devtools verify --quick\n- devtools verify --affected --skip-slow\n\nRef #867
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (7)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a91f73fb78
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
## Summary Wire the MK3 reader shell to the durable user-state APIs added in #1050 so marks and saved views are visible and actionable in the local reader instead of remaining placeholder text. ## Problem #867 requires durable marks and saved views to be reader product state, not browser-local or hidden API data. After #1050, the daemon exposed `/api/user/*`, but the web reader still did not load marks, display them in the conversation list/header, toggle them, or save/open query-backed views. ## Solution - Load `/api/user/marks` and `/api/user/saved-views` during reader startup. - Display star/pin/archive state in the conversation list and detail header. - Add header and Notes-panel controls that toggle marks through the daemon API. - Add saved-view controls that save the current query/provider view and reopen saved query JSON. - Seed visual fixtures with durable marks and a saved view so DOM/API evidence proves archive-backed state wiring. - Update the MK3 execution log with the active slice, verification lane, and remaining #867 scope. Remaining #867 scope: annotation storage, message/range targets, CLI parity, and MCP parity. Ref #867 ## Verification - `ruff format --check polylogue/daemon/web_shell.py tests/visual/conftest.py tests/visual/test_reader_dom_smoke.py` -> 3 files already formatted - `ruff check polylogue/daemon/web_shell.py tests/visual/conftest.py tests/visual/test_reader_dom_smoke.py` -> All checks passed - `mypy polylogue/daemon/web_shell.py tests/visual/conftest.py tests/visual/test_reader_dom_smoke.py` -> Success - `node -e "... new Function(script) ..."` -> script ok - `pytest -q tests/visual tests/unit/daemon/test_web_reader.py -k "reader or UserState or saved_views or marks"` -> 45 passed - `devtools verify --quick` -> exit_code 0 - `devtools verify --affected --skip-slow` -> exit_code 0; pytest count 6361
## Summary Wire the existing `/api/user/saved-views` substrate (shipped via #1050-#1057 under the #867 user-state umbrella) into the web reader so an operator can save the current filter chain under a name, recall it, and delete it without leaving the reader. Adds a toolbar entry-point, a Delete affordance, a naming-conflict guard, and an actionable empty state. ## Problem #1118 calls out the reader UI gap for saved views: the storage table and the HTTP envelope existed, and the Notes inspector tab could already save/open a view, but there was no way to delete an existing view from the UI, no naming-conflict UX (the SQLite `UNIQUE(name)` constraint would surface as an opaque error), and no toolbar-level entry-point — saved views were reachable only by opening the Notes inspector tab on a selected conversation. The acceptance criteria require list/recall/delete affordances, an empty state distinct from a populated one, and naming-conflict handling. ## Solution - `polylogue/daemon/web_shell_workspace.py`: adds a `Saved views` `<select>` and a `Save view` button to the workspace toolbar (mirroring the existing `Restore workspace` select pattern). Populates the select in `renderWorkspaceToolbar` with `state.savedViews`, disables it when empty, and falls back through `applySavedView` → `loadConversations` + `loadFacets`. Moves `saveCurrentView` and adds `deleteSavedView` here. `saveCurrentView` now trims whitespace, rejects empty names, and detects a naming clash against `state.savedViews` locally — prompting `window.confirm` to overwrite (DELETE the existing view_id, then POST) or abort. `deleteSavedView` confirms by name before issuing the DELETE. - `polylogue/daemon/web_shell.py`: the Notes inspector list now renders a per-row Delete button next to Open; the empty state is reworded to name the next action (`Click "Save current view" to name the current filter chain.`). - `tests/unit/daemon/test_web_reader.py`: adds `TestReaderSavedViewsUI` with five tests — toolbar entry-point presence, naming-conflict UX strings, delete-button wiring, actionable empty-state copy, and an HTTP roundtrip (save → list → delete) that catches regressions in the new toolbar surface. The MCP coverage criterion (#1118 AC: "At least one MCP read tool exposes saved views by id") was already satisfied by `list_saved_views` / `save_saved_view` / `delete_saved_view` in `polylogue/mcp/server_mutation_tools.py` — no change there. The naming-conflict handling is client-side rather than at the HTTP envelope. The shared `user_state_http.py` is owned by another lane per the dispatch plan and the existing `save_view` SQL is an `INSERT OR REPLACE BY view_id`; the UNIQUE constraint is on `name`, which means a different `view_id` for the same name would 500. Detecting the conflict client-side keeps the UX coherent without changing the contract. `polylogue/daemon/web_shell.py` net change is −13 LOC (functions moved into the workspace asset module), keeping the file under the 1100-line budget enforced by `verify-file-budgets`. ## Verification ``` nix develop -c pytest tests/unit/daemon/test_web_reader.py -q # 62 passed in 14.74s (5 new under TestReaderSavedViewsUI) nix develop -c pytest tests/unit/daemon -q # 389 passed in 13.45s nix develop -c devtools verify --quick # exit_code: 0 (format + lint + mypy + render-all + manifest/lifecycle/topology lints) ``` `devtools verify` (full pytest path) requires `devtools verify --seed-testmon` on this fresh worktree; the affected unit suite was exercised directly above. `render-pages` was re-emitted to clear a pre-existing `.cache/site` drift unrelated to this PR. Closes #1118 Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Expose the existing durable reader user-state substrate through daemon HTTP APIs for conversation marks, saved views, and recall packs, with deterministic JSON contracts and reader smoke coverage.
Problem
#867 already had partial storage/API substrate for marks, saved views, and recall packs, but the daemon reader surface had no
/api/user/*routes for that state. The existing SQLite helpers also opened ordinary request-scoped connections without committing, so mark/view/pack writes were not durable across HTTP requests.Solution
/api/user/markslist/create/delete routes for conversation-target marks./api/user/saved-viewslist/create/get/delete routes.ConversationQuerySpecconstruction before storing canonical JSON./api/user/recall-packslist/create/get/delete routes for cited conversation bundles.polylogue/daemon/user_state_http.pyto keeppolylogue/daemon/http.pywithin file budgets.Remaining #867 scope: annotations, message/range targets, UI controls, CLI parity, and MCP parity remain open.
Ref #867
Verification
ruff format --check polylogue/daemon/http.py polylogue/daemon/user_state_http.py polylogue/storage/sqlite/queries/conversations_identity.py tests/unit/daemon/test_web_reader.py-> 4 files already formattedruff check polylogue/daemon/http.py polylogue/daemon/user_state_http.py polylogue/storage/sqlite/queries/conversations_identity.py tests/unit/daemon/test_web_reader.py-> All checks passedmypy polylogue/daemon/http.py polylogue/daemon/user_state_http.py polylogue/storage/sqlite/queries/conversations_identity.py tests/unit/daemon/test_web_reader.py-> Successpytest -q tests/unit/daemon/test_web_reader.py -k "UserState or marks or saved_views or recall_packs"-> 4 passedpytest -q tests/unit/daemon/test_web_reader.py-> 41 passedpytest -q tests/visual-> 4 passeddevtools render-pages-> site builtdevtools render-all --check-> OK:.cache/sitematches sourcesdevtools verify --quick-> all structural gates passed after render-pages refreshdevtools verify --affected --skip-slow-> all structural gates passed; pytest affected passed