mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-09-09 04:02:35 +00:00
Trajectory 现在通过共享的 ui-attachment 画廊渲染会话日志中的持久化图片引用:ui-conversation 拥有按会话的图片 URL 缓存(ctx.uiConversation.imageUrl),ui-trajectory 声明 conversation.trajectory.images 子槽位,纯图片记录行以图片数量标注,内联 imageSrc 嗅探作为死代码删除。 Closes #2986
53 lines
1.9 KiB
TypeScript
53 lines
1.9 KiB
TypeScript
import { Context } from '@deepseek-ai/cordis'
|
|
import { describe, expect, it } from 'vitest'
|
|
import { SlotRegistry } from '@deepseek-ai/dsh-client-ui-renderer/client'
|
|
import { apply as applyHost } from '../src/index.ts'
|
|
import { apply, inject } from '../src/client/index.ts'
|
|
import { ComposerAttachments } from '../src/client/ComposerAttachments.tsx'
|
|
import { MessageImages } from '../src/client/MessageImages.tsx'
|
|
|
|
async function bench() {
|
|
const ctx = new Context()
|
|
await ctx.plugin(SlotRegistry).await()
|
|
ctx.slots.register({
|
|
name: 'root',
|
|
children: {
|
|
'conversation.input.attachments': { kind: 'single', scope: 'session-maybe' },
|
|
'conversation.message.images': { kind: 'single', scope: 'session' },
|
|
'conversation.trajectory.images': { kind: 'single', scope: 'session' },
|
|
},
|
|
} as never, () => null)
|
|
const fiber = ctx.plugin({ inject: [...inject], apply })
|
|
await fiber.await()
|
|
return { ctx, fiber }
|
|
}
|
|
|
|
describe('attachment plugin', () => {
|
|
it('keeps the host half empty', () => {
|
|
expect(() => { applyHost() }).not.toThrow()
|
|
})
|
|
|
|
it('registers all entries and removes them with the plugin fiber', async () => {
|
|
const { ctx, fiber } = await bench()
|
|
expect(inject).toEqual(['slots'])
|
|
expect(ctx.slots.entries('conversation.input.attachments')).toMatchObject([{
|
|
locale: 'conversation',
|
|
component: ComposerAttachments,
|
|
}])
|
|
expect(ctx.slots.entries('conversation.message.images')).toMatchObject([{
|
|
locale: 'conversation',
|
|
component: MessageImages,
|
|
}])
|
|
expect(ctx.slots.entries('conversation.trajectory.images')).toMatchObject([{
|
|
locale: 'conversation',
|
|
component: MessageImages,
|
|
}])
|
|
|
|
await fiber.dispose()
|
|
|
|
expect(ctx.slots.entries('conversation.input.attachments')).toHaveLength(0)
|
|
expect(ctx.slots.entries('conversation.message.images')).toHaveLength(0)
|
|
expect(ctx.slots.entries('conversation.trajectory.images')).toHaveLength(0)
|
|
})
|
|
})
|