diff --git a/src/vs/workbench/contrib/void/browser/editCodeService.ts b/src/vs/workbench/contrib/void/browser/editCodeService.ts index fcb4e06f..ccf5484e 100644 --- a/src/vs/workbench/contrib/void/browser/editCodeService.ts +++ b/src/vs/workbench/contrib/void/browser/editCodeService.ts @@ -1172,7 +1172,14 @@ class EditCodeService extends Disposable implements IEditCodeService { } else if (opts.from === 'ClickApply') { if (this._settingsService.state.globalSettings.enableFastApply) { - res = await this._initializeSearchAndReplaceStream(opts) // fast apply + const numCharsInFile = this._fileLengthOfGivenURI(opts.uri) + if (numCharsInFile === null) return null + if (numCharsInFile < 1000) { // slow apply for short files (especially important for empty files) + res = await this._initializeWriteoverStream(opts) + } + else { + res = await this._initializeSearchAndReplaceStream(opts) // fast apply + } } else { res = await this._initializeWriteoverStream(opts) // rewrite @@ -1311,7 +1318,7 @@ class EditCodeService extends Disposable implements IEditCodeService { let ctrlKZoneIfQuickEdit: CtrlKZone | null = null if (from === 'ClickApply') { - const uri_ = this._getActiveEditorURI() + const uri_ = this._uriOfGivenURI(opts.uri) if (!uri_) return uri = uri_ startRange = 'fullFile' @@ -1505,19 +1512,29 @@ class EditCodeService extends Disposable implements IEditCodeService { - - private async _initializeSearchAndReplaceStream(opts: StartApplyingOpts & { from: 'ClickApply' }): Promise<[DiffZone, Promise] | undefined> { - const { from, applyStr, uri: givenURI, } = opts - let uri: URI - + _uriOfGivenURI(givenURI: URI | 'current') { if (givenURI === 'current') { const uri_ = this._getActiveEditorURI() if (!uri_) return - uri = uri_ - } - else { - uri = givenURI + return uri_ } + return givenURI + } + _fileLengthOfGivenURI(givenURI: URI | 'current') { + const uri = this._uriOfGivenURI(givenURI) + if (!uri) return null + const { model } = this._voidModelService.getModel(uri) + if (!model) return null + const numCharsInFile = model.getValueLength(EndOfLinePreference.LF) + return numCharsInFile + } + + + private async _initializeSearchAndReplaceStream(opts: StartApplyingOpts & { from: 'ClickApply' }): Promise<[DiffZone, Promise] | undefined> { + const { from, applyStr, uri: givenURI, } = opts + + const uri = this._uriOfGivenURI(givenURI) + if (!uri) return await this._voidModelService.initializeModel(uri) const { model } = this._voidModelService.getModel(uri) diff --git a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx index 7622e310..77697ee8 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx @@ -2020,7 +2020,7 @@ export const SidebarChat = () => { const proposed = toolNameSoFar && toolNames.includes(toolNameSoFar as ToolName) ? titleOfToolName[toolNameSoFar as ToolName]?.proposed : toolNameSoFar const toolTitle = typeof proposed === 'function' ? proposed(null) : proposed const currStreamingToolHTML = toolIsLoading ? - writing} /> + Getting parameters} /> : null const allMessagesHTML = [...previousMessagesHTML, currStreamingMessageHTML, currStreamingToolHTML] diff --git a/src/vs/workbench/contrib/void/browser/react/src/void-command-bar-tsx/VoidCommandBar.tsx b/src/vs/workbench/contrib/void/browser/react/src/void-command-bar-tsx/VoidCommandBar.tsx index 7ad03ee9..25ffbaec 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/void-command-bar-tsx/VoidCommandBar.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/void-command-bar-tsx/VoidCommandBar.tsx @@ -271,8 +271,8 @@ const VoidCommandBar = ({ uri, editor }: VoidCommandBarProps) => {
{/* Changes in file */}
- {downButton} {upButton} + {downButton} {isADiffInThisFile ? `Diff ${(currDiffIdx ?? 0) + 1} of ${sortedDiffIds.length}` diff --git a/src/vs/workbench/contrib/void/common/prompt/prompts.ts b/src/vs/workbench/contrib/void/common/prompt/prompts.ts index b84d3af5..b6e27ce6 100644 --- a/src/vs/workbench/contrib/void/common/prompt/prompts.ts +++ b/src/vs/workbench/contrib/void/common/prompt/prompts.ts @@ -165,7 +165,8 @@ ${mode === 'agent' ? `\ - Only use tools if they help you accomplish the user's goal. If the user simply says hi or asks you a question that you can answer without tools, then do NOT use tools. - ALWAYS use tools to take actions. For example, if you would like to edit a file, you MUST use a tool.` : mode === 'gather' ? `\ -- Your primary use of tools should be to gather information to help the user understand the codebase and answer their query.` +- Your primary use of tools should be to gather information to help the user understand the codebase and answer their query. +- You should extensively read files, types, etc and gather relevant context.` : ''} - If you think you should use tools, you do not need to ask for permission. Feel free to call tools whenever you'd like. You can use them to understand the codebase, ${mode === 'agent' ? 'run terminal commands, edit files, ' : 'gather relevant files and information, '}etc. - NEVER refer to a tool by name when speaking with the user (NEVER say something like "I'm going to use \`tool_name\`"). Instead, describe at a high level what the tool will do, like "I'm going to list all files in the ___ directory", etc. Also do not refer to "pages" of results, just say you're getting more results.