Skip to content

Widget: Privacy choices control with page use and usage data choices - #708

Merged
neuromechanist merged 16 commits into
developfrom
feature/issue-706-privacy-choices
Nov 11, 2026
Merged

neuromechanist merged 16 commits into
developfrom
feature/issue-706-privacy-choices

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Summary

  • The widget footer's "Share page URL to help answer questions" checkbox is replaced by a Privacy choices button (nemar.org's opt-out symbol, 30:14, 14 px tall, fixed #fff and #06f, never themed) that opens a modal dialog with Use this page for answers (same osa-page-context-enabled key, so earlier choices carry over; helper text says the dataset a page names is still sent), Share usage data (new osa-share-usage-enabled key, default on), and a link to the privacy page.
  • With usage sharing off, /chat and /chat/resume bodies carry a top-level share_usage: false (omitted when on). ChatRequest, ResumeRequest and AskRequest take share_usage: bool = True; a non-persisted RequestLogEntry.share_usage makes log_request write the row without conversation_id, tools_called and langfuse_trace_id, keeping tokens, cost, tier and counts so budgets still add up. Feedback is unaffected.
  • widget.privacy_url (https only, validated like analysis_docs, shared _https_url helper) is served in the widget config and validated again in the widget, falling back to the default PRIVACY.md URL (one constant, DEFAULT_PRIVACY_URL).
  • The dialog is another .osa-settings-overlay (.osa-privacy-overlay) with its own keydown (Tab wrap, Escape, preventDefault) so the corner mode traps too; one branch added in handleCenterKey's Escape handling; the center trap code is otherwise untouched.

Closes #706

Commands run

  • uv sync --all-extras --dev and bun install
  • bun 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); also test-widget-tools.js (443, its accent-color probe pointed at the dialog's checkbox) and every other frontend/test-widget-*.js
  • bun frontend/browser-harness/privacy-choices-check.mjs (324 checks, 0 failures: 1280x900 and 390x844, light and dark, corner and center) and center-stage-check.mjs (122, 0 failures), in headless Chrome 157
  • uv run pytest tests/test_api tests/test_metrics tests/test_core/test_config tests/test_frontend -q (all pass, including the new tests/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 . and uv run ruff format --check .

Deviations

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.
…routed opted-out rows (tested: routing, opt-out, router tests)
… cannot be saved, narrow the usage helper text (tested: frontend widget tests)
…eout, always upload the Privacy choices screenshots (tested: router tests, ruff)
@neuromechanist

Copy link
Copy Markdown
Member Author

Review round 1: every finding and its outcome. Pushed to feature/issue-706-privacy-choices; develop is merged in (CHANGELOG conflict resolved by keeping both entries).

  • Behind develop, docs: privacy page for the osc.earth deployment; feedback sends the page address only when shared #707's test-widget-feedback-page-url.js fails (important): fixed. Merged origin/develop; the test now opens the dialog and uses #osa-privacy-page, comment and messages updated. Every frontend/test-widget-*.js passes.
  • PRIVACY.md stale (important): fixed. Footer box renamed to the Privacy choices dialog with "Use this page for answers" and "Share usage data"; the table, the usage-metrics paragraph, "Your choices" and the tracing note describe the opt-out (no conversation id, tools or trace id; the dataset a page names is still sent). New tests/test_frontend/test_privacy_page.py reads the dialog's labels from the widget and requires the page to use each (the docs-only job runs only the embed hygiene test, so this runs in the full job).
  • Helper text says only counts and costs are kept, but Langfuse is untouched (important): fixed, preferred option. create_community_assistant takes trace and /chat, /chat/resume and /ask pass the reader's share_usage, so no Langfuse config or trace id is attached and no trace exists. The helper text now reads "Off, the usage log keeps only counts and costs, and your conversation is not traced. Feedback you send is still received, but is not attached to a trace." Docs, CHANGELOG and PRIVACY.md state that an opted-out answer's thumbs are not attached to a trace (the answer has none). Tests: test_an_opted_out_reader_gets_no_trace and the routed cases below. The server's in-memory session is unchanged (it is what lets a follow-up work) and is documented as such.
  • Tier not shown for an opted-out row (important): fixed. New TestAnOptedOutReaderOnARoutedCommunity in test_model_routing.py (real assistant builder, real routing): a quick turn keeps tier == "quick"; a handover asserts the analysis row and the <request id>:quick row both keep their tier and have NULL conversation_id, tools_called and langfuse_trace_id; the default still traces. The cases also assert the trace argument.
  • Failed save only console.warn'd (suggestion): fixed. A failed save shows a role="status" note in the dialog ("could not be saved in this browser ... goes back to the default"), and a choice whose save failed outranks whatever storage still holds. Test uses a localStorage whose setItem throws, with storage seeded to the opposite answer.
  • Choice read once at init (suggestion): fixed. syncPrivacyChoices() re-reads both saved choices when a request or feedback is built and when the dialog opens. Test sets both keys as another tab would, then sends, and reopens the dialog.
  • Vacuous privacy_url registry test (suggestion): fixed by making it assert for every registered community (served value equals the config's, None included; https when set) with a checked > 0 guard. Not fixed by setting NEMAR's privacy_url: the dialog's default link is the page that describes the assistant, and pointing NEMAR at nemar.org's own policy would change what its readers see, which is a product choice for the NEMAR maintainers.
  • Test name and cross-module imports (suggestion): renamed to test_share_usage_must_be_a_boolean. Moving the shared fixtures is not done in this PR: five other test modules import the same helpers from test_tool_call_streaming.py, so the move touches tests this PR did not change. Filed as Move the shared tool-call resume test fixtures to tests/helpers #710.
  • Test hygiene in test-widget-privacy-choices.js (suggestion): fixed. Indentation corrected; added a Tab-wrap case for allowPageContext: false. Space stays verified in real Chrome, as noted.
  • CI wall time and screenshots (suggestion): recent Frontend Tests runs take 400 to 465 s against a 10 minute limit, so the timeout is now 15 minutes, and the Privacy choices screenshots are uploaded with if: always() (14 days) as the privacy-check-screenshots artifact on the PR run, for the eight combinations.

Tested locally: ruff check and format clean; the full Python suite passes (5997) except test_hed_suggest (the HED tool, unrelated to this change, fails in this Python 3.14 environment) and test_llm_service (a pydantic v1 import error on 3.14); every frontend/test-widget-*.js; the Chrome harness privacy-choices-check.mjs.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Preview Deployment

Name Link
Preview URL https://feature-issue-706-privacy-ch-demo.osc.earth
Branch feature/issue-706-privacy-choices
Commit 5b10f6d

This preview will be updated automatically when you push new commits.

@neuromechanist

Copy link
Copy Markdown
Member Author

Review round 2 outcomes:

  • Save-failure note reflects only the last save (important): fixed in b7b060e. showPrivacySaveNote now reads unsavedChoices itself, so the note stays while any choice is unsaved, on both change handlers and on open. New test: only the page key is blocked, the usage box then saves cleanly, and the note stays, including after closing and reopening the dialog. Verified it fails against the old code (2 failures) and passes now.
  • Opt-out tests did not assert the no-trace guarantee on every route (important): fixed in 0febb27. The scripted-assistant stand-ins in test_usage_opt_out.py now record the keyword arguments of each create_community_assistant call, and a new test asserts trace is [True, True, False] for default, explicit share and opted-out requests on streaming /chat, non-streaming /chat, /chat/resume, streaming /ask and non-streaming /ask. Mutation-checked: changing the non-streaming /ask site to trace=True fails it. Note: it records the call rather than wrapping the real function, because these tests replace the assistant with the scripted one; the real function's trace=False handling is already covered in test_model_routing.py.
  • Docs-only PRs skip the privacy page guard (suggestion): fixed in df52f16. tests/test_frontend/test_privacy_page.py is added to the documentation-only step in tests.yml; the workflow comments, .rules/ci_cd.md and AGENTS.md now say two tests run.

Tested: full tests/test_api, tests/test_frontend, tests/test_metrics (2229 passed), every frontend/test-widget-*.js under bun, ruff check and ruff format --check clean.

…and privacy choices; tested: widget tests, both Chrome harnesses, frontend and opt-out pytest)
@neuromechanist
neuromechanist merged commit cf82fbf into develop Nov 11, 2026
13 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-706-privacy-choices branch November 11, 2026 11:08
@neuromechanist

Copy link
Copy Markdown
Member Author

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 privacy-check-screenshots artifact on the final CI run (gh cannot attach images to a PR).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant