get ready to add searchReplaceService

This commit is contained in:
Andrew Pareles 2025-02-17 15:22:24 -08:00
parent 0fd10f404e
commit d3547134e7
2 changed files with 40 additions and 1 deletions

View file

@ -1192,7 +1192,7 @@ class EditCodeService extends Disposable implements IEditCodeService {
const userMessageContent = searchReplace_userMessage({ originalCode: fileContents, applyStr: applyStr })
const messages: LLMChatMessage[] = [
{ role: 'system', content: searchReplace_systemMessage },
{ role: 'user', content: userMessageContent }
{ role: 'user', content: userMessageContent },
]
let streamRequestIdRef: { current: string | null } = { current: null }
@ -1232,8 +1232,10 @@ class EditCodeService extends Disposable implements IEditCodeService {
}
// any time there's an error, add assistant's message, then user message saying the problem and to retry
// TODO!!! turn this into a service and provide it
// this generates >>>>>>> ORIGINAL <<<<<<< REPLACE blocks and and simultaneously applies it
streamRequestIdRef.current = this._llmMessageService.sendLLMMessage({
messagesType: 'chatMessages',
useProviderFor: 'Apply',

View file

@ -0,0 +1,37 @@
/*--------------------------------------------------------------------------------------
* Copyright 2025 Glass Devtools, Inc. All rights reserved.
* Licensed under the Apache License, Version 2.0. See LICENSE.txt for more information.
*--------------------------------------------------------------------------------------*/
import { Emitter, Event } from '../../../../base/common/event.js';
import { Disposable } from '../../../../base/common/lifecycle.js';
import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
import { ILLMMessageService } from '../common/llmMessageService.js';
export interface ISearchReplaceService {
readonly _serviceBrand: undefined;
}
export const ISearchReplaceService = createDecorator<ISearchReplaceService>('SearchReplaceService');
class SearchReplaceService extends Disposable implements ISearchReplaceService {
_serviceBrand: undefined;
static readonly ID = 'SearchReplaceService';
private readonly _onDidChangeState = new Emitter<void>();
readonly onDidChangeState: Event<void> = this._onDidChangeState.event;
constructor(
@ILLMMessageService private readonly llmMessageService: ILLMMessageService,
) {
super()
// this.llmMessageService.sendLLMMessage({})
}
}
registerSingleton(ISearchReplaceService, SearchReplaceService, InstantiationType.Eager);