Skip to content

feat(dev-tools): rotate sessions tool and experiment feature flags#700

Draft
Just-Insane wants to merge 15 commits intoSableClient:devfrom
Just-Insane:feat/developer-tools
Draft

feat(dev-tools): rotate sessions tool and experiment feature flags#700
Just-Insane wants to merge 15 commits intoSableClient:devfrom
Just-Insane:feat/developer-tools

Conversation

@Just-Insane
Copy link
Copy Markdown
Contributor

Summary

Consolidates two developer-tooling branches. Adds a "Rotate Sessions" tool to Developer Tools settings and an Experiments panel for percentage-rollout feature flags, with build-time injection from environment variables.


Changes

feat/devtool-rotate-sessions

  • Add a Rotate Sessions button to the Developer Tools settings panel.
  • Calls prepareToEncrypt() on all joined rooms to force Megolm session rotation, useful for testing encryption key rotation flows.
  • Includes error handling and user feedback via toast/alert.

feat/feature-flag-env-vars

  • deepMerge prototype-pollution fix: block keys like __proto__, constructor, and prototype in the deep-merge utility used to inject runtime config.
  • Build-time config injection: scripts/inject-client-config.js reads CLIENT_CONFIG_* environment variables at build time and merges them into config.json, enabling CI/CD pipelines and GitHub Actions to configure feature flags without modifying the source file.
  • Experiment bucketing (useExperimentVariant): typed helper that deterministically buckets users into experiment variants by percentage rollout, based on user ID hash.
  • ExperimentsPanel: new settings panel under Developer Tools listing active experiments and their variant assignments.
  • useClientConfig test: unit tests covering experiment bucketing logic and the useExperimentVariant hook.

Testing Checklist

  • Developer Tools → "Rotate Sessions": button present, triggers Megolm rotation, error handled gracefully
  • Developer Tools → Experiments panel: visible, lists configured experiments
  • CLIENT_CONFIG_* env vars at build time: merged into runtime config correctly
  • deepMerge with __proto__ key: rejected, no prototype pollution

Changeset

  • feat: Rotate Sessions developer tool
  • feat: Experiment bucketing with env-var-injectable config
  • fix: Prototype-pollution guard in deepMerge

Just-Insane and others added 15 commits April 6, 2026 12:36
Add scripts/inject-client-config.js which reads HOMESERVER_LIST,
ELEMENT_CALL_URL, EXPERIMENTS and other config keys from the GH Actions
environment and merges them into config.json at build time.
CI workflows pass these through via env; the setup action prints an
injected-config summary in the job summary.
knip.json updated to include the new script as an entry point.
…ntages

useClientConfig.ts gains getExperimentVariant() which deterministically
buckets a userId into a variant using a hash of userId+experimentName, then
checks it against rolloutPercentage. Experiment defaults shape is typed so
all callers get compile-time checking of known experiment names.
ExperimentsPanel shows every experiment name, current variant, rollout
percentage, and whether the user is enrolled — readable without opening
the console. DevelopTools.tsx wires it into the developer settings tab.
- Import KnownMembership from $types/matrix-sdk instead of matrix-js-sdk/lib/types
- Use Promise.allSettled to handle partial failures and report accurate count
- Add window.confirm confirmation before discarding sessions
- Clarify changeset: 'encryption sessions' not 'sessions'
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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