avoid global customizationItemsModel#324077
Draft
aeschli wants to merge 3 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the window-global IAICustomizationItemsModel singleton and instead creates/owns an AICustomizationItemsModel per hosting surface (the AI Customizations management editor in core workbench, and the customizations toolbar in the Sessions window), passing that shared instance down to nested widgets so item discovery/counts stay consistent within each surface.
Changes:
- Stop registering
IAICustomizationItemsModelas a singleton; instantiateAICustomizationItemsModelwhere it’s owned (editor / sessions contribution) and share via constructor params. - Update the management editor to own a single
AICustomizationItemsModelinstance and pass it into list/plugin widgets; also stop using a global editor input for harness label updates. - Update Sessions window customizations surfaces to share a single model instance via
CustomizationsToolbarContributionand a smallgetSessionsCustomizationItemsModel()helper.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/browser/aiCustomization/pluginListWidget.ts | Switches plugin list widget from DI singleton model to an explicitly passed items model instance. |
| src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationManagementEditor.ts | Creates/owns one items model per editor instance, passes it to nested widgets, and scopes harness label updates to the active input. |
| src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationListWidget.ts | Switches list widget to receive the shared items model instance via constructor arg. |
| src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationItemsModel.ts | Removes singleton registration and updates documentation to reflect per-surface ownership. |
| src/vs/sessions/contrib/sessions/browser/views/sessionsView.ts | Wires Sessions sidebar customizations widget to use the Sessions-owned shared items model. |
| src/vs/sessions/contrib/sessions/browser/customizationsToolbar.contribution.ts | Creates/owns the Sessions window’s shared items model and passes it to sidebar link view items. |
| src/vs/sessions/contrib/sessions/browser/customizationsItemsModel.ts | Adds helper to retrieve the Sessions-owned items model via the workbench contribution registry. |
| src/vs/sessions/contrib/sessions/browser/aiCustomizationShortcutsWidget.ts | Switches shortcuts widget to receive the shared items model instance via constructor arg. |
| src/vs/sessions/AI_CUSTOMIZATIONS.md | Updates docs to describe non-singleton model ownership and sharing. |
Review details
- Files reviewed: 9/9 changed files
- Comments generated: 7
- Review effort level: Low
| import { IConfigurationService } from '../../../../../platform/configuration/common/configuration.js'; | ||
| import { ChatConfiguration } from '../../common/constants.js'; | ||
| import { IAICustomizationItemsModel } from './aiCustomizationItemsModel.js'; | ||
| import { AICustomizationItemsModel, IAICustomizationItemsModel } from './aiCustomizationItemsModel.js'; |
Comment on lines
418
to
432
| @@ -427,7 +428,6 @@ export class PluginListWidget extends Disposable { | |||
| @ILabelService private readonly labelService: ILabelService, | |||
| @ICommandService private readonly commandService: ICommandService, | |||
| @ICustomizationHarnessService private readonly harnessService: ICustomizationHarnessService, | |||
| @IAICustomizationItemsModel private readonly itemsModel: IAICustomizationItemsModel, | |||
| @IConfigurationService private readonly configurationService: IConfigurationService, | |||
| ) { | |||
| import { ICommandService } from '../../../../../platform/commands/common/commands.js'; | ||
| import { IAICustomizationListItem } from './aiCustomizationItemSource.js'; | ||
| import { IAICustomizationItemsModel, ItemsModelSection } from './aiCustomizationItemsModel.js'; | ||
| import { AICustomizationItemsModel, IAICustomizationItemsModel, ItemsModelSection } from './aiCustomizationItemsModel.js'; |
Comment on lines
622
to
626
| constructor( | ||
| private readonly itemsModel: AICustomizationItemsModel, | ||
| @IInstantiationService private readonly instantiationService: IInstantiationService, | ||
| @IPromptsService private readonly promptsService: IPromptsService, | ||
| @IContextViewService private readonly contextViewService: IContextViewService, |
Comment on lines
64
to
72
| constructor( | ||
| container: HTMLElement, | ||
| options: IAICustomizationShortcutsWidgetOptions | undefined, | ||
| private readonly itemsModel: AICustomizationItemsModel, | ||
| @IInstantiationService private readonly instantiationService: IInstantiationService, | ||
| @IMcpService private readonly mcpService: IMcpService, | ||
| @IAICustomizationItemsModel private readonly itemsModel: IAICustomizationItemsModel, | ||
| @ICustomizationHarnessService private readonly harnessService: ICustomizationHarnessService, | ||
| @IStorageService private readonly storageService: IStorageService, | ||
| ) { |
Comment on lines
340
to
345
| getItemsModel(): AICustomizationItemsModel { | ||
| return this.itemsModel; | ||
| } | ||
| } | ||
|
|
||
| registerWorkbenchContribution2(CustomizationsToolbarContribution.ID, CustomizationsToolbarContribution, WorkbenchPhase.AfterRestored); |
Comment on lines
418
to
421
| constructor( | ||
| @IInstantiationService private readonly instantiationService: IInstantiationService, | ||
| private readonly itemsModel: AICustomizationItemsModel, | ||
| @IAgentPluginService private readonly agentPluginService: IAgentPluginService, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.