✨ feat(vscode): 问 AI 输入框旁边能选 Claude profile,记住上次选的,问答灰字写用哪个 profile 答的
This commit is contained in:
1 parent
1eb42d8389
commit
9efae1f496
20 files changed
+397
-63
No files matched your search
@@ -143,6 +143,10 @@ class Preview {
|
||||
if (uris.some(uri => uri.toString() === document.uri.toString()))
|
||||
this.postQa()
|
||||
}),
|
||||
owner.qa.profiles.subscribe((choice) => {
|
||||
if (this.ready)
|
||||
this.post({ type: 'askProfiles', ...choice })
|
||||
}),
|
||||
owner.qa.onDidAnswer((event) => {
|
||||
if (event.owner !== document.uri.toString() || !this.ready)
|
||||
return
|
||||
@@ -218,18 +222,25 @@ class Preview {
|
||||
this.post(this.owner.qa.view(this.document.uri))
|
||||
}
|
||||
|
||||
/** profile 列表每次现读(同看板),读完页面还在才发。 */
|
||||
private async postProfiles(): Promise<void> {
|
||||
const choice = await this.owner.qa.profiles.choice()
|
||||
if (this.ready)
|
||||
this.post({ type: 'askProfiles', ...choice })
|
||||
}
|
||||
|
||||
/**
|
||||
* 问 anchor 那块代码:按最近一次发出去的块树找到它,把完整问题和追问的话都交给 CodeQa,接不接着上次的会话由它定。
|
||||
* 找不到这块(代码刚改过、还没重新发)或问不了时,直接回一条失败。
|
||||
*/
|
||||
private ask(askId: string, anchor: string, question: string): void {
|
||||
private async ask(askId: string, anchor: string, question: string): Promise<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 && followUpPrompt(subject, question)
|
||||
const refused = prompt === undefined || followUp === undefined
|
||||
? '这块代码刚改过,找不到了。等预览刷新后重新点「问 AI」再问。'
|
||||
: this.owner.qa.ask(this.document.uri, { askId, anchor, question, prompt, followUp })
|
||||
: await 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
|
||||
@@ -249,10 +260,14 @@ class Preview {
|
||||
// 先于文档发:第一份文档按筛选画,不会先整份露出来再藏
|
||||
this.post({ type: 'filter', excluded: this.filter.excluded })
|
||||
this.postQa()
|
||||
void this.postProfiles()
|
||||
await this.push()
|
||||
return
|
||||
case 'ask':
|
||||
this.ask(msg.askId, msg.anchor, msg.question)
|
||||
await this.ask(msg.askId, msg.anchor, msg.question)
|
||||
return
|
||||
case 'selectAskProfile':
|
||||
await this.owner.qa.profiles.select(msg.id)
|
||||
return
|
||||
case 'stopAsk':
|
||||
this.owner.qa.stop(msg.askId)
|
||||
|
||||
Reference in new issue
Block a user