mirror of
https://github.com/voideditor/void
synced 2026-05-24 09:58:23 +00:00
bug
This commit is contained in:
parent
d4e9dbb82a
commit
847b57c406
1 changed files with 10 additions and 13 deletions
|
|
@ -122,22 +122,14 @@ export type ThreadStreamState = {
|
|||
}
|
||||
}
|
||||
|
||||
const defaultThreadAttributes = () => {
|
||||
const newThreadObject = () => {
|
||||
const now = new Date().toISOString()
|
||||
return {
|
||||
id: generateUuid(),
|
||||
createdAt: now,
|
||||
lastModified: now,
|
||||
messages: [],
|
||||
state: defaultThreadState,
|
||||
}
|
||||
}
|
||||
|
||||
const newThreadObject = () => {
|
||||
|
||||
return {
|
||||
id: generateUuid(),
|
||||
...defaultThreadAttributes()
|
||||
|
||||
} satisfies ChatThreads[string]
|
||||
}
|
||||
|
||||
|
|
@ -1253,11 +1245,16 @@ class ChatThreadService extends Disposable implements IChatThreadService {
|
|||
const { allThreads: currentThreads } = this.state
|
||||
for (const threadId in currentThreads) {
|
||||
if (currentThreads[threadId]!.messages.length === 0) {
|
||||
// clear the thread
|
||||
currentThreads[threadId]! = { id: currentThreads[threadId]!.id, ...defaultThreadAttributes() }
|
||||
|
||||
// switch to the thread
|
||||
this.switchToThread(threadId)
|
||||
return
|
||||
|
||||
// add the current file as a staging selection
|
||||
const model = this._codeEditorService.getActiveCodeEditor()?.getModel()
|
||||
if (model) {
|
||||
this._setCurrentThreadState({ ...defaultThreadState, stagingSelections: [{ type: 'File', fileURI: model.uri, language: model.getLanguageId(), selectionStr: null, range: null, state: { isOpened: false, wasAddedAsCurrentFile: true } }] })
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
// otherwise, start a new thread
|
||||
|
|
|
|||
Loading…
Reference in a new issue