✨ feat(vscode): 文件和文件夹在预览顶部问
侧栏「问 AI」打开代码阅读预览。文件夹是没有代码块的一页,源码文件在整页顶部聊,代码块下面的问答不动。历史按工作区文件夹和相对路径记在窗口状态里,不写进按块存的记录。
This commit is contained in:
1 parent
2be635d1e5
commit
2c10acf9c4
19 files changed
+610
-459
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import type { QaAction, QaState } from './qa'
|
||||
import type { QaMessage, QaThreadView } from './types'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { answerPreview, asksOf, EMPTY_QA, historyOf, qaReducer, relativeTime } from './qa'
|
||||
import { answerPreview, asksOf, EMPTY_QA, historyOf, PATH_ASK_ANCHOR, qaReducer, relativeTime } from './qa'
|
||||
|
||||
const IF = 'function get_user > if @3fa1c2d0'
|
||||
|
||||
@@ -10,7 +10,7 @@ function thread(anchor: string, ...ids: string[]): QaThreadView {
|
||||
}
|
||||
|
||||
function message(threads: QaThreadView[], running: QaMessage['running'] = []): QaMessage {
|
||||
return { type: 'qa', available: true, threads, running }
|
||||
return { type: 'qa', available: true, threads, path: [], subject: 'file', running }
|
||||
}
|
||||
|
||||
function qa(threads: QaThreadView[], running: QaMessage['running'] = []): QaAction {
|
||||
@@ -42,6 +42,24 @@ describe('问 AI 的状态', () => {
|
||||
expect(state.threads).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('顶部的问答记在路径上,不进任何一块的历史', () => {
|
||||
const state = run({
|
||||
type: 'qa',
|
||||
message: {
|
||||
type: 'qa',
|
||||
available: true,
|
||||
threads: [],
|
||||
path: [{ id: 'p', question: '这文件夹干什么', answer: '放源码', createdAt: '2026-09-25T10:00:00.000Z' }],
|
||||
subject: 'folder',
|
||||
running: [],
|
||||
},
|
||||
})
|
||||
expect(state.path.map(entry => entry.id)).toEqual(['p'])
|
||||
expect(state.subject).toBe('folder')
|
||||
expect(historyOf(state, PATH_ASK_ANCHOR).map(entry => entry.id)).toEqual(['p'])
|
||||
expect(historyOf(state, IF)).toEqual([])
|
||||
})
|
||||
|
||||
it('收起就结束这一轮:答完的回到历史,还在答的留着;再展开', () => {
|
||||
let state = run(
|
||||
qa([thread(IF, 'e1')]),
|
||||
|
||||
Reference in new issue
Block a user