✨ feat(vscode): 新增「了解一块代码」:AI 找功能代码占一栏,对话里接着改
主栏标题栏的放大镜问要了解哪一块,占一个栏位建一栏(和收藏共用 30 个栏位,视图改名 slot1..30,按 slotKindN 分收藏 / 功能挂标题栏按钮),同时开对话页让 Claude 只读地在全部工作区文件夹里找,按 --json-schema 交回环节 → 文件 + 符号 + 一句话。 对话复用预览顶部的聊天(CodeQa.askTop:会话续接、进行中的一轮、记录存 workspaceState);结构不合格算这一轮没答成、留着能再画出来。 条目每次画、点时按眼下的代码找:有语言插件的解析成代码块按「类名.方法名」找,没有的问 VS Code 文档符号;找不到画成灰的。
This commit is contained in:
1 parent
16d27004d8
commit
880bf7fc57
38 files changed
+3386
-378
No files matched your search
@@ -6,7 +6,7 @@ import type { OccurrencePage } from './useOccurrences'
|
||||
import type { ViewState } from './viewState'
|
||||
import { TriangleAlert } from 'lucide-react'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { AskThread } from './AskThread'
|
||||
import { AskThread, FEATURE_THREAD } from './AskThread'
|
||||
import { BlockLevel } from './BlockTree'
|
||||
import { CallTreeDialog } from './CallTreeDialog'
|
||||
import { DefinitionPeekPopup } from './DefinitionPeekPopup'
|
||||
@@ -268,6 +268,7 @@ export function App(): ReactElement | null {
|
||||
asks={asksOf(qa.state, PATH_ASK_ANCHOR)}
|
||||
open
|
||||
hint={qa.state.subject === 'folder' ? '这个文件夹' : '这个文件'}
|
||||
{...(qa.state.subject === 'feature' && { wording: FEATURE_THREAD })}
|
||||
autoFocus={false}
|
||||
focusToken={pathFocus}
|
||||
closable={false}
|
||||
@@ -294,7 +295,7 @@ export function App(): ReactElement | null {
|
||||
</div>
|
||||
)}
|
||||
{doc.blocks.length === 0
|
||||
? doc.error === undefined && qa.state.subject !== 'folder' && <div className="text-[var(--vscode-descriptionForeground)]">这个文件里没有代码。</div>
|
||||
? doc.error === undefined && qa.state.subject === 'file' && <div className="text-[var(--vscode-descriptionForeground)]">这个文件里没有代码。</div>
|
||||
: doc.blocks.some(block => !filter.hidden.has(block.id))
|
||||
? <BlockLevel blocks={doc.blocks} tree={tree} />
|
||||
: <div className="text-[var(--vscode-descriptionForeground)]">所有块都被筛选隐藏了。</div>}
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { ClipboardEvent, DragEvent, KeyboardEvent, ReactElement } from 'rea
|
||||
import type { Ask } from './qa'
|
||||
import type { PendingImage } from './qaImages'
|
||||
import type { ProfileChoice, QaEntryView } from './types'
|
||||
import { ChevronDown, ChevronRight, CircleStop, Hourglass, LoaderCircle, MessageSquareText, SendHorizontal, Sparkles, Trash2, TriangleAlert, X } from 'lucide-react'
|
||||
import { ChevronDown, ChevronRight, CircleStop, Hourglass, LoaderCircle, MessageSquareText, Search, SendHorizontal, Sparkles, Trash2, TriangleAlert, X } from 'lucide-react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { SelectMenu } from '@/components/ui/select-menu'
|
||||
@@ -33,6 +33,17 @@ export const ASK_THREAD: ThreadWording = {
|
||||
answering: '正在回答…',
|
||||
}
|
||||
|
||||
/** 「了解一块代码」的对话页:第一轮是侧栏里问的那句话,输入框里接着说哪里漏了、哪些不相关,AI 改完整栏换成新结果 */
|
||||
export const FEATURE_THREAD: ThreadWording = {
|
||||
label: '了解一块代码',
|
||||
icon: Search,
|
||||
summary: count => `说过 ${count} 次`,
|
||||
deleteLabel: '删除这一轮',
|
||||
placeholder: () => '接着说:还漏了什么、哪些不相关…',
|
||||
inputLabel: '接着说的话',
|
||||
answering: '正在找…',
|
||||
}
|
||||
|
||||
/** 重写注释:第一轮由块右上角的按钮发技能命令,输入框里说的是对这段注释的修改意见 */
|
||||
export const REWRITE_THREAD: ThreadWording = {
|
||||
label: '按注释规范重写',
|
||||
|
||||
@@ -42,8 +42,8 @@ export interface ChatState {
|
||||
export interface QaState extends ChatState {
|
||||
/** 这一页顶部按路径记的问答 */
|
||||
path: QaEntryView[]
|
||||
/** 顶部问的是这个文件还是这个文件夹 */
|
||||
subject: 'file' | 'folder'
|
||||
/** 顶部问的是这个文件、这个文件夹,还是「了解一块代码」找的一个功能 */
|
||||
subject: 'file' | 'folder' | 'feature'
|
||||
/** 输入框旁边的 profile 下拉,所有块共用 */
|
||||
profiles: ProfileChoice
|
||||
}
|
||||
|
||||
@@ -308,8 +308,8 @@ export interface QaMessage {
|
||||
threads: QaThreadView[]
|
||||
/** 这一页顶部、按路径记的问答;不挂在块上 */
|
||||
path: QaEntryView[]
|
||||
/** 顶部问的是这个文件还是这个文件夹 */
|
||||
subject: 'file' | 'folder'
|
||||
/** 顶部问的是这个文件、这个文件夹,还是「了解一块代码」找的一个功能 */
|
||||
subject: 'file' | 'folder' | 'feature'
|
||||
current: AskRound[]
|
||||
/** 块下面的重写记录,按块的记号 */
|
||||
rewrites: QaThreadView[]
|
||||
|
||||
Reference in new issue
Block a user