Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,52 @@
import {
CustomizationHarness,
CustomizationHarnessServiceBase,
IExternalCustomizationItemProvider,
createCliHarnessDescriptor,
getCliUserRoots,
} from '../../../../workbench/contrib/chat/common/customizationHarnessService.js';
import { IPathService } from '../../../../workbench/services/path/common/pathService.js';
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
import { PromptsServiceCustomizationProvider } from '../../../../workbench/contrib/chat/browser/aiCustomization/promptsServiceCustomizationProvider.js';
import { BUILTIN_STORAGE } from '../common/builtinPromptsStorage.js';

/**
* Sessions-window override of the customization harness service.
*
* Only the CLI harness is registered because sessions always run via
* the Copilot CLI. With a single harness the toggle bar is hidden.
*
* A {@link PromptsServiceCustomizationProvider} wraps IPromptsService
* so that the management editor can display items without needing an
* extension-contributed provider.
*
* The provider is created lazily via IInstantiationService to avoid
* cyclic dependencies.
*/
export class SessionsCustomizationHarnessService extends CustomizationHarnessServiceBase {
constructor(
@IPathService pathService: IPathService,
@IInstantiationService instantiationService: IInstantiationService,
) {
const userHome = pathService.userHome({ preferLocal: true });
const extras = [BUILTIN_STORAGE];
const descriptor = createCliHarnessDescriptor(getCliUserRoots(userHome), extras);

// Lazy provider: created on first call to avoid cyclic DI resolution.
let provider: PromptsServiceCustomizationProvider | undefined;
const lazyItemProvider: IExternalCustomizationItemProvider = {
get onDidChange() {
provider ??= instantiationService.createInstance(PromptsServiceCustomizationProvider, descriptor);
return provider.onDidChange;
},
provideChatSessionCustomizations(token) {
provider ??= instantiationService.createInstance(PromptsServiceCustomizationProvider, descriptor);
return provider.provideChatSessionCustomizations(token);
},
};

super(
[createCliHarnessDescriptor(getCliUserRoots(userHome), extras)],
[{ ...descriptor, itemProvider: lazyItemProvider }],
CustomizationHarness.CLI,
);
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,50 @@ import {
CustomizationHarness,
CustomizationHarnessServiceBase,
ICustomizationHarnessService,
IExternalCustomizationItemProvider,
createVSCodeHarnessDescriptor,
} from '../../common/customizationHarnessService.js';
import { PromptsStorage } from '../../common/promptSyntax/service/promptsService.js';
import { BUILTIN_STORAGE } from '../../common/aiCustomizationWorkspaceService.js';
import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';
import { PromptsServiceCustomizationProvider } from './promptsServiceCustomizationProvider.js';

/**
* Core implementation of the customization harness service.
*
* Only the Local harness is registered statically. All other harnesses
* (e.g. Copilot CLI) are contributed by extensions via the provider API.
*
* A {@link PromptsServiceCustomizationProvider} wraps IPromptsService
* so the management editor uses the same provider-based code path for
* Local items as it does for extension-contributed harnesses.
*
* The provider is created lazily via IInstantiationService to avoid
* cyclic dependencies between ICustomizationHarnessService and
* IPromptsService (which depends on the extension host).
*/
class CustomizationHarnessService extends CustomizationHarnessServiceBase {
constructor() {
constructor(
@IInstantiationService instantiationService: IInstantiationService,
) {
const localExtras = [PromptsStorage.extension, BUILTIN_STORAGE];
const descriptor = createVSCodeHarnessDescriptor(localExtras);

// Lazy provider: created on first call to avoid cyclic DI resolution.
let provider: PromptsServiceCustomizationProvider | undefined;
const lazyItemProvider: IExternalCustomizationItemProvider = {
get onDidChange() {
provider ??= instantiationService.createInstance(PromptsServiceCustomizationProvider, descriptor);
return provider.onDidChange;
},
provideChatSessionCustomizations(token) {
provider ??= instantiationService.createInstance(PromptsServiceCustomizationProvider, descriptor);
return provider.provideChatSessionCustomizations(token);
},
};

super(
[createVSCodeHarnessDescriptor(localExtras)],
[{ ...descriptor, itemProvider: lazyItemProvider }],
CustomizationHarness.VSCode,
);
}
Expand Down
Loading
Loading