Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/void/browser/editCodeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ class EditCodeService extends Disposable implements IEditCodeService {

const startLine = startRange === 'fullFile' ? 1 : startRange[0]
const endLine = startRange === 'fullFile' ? model.getLineCount() : startRange[1]
const { prefix, suffix } = voidPrefixAndSuffix({ fullFileStr: originalFileCode, startLine, endLine })
const { prefix, suffix } = voidPrefixAndSuffix({ settingsService: this._settingsService, fullFileStr: originalFileCode, startLine, endLine })
const userContent = ctrlKStream_userMessage({ selection: originalCode, instructions: instructions, prefix, suffix, fimTags: quickEditFIMTags, language })

const { messages: a, separateSystemMessage: b } = this._convertToLLMMessageService.prepareLLMSimpleMessages({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { approvalTypeOfBuiltinToolName, BuiltinToolCallParams, BuiltinToolName,
import { CopyButton, EditToolAcceptRejectButtonsHTML, IconShell1, JumpToFileButton, JumpToTerminalButton, StatusIndicator, StatusIndicatorForApplyButton, useApplyStreamState, useEditToolStreamState } from '../markdown/ApplyBlockHoverButtons.js';
import { IsRunningType } from '../../../chatThreadService.js';
import { acceptAllBg, acceptBorder, buttonFontSize, buttonTextColor, rejectAllBg, rejectBg, rejectBorder } from '../../../../common/helpers/colors.js';
import { builtinToolNames, isABuiltinToolName, MAX_FILE_CHARS_PAGE, MAX_TERMINAL_INACTIVE_TIME } from '../../../../common/prompt/prompts.js';
import { builtinToolNames, isABuiltinToolName } from '../../../../common/prompt/prompts.js';
import { RawToolCallObj } from '../../../../common/sendLLMMessageTypes.js';
import ErrorBoundary from './ErrorBoundary.js';
import { ToolApprovalTypeSwitch } from '../void-settings-tsx/Settings.js';
Expand Down Expand Up @@ -1946,7 +1946,7 @@ const builtinToolNameToComponent: { [T in BuiltinToolName]: { resultWrapper: Res
const { result } = toolMessage
componentParams.onClick = () => { voidOpenFileFn(params.uri, accessor, range) }
if (result.hasNextPage && params.pageNumber === 1) // first page
componentParams.desc2 = `(truncated after ${Math.round(MAX_FILE_CHARS_PAGE) / 1000}k)`
componentParams.desc2 = '(truncated)'
else if (params.pageNumber > 1) // subsequent pages
componentParams.desc2 = `(part ${params.pageNumber})`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------*/

import React, { useCallback, useEffect, useMemo, useState, useRef } from 'react'; // Added useRef import just in case it was missed, though likely already present
import { ProviderName, SettingName, displayInfoOfSettingName, providerNames, VoidStatefulModelInfo, customSettingNamesOfProvider, RefreshableProviderName, refreshableProviderNames, displayInfoOfProviderName, nonlocalProviderNames, localProviderNames, GlobalSettingName, featureNames, displayInfoOfFeatureName, isProviderNameDisabled, FeatureName, hasDownloadButtonsOnModelsProviderNames, subTextMdOfProviderName } from '../../../../common/voidSettingsTypes.js'
import { ProviderName, SettingName, displayInfoOfSettingName, providerNames, VoidStatefulModelInfo, customSettingNamesOfProvider, RefreshableProviderName, refreshableProviderNames, displayInfoOfProviderName, nonlocalProviderNames, localProviderNames, GlobalSettingName, featureNames, displayInfoOfFeatureName, isProviderNameDisabled, FeatureName, hasDownloadButtonsOnModelsProviderNames, subTextMdOfProviderName, GlobalSettings, defaultGlobalSettings, displayNameAndDescriptionOfSetting } from '../../../../common/voidSettingsTypes.js'
import ErrorBoundary from '../sidebar-tsx/ErrorBoundary.js'
import { VoidButtonBgDarken, VoidCustomDropdownBox, VoidInputBox2, VoidSimpleInputBox, VoidSwitch } from '../util/inputs.js'
import { useAccessor, useIsDark, useIsOptedOut, useRefreshModelListener, useRefreshModelState, useSettingsState } from '../util/services.js'
Expand All @@ -23,13 +23,15 @@ import { MCPServer } from '../../../../common/mcpServiceTypes.js';
import { useMCPServiceState } from '../util/services.js';
import { OPT_OUT_KEY } from '../../../../common/storageKeys.js';
import { StorageScope, StorageTarget } from '../../../../../../../platform/storage/common/storage.js';
import { VoidSettingsState } from '../../../../common/voidSettingsService.js';

type Tab =
| 'models'
| 'localProviders'
| 'providers'
| 'featureOptions'
| 'mcp'
| 'limits'
| 'general'
| 'all';

Expand Down Expand Up @@ -796,6 +798,57 @@ export const AIInstructionsBox = () => {
/>
}

export const LimitComponent = ({ setting, onVoidSettingsInit, onVoidDefaultSettingsInit }: {
setting: GlobalSettingName
onVoidSettingsInit: (state: VoidSettingsState) => number
onVoidDefaultSettingsInit: (settings: GlobalSettings) => number
}) => {
const accessor = useAccessor()
const voidSettingsService = accessor.get('IVoidSettingsService')
const voidSettingsState = useSettingsState()
const [name, description] = displayNameAndDescriptionOfSetting(setting)
return (
<div className="flex flex-col gap-1">
<h4 className="text-base">{name}</h4>
{description && (
<div className="text-sm text-void-fg-3 mt-1">
<span>{description}</span>
</div>
)}
<VoidSimpleInputBox
value={onVoidSettingsInit(voidSettingsState)?.toString() ?? onVoidDefaultSettingsInit(defaultGlobalSettings)}
placeholder={`Default: ${onVoidDefaultSettingsInit(defaultGlobalSettings)}`}
onChangeValue={(newVal) => {
const parsed = parseInt(newVal)
if (!parsed || isNaN(parsed)) {
return
}

voidSettingsService.setGlobalSetting(setting, parsed >= 0 ? parsed : 0)
}}
/>
</div>
)
}


export const LimitsList = ({ settings }: { settings: GlobalSettingName[] }) => {
return (
<div className="my-2">
<div className="flex flex-col gap-2">
{settings.map((setting) => (
<LimitComponent
key={setting}
setting={setting}
onVoidSettingsInit={(state: VoidSettingsState) => state.globalSettings[setting] as number}
onVoidDefaultSettingsInit={(settings: GlobalSettings) => settings[setting] as number}
/>
))}
</div>
</div>
)
}

const FastApplyMethodDropdown = () => {
const accessor = useAccessor()
const voidSettingsService = accessor.get('IVoidSettingsService')
Expand Down Expand Up @@ -1042,6 +1095,7 @@ export const Settings = () => {
{ tab: 'featureOptions', label: 'Feature Options' },
{ tab: 'general', label: 'General' },
{ tab: 'mcp', label: 'MCP' },
{ tab: 'limits', label: 'Limits' },
{ tab: 'all', label: 'All Settings' },
];
const shouldShowTab = (tab: Tab) => selectedSection === 'all' || selectedSection === tab;
Expand Down Expand Up @@ -1551,10 +1605,44 @@ Use Model Context Protocol to provide Agent mode with more tools.



{/* Limits section */}
<div className={shouldShowTab('limits') ? `` : 'hidden'}>
<div className='flex flex-col gap-8'>
<div>
<h2 className='text-3xl mb-2'>Directory Structure</h2>
<h4 className='text-void-fg-3 mb-4'>Define the maximum allowable limits for directory queries.</h4>
<ErrorBoundary>
<LimitsList settings={['maxDirstrCharsTotalBeginning', 'maxDirstrCharsTotalTool', 'maxDirstrResultsTotalBeginning', 'maxDirstrResultsTotalTool']} />
</ErrorBoundary>
</div>
<div>
<h2 className='text-3xl mb-2'>Tool Info</h2>
<h4 className='text-void-fg-3 mb-4'>Define the maximum limits regarding the tool itself.</h4>
<ErrorBoundary>
<LimitsList settings={['maxFileCharsPage', 'maxChildrenUrisPage']} />
</ErrorBoundary>
</div>
<div>
<h2 className='text-3xl mb-2'>Terminal Info</h2>
<h4 className='text-void-fg-3 mb-4'>Define the maximum allowed characters for terminal related activities.</h4>
<ErrorBoundary>
<LimitsList settings={['maxTerminalChars', 'maxTerminalInactiveTime', 'maxTerminalBgCommandTime']} />
</ErrorBoundary>
</div>
<div>
<h2 className='text-3xl mb-2'>Context</h2>
<h4 className='text-void-fg-3 mb-4'>Define the maximum how long context strings can be.</h4>
<ErrorBoundary>
<LimitsList settings={['maxPrefixSuffixChars']} />
</ErrorBoundary>
</div>
</div>
</div>


</div>


</div>
</div>
</main>
</div>
Expand Down
15 changes: 8 additions & 7 deletions src/vs/workbench/contrib/void/browser/terminalToolService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { createDecorator } from '../../../../platform/instantiation/common/insta
import { TerminalLocation } from '../../../../platform/terminal/common/terminal.js';
import { IWorkspaceContextService } from '../../../../platform/workspace/common/workspace.js';
import { ITerminalService, ITerminalInstance, ICreateTerminalOptions } from '../../../../workbench/contrib/terminal/browser/terminal.js';
import { MAX_TERMINAL_BG_COMMAND_TIME, MAX_TERMINAL_CHARS, MAX_TERMINAL_INACTIVE_TIME } from '../common/prompt/prompts.js';
import { TerminalResolveReason } from '../common/toolsServiceTypes.js';
import { timeout } from '../../../../base/common/async.js';
import { IVoidSettingsService } from '../common/voidSettingsService.js';



Expand Down Expand Up @@ -74,6 +74,7 @@ export class TerminalToolService extends Disposable implements ITerminalToolServ
constructor(
@ITerminalService private readonly terminalService: ITerminalService,
@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService,
@IVoidSettingsService private readonly voidSettingsService: IVoidSettingsService,
) {
super();

Expand Down Expand Up @@ -229,8 +230,8 @@ export class TerminalToolService extends Disposable implements ITerminalToolServ

let result = removeAnsiEscapeCodes(lines.join('\n'));

if (result.length > MAX_TERMINAL_CHARS) {
const half = MAX_TERMINAL_CHARS / 2;
if (result.length > this.voidSettingsService.state.globalSettings.maxTerminalChars) {
const half = this.voidSettingsService.state.globalSettings.maxTerminalChars / 2;
result = result.slice(0, half) + '\n...\n' + result.slice(result.length - half);
}

Expand Down Expand Up @@ -323,7 +324,7 @@ export class TerminalToolService extends Disposable implements ITerminalToolServ
setTimeout(() => {
resolveReason = { type: 'timeout' };
res()
}, MAX_TERMINAL_BG_COMMAND_TIME * 1000)
}, this.voidSettingsService.state.globalSettings.maxTerminalBgCommandTime * 1000)
})
// inactivity-based timeout
: new Promise<void>(res => {
Expand All @@ -335,7 +336,7 @@ export class TerminalToolService extends Disposable implements ITerminalToolServ

resolveReason = { type: 'timeout' };
res();
}, MAX_TERMINAL_INACTIVE_TIME * 1000);
}, this.voidSettingsService.state.globalSettings.maxTerminalInactiveTime * 1000);
};

const dTimeout = terminal.onData(() => { resetTimer(); });
Expand Down Expand Up @@ -364,8 +365,8 @@ export class TerminalToolService extends Disposable implements ITerminalToolServ
if (!isPersistent) result = `$ ${command}\n${result}`
result = removeAnsiEscapeCodes(result)
// trim
if (result.length > MAX_TERMINAL_CHARS) {
const half = MAX_TERMINAL_CHARS / 2
if (result.length > this.voidSettingsService.state.globalSettings.maxTerminalChars) {
const half = this.voidSettingsService.state.globalSettings.maxTerminalChars / 2
result = result.slice(0, half)
+ '\n...\n'
+ result.slice(result.length - half, Infinity)
Expand Down
21 changes: 10 additions & 11 deletions src/vs/workbench/contrib/void/browser/toolsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { computeDirectoryTree1Deep, IDirectoryStrService, stringifyDirectoryTree
import { IMarkerService, MarkerSeverity } from '../../../../platform/markers/common/markers.js'
import { timeout } from '../../../../base/common/async.js'
import { RawToolParamsObj } from '../common/sendLLMMessageTypes.js'
import { MAX_CHILDREN_URIs_PAGE, MAX_FILE_CHARS_PAGE, MAX_TERMINAL_BG_COMMAND_TIME, MAX_TERMINAL_INACTIVE_TIME } from '../common/prompt/prompts.js'
import { IVoidSettingsService } from '../common/voidSettingsService.js'
import { generateUuid } from '../../../../base/common/uuid.js'

Expand Down Expand Up @@ -311,16 +310,16 @@ export class ToolsService implements IToolsService {

const totalNumLines = model.getLineCount()

const fromIdx = MAX_FILE_CHARS_PAGE * (pageNumber - 1)
const toIdx = MAX_FILE_CHARS_PAGE * pageNumber - 1
const fromIdx = this.voidSettingsService.state.globalSettings.maxFileCharsPage * (pageNumber - 1)
const toIdx = this.voidSettingsService.state.globalSettings.maxFileCharsPage * pageNumber - 1
const fileContents = contents.slice(fromIdx, toIdx + 1) // paginate
const hasNextPage = (contents.length - 1) - toIdx >= 1
const totalFileLen = contents.length
return { result: { fileContents, totalFileLen, hasNextPage, totalNumLines } }
},

ls_dir: async ({ uri, pageNumber }) => {
const dirResult = await computeDirectoryTree1Deep(fileService, uri, pageNumber)
const dirResult = await computeDirectoryTree1Deep(fileService, voidSettingsService, uri, pageNumber)
return { result: dirResult }
},

Expand All @@ -338,8 +337,8 @@ export class ToolsService implements IToolsService {
})
const data = await searchService.fileSearch(query, CancellationToken.None)

const fromIdx = MAX_CHILDREN_URIs_PAGE * (pageNumber - 1)
const toIdx = MAX_CHILDREN_URIs_PAGE * pageNumber - 1
const fromIdx = this.voidSettingsService.state.globalSettings.maxChildrenUrisPage * (pageNumber - 1)
const toIdx = this.voidSettingsService.state.globalSettings.maxChildrenUrisPage * pageNumber - 1
const uris = data.results
.slice(fromIdx, toIdx + 1) // paginate
.map(({ resource, results }) => resource)
Expand All @@ -360,8 +359,8 @@ export class ToolsService implements IToolsService {

const data = await searchService.textSearch(query, CancellationToken.None)

const fromIdx = MAX_CHILDREN_URIs_PAGE * (pageNumber - 1)
const toIdx = MAX_CHILDREN_URIs_PAGE * pageNumber - 1
const fromIdx = this.voidSettingsService.state.globalSettings.maxChildrenUrisPage * (pageNumber - 1)
const toIdx = this.voidSettingsService.state.globalSettings.maxChildrenUrisPage * pageNumber - 1
const uris = data.results
.slice(fromIdx, toIdx + 1) // paginate
.map(({ resource, results }) => resource)
Expand Down Expand Up @@ -470,7 +469,7 @@ export class ToolsService implements IToolsService {
return lintErrors
.map((e, i) => `Error ${i + 1}:\nLines Affected: ${e.startLineNumber}-${e.endLineNumber}\nError message:${e.message}`)
.join('\n\n')
.substring(0, MAX_FILE_CHARS_PAGE)
.substring(0, this.voidSettingsService.state.globalSettings.maxFileCharsPage)
}

// given to the LLM after the call for successful tool calls
Expand Down Expand Up @@ -538,7 +537,7 @@ export class ToolsService implements IToolsService {
}
// normal command
if (resolveReason.type === 'timeout') {
return `${result_}\nTerminal command ran, but was automatically killed by Void after ${MAX_TERMINAL_INACTIVE_TIME}s of inactivity and did not finish successfully. To try with more time, open a persistent terminal and run the command there.`
return `${result_}\nTerminal command ran, but was automatically killed by Void after ${this.voidSettingsService.state.globalSettings.maxTerminalInactiveTime}s of inactivity and did not finish successfully. To try with more time, open a persistent terminal and run the command there.`
}
throw new Error(`Unexpected internal error: Terminal command did not resolve with a valid reason.`)
},
Expand All @@ -552,7 +551,7 @@ export class ToolsService implements IToolsService {
}
// bg command
if (resolveReason.type === 'timeout') {
return `${result_}\nTerminal command is running in terminal ${persistentTerminalId}. The given outputs are the results after ${MAX_TERMINAL_BG_COMMAND_TIME} seconds.`
return `${result_}\nTerminal command is running in terminal ${persistentTerminalId}. The given outputs are the results after ${this.voidSettingsService.state.globalSettings.maxTerminalBgCommandTime} seconds.`
}
throw new Error(`Unexpected internal error: Terminal command did not resolve with a valid reason.`)
},
Expand Down
18 changes: 10 additions & 8 deletions src/vs/workbench/contrib/void/common/directoryStrService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { createDecorator } from '../../../../platform/instantiation/common/insta
import { IFileService, IFileStat } from '../../../../platform/files/common/files.js';
import { IWorkspaceContextService } from '../../../../platform/workspace/common/workspace.js';
import { ShallowDirectoryItem, BuiltinToolCallParams, BuiltinToolResultType } from './toolsServiceTypes.js';
import { MAX_CHILDREN_URIs_PAGE, MAX_DIRSTR_CHARS_TOTAL_BEGINNING, MAX_DIRSTR_CHARS_TOTAL_TOOL } from './prompt/prompts.js';
import { IVoidSettingsService } from './voidSettingsService.js';


const MAX_FILES_TOTAL = 1000;
Expand Down Expand Up @@ -74,6 +74,7 @@ const shouldExcludeDirectory = (name: string) => {

export const computeDirectoryTree1Deep = async (
fileService: IFileService,
voidSettingsService: IVoidSettingsService,
rootURI: URI,
pageNumber: number = 1,
): Promise<BuiltinToolResultType['ls_dir']> => {
Expand All @@ -84,8 +85,8 @@ export const computeDirectoryTree1Deep = async (

const nChildren = stat.children?.length ?? 0;

const fromChildIdx = MAX_CHILDREN_URIs_PAGE * (pageNumber - 1);
const toChildIdx = MAX_CHILDREN_URIs_PAGE * pageNumber - 1; // INCLUSIVE
const fromChildIdx = voidSettingsService.state.globalSettings.maxChildrenUrisPage * (pageNumber - 1);
const toChildIdx = voidSettingsService.state.globalSettings.maxChildrenUrisPage * pageNumber - 1; // INCLUSIVE
const listChildren = stat.children?.slice(fromChildIdx, toChildIdx + 1);

const children: ShallowDirectoryItem[] = listChildren?.map(child => ({
Expand Down Expand Up @@ -387,6 +388,7 @@ class DirectoryStrService extends Disposable implements IDirectoryStrService {
constructor(
@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService,
@IFileService private readonly fileService: IFileService,
@IVoidSettingsService private readonly voidSettingsService: IVoidSettingsService,
) {
super();
}
Expand All @@ -405,7 +407,7 @@ class DirectoryStrService extends Disposable implements IDirectoryStrService {
const { content: initialContent, wasCutOff: initialCutOff } = await computeAndStringifyDirectoryTree(
eRoot,
this.fileService,
MAX_DIRSTR_CHARS_TOTAL_TOOL,
this.voidSettingsService.state.globalSettings.maxDirstrCharsTotalTool,
{ count: 0 },
{ maxDepth: START_MAX_DEPTH, currentDepth: 0, maxItemsPerDir }
);
Expand All @@ -416,7 +418,7 @@ class DirectoryStrService extends Disposable implements IDirectoryStrService {
const result = await computeAndStringifyDirectoryTree(
eRoot,
this.fileService,
MAX_DIRSTR_CHARS_TOTAL_TOOL,
this.voidSettingsService.state.globalSettings.maxDirstrCharsTotalTool,
{ count: 0 },
{ maxDepth: DEFAULT_MAX_DEPTH, currentDepth: 0, maxItemsPerDir: DEFAULT_MAX_ITEMS_PER_DIR }
);
Expand All @@ -427,7 +429,7 @@ class DirectoryStrService extends Disposable implements IDirectoryStrService {
wasCutOff = initialCutOff;
}

let c = content.substring(0, MAX_DIRSTR_CHARS_TOTAL_TOOL)
let c = content.substring(0, this.voidSettingsService.state.globalSettings.maxDirstrCharsTotalTool)
c = `Directory of ${uri.fsPath}:\n${content}`
if (wasCutOff) c = `${c}\n...Result was truncated...`

Expand Down Expand Up @@ -459,7 +461,7 @@ class DirectoryStrService extends Disposable implements IDirectoryStrService {
const { content: initialContent, wasCutOff: initialCutOff } = await computeAndStringifyDirectoryTree(
eRoot,
this.fileService,
MAX_DIRSTR_CHARS_TOTAL_BEGINNING - str.length,
this.voidSettingsService.state.globalSettings.maxDirstrCharsTotalBeginning - str.length,
{ count: 0 },
{ maxDepth: START_MAX_DEPTH, currentDepth: 0, maxItemsPerDir: startMaxItemsPerDir }
);
Expand All @@ -470,7 +472,7 @@ class DirectoryStrService extends Disposable implements IDirectoryStrService {
const result = await computeAndStringifyDirectoryTree(
eRoot,
this.fileService,
MAX_DIRSTR_CHARS_TOTAL_BEGINNING - str.length,
this.voidSettingsService.state.globalSettings.maxDirstrCharsTotalBeginning - str.length,
{ count: 0 },
{ maxDepth: DEFAULT_MAX_DEPTH, currentDepth: 0, maxItemsPerDir: DEFAULT_MAX_ITEMS_PER_DIR }
);
Expand Down
Loading