mirror of
https://github.com/voideditor/void
synced 2026-05-24 09:58:23 +00:00
interruption handling
This commit is contained in:
parent
b3522ad73c
commit
c889acadc0
4 changed files with 12 additions and 13 deletions
|
|
@ -1245,18 +1245,11 @@ 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
|
||||
// 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
|
||||
// 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) })
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1498,7 +1491,7 @@ class EditCodeService extends Disposable implements IEditCodeService {
|
|||
} // end while
|
||||
} // end writeover
|
||||
|
||||
const applyDonePromise = runWriteover()
|
||||
const applyDonePromise = new Promise<void>((res, rej) => { runWriteover().then(res).catch(rej) })
|
||||
return [diffZone, applyDonePromise]
|
||||
}
|
||||
|
||||
|
|
@ -1865,7 +1858,7 @@ class EditCodeService extends Disposable implements IEditCodeService {
|
|||
|
||||
} // end retryLoop
|
||||
|
||||
const applyDonePromise = runSearchReplace()
|
||||
const applyDonePromise = new Promise<void>((res, rej) => { runSearchReplace().then(res).catch(rej) })
|
||||
return [diffZone, applyDonePromise]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -165,6 +165,8 @@ export const useApplyButtonHTML = ({ codeStr, applyBoxId, uri }: { codeStr: stri
|
|||
uri: uri,
|
||||
startBehavior: 'keep-conflicts',
|
||||
}) ?? []
|
||||
// catch any errors by interrupting the stream
|
||||
applyDonePromise?.catch(e => { if (newApplyingUri) editCodeService.interruptURIStreaming({ uri: newApplyingUri }) })
|
||||
|
||||
applyingURIOfApplyBoxIdRef.current[applyBoxId] = newApplyingUri ?? undefined
|
||||
|
||||
|
|
|
|||
|
|
@ -58,16 +58,20 @@ export const QuickEditChat = ({
|
|||
className="@@codicon @@codicon-loading @@codicon-modifier-spin @@codicon-no-default-spin text-void-fg-3"
|
||||
/>
|
||||
|
||||
const onSubmit = useCallback(() => {
|
||||
const onSubmit = useCallback(async () => {
|
||||
if (isDisabled) return
|
||||
if (isStreamingRef.current) return
|
||||
textAreaFnsRef.current?.disable()
|
||||
|
||||
const res = editCodeService.startApplying({
|
||||
const [newApplyingUri, applyDonePromise] = await editCodeService.startApplying({
|
||||
from: 'QuickEdit',
|
||||
diffareaid,
|
||||
startBehavior: 'keep-conflicts',
|
||||
})
|
||||
}) ?? []
|
||||
// catch any errors by interrupting the stream
|
||||
applyDonePromise?.catch(e => { if (newApplyingUri) editCodeService.interruptCtrlKStreaming({ diffareaid }) })
|
||||
|
||||
|
||||
}, [isStreamingRef, isDisabled, editCodeService, diffareaid])
|
||||
|
||||
const onInterrupt = useCallback(() => {
|
||||
|
|
|
|||
|
|
@ -1946,7 +1946,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 ?
|
||||
<ToolHeaderWrapper key={getChatBubbleId(currentThread.id, streamingChatIdx + 1)} title={toolTitle} desc1={<IconLoading />} />
|
||||
<ToolHeaderWrapper key={getChatBubbleId(currentThread.id, streamingChatIdx + 1)} title={toolTitle} desc1={<span className='flex items-center'>writing<IconLoading /></span>} />
|
||||
: null
|
||||
|
||||
const allMessagesHTML = [...previousMessagesHTML, currStreamingMessageHTML, currStreamingToolHTML]
|
||||
|
|
|
|||
Loading…
Reference in a new issue