Add quick disable toggle to options popup
Created by: felixfbecker
If our extension is causing performance issues or has a bug, it is better that users have an easy way to temporarily disable all features than for them to uninstall the extension.
This could be a quick toggle in the options page, below the URL. Example mock:
The options page is defined here: https://sourcegraph.com/github.com/sourcegraph/sourcegraph/-/blob/browser/src/libs/options/OptionsMenu.tsx#L47:14
The toggle needs to set a boolean flag in the local settings (not synced).
The content script needs
- if the flag is false, do not init features and set a listener for changes that initializes
- if the flag is true, initialize features and set a listener that
.unsubscribe()
s the features to remove them and set listener described above.
All initialization of code intel features goes through this function: https://sourcegraph.com/github.com/sourcegraph/sourcegraph/-/blob/browser/src/libs/code_intelligence/inject.ts?utm_source=VSCode-1.0.14#L12:23
However, injecting the style sheet is currently duplicated for native integrations and the browser extension: https://sourcegraph.com/search?q=repo:%5Egithub%5C.com/sourcegraph/sourcegraph%24+%22document.createElement%28%27link%27%29%22+f:browser/
This would be best to refactor into a shared function too.
There also seems to be this old disableExtension
storage flag that is not set anywhere and inconsistently checked for: https://sourcegraph.com/github.com/sourcegraph/sourcegraph/-/blob/browser/src/extension/scripts/inject.tsx#L69:17
This should be removed.
To get started with browser extension development, check out https://sourcegraph.com/github.com/sourcegraph/sourcegraph/-/blob/browser/README.md