✨ feat(vscode): 问 AI 和重写注释各用各的 profile,设置里加重写注释默认模型
This commit is contained in:
1 parent
925f1ed39a
commit
b83c445dd0
25 files changed
+363
-111
No files matched your search
@@ -14,7 +14,7 @@ import type { TreeSitterRuntime } from '../runtime'
|
||||
import type { ImportedName, LinkTarget, SymbolNode } from '../symbolLinks'
|
||||
import type { BlockFilter } from './blockFilter'
|
||||
import type { FoundLocation } from './definitions'
|
||||
import type { DefinitionPeek, ExtensionToWebview, Occurrence, Reveal, WebviewToExtension } from './messages'
|
||||
import type { ChatKind, DefinitionPeek, ExtensionToWebview, Occurrence, Reveal, WebviewToExtension } from './messages'
|
||||
import type { TargetSpot } from './openTarget'
|
||||
import type { TopSubject } from './pathPreview'
|
||||
import { realpath } from 'node:fs/promises'
|
||||
@@ -51,6 +51,9 @@ export const PREVIEW_VIEW_TYPE = 'superpowers.codeReader.preview'
|
||||
/** 连续输入时合并成一次重新解析。 */
|
||||
const REFRESH_DELAY_MS = 150
|
||||
|
||||
/** 预览里各有一个 profile 下拉的两种对话 */
|
||||
const CHAT_KINDS: readonly ChatKind[] = ['ask', 'rewrite']
|
||||
|
||||
/**
|
||||
* 一次打开预览带的话:这个标签页是从哪儿打开的(定对比什么);要滚到哪(从文本编辑器切过来时它顶部那一行,或跳到的定义);
|
||||
* 要不要把光标放进顶部「问 AI」输入框(侧栏「问 AI」打开的)。
|
||||
@@ -290,10 +293,10 @@ class Preview {
|
||||
if (uris.some(uri => uri.toString() === this.subject().uri.toString()))
|
||||
this.postQa()
|
||||
}),
|
||||
owner.qa.profiles.subscribe((choice) => {
|
||||
...CHAT_KINDS.map(kind => owner.qa.profiles[kind].subscribe((choice) => {
|
||||
if (this.ready)
|
||||
this.post({ type: 'askProfiles', ...choice })
|
||||
}),
|
||||
this.post({ type: 'profiles', kind, ...choice })
|
||||
})),
|
||||
owner.qa.onDidAnswer((event) => {
|
||||
if (event.owner !== this.subject().uri.toString() || !this.ready)
|
||||
return
|
||||
@@ -546,11 +549,11 @@ class Preview {
|
||||
this.post({ type: 'focusPathAsk' })
|
||||
}
|
||||
|
||||
/** profile 列表每次现读(同看板),读完页面还在才发。 */
|
||||
private async postProfiles(): Promise<void> {
|
||||
const choice = await this.owner.qa.profiles.choice()
|
||||
/** kind 那种对话的 profile 列表每次现读(同看板),读完页面还在才发。 */
|
||||
private async postProfiles(kind: ChatKind): Promise<void> {
|
||||
const choice = await this.owner.qa.profiles[kind].choice()
|
||||
if (this.ready)
|
||||
this.post({ type: 'askProfiles', ...choice })
|
||||
this.post({ type: 'profiles', kind, ...choice })
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -601,7 +604,8 @@ class Preview {
|
||||
this.postHoverDelay()
|
||||
this.postStickyScroll()
|
||||
this.postQa()
|
||||
void this.postProfiles()
|
||||
for (const kind of CHAT_KINDS)
|
||||
void this.postProfiles(kind)
|
||||
await this.push()
|
||||
if (this.pendingPathFocus)
|
||||
this.focusPathAsk()
|
||||
@@ -609,13 +613,13 @@ class Preview {
|
||||
case 'ask':
|
||||
await this.ask(msg.askId, msg.anchor, msg.question, msg.images)
|
||||
return
|
||||
case 'selectAskProfile':
|
||||
case 'selectProfile':
|
||||
try {
|
||||
await this.owner.qa.profiles.select(msg.id)
|
||||
await this.owner.qa.profiles[msg.kind].select(msg.id)
|
||||
}
|
||||
catch (err) {
|
||||
void window.showErrorMessage(err instanceof Error ? err.message : String(err))
|
||||
await this.postProfiles()
|
||||
await this.postProfiles(msg.kind)
|
||||
}
|
||||
return
|
||||
case 'stopAsk':
|
||||
|
||||
Reference in new issue
Block a user