This commit is contained in:
Andrew Pareles 2025-02-20 23:23:55 -08:00
parent 33d80bed80
commit 1959c53d75
3 changed files with 36 additions and 31 deletions

View file

@ -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<ThreadType['state']>) => void];
_useCurrentMessageState(messageIdx: number): readonly [UserMessageState, (newState: Partial<UserMessageState>) => void];
// call to edit a message
editUserMessageAndStreamResponse({ userMessage, chatMode, messageIdx }: { userMessage: string, chatMode: ChatMode, messageIdx: number }): Promise<void>;
// call to add a message
addUserMessageAndStreamResponse({ userMessage, chatMode }: { userMessage: string, chatMode: ChatMode }): Promise<void>;
cancelStreaming(threadId: string): void;
dismissStreamError(threadId: string): void;

View file

@ -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)

View file

@ -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 },
},