Skip to content

Store the usage data opt-out as a single global setting - #238

Merged
rhennigan merged 1 commit into
mainfrom
bugfix/prefs-submit-usage-checkbox
Aug 26, 2026
Merged

rhennigan merged 1 commit into
mainfrom
bugfix/prefs-submit-usage-checkbox

Conversation

@rhennigan

Copy link
Copy Markdown
Member

Summary

The Share anonymous usage data checkbox in the preferences panel (from #237) stored its state in the front end and re-deployed every configured built-in toolset whenever it was toggled — far too slow for a checkbox. This replaces that with a single machine-wide setting on disk that every built-in server reads when it starts, so toggling it is instant and never touches any client configuration.

  • Global settings store (Kernel/Files.wl): $rootPath/GlobalSettings.wxf holds a WXF association read and written by readGlobalSettings, getGlobalSetting, and setGlobalSetting (a missing or unreadable file counts as no settings; writes merge into the existing settings). It currently has one entry, "SubmitUsageData", but is meant to take other global settings later.
  • Enabling logic (Kernel/Server/UsageData.wl): getGlobalUsageDataSetting/setGlobalUsageDataSetting wrap that entry (only an explicit False opts out), and usageDataEnabledQ now requires "EnableUsageData" -> True and no global opt-out when SUBMIT_USAGE_DATA is unset. An explicit SUBMIT_USAGE_DATA in a client configuration still wins in both directions, so the "SubmitUsageData" option of InstallMCPServer is unchanged.
  • Checkbox (Kernel/PreferencesContent.wl): now a DynamicModule whose Initialization reads the stored value when the panel is displayed and whose Dynamic setter writes it (through catchAlways, so a failed write can't surface as an uncaught Throw in the front end). The usageDataOptOutQ/usageDataDeployOptions/applyUsageDataSetting/redeployForUsageData helpers are gone, and deployments made from the panel no longer pass "SubmitUsageData".
  • CreatePreferencesContent wraps its result in UsingFrontEnd: its subtitle is a StringTemplate built from a front-end string resource, so the panel can now be built (and smoke-tested) in a headless kernel without FrontEndObject::notavail.
  • Tests: a shared withTemporaryRoot helper in Tests/Common.wl (Blocks $rootPath to a temporary directory); new tests in Files.wlt, UsageData.wlt, and PreferencesContent.wlt.
  • Docs: usage-data.md, preferences-content.md, mcp-clients.md, servers.md, Specs/UsageData.md, AGENTS.md.

No migration of the old front-end setting is needed: the previous checkbox never shipped in a tagged release.

Test plan

  • Tests/Files.wlt: settings file location; unset ⇒ <||> / Missing / default with nothing created; set/get round trip; merging keeps other keys; unreadable and non-association files count as no settings and are replaced by the next write
  • Tests/UsageData.wlt: getGlobalUsageDataSetting default / opt-out / opt-in, other settings preserved, only an explicit False opts out, non-boolean values rejected; usageDataEnabledQ honors the global opt-out, the environment variable still takes precedence, opting back in restores the default; initializeUsageData reads the opt-out at startup (the existing property-dependent tests now run under a temporary root so a developer's own opt-out can't affect them) — 59/59 including the subprocess integration tests
  • Tests/PreferencesContent.wlt: checkbox structure (DynamicModule whose Initialization reads the setting), the setter writes the file and updates the module variable, the checkbox contains no deploy/SessionSubmit logic; CreatePreferencesContent-SmokeTest now passes headlessly — 7/7
  • Regression: InstallMCPServer.wlt, DeployAgentTools.wlt, MCPServerObject.wlt — 689/689; CodeInspector clean on every changed file
  • Preferences panel checkbox in the desktop front end (not verifiable headless here)

🤖 Generated with Claude Code

https://claude.ai/code/session_01MKdo7zY8D9SN5oYaBFvJ4k

The preferences panel's "Share anonymous usage data" checkbox kept its
state in the front end and re-deployed every configured built-in toolset
on each toggle, which was far too slow. It is now a machine-wide setting
on disk that every built-in server reads when it starts:

- Kernel/Files.wl: a general store for global settings,
  $rootPath/GlobalSettings.wxf (readGlobalSettings, getGlobalSetting,
  setGlobalSetting), meant to hold other settings in the future
- Kernel/Server/UsageData.wl: getGlobalUsageDataSetting and
  setGlobalUsageDataSetting wrap its "SubmitUsageData" entry (only an
  explicit False opts out); usageDataEnabledQ falls back to it when
  SUBMIT_USAGE_DATA is not set, which still takes precedence
- Kernel/PreferencesContent.wl: the checkbox is a DynamicModule that
  reads the setting when displayed and writes it when toggled; the
  re-deployment helpers are gone and deployments made from the panel no
  longer pass "SubmitUsageData". CreatePreferencesContent wraps its
  result in UsingFrontEnd so the panel (whose subtitle comes from a
  front end resource) can be built in a headless kernel
- Tests: withTemporaryRoot helper in Tests/Common.wl; new tests in
  Files.wlt, UsageData.wlt, and PreferencesContent.wlt
- Docs: usage-data.md, preferences-content.md, mcp-clients.md,
  servers.md, Specs/UsageData.md, AGENTS.md

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MKdo7zY8D9SN5oYaBFvJ4k
Copilot AI lite review requested due to automatic review settings August 26, 2026 12:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR changes the anonymous usage-data opt-out from a front-end/private setting that triggered slow re-deployments into a single machine-wide on-disk setting ($rootPath/GlobalSettings.wxf) that each built-in server reads at startup, making the preferences checkbox toggle effectively instant and independent of client configuration.

Changes:

  • Added a global settings store (readGlobalSettings / getGlobalSetting / setGlobalSetting) backed by $rootPath/GlobalSettings.wxf.
  • Updated usage-data enablement to also honor a global opt-out (getGlobalUsageDataSetting / setGlobalUsageDataSetting) when SUBMIT_USAGE_DATA is unset.
  • Reworked the preferences checkbox to read/write the global setting via a DynamicModule, removed re-deploy logic, and added/updated tests + docs accordingly.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Kernel/Files.wl Introduces the machine-wide global settings file and read/get/set helpers.
Kernel/CommonSymbols.wl Exposes the new global settings / usage-data-setting symbols for cross-file use.
Kernel/Server/UsageData.wl Adds global-opt-out wrappers and integrates them into usageDataEnabledQ.
Kernel/PreferencesContent.wl Switches the checkbox to a DynamicModule that reads/writes the global setting; stops passing "SubmitUsageData" into deployments; wraps panel build in UsingFrontEnd.
Tests/Common.wl Adds withTemporaryRoot to isolate tests from developer-machine settings.
Tests/Files.wlt Adds coverage for global settings file behavior (missing, read, merge, unreadable, overwrite-on-write).
Tests/UsageData.wlt Adds tests for global opt-out/in behavior and environment precedence; ensures startup reads global setting.
Tests/PreferencesContent.wlt Updates tests to validate checkbox structure/setter and absence of redeploy / submit logic.
Specs/UsageData.md Updates spec to reflect the new global-setting-based opt-out behavior.
docs/usage-data.md Documents the global settings file and updated opt-out/in semantics and precedence.
docs/preferences-content.md Updates checkbox documentation and notes UsingFrontEnd behavior for headless kernels.
docs/mcp-clients.md Clarifies "SubmitUsageData" -> Automatic behavior with global opt-out.
docs/servers.md Updates server docs to describe global checkbox behavior for built-in servers.
AGENTS.md Updates repo guidance to mention the global settings store and usage-data opt-out location.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread Kernel/PreferencesContent.wl
@rhennigan
rhennigan merged commit a80f3fa into main Aug 26, 2026
2 checks passed
@rhennigan
rhennigan deleted the bugfix/prefs-submit-usage-checkbox branch August 26, 2026 12:53
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.

2 participants