Repository navigation
Widget: Privacy choices control with page use and usage data choices - #708
Conversation
share_usage (default true) on ChatRequest, ResumeRequest and AskRequest; when false, log_request writes the usage row without conversation_id, tools_called and langfuse_trace_id, keeping tokens, cost, tier and counts. widget.privacy_url is an https-only config field served in the widget config response. Tested: new test_usage_opt_out.py, config and router cases, db unit test.
Tested: bun workers/osa-worker/test-routing.js (206 passed).
The footer's page-URL checkbox becomes a Privacy choices button (nemar.org's opt-out symbol) opening a modal with Use this page for answers (same storage key) and Share usage data (new key, default on) and a privacy link. Usage off adds share_usage: false to /chat and /chat/resume. widget.privacy_url is read and validated again, falling back to the default. Tested: new test-widget-privacy-choices.js; settings, host-api, context-switch, tools suites pass.
…tests into CI privacy-choices-check.mjs: 1280x900 and 390x844, light and dark, corner and center; real Tab, Space and Escape, target sizes, contrast. Tests job runs the privacy suite after the Settings suite and the harness after the center-stage check, with a screenshot upload on failure. Tested: both run green locally in headless Chrome.
docs/community-widget.md section and config tables, CHANGELOG [Unreleased]. Docs only; tested via tests/test_frontend.
Tested: tests/test_frontend passes (172).
…d: frontend widget tests)
…routed opted-out rows (tested: routing, opt-out, router tests)
… cannot be saved, narrow the usage helper text (tested: frontend widget tests)
…trace opt-out (tested: new page test)
…eout, always upload the Privacy choices screenshots (tested: router tests, ruff)
|
Review round 1: every finding and its outcome. Pushed to
Tested locally: ruff check and format clean; the full Python suite passes (5997) except |
Preview Deployment
This preview will be updated automatically when you push new commits. |
…ce, not the last save (tested: frontend widget tests)
…d: usage opt-out tests, mutation-checked)
… docs tests locally)
|
Review round 2 outcomes:
Tested: full |
…and privacy choices; tested: widget tests, both Chrome harnesses, frontend and opt-out pytest)
|
PM verdict: ready and merged. Every acceptance criterion was checked against the diff and tests, both review rounds have an outcome in a comment, and all checks passed (Lint, Test 3.11 and 3.12, Frontend Tests, Docker, notebook site, deploy, sync-cors). develop moved (#709) and conflicted in CHANGELOG.md, the browser-harness README and the widget; I merged develop into the branch keeping the plan rail and the privacy choices, reran the widget tests, both Chrome harnesses and the frontend/opt-out/config pytest, and pushed normally. The eight Privacy choices screenshots are the |
Summary
#fffand#06f, never themed) that opens a modal dialog with Use this page for answers (sameosa-page-context-enabledkey, so earlier choices carry over; helper text says the dataset a page names is still sent), Share usage data (newosa-share-usage-enabledkey, default on), and a link to the privacy page./chatand/chat/resumebodies carry a top-levelshare_usage: false(omitted when on).ChatRequest,ResumeRequestandAskRequesttakeshare_usage: bool = True; a non-persistedRequestLogEntry.share_usagemakeslog_requestwrite the row withoutconversation_id,tools_calledandlangfuse_trace_id, keeping tokens, cost, tier and counts so budgets still add up. Feedback is unaffected.widget.privacy_url(https only, validated likeanalysis_docs, shared_https_urlhelper) is served in the widget config and validated again in the widget, falling back to the defaultPRIVACY.mdURL (one constant,DEFAULT_PRIVACY_URL)..osa-settings-overlay(.osa-privacy-overlay) with its own keydown (Tab wrap, Escape, preventDefault) so the corner mode traps too; one branch added inhandleCenterKey's Escape handling; the center trap code is otherwise untouched.Closes #706
Commands run
uv sync --all-extras --devandbun installbun frontend/test-widget-privacy-choices.js(128 passed),test-widget-settings.js(184),test-widget-context-switch.js(160),test-widget-host-api.js(243),workers/osa-worker/test-routing.js(206); alsotest-widget-tools.js(443, its accent-color probe pointed at the dialog's checkbox) and every otherfrontend/test-widget-*.jsbun frontend/browser-harness/privacy-choices-check.mjs(324 checks, 0 failures: 1280x900 and 390x844, light and dark, corner and center) andcenter-stage-check.mjs(122, 0 failures), in headless Chrome 157uv run pytest tests/test_api tests/test_metrics tests/test_core/test_config tests/test_frontend -q(all pass, including the newtests/test_api/test_usage_opt_out.py: 23 cases over streaming and plain/chat,/chat/resume,/ask, plus the budget total)uv run ruff check .anduv run ruff format --check .Deviations
git show origin/develop:PRIVACY.mdfails (PR docs: privacy page for the osc.earth deployment; feedback sends the page address only when shared #707 is not merged), so its "Your choices" and usage-metrics paragraphs still need Widget: Privacy choices control with page use and usage data choices #706's update once docs: privacy page for the osc.earth deployment; feedback sends the page address only when shared #707 lands. docs: privacy page for the osc.earth deployment; feedback sends the page address only when shared #707 also edits the feedbackpage_urlline and adds a step totests.yml; rebase after it.tool_call_countis kept on an opted-out row, and the row still hasrequest_idandkey_source. Langfuse tracing, the search overview, deleting stored metrics, per-conversation memory of the choice and the center dialog's layout are untouched.PRIVACY_CHECK_SCREENSHOTS); CI uploads them on failure as the brief specified.ghcannot attach images to a PR, so they are not attached here; runbun frontend/browser-harness/privacy-choices-check.mjs <dir>to regenerate.closePrivacy(..., {restoreFocus: false})totoggleChat's close branch andopenChatWindowso a closed or reopened window never shows a stale dialog.pageContextLabelremoved from the widget config (unused now);test-widget-tools.js's accent probe andtests/test_frontend/test_embed_snippet_hygiene.pyupdated for the new markup and harness page.osa-share-usage-enabled) and the helper wording were not specified; chosen to mirror the existing key and the board's Settings tone.