always add tool_request

This commit is contained in:
Andrew Pareles 2025-03-20 05:55:15 -07:00
parent 794c4593e6
commit dafc509fa1
5 changed files with 30 additions and 12 deletions

View file

@ -783,10 +783,14 @@ class ChatThreadService extends Disposable implements IChatThreadService {
}
// 2. if tool requires approval, break from the loop, awaiting approval
const requiresApproval = !this._settingsService.state.globalSettings.autoApprove
if (requiresApproval && toolNamesThatRequireApproval.has(toolName)) {
const requiresApproval = toolNamesThatRequireApproval.has(toolName)
if (requiresApproval) {
const autoApprove = this._settingsService.state.globalSettings.autoApprove
// add a tool_request because we use it for UI if a tool is loading (this should be improved in the future)
this._addMessageToThread(threadId, { role: 'tool_request', name: toolName, paramsStr: toolParamsStr, params: toolParams, id: toolId })
return { awaitingUserApproval: true }
if (!autoApprove) {
return { awaitingUserApproval: true }
}
}
}
else {

View file

@ -1244,12 +1244,18 @@ class EditCodeService extends Disposable implements IEditCodeService {
// ctrlkzone should never have any conflicts
}
else {
console.log('KEEPING CONFLICTS!!!!!!!!')
// keep conflict on whole file - to keep conflict, revert the change and use those contents as original, then un-revert the file
const currentFileStr = originalFileStr
console.log('originalFile', originalFileStr)
console.log('diffareas A', JSON.stringify(this.diffAreasOfURI, null, 2))
this.acceptOrRejectAllDiffAreas({ uri, removeCtrlKs: true, behavior: 'reject', _addToHistory: false })
console.log('diffareas B', JSON.stringify(this.diffAreasOfURI, null, 2))
const oldFileStr = model.getValue(EndOfLinePreference.LF) // use this as original code
this._writeURIText(uri, currentFileStr, 'wholeFileRange', { shouldRealignDiffAreas: true }) // un-revert
console.log('oldFileStr', { oldFileStr })
this._writeURIText(uri, originalFileStr, 'wholeFileRange', { shouldRealignDiffAreas: true }) // un-revert
originalCode = oldFileStr
console.log('originalCode', { originalCode })
console.log('NEW STR', { newStr: model.getValue(EndOfLinePreference.LF) })
}
}
@ -1772,7 +1778,7 @@ class EditCodeService extends Disposable implements IEditCodeService {
onFinalMessage: async (params) => {
const { fullText } = params
console.log('DONE - editCode!', fullText)
console.log('DONE - editCode!', { fullText })
// 1. wait 500ms and fix lint errors - call lint error workflow
// (update react state to say "Fixing errors")
@ -1788,7 +1794,7 @@ class EditCodeService extends Disposable implements IEditCodeService {
addedTrackingZoneOfBlockNum.sort((a, b) => a.metadata.originalBounds[0] - b.metadata.originalBounds[0])
const { model } = this._voidModelService.getModel(uri)
console.log('CURRENT\n', model?.getValue())
console.log('CURRENT!!!', { current: model?.getValue() })
console.log('ADDED', addedTrackingZoneOfBlockNum)
console.log('BLOX', blocks)

View file

@ -1113,7 +1113,7 @@ const ReasoningWrapper = ({ isDoneReasoning, isStreaming, children }: { isDoneRe
const loadingTitleWrapper = (item: React.ReactNode) => {
return <span className='flex items-center flex-nowrap'>
{item}
<IconLoading className='w-4'/>
<IconLoading className='w-3 text-sm' />
</span>
}
const folderFileStr = (isFolder: boolean) => isFolder ? 'folder' : 'file'
@ -1652,6 +1652,11 @@ const toolNameToComponent: { [T in ToolName]: ToolComponent<T> } = {
/>
</ToolChildrenWrapper>
}
else {
componentParams.children = <ErrorChildren>
{value}
</ErrorChildren>
}
}
}
@ -1769,7 +1774,7 @@ const ChatBubble = ({ chatMessage, isCommitted, messageIdx, isLast, chatIsRunnin
/>
}
else if (role === 'tool_request') {
const ToolRequestWrapper = toolNameToComponent[chatMessage.name].requestWrapper as RequestWrapper<ToolName>
const ToolRequestWrapper = toolNameToComponent[chatMessage.name]?.requestWrapper as RequestWrapper<ToolName>
const toolRequestType = (
chatIsRunning === 'awaiting_user' ? 'awaiting_user'
: chatIsRunning === 'tool' ? 'running'
@ -1784,7 +1789,7 @@ const ChatBubble = ({ chatMessage, isCommitted, messageIdx, isLast, chatIsRunnin
return null
}
else if (role === 'tool') {
const ToolResultWrapper = toolNameToComponent[chatMessage.name].resultWrapper as ResultWrapper<ToolName>
const ToolResultWrapper = toolNameToComponent[chatMessage.name]?.resultWrapper as ResultWrapper<ToolName>
if (ToolResultWrapper)
return <ToolResultWrapper toolMessage={chatMessage} messageIdx={messageIdx} threadId={threadId} />
return null

View file

@ -208,7 +208,10 @@ const VoidCommandBar = ({ uri, editor }: { uri: URI | null, editor: ICodeEditor
File {currUriIdx + 1} of {sortedCommandBarURIs.length}
</div>}
{currDiffIdx !== null && sortedDiffIds?.length && <div>
Diff {currDiffIdx + 1} of {sortedDiffIds?.length ?? 0}
{(sortedDiffIds?.length ?? 0) === 0 ?
<>Diff {currDiffIdx + 1} of {sortedDiffIds?.length ?? 0}</>
: <>(No changes)</>}
</div>}
</div>
</div >

View file

@ -120,7 +120,7 @@ const validateStr = (argName: string, value: unknown) => {
// We are NOT checking to make sure in workspace
const validateURI = (uriStr: unknown) => {
if (typeof uriStr !== 'string') throw new Error('Error: provided uri must be a string.')
if (typeof uriStr !== 'string') throw new Error('Provided uri must be a string.')
const uri = URI.file(uriStr)
return uri