diff --git a/src/vs/workbench/contrib/void/browser/chatThreadService.ts b/src/vs/workbench/contrib/void/browser/chatThreadService.ts index 05ef405b..1526406d 100644 --- a/src/vs/workbench/contrib/void/browser/chatThreadService.ts +++ b/src/vs/workbench/contrib/void/browser/chatThreadService.ts @@ -156,6 +156,8 @@ export interface IChatThreadService { openNewThread(): void; switchToThread(threadId: string): void; + // you can edit multiple messages + // the one you're currently editing is "focused", and we add items to that one when you press cmd+L. getFocusedMessageIdx(): number | undefined; isFocusingMessage(): boolean; setFocusedMessageIdx(messageIdx: number | undefined): void; @@ -164,8 +166,12 @@ export interface IChatThreadService { _useCurrentThreadState(): readonly [ThreadType['state'], (newState: Partial) => void]; _useCurrentMessageState(messageIdx: number): readonly [UserMessageState, (newState: Partial) => void]; + // call to edit a message editUserMessageAndStreamResponse({ userMessage, chatMode, messageIdx }: { userMessage: string, chatMode: ChatMode, messageIdx: number }): Promise; + + // call to add a message addUserMessageAndStreamResponse({ userMessage, chatMode }: { userMessage: string, chatMode: ChatMode }): Promise; + cancelStreaming(threadId: string): void; dismissStreamError(threadId: string): void; diff --git a/src/vs/workbench/contrib/void/browser/editCodeService.ts b/src/vs/workbench/contrib/void/browser/editCodeService.ts index de920242..f0ee5c45 100644 --- a/src/vs/workbench/contrib/void/browser/editCodeService.ts +++ b/src/vs/workbench/contrib/void/browser/editCodeService.ts @@ -1619,48 +1619,47 @@ class EditCodeService extends Disposable implements IEditCodeService { console.log('delta', deltaFinalText) console.log('currLines', infoOfAddedBlockNum[blockNum].currentBounds) - } // end for console.log('diffZone._streamState.line', diffZone._streamState.line) this._refreshStylesAndDiffsInURI(uri) }, onFinalMessage: async ({ fullText }) => { - // console.log('final message!!', fullText) + console.log('final message!!', fullText) - // // 1. wait 500ms and fix lint errors - call lint error workflow - // // (update react state to say "Fixing errors") - // const blocks = extractSearchReplaceBlocks(fullText) + // 1. wait 500ms and fix lint errors - call lint error workflow + // (update react state to say "Fixing errors") + const blocks = extractSearchReplaceBlocks(fullText) - // if (blocks.length === 0) { - // this._notificationService.info(`Void: When running Apply, your model didn't output any changes that Void recognized. You might need to use a smarter model for Apply.`) - // } + if (blocks.length === 0) { + this._notificationService.info(`Void: When running Apply, your model didn't output any changes that Void recognized. You might need to use a smarter model for Apply.`) + } - // // writeover the whole file - // let newCode = originalFileCode - // for (let blockNum = infoOfAddedBlockNum.length - 1; blockNum >= 0; blockNum -= 1) { - // const { originalBounds } = infoOfAddedBlockNum[blockNum] - // const finalCode = blocks[blockNum].final + // writeover the whole file + let newCode = originalFileCode + for (let blockNum = infoOfAddedBlockNum.length - 1; blockNum >= 0; blockNum -= 1) { + const { originalBounds } = infoOfAddedBlockNum[blockNum] + const finalCode = blocks[blockNum].final - // if (finalCode === null) continue + if (finalCode === null) continue - // const [originalStart, originalEnd] = originalBounds - // const lines = newCode.split('\n') - // newCode = [ - // ...lines.slice(0, (originalStart - 1)), - // ...finalCode.split('\n'), - // ...lines.slice((originalEnd - 1) + 1, Infinity) - // ].join('\n') - // } - // const numLines = this._getNumLines(uri) - // if (numLines !== null) { - // this._writeText(uri, newCode, - // { startLineNumber: 1, startColumn: 1, endLineNumber: numLines, endColumn: Number.MAX_SAFE_INTEGER }, - // { shouldRealignDiffAreas: true } - // ) - // } + const [originalStart, originalEnd] = originalBounds + const lines = newCode.split('\n') + newCode = [ + ...lines.slice(0, (originalStart - 1)), + ...finalCode.split('\n'), + ...lines.slice((originalEnd - 1) + 1, Infinity) + ].join('\n') + } + const numLines = this._getNumLines(uri) + if (numLines !== null) { + this._writeText(uri, newCode, + { startLineNumber: 1, startColumn: 1, endLineNumber: numLines, endColumn: Number.MAX_SAFE_INTEGER }, + { shouldRealignDiffAreas: true } + ) + } - // onDone() + onDone() }, onError: (e) => { this._notifyError(e) diff --git a/src/vs/workbench/contrib/void/common/toolsService.ts b/src/vs/workbench/contrib/void/common/toolsService.ts index dbdd0e15..9686920f 100644 --- a/src/vs/workbench/contrib/void/common/toolsService.ts +++ b/src/vs/workbench/contrib/void/common/toolsService.ts @@ -31,7 +31,7 @@ const paginationHelper = { export const voidTools = { read_file: { name: 'read_file', - description: 'Returns file contents of a given URI.', + description: `Returns file contents of a given URI. ${paginationHelper.desc}`, params: { uri: { type: 'string', description: undefined }, },