21 KiB
Area plugins: the contract
wayBetter for X has eight area plugins instead of one Tweaks section (46 toggles) plus 14 small plugins: Compose+, Reader+, Profile+, Chat+, Media+, Search+, Notifications+, Navigation+. This file is the contract for everyone who adds to one of them. It describes what is built (integration pass, 2026-09-30); the plan with the full inventory is .omc/plans/area-plugins.md, and where the two disagree, this file wins.
What is still open is in section 11; what has to be checked on live x.com is in verification/area-plugins/LIVE-CHECKLIST.md.
1. What exists
| Piece | Where |
|---|---|
| Feature table: areas, flags, core flags, modes, feature health (pure data and functions) | waybetter/packages/runtime/src/featureTable.ts |
Feature registry: starts a module while its flag and area are on and the page is on one of its surfaces; settings, commands, probes, the health palette entry |
waybetter/packages/runtime/src/featureModules.ts |
| Settings schema and the generated form | waybetter/packages/runtime/src/settingsForm.ts |
One shared observer (observeSelector, watchDom); api.observe uses it too |
waybetter/packages/runtime/src/domHub.ts |
| Panel: area cards (paused note, "plugin file" badge), Fixes list, first-run screen, Mode settings | waybetter/packages/shell/src/panel/{PluginFeatures,Modes,featureModel}.ts(x) |
Native: 256 flags, mode_get/mode_set (shell-only), migration of replaced plugin files |
waybetter/crates/waybetter-host/src/{settings,modes,plugins/migrate}.rs |
X's table, put together; the mode presets (X_ADVANCED, X_POWER) |
apps/desktop/src/areas/table.ts |
| X's rows per area, modules per area | apps/desktop/src/areas/<area>/{features.ts,index.ts} |
| New English words of an area, until the next words step | apps/desktop/src/areas/<area>/messages.en.json |
| Core flags | apps/desktop/src/areas/core.ts |
| Surfaces (which part of X a page is) | apps/desktop/src/areas/surfaces.ts |
| Reference area | apps/desktop/src/areas/navigation/ and apps/desktop/tests/area-navigation.test.ts |
| Native list generated from the table | apps/desktop/src-tauri/src/areas.rs (node scripts/build-areas.ts) |
| Test page for modules | apps/desktop/tests/helpers/areaPage.ts |
| Table-level tests (every module starts and stops clean, exact mode sets, words) | apps/desktop/tests/areas.test.ts |
| Every palette command and shortcut, in one table | apps/desktop/tests/areaCommands.test.ts |
2. Words
| Word | Meaning |
|---|---|
| Area | One card in Plugins. Its switch is the flag area.<id>. Off: everything it owns is off; the features keep their own values. |
| Feature | One on/off flag owned by an area. Its row is in src/areas/<area>/features.ts. |
| Core flag | A flag no area owns (area: null): branding, split-view navigation, the ten fixes. No plugin switch turns it off. Listed under "Fixes", in Appearance or in Settings. |
| Backing | Where a feature's code lives: module (a feature module), app (part of the X runtime: a native command or document-start timing), plugin (an old bundled plugin file, not ported: its switch is the file). |
| Surface | A part of X a page is: timeline home status profile notifications search explore bookmarks chat viewer composer settings other. |
| Mode | A preset: Basic, Advanced (recommended), Power User. A starting point, never a lock. |
Backing today: every feature is a module, except
| Flag | Backing | Why |
|---|---|---|
composerDrafts (Compose+) |
app | native commands (drafts popover, capture) |
mediaDownload (Media+) |
app | reads X's responses, fetches from X's CDN, native save |
notifications.keywordAlerts (Notifications+) |
app | native notification, re-checked natively |
compose.emojiPicker (Compose+) |
plugin | still the bundled file emoji-picker.plugin.js |
| the 14 core flags | app | fixes that wrap X's requests at document start, branding, split-view navigation |
The runtime's own stylesheet (src/inject/features.ts) is branding only; every hide or layout rule is a module's.
3. Adding or porting a feature
-
Row. Add it to
FEATURESin yoursrc/areas/<area>/features.tswith the builders ofsrc/areas/rows.ts:- new feature:
...modules('<area>', '<group>', [{ id: '<area>.<name>', surfaces: [...], settings: true }]); - port of a bundled plugin: replace its
plugin(...)row withported('<area>.<name>', '<plugin source name>', { ... })insidemodules(...). That setssupersedes(the migration) and keeps the plugin's name and description as label and description; - a feature that must stay in the runtime (native command, document-start timing):
app(...). - a feature that must keep running on X's chat pages (a request stage, listeners on X's videos, CSS that reaches chats):
heavy: true.
- new feature:
-
Module. One file per feature in
src/areas/<area>/, exported throughMODULESin yourindex.ts:export const readMarker: FeatureModule<PluginApi> = { id: 'reader.readMarker', probes: { cell: { selector: '[data-testid="cellInnerDiv"]', when: '[data-testid="primaryColumn"]' } }, settings: [{ key: 'toast', type: 'toggle', default: true, label: 'toast' }], start(ctx) { ctx.css('...'); ctx.observe(ctx.selector('cell'), cell => { /* ... */ }); ctx.command({ id: 'readMarker.jump', title: ctx.text('jump'), run: () => { /* ... */ } }); }, };Everything goes through
ctx:css,observe,watch,on,onKey,onRouteChange,add,defer,ui,command,text,storage,settings,selector,surfaces,win,api. Whateverctxdid is undone when the feature stops. Do not use the globalswindow/document(usectx.win), do not create aMutationObserver, do not keep state outside the closure ofstart. A route listener of a feature the route just stopped is not called (the framework guarantees it). -
A ported plugin keeps its data and words. Set
words: '<plugin source name>'(its catalog keysplugin.<name>.<key>stay as they are: no retranslation) andstorage: '<its old namespace>'withsettingsKeyif it was notsettings. A test checks both. -
Words. New English words go into your
src/areas/<area>/messages.en.jsonwith full catalog keys. They count as English everywhere until the next words step moves them intoapps/desktop/locales/en.jsonand translates them; do not editapps/desktop/locales/*for a feature. -
Native list. After changing rows run
node scripts/build-areas.tsinapps/desktop(writessrc-tauri/src/areas.rs;tests/areas.test.tsfails when it is stale). -
Modes. A calm feature that only adds something goes into
X_ADVANCED(src/areas/table.ts); one for people who want more into your area'sPOWER. A feature that hides content or changes what X does goes into neither. The exact sets are pinned intests/areas.test.ts: change them there on purpose. -
Commands. Add every
ctx.commandto the table intests/areaCommands.test.ts. -
Tests in
tests/area-<area>.test.ts(see section 7), then the gates of section 9.
Rules every feature follows: it works on what X already rendered or already fetched; it makes no request; it never clicks Post, Like, Repost, Follow or Send (navigation clicks only); when it cannot tell, it leaves things visible ("unknown never hides").
4. Naming
| Thing | Rule |
|---|---|
| Flag of a new or ported feature | <area>.<camelCaseName> (reader.readMarker). At most 64 characters. Never renamed once shipped. |
| The 46 flags that were Tweaks | Keep their names (hideSidebar). |
| Area switch | area.<area> (reserved prefix). |
| Module file | src/areas/<area>/<camelCaseName>.ts, exported const of the same name. |
| Stylesheet | ctx.css(css) gives wbf-<flag>; a second sheet: ctx.css(css, 'part'). |
| DOM attributes and classes you add | data-bt-<area>-…, .bt-<area>-…; remove them in ctx.defer. |
| Palette command | ctx.command({ id: '<name>.<action>' }). The registry owns settings and health. At most 5 per area including settings (the tab reports at most 48). A shortcut goes in the command (shortcut: 'Alt+Shift+F'), not in a key listener. |
| Storage namespace | default <area>-plus.<name>; a port keeps the plugin's. |
| Settings | a schema on the module (toggle, number, text, select, list, divider); labels are keys for ctx.text. The card's Settings button and the palette open the generated dialog. |
Commands and shortcuts
Every palette command of the areas (tests/areaCommands.test.ts fails on a shortcut two features share, on one the app itself takes, and on an area that could exceed its budget):
| Area | Commands (shortcut) |
|---|---|
| Compose+ | replyGuard.settings (Alt+Shift+R), snippets.insert |
| Reader+ | mutedRegex.edit (Alt+Shift+M), quickMute.add (Alt+Shift+U), readMarker.jump, threadReader.open |
| Profile+ | privateLabels.edit |
| Chat+ | bookmarks.open, personFilter.pick, pins.edit, searchLoaded.open (Ctrl+Shift+F) |
| Media+ | blurMedia.toggle (Alt+Shift+B), videoSpeed.faster (Alt+Shift+ArrowUp), videoSpeed.slower (Alt+Shift+ArrowDown) |
| Search+ | advancedSearch.open, savedSearches.open, savedSearches.pin |
| Notifications+ | none |
| Navigation+ | focusMode.toggle (Alt+Shift+F) |
One key outside the palette, kept from the plugin it was: Alt+Shift+H opens the settings of reader.collapseVerified (Reader+ has no command left in its budget).
The app takes these keys before a page sees them (the tab's bridge forwards them to the shell), so a feature can never use them: Ctrl+T, Ctrl+Shift+T, Ctrl+W, Ctrl+Shift+W, Ctrl+L, Ctrl+Shift+G, Ctrl+K, Ctrl+R, Ctrl+F (find in page), Ctrl+, Alt+Left/Right, Alt+F and F10 (app menu), F3, Ctrl+Shift+D, the zoom keys and, in a deck, Alt+1…9, Alt+R, Alt+U, Ctrl+Alt+N.
5. Words (i18n)
| Key | For |
|---|---|
plugin.<area>-plus.description |
the card's description (exists for all eight) |
plugin.<area>-plus.feature.<name>.label / .description |
a new feature's row on the card; set label/description on the row |
plugin.<area>-plus.<name>.<key> |
what ctx.text('<key>') reads (toasts, dialog labels, command titles) |
plugin.<old plugin>.<key> |
what ctx.text reads for a module with words: '<old plugin>' |
features.<flag>.label / .description |
the rows of the 46 old flags (unchanged); also allowed for features.<area>.<name>.* |
features.group.<group> |
group titles on a card. Existing: timeline sidebar navigation posts video layout tools. |
ctx.text, nott: the i18n tools readt('…')as a whole catalog key.- Only
x.*,kit.*andplugin.*reach an X tab. Anything a module shows in the page must be aplugin.*key. - The first words step is done: the areas' 275 keys are in
apps/desktop/locales/en.jsonand in all 48 translated catalogs (machine translations; 17 supported languages, Russian among them, and 33 community ones).messages.en.jsonof every area is empty again and takes the next new words. - The old
plugin.<old>.*keys were not renamed: the old plugin files are still bundled, and the i18n check requires their inline English to match the catalog. The rename maps (i18n/area-plugins-*.json,waybetter i18n rename --map) run together with the removal of those files (section 11); until then a ported module reads its plugin's keys throughwords. - Placeholders as in the catalogs:
{name}, ICU plurals. No markup.
6. Who may touch what
One owner per file. A change in a file that is not yours goes through the integrator (the main session).
| Owner | Files |
|---|---|
every area <a> |
apps/desktop/src/areas/<a>/**, apps/desktop/tests/area-<a>.test.ts, apps/desktop/tests/fixtures/x/<a>/**, verification/area-plugins/<a>/** |
| Compose+ | also apps/desktop/src/inject/drafts.ts |
| Reader+ | also apps/desktop/src/fixes/replySort.ts |
| Profile+ | also apps/desktop/src/inject/userInfo.ts, apps/desktop/tests/userInfo.test.ts |
| Media+ | also apps/desktop/src/inject/media/**, apps/desktop/src/fixes/video.ts |
| Search+ | also apps/desktop/src/inject/searchChips.ts, apps/desktop/src/core/searchOperators.ts |
| Notifications+ | also apps/desktop/src/inject/alerts.ts |
| integrator | the framework (waybetter/), apps/desktop/src/areas/{table,rows,core,modules,messages,surfaces}.ts, apps/desktop/src/areas/navigation/**, apps/desktop/src/inject/{entry.tsx,features.ts,i18n.ts,pluginApi.ts,xSite.ts}, apps/desktop/src/{ui,shell,i18n}/**, the catalogs, apps/desktop/src-tauri/** (src/areas.rs is generated, never edited by hand), apps/desktop/tests/{areas,areaCommands,bundledPlugins,install,i18n}.test.ts, apps/desktop/tests/helpers/**, docs/** |
Commit path-limited to your own files. src-tauri/src/areas.rs is committed together with the rows that changed it.
7. Tests and fixtures
tests/area-<area>.test.ts, one per area. Copy the shape oftests/area-navigation.test.ts.areaPage(path)(tests/helpers/areaPage.ts) gives the registry with every module defined, the X plugin API, recorded styles/listeners/storage/observers,go(path),mutate(),matches(elements per selector).flagsWith({ flag: true })builds the flags as the runtime applies them;flagsOnly({ … })forces every other module off first. Some modules are on by default (hidePromotedPosts,rememberVideoVolume,searchOperators): an area's test turns the other areas off (area.<other>: false) so only its own modules run.- Per feature: its pure decision functions (as the old plugin tests did); on -> the expected effect; off -> nothing left (
tests/areas.test.tsalready checks styles, commands, listeners and observers for every module); a port -> compared with the old plugin file loaded fromsrc-tauri/bundled-plugins/(Focus Mode compares all 64 setting combinations byte for byte). - Always
registry.dispose()at the end of a test that made a page. (A test that fails before it no longer hangs the run: the route poll does not keep the process alive.) - Fixtures:
tests/fixtures/x/<area>/*.htmlwhen a feature needs real markup. Sanitized: neutral names, invented text, no real DM content;node scripts/privacy-scan.mjs --fastmust stay green. - In-page screenshots:
node scripts/area-plugins-shots.mjs <outDir> 'name|path|flags|command'(built runtime in a static x.com fixture). Panel screenshots:node scripts/panel-screenshots.mjswith?section=plugins&flags=…&off=…&onboarding=fresh|existing&lang=…(dev harness on port 1433). - Live checks on x.com are a separate step with the two test accounts only. Nothing is "verified live" from fixtures.
8. Selector health
- A module names the selectors it depends on in
probesand reads them withctx.selector(name), so a signed hotfix can replace one (selectors["<flag>.<probe>"]) or switch the feature off (flags["<flag>"] = false). - After the page has settled (the primary column is there, then 3 s), a probe that matches nothing is a miss. Three misses in a row, on three visits, pause that one feature for the session: one toast, a note in the settings dialog, a "Paused features of " entry in the palette (it opens the notes), and a "paused" badge with a note on the feature's row and card in the panel. The rest of the area keeps running.
- The panel learns it from the focused tab's command list (the area's
healthentry carries the paused flags in its keywords;pausedFeaturesinfeatureTable.ts). No new report crosses to the host. - Give a probe a
whenselector (the part of the page it lives in): without it, a narrow window or a signed-out page counts as a miss. A probe that reads an English label setsenglish: true. - Add a probe only for a selector you have seen on live x.com. A wrong probe pauses a working feature. When in doubt, no probe, and note it for the live pass.
9. Acceptance, per feature and per area
- Every toggle works: on -> the effect; off -> styles, nodes, attributes, listeners and commands gone.
- The area's switch off -> all of its features off,
app-backed ones included; on -> back, without a reload. - Settings persist across reload; a port reads the plugin's old settings unchanged.
- No console errors:
node scripts/runtime-start-check.mjs(every flag on, off, on; timeline, chat, profile, notifications). - No request of its own; no click on Post, Like, Repost, Follow, Send; nothing collapsed or hidden when the data to decide is missing.
- Selector health as in section 8.
- At most 5 palette commands for the area; every command in the table of
tests/areaCommands.test.ts; no shortcut the app takes. - Words: English complete in
messages.en.json; nothing hard-coded. - Gates green:
bun run build,bun run test,bun run test:rust,node scripts/privacy-scan.mjs --fast, and inwaybetter/:bun run checkwhen the framework changed (integrator).
Owner decisions that bind the areas:
- Hide Blue Checks (Reader+
reader.collapseVerified, Profile+): never collapse a post by the owner of the profile page being visited (every profile sub-route, handle compared case-insensitively), nor the focal post of an opened post page. A post they reposted from someone else follows the normal rule. An author X has not described yet is never collapsed. Leaving the profile re-checks the posts on screen. ThehideVerifiedBadgestweak keeps the badge in the visited profile's header. - Starred DMs (Chat+): a message the user explicitly stars may be stored locally in full (message id, conversation id, sender, text, time, media references). Never in sync. In a backup only when the owner ticks it (not built yet: Export/Import as JSON stands in). No passive collection of any kind.
- Launch scope: the ports of what exists and the 29 "must" items of the plan. The 35 "nice" and 7 "later" items come after launch.
- Modes (first run; an existing setup keeps what it has):
- Basic = the fixes and the shell, X unchanged, every area off.
- Advanced (recommended) = every area on, the defaults, plus the calm features that came with the areas (
X_ADVANCED):compose.postingAs,compose.lengthMeter,reader.readMarker,reader.cleanLinks,reader.copyAsMarkdown,reader.exactTimestamps,reader.readingTime,reader.threadReader,profile.accountAge,profile.hoverPeek,chat.bookmarks,chat.searchLoaded,chat.pins,media.videoSpeed,media.pictureInPicture,media.altText,search.savedSearches,search.advancedSearch,notifications.keywordHighlight. - Power User = Advanced plus the rest of each area's
POWER:compose.altTextReminder,compose.snippets,profile.privateLabels,chat.personFilter,chat.keywords,navigation.keyboardPlus. - In no mode, only by the owner's own switch: anything that hides content or changes what X does (media blur, notification filters by kind, Open on Mentions, collapse verified, Muted Regex, quick mute, language filter, Latest by default, Reply Guard, Focus Mode, and the hide rules).
- The modes are presets applied through
features_set; the rows' defaults did not change, so a setup from before the area plugins runs exactly what it ran.
- Plugin files from outside (the Store, dropped files, the folder) stay off until the owner turns them on. Unchanged.
10. Migration, as built
| Old state | After the first start of the new version |
|---|---|
A bundled plugin that is now a feature (SUPERSEDED), enabled, file as shipped |
its flag is on; the file and its entry are gone |
| The same, disabled | the file is gone; the flag stays off |
| The same, but edited by the owner | the file stays with its on/off state; the built-in feature stays off; its row says so and asks before both could run |
| Deleted by the owner earlier | nothing |
| The 46 flags | unchanged names, unchanged values |
| A fresh install | the replaced files are never written; nothing enabled until a mode is chosen |
The marker (plugins/migrations.json) lists the files already handled, so an area that ports a plugin later is migrated on the next start. Flags are saved before any file is touched; every step can be repeated. An imported backup that names a replaced plugin turns its flag on instead, unless it carries the owner's copy of the file. Settings of ported plugins stay in page storage under their old namespace.
Existing installs keep exactly what they have and see the mode screen once, with "Keep my current setup".
11. What is left
- The Store switch: area plugins as the 8 Store items instead of the 14 old ones (the areas are app-owned: the card and the features are compiled into the app, and the table's
owneris the file name an area would ship as). With it: removing the 13 replaced files fromsrc-tauri/bundled-plugins/, then the key rename maps for their words. - Emoji Picker as a feature module (it is the one bundled plugin that is still a file).
- Shell-side palette entries to turn a feature on or off (needs the flags in the shell's palette context; not built).
- Backup of starred chat messages (ticked by the owner), third-party plugins with features of their own (
p.<file>.<feature>), a perf probe with all eight areas on. - The live pass on x.com (
verification/area-plugins/LIVE-CHECKLIST.md) and an upgrade test on a copy of real app data.