Why: reproduced with headless Chromium - clicking an artifact row with no conversation selected closed the workspace overlay and nothing else appeared. requestPreview stores tabs under currentConvId ?? '_' while the render side required a non-null currentConvId, so the preview pane never mounted in the empty state. The empty state was itself a trap: currentConvId was not persisted, so every reload landed there. Evidence: vitest 85/85 (new preview-empty-state tests for the key contract and orphan-tab merge); browser replay on the fixed build shows the preview pane mounting with rendered docx content from the empty state and the conversation restoring after reload (screenshots in the Dev task card). Impact: previewTabsKey() unifies the read/write key; entering a conversation adopts orphan '_' tabs; the last conversation id persists and restores once on boot; deliverable cards toast when the artifact is gone instead of silently doing nothing. Refs: Dev task feature/empty-state-preview-fix; diagnosis session 2026-10-10.
31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
// 空态点工件无反应(2026-10-10 实测复现):requestPreview 写 '_' 键、渲染判
|
|
// currentConvId 非空——键口径不一致导致空态点击只剩弹层关闭。这里测纯函数口径。
|
|
import { describe, expect, it } from 'vitest'
|
|
import { mergeOrphanPreviewTabs, previewTabsKey } from '../src/previewtabs'
|
|
|
|
describe('previewTabsKey', () => {
|
|
it('falls back to the empty-state key when no conversation is selected', () => {
|
|
expect(previewTabsKey(null)).toBe('_')
|
|
expect(previewTabsKey(undefined)).toBe('_')
|
|
expect(previewTabsKey('cnv_1')).toBe('cnv_1')
|
|
})
|
|
})
|
|
|
|
describe('mergeOrphanPreviewTabs', () => {
|
|
it('merges empty-state tabs into the conversation key and clears the orphan key', () => {
|
|
const got = mergeOrphanPreviewTabs({
|
|
_: [{ id: 'a', name: 'A.docx' }, { id: 'b', name: 'B.md' }],
|
|
cnv_1: [{ id: 'b', name: 'B.md' }],
|
|
}, 'cnv_1')
|
|
expect(got._).toEqual([])
|
|
expect(got.cnv_1.map(t => t.id)).toEqual(['b', 'a'])
|
|
})
|
|
|
|
it('returns the input untouched when there is no orphan or the target is the orphan key', () => {
|
|
const none = { cnv_1: [{ id: 'a', name: 'A' }] }
|
|
expect(mergeOrphanPreviewTabs(none, 'cnv_1')).toBe(none)
|
|
const self = { _: [{ id: 'a', name: 'A' }] }
|
|
expect(mergeOrphanPreviewTabs(self, '_')).toBe(self)
|
|
})
|
|
})
|