✨ feat(vscode): 问 AI 收起再展开、重启后接着这块最近的会话问;代码改了对不上的问答不再显示
This commit is contained in:
1 parent
cbe447ade8
commit
f0a3ad80e1
16 files changed
+82
-211
No files matched your search
@@ -157,7 +157,7 @@ class Preview {
|
||||
askId: event.ask.askId,
|
||||
status: end.status,
|
||||
...(end.status === 'failed' && { error: end.error }),
|
||||
...(end.status === 'done' && { text: end.answer.text, entryId, sessionId: end.answer.sessionId }),
|
||||
...(end.status === 'done' && { text: end.answer.text, entryId }),
|
||||
})
|
||||
this.postQa()
|
||||
}),
|
||||
@@ -219,17 +219,17 @@ class Preview {
|
||||
}
|
||||
|
||||
/**
|
||||
* 问 anchor 那块代码:按最近一次发出去的块树找到它、带上代码上下文交给 CodeQa;resume 是追问时上一次的会话 id。
|
||||
* 问 anchor 那块代码:按最近一次发出去的块树找到它,把完整问题和追问的话都交给 CodeQa,接不接着上次的会话由它定。
|
||||
* 找不到这块(代码刚改过、还没重新发)或问不了时,直接回一条失败。
|
||||
*/
|
||||
private ask(askId: string, anchor: string, question: string, resume: string | undefined): void {
|
||||
private ask(askId: string, anchor: string, question: string): void {
|
||||
const at = locate(this.document.uri)
|
||||
const subject = at && this.sent && { path: at.key, languageId: this.document.languageId, ...this.sent, anchor }
|
||||
const prompt = subject && askPrompt(subject, question)
|
||||
const followUp = subject && resume ? followUpPrompt(subject, question) : undefined
|
||||
const refused = prompt === undefined
|
||||
const followUp = subject && followUpPrompt(subject, question)
|
||||
const refused = prompt === undefined || followUp === undefined
|
||||
? '这块代码刚改过,找不到了。等预览刷新后重新点「问 AI」再问。'
|
||||
: this.owner.qa.ask(this.document.uri, { askId, anchor, question, prompt, ...(resume && followUp && { followUp: { sessionId: resume, prompt: followUp } }) })
|
||||
: this.owner.qa.ask(this.document.uri, { askId, anchor, question, prompt, followUp })
|
||||
if (refused !== undefined) {
|
||||
this.post({ type: 'answerEnd', askId, status: 'failed', error: refused })
|
||||
return
|
||||
@@ -252,7 +252,7 @@ class Preview {
|
||||
await this.push()
|
||||
return
|
||||
case 'ask':
|
||||
this.ask(msg.askId, msg.anchor, msg.question, msg.resume)
|
||||
this.ask(msg.askId, msg.anchor, msg.question)
|
||||
return
|
||||
case 'stopAsk':
|
||||
this.owner.qa.stop(msg.askId)
|
||||
|
||||
Reference in new issue
Block a user