mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-05 12:42:30 +00:00
Register previewable artifacts from the tool row, feed a session-scoped store, and render compact rows above the composer. Remove the inline preview card.
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { beforeEach, describe, expect, it } from 'vitest'
|
|
|
|
import {
|
|
$previewStatusBySession,
|
|
clearPreviewArtifacts,
|
|
dismissPreviewArtifact,
|
|
recordPreviewArtifact
|
|
} from './preview-status'
|
|
|
|
beforeEach(() => $previewStatusBySession.set({}))
|
|
|
|
describe('recordPreviewArtifact', () => {
|
|
it('appends new targets newest-last and is idempotent', () => {
|
|
recordPreviewArtifact('s1', '/a/index.html', '/work')
|
|
recordPreviewArtifact('s1', '/a/about.html', '/work')
|
|
recordPreviewArtifact('s1', '/a/index.html', '/work')
|
|
|
|
expect($previewStatusBySession.get().s1.map(i => i.id)).toEqual(['/a/index.html', '/a/about.html'])
|
|
})
|
|
|
|
it('caps the list and derives a label', () => {
|
|
for (const n of [1, 2, 3, 4, 5]) {
|
|
recordPreviewArtifact('s1', `/a/p${n}.html`, '/work')
|
|
}
|
|
|
|
const list = $previewStatusBySession.get().s1
|
|
expect(list).toHaveLength(4)
|
|
expect(list[0].id).toBe('/a/p2.html')
|
|
expect(list[3].label).toBe('p5.html')
|
|
})
|
|
|
|
it('dismiss and clear remove rows', () => {
|
|
recordPreviewArtifact('s1', '/a/index.html', '/work')
|
|
recordPreviewArtifact('s1', '/a/about.html', '/work')
|
|
dismissPreviewArtifact('s1', '/a/index.html')
|
|
expect($previewStatusBySession.get().s1.map(i => i.id)).toEqual(['/a/about.html'])
|
|
|
|
clearPreviewArtifacts('s1')
|
|
expect($previewStatusBySession.get().s1).toBeUndefined()
|
|
})
|
|
})
|