✨ feat(vscode): 问 AI 收起再展开、重启后接着这块最近的会话问;代码改了对不上的问答不再显示
This commit is contained in:
1 parent
cbe447ade8
commit
f0a3ad80e1
16 files changed
+82
-211
No files matched your search
@@ -4,7 +4,7 @@ import * as os from 'node:os'
|
||||
import * as path from 'node:path'
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
||||
import { dropEntries, moveEntries, readPathMap, writePathMap } from '../pathMap'
|
||||
import { QA_FILE, withEntry, withoutEntry } from './qaMap'
|
||||
import { latestSession, QA_FILE, withEntry, withoutEntry } from './qaMap'
|
||||
|
||||
function entry(id: string, createdAt: string, question = `问 ${id}`): QaEntry {
|
||||
return { id, question, answer: `答 ${id}`, createdAt, sessionId: `s-${id}` }
|
||||
@@ -67,6 +67,24 @@ describe('记一次、删一次', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('再问时接着哪个会话', () => {
|
||||
it('接着这块最近一次问答的会话;别的块、没问过的块、没记会话 id 的都重新开', () => {
|
||||
let map: QaMap = {}
|
||||
map = withEntry(map, 'a.py', IF, entry('new', '2026-09-26T10:00:00.000Z'))
|
||||
map = withEntry(map, 'a.py', IF, entry('old', '2026-09-25T10:00:00.000Z'))
|
||||
map = withEntry(map, 'a.py', DISPLAY, { ...entry('bare', '2026-09-26T11:00:00.000Z'), sessionId: '' })
|
||||
expect(latestSession(map['a.py'], IF)).toBe('s-new')
|
||||
expect(latestSession(map['a.py'], DISPLAY)).toBeUndefined()
|
||||
expect(latestSession(map['a.py'], 'function gone')).toBeUndefined()
|
||||
expect(latestSession(undefined, IF)).toBeUndefined()
|
||||
})
|
||||
|
||||
it('删掉最近那次,就接着剩下里最近的', () => {
|
||||
const map = withEntry(withEntry({}, 'a.py', IF, entry('a', '2026-09-25T10:00:00.000Z')), 'a.py', IF, entry('b', '2026-09-26T10:00:00.000Z'))
|
||||
expect(latestSession(withoutEntry(map, 'a.py', IF, 'b')['a.py'], IF)).toBe('s-a')
|
||||
})
|
||||
})
|
||||
|
||||
describe('读写 .spx/code-qa.json', () => {
|
||||
it('文件不存在、解析失败、不是对象都当没有', async () => {
|
||||
expect(await readPathMap(root, QA_FILE)).toEqual({})
|
||||
|
||||
Reference in new issue
Block a user