agent host: one representation and one cascade rule for customization enablement
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
Follow-up cleanup from the scoped-enablement work (#330566, #330715).
## Problem
There are three representations of "is this on?" in session state:
- `DirectoryCustomization.enabled: boolean` (`state.ts:861`)
- `ChildCustomizationBase.enabled?: boolean` (`state.ts:894`)
- `enablement?: CustomizationEnablement[]` on `PluginCustomization` and `McpServerCustomization` (`state.ts:804`, `1057`)
The tell that this is one representation too many is that the protocol doc comment has to *teach a rule you must memorize*:
> the **effective** enabled state of a plugin child is the plugin's derived enabled value and `(child.enabled ?? true)`, so a disabled plugin disables every child regardless of each child's own flag. A directory child instead uses the directory's `enabled` value and its own flag.
Two different cascade rules depending on container type, neither enforced anywhere.
Predictably, consumers hand-roll the cascade. The same expression appears in at least three places across two files:
```ts
enabled: isCustomizationEnabled(server) && (!plugin || isCustomizationEnabled(plugin))
```
- `src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostCustomizationService.ts:191`
- `src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostCustomizationService.ts:218`
- `src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts:3691`
There are ~32 enablement-derivation sites in total across the agent host and its consumers. Any one of them getting the cascade subtly wrong is a silently-wrong enabled state in the UI or, worse, at the SDK boundary.
## Suggestions
**Minimum viable:** export a single `isEffectivelyEnabled(child, container)` in `common/customizationEnablement.ts` and use it everywhere the cascade is currently re-derived. Cheap, no protocol change, removes the duplication.
**Better, if a protocol change is acceptable:** collapse to one representation so directories and plugins cascade identically and the doc comment no longer needs to describe two rules. Note the protocol lives in [microsoft/agent-host-protocol](https://github.com/microsoft/agent-host-protocol) (`types/` is canonical; vscode's `common/state/protocol/` mirrors it), so this needs a change there first.
Contributor guide
Assessment
This issue has not been assessed yet.