test(tui): replay recorded sessions through real tools

This commit is contained in:
Tianyi Cui
2026-07-19 01:31:55 +08:00
parent bea6a74ea0
commit e68cef1be1
32 changed files with 1874 additions and 488 deletions

View File

@@ -1,50 +0,0 @@
terminal 96x36 buffer=normal length=36 base=0 viewport=0
lifecycle started=1 stopped=0 progress=inactive
title "DSH snapshot"
cursor hidden column=1 viewportRow=14 bufferRow=14
buffer
0| "╭──────────────────────────────────────────────────────────────────────────────────────────────╮"
style 0-95 fg=bright-blue
1| "│ DEEPSEEK HARNESS │"
style 0-0 fg=bright-blue
style 2-9 fg=bright-blue bold
style 11-17 bold
style 95-95 fg=bright-blue
2| "│ Snapshot agent ready. │"
style 0-0 fg=bright-blue
style 2-22 fg=bright-black
style 95-95 fg=bright-blue
3| "│ main • deepseek-v4-flash • main-session │"
style 0-0 fg=bright-blue
style 2-44 dim
style 95-95 fg=bright-blue
4| "╰──────────────────────────────────────────────────────────────────────────────────────────────╯"
style 0-95 fg=bright-blue
5| <blank>
6| "▌ "
style 0-0 fg=green
7| "▌ ✓ const first = await tools.bash({ command: 'echo CODE_ONE' }) "
style 0-0 fg=green
style 2-2 fg=green bold
style 3-95 bold
8| "▌ const second = await tools.bas "
style 0-0 fg=green
style 2-31 bold
9| "▌ CODE_ONE "
style 0-0 fg=green
10| "▌ CODE_TWO "
style 0-0 fg=green
11| "▌ combined: CODE_ONE+CODE_TWO "
style 0-0 fg=green
12| "▌ "
style 0-0 fg=green
13| "────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-95 dim
14| " "
style 1-1 inverse
15| "────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-95 dim
16| "/workspace/project ↑0 ↓0 idle reasoning:on tools:compact"
style 0-24 dim
style 63-95 dim
17-35| <blank>

View File

@@ -1,75 +0,0 @@
terminal 96x36 buffer=normal length=43 base=7 viewport=7
lifecycle started=1 stopped=0 progress=inactive
title "DSH snapshot"
cursor hidden column=1 viewportRow=33 bufferRow=40
viewport
7| "▌ You "
style 0-0 fg=bright-blue
style 2-4 fg=bright-blue bold
8| "▌ Explain snapshot fidelity with cells. "
style 0-0 fg=bright-blue
style 10-26 bold
style 33-37 fg=cyan
9| "▌ "
style 0-0 fg=bright-blue
10| <blank>
11| " Reasoning "
style 1-9 fg=bright-black italic
12| " Compare the terminal state, not write fragments. "
style 1-48 fg=bright-black italic
13| <blank>
14| " Assistant "
style 1-9 fg=bright-magenta bold
15| " Result "
style 1-6 fg=bright-blue bold
16| " "
17| " - final viewport "
style 1-2 fg=bright-blue
18| " - semantic styles "
style 1-2 fg=bright-blue
19| " "
20| " │ deterministic and reviewable "
style 1-2 fg=bright-magenta
style 3-30 fg=bright-black italic
21| <blank>
22| "▌ "
style 0-0 fg=bright-blue
23| "▌ You "
style 0-0 fg=bright-blue
style 2-4 fg=bright-blue bold
24| "▌ Show the live update. "
style 0-0 fg=bright-blue
25| "▌ "
style 0-0 fg=bright-blue
26| <blank>
27| " Reasoning "
style 1-9 fg=bright-black italic
28| " Inspecting width and styles. "
style 1-28 fg=bright-black italic
29| <blank>
30| " Assistant "
style 1-9 fg=bright-magenta bold
31| " Streaming visible state is complete. "
style 11-23 bold
32| <blank>
33| " The model reached its output-token limit. "
style 1-41 fg=yellow
34| <blank>
35| "Plan"
style 0-3 fg=bright-blue bold
36| " ✓ model the terminal"
style 2-2 fg=green
style 4-21 fg=bright-black
37| " ● capture advanced states"
style 2-2 fg=yellow
38| " ○ verify PTY cleanup"
style 2-2 dim
39| "────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-95 dim
40| " "
style 1-1 inverse
41| "────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-95 dim
42| "/workspace/project ↑13k ↓760 idle reasoning:on tools:compact"
style 0-28 dim
style 63-95 dim

View File

@@ -1,73 +0,0 @@
terminal 96x36 buffer=normal length=36 base=0 viewport=0
lifecycle started=1 stopped=0 progress=inactive
title "DSH snapshot"
cursor hidden column=1 viewportRow=27 bufferRow=27
viewport
0| "╭──────────────────────────────────────────────────────────────────────────────────────────────╮"
style 0-95 fg=bright-blue
1| "│ DEEPSEEK HARNESS │"
style 0-0 fg=bright-blue
style 2-9 fg=bright-blue bold
style 11-17 bold
style 95-95 fg=bright-blue
2| "│ Snapshot agent ready. │"
style 0-0 fg=bright-blue
style 2-22 fg=bright-black
style 95-95 fg=bright-blue
3| "│ main • deepseek-v4-flash • main-session │"
style 0-0 fg=bright-blue
style 2-44 dim
style 95-95 fg=bright-blue
4| "╰──────────────────────────────────────────────────────────────────────────────────────────────╯"
style 0-95 fg=bright-blue
5| <blank>
6| "▌ "
style 0-0 fg=bright-blue
7| "▌ You "
style 0-0 fg=bright-blue
style 2-4 fg=bright-blue bold
8| "▌ Explain snapshot fidelity with cells. "
style 0-0 fg=bright-blue
style 10-26 bold
style 33-37 fg=cyan
9| "▌ "
style 0-0 fg=bright-blue
10| <blank>
11| " Reasoning "
style 1-9 fg=bright-black italic
12| " Compare the terminal state, not write fragments. "
style 1-48 fg=bright-black italic
13| <blank>
14| " Assistant "
style 1-9 fg=bright-magenta bold
15| " Result "
style 1-6 fg=bright-blue bold
16| " "
17| " - final viewport "
style 1-2 fg=bright-blue
18| " - semantic styles "
style 1-2 fg=bright-blue
19| " "
20| " │ deterministic and reviewable "
style 1-2 fg=bright-magenta
style 3-30 fg=bright-black italic
21| <blank>
22| "Plan"
style 0-3 fg=bright-blue bold
23| " ✓ model the terminal"
style 2-2 fg=green
style 4-21 fg=bright-black
24| " ● capture advanced states"
style 2-2 fg=yellow
25| " ○ verify PTY cleanup"
style 2-2 dim
26| "────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-95 dim
27| " "
style 1-1 inverse
28| "────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-95 dim
29| "/workspace/project ↑13k ↓640 idle reasoning:on tools:compact"
style 0-28 dim
style 63-95 dim
30-35| <blank>

View File

@@ -1,75 +1,52 @@
terminal 96x36 buffer=normal length=41 base=5 viewport=5
terminal 96x36 buffer=normal length=36 base=0 viewport=0
lifecycle started=1 stopped=0 progress=inactive
title "DSH snapshot"
cursor hidden column=1 viewportRow=33 bufferRow=38
cursor hidden column=1 viewportRow=17 bufferRow=17
viewport
0| "╭──────────────────────────────────────────────────────────────────────────────────────────────╮"
style 0-95 fg=bright-blue
1| "│ DEEPSEEK HARNESS │"
style 0-0 fg=bright-blue
style 2-9 fg=bright-blue bold
style 11-17 bold
style 95-95 fg=bright-blue
2| "│ Snapshot agent ready. │"
style 0-0 fg=bright-blue
style 2-22 fg=bright-black
style 95-95 fg=bright-blue
3| "│ main • deepseek-v4-flash • main-session │"
style 0-0 fg=bright-blue
style 2-44 dim
style 95-95 fg=bright-blue
4| "╰──────────────────────────────────────────────────────────────────────────────────────────────╯"
style 0-95 fg=bright-blue
5| <blank>
6| "▌ "
style 0-0 fg=bright-blue
7| "▌ You "
style 0-0 fg=bright-blue
style 2-4 fg=bright-blue bold
8| "▌ Explain snapshot fidelity with cells. "
8| "▌ Show the live update. "
style 0-0 fg=bright-blue
style 10-26 bold
style 33-37 fg=cyan
9| "▌ "
style 0-0 fg=bright-blue
10| <blank>
11| " Reasoning "
style 1-9 fg=bright-black italic
12| " Compare the terminal state, not write fragments. "
style 1-48 fg=bright-black italic
12| " Inspecting width and styles. "
style 1-28 fg=bright-black italic
13| <blank>
14| " Assistant "
style 1-9 fg=bright-magenta bold
15| " Result "
style 1-6 fg=bright-blue bold
16| " "
17| " - final viewport "
style 1-2 fg=bright-blue
18| " - semantic styles "
style 1-2 fg=bright-blue
19| " "
20| " │ deterministic and reviewable "
style 1-2 fg=bright-magenta
style 3-30 fg=bright-black italic
21| <blank>
22| "▌ "
style 0-0 fg=bright-blue
23| "▌ You "
style 0-0 fg=bright-blue
style 2-4 fg=bright-blue bold
24| "▌ Show the live update. "
style 0-0 fg=bright-blue
25| "▌ "
style 0-0 fg=bright-blue
26| <blank>
27| " Reasoning "
style 1-9 fg=bright-black italic
28| " Inspecting width and styles. "
style 1-28 fg=bright-black italic
29| <blank>
30| " Assistant "
style 1-9 fg=bright-magenta bold
31| " Streaming visible state… "
15| " Streaming visible state… "
style 11-23 bold
32| <blank>
33| "Plan"
style 0-3 fg=bright-blue bold
34| " ✓ model the terminal"
style 2-2 fg=green
style 4-21 fg=bright-black
35| " ● capture advanced states"
style 2-2 fg=yellow
36| " ○ verify PTY cleanup"
style 2-2 dim
37| "────────────────────────────────────────────────────────────────────────────────────────────────"
16| "────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-95 dim
38| " "
17| " "
style 1-1 inverse
39| "────────────────────────────────────────────────────────────────────────────────────────────────"
18| "────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-95 dim
40| "/workspace/project ↑13k ↓640 idle reasoning:on tools:compact"
style 0-28 dim
19| "/workspace/project ↑0 ↓0 idle reasoning:on tools:compact"
style 0-24 dim
style 63-95 dim
20-35| <blank>

View File

@@ -1,73 +0,0 @@
terminal 96x36 buffer=normal length=36 base=0 viewport=0
lifecycle started=1 stopped=0 progress=inactive
title "DSH snapshot"
cursor hidden column=1 viewportRow=25 bufferRow=25
buffer
0| "╭──────────────────────────────────────────────────────────────────────────────────────────────╮"
style 0-95 fg=bright-blue
1| "│ DEEPSEEK HARNESS │"
style 0-0 fg=bright-blue
style 2-9 fg=bright-blue bold
style 11-17 bold
style 95-95 fg=bright-blue
2| "│ Snapshot agent ready. │"
style 0-0 fg=bright-blue
style 2-22 fg=bright-black
style 95-95 fg=bright-blue
3| "│ main • deepseek-v4-flash • main-session │"
style 0-0 fg=bright-blue
style 2-44 dim
style 95-95 fg=bright-blue
4| "╰──────────────────────────────────────────────────────────────────────────────────────────────╯"
style 0-95 fg=bright-blue
5| <blank>
6| "▌ "
style 0-0 fg=green
7| "▌ ✓ Inspect cordis runtime: tools "
style 0-0 fg=green
style 2-2 fg=green bold
style 3-32 bold
8| "▌ ## tools "
style 0-0 fg=green
9| "▌ run_code "
style 0-0 fg=green
10| "▌ workflow "
style 0-0 fg=green
11| "▌ cordis_mount "
style 0-0 fg=green
12| "▌ cordis_unmount "
style 0-0 fg=green
13| "▌ "
style 0-0 fg=green
14| <blank>
15| "▌ "
style 0-0 fg=green
16| "▌ ✓ Mount plugin into live cordis runtime "
style 0-0 fg=green
style 2-2 fg=green bold
style 3-40 bold
17| "▌ mounted dyn-1 (plugin \"snapshot-marker\", state: active) "
style 0-0 fg=green
18| "▌ "
style 0-0 fg=green
19| <blank>
20| "▌ "
style 0-0 fg=green
21| "▌ ✓ Unmount dyn-1 "
style 0-0 fg=green
style 2-2 fg=green bold
style 3-16 bold
22| "▌ unmounted dyn-1 (plugin \"snapshot-marker\") "
style 0-0 fg=green
23| "▌ "
style 0-0 fg=green
24| "────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-95 dim
25| " "
style 1-1 inverse
26| "────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-95 dim
27| "/workspace/project ↑0 ↓0 idle reasoning:on tools:compact"
style 0-24 dim
style 63-95 dim
28-35| <blank>

View File

@@ -1,53 +0,0 @@
terminal 96x36 buffer=normal length=36 base=0 viewport=0
lifecycle started=1 stopped=0 progress=inactive
title "DSH snapshot"
cursor hidden column=1 viewportRow=16 bufferRow=16
buffer
0| "╭──────────────────────────────────────────────────────────────────────────────────────────────╮"
style 0-95 fg=bright-blue
1| "│ DEEPSEEK HARNESS │"
style 0-0 fg=bright-blue
style 2-9 fg=bright-blue bold
style 11-17 bold
style 95-95 fg=bright-blue
2| "│ Snapshot agent ready. │"
style 0-0 fg=bright-blue
style 2-22 fg=bright-black
style 95-95 fg=bright-blue
3| "│ main • deepseek-v4-flash • main-session │"
style 0-0 fg=bright-blue
style 2-44 dim
style 95-95 fg=bright-blue
4| "╰──────────────────────────────────────────────────────────────────────────────────────────────╯"
style 0-95 fg=bright-blue
5| <blank>
6| "▌ "
style 0-0 fg=green
7| "▌ ✓ workflow: tui-matrix "
style 0-0 fg=green
style 2-2 fg=green bold
style 3-23 bold
8| "▌ workflow \"tui-matrix\" completed (2 agents). "
style 0-0 fg=green
9| "▌ Return value: "
style 0-0 fg=green
10| "▌ { "
style 0-0 fg=green
11| "▌ \"reports\": [\"layout ok\", \"lifecycle ok\"], "
style 0-0 fg=green
12| "▌ \"verdict\": \"covered\" "
style 0-0 fg=green
13| "▌ } "
style 0-0 fg=green
14| "▌ "
style 0-0 fg=green
15| "────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-95 dim
16| " "
style 1-1 inverse
17| "────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-95 dim
18| "/workspace/project ↑0 ↓0 idle reasoning:on tools:compact"
style 0-24 dim
style 63-95 dim
19-35| <blank>

View File

@@ -23,15 +23,10 @@ const SNAPSHOTS_DIR = join(dirname(fileURLToPath(import.meta.url)), 'snapshots')
const REFRESHING = process.env.DSH_SNAPSHOT === 'refresh'
const CHECKPOINTS = [
'conversation-replay',
'conversation-streaming',
'conversation-complete',
'code-mode-pending',
'code-mode-complete',
'dynamic-workflow-pending',
'dynamic-workflow-complete',
'cordis-tools-pending',
'cordis-tools-complete',
'advanced-cards-collapsed',
'advanced-cards-expanded',
'question-dialog',
@@ -194,25 +189,8 @@ const ADVANCED_CARD_TOOLS: Record<string, ToolDefinition> = {
}
describe('TUI terminal-state snapshots', () => {
it('pins resumed conversation, streaming, completion, plans, tokens, and Markdown', async () => {
const harness = await setupSnapshot({
beforeMount(session) {
appendUser(session, 'Explain **snapshot fidelity** with `cells`.')
appendAssistant(session, [
{ type: 'reasoning', text: 'Compare the terminal state, not write fragments.' },
{ type: 'text', text: '## Result\n\n- final viewport\n- semantic styles\n\n> deterministic and reviewable' },
], { inputTokens: 12_500, outputTokens: 640 })
session.append('todo/write', {
todos: [
{ content: 'model the terminal', status: 'completed' },
{ content: 'capture advanced states', status: 'in_progress' },
{ content: 'verify PTY cleanup', status: 'pending' },
],
})
},
})
await checkpoint('conversation-replay', harness.terminal)
it('pins an in-flight reasoning and Markdown stream', async () => {
const harness = await setupSnapshot()
await renderAfter(harness, () => {
appendUser(harness.session, 'Show the live update.')
harness.session.append('assistant/chunk', {
@@ -237,15 +215,6 @@ describe('TUI terminal-state snapshots', () => {
})
})
await checkpoint('conversation-streaming', harness.terminal)
await renderAfter(harness, () => {
appendAssistant(harness.session, [
{ type: 'reasoning', text: 'Inspecting width and styles.' },
{ type: 'text', text: 'Streaming **visible state** is complete.' },
], { inputTokens: 800, outputTokens: 120 })
harness.session.append('turn/end', { turn: 2, reason: { kind: 'max-tokens' } })
})
await checkpoint('conversation-complete', harness.terminal)
await disposeSnapshot(harness)
})
@@ -260,13 +229,6 @@ describe('TUI terminal-state snapshots', () => {
}
await renderAfter(harness, () => { appendToolCalls(harness.session, [call]) })
await checkpoint('code-mode-pending', harness.terminal, { includeScrollback: true })
await renderAfter(harness, () => {
appendToolResult(harness.session, call.id, [{ type: 'text', text: 'CODE_ONE\n+CODE_TWO' }], {
meta: { logs: ['CODE_ONE', 'CODE_TWO', 'combined: CODE_ONE+CODE_TWO'] },
})
})
await checkpoint('code-mode-complete', harness.terminal, { includeScrollback: true })
await disposeSnapshot(harness)
})
@@ -290,14 +252,6 @@ describe('TUI terminal-state snapshots', () => {
}
await renderAfter(harness, () => { appendToolCalls(harness.session, [call]) })
await checkpoint('dynamic-workflow-pending', harness.terminal, { includeScrollback: true })
await renderAfter(harness, () => {
appendToolResult(harness.session, call.id, [{
type: 'text',
text: 'workflow "tui-matrix" completed (2 agents).\nReturn value:\n{\n "reports": ["layout ok", "lifecycle ok"],\n "verdict": "covered"\n}',
}])
})
await checkpoint('dynamic-workflow-complete', harness.terminal, { includeScrollback: true })
await disposeSnapshot(harness)
})
@@ -314,13 +268,6 @@ describe('TUI terminal-state snapshots', () => {
]
await renderAfter(harness, () => { appendToolCalls(harness.session, calls) })
await checkpoint('cordis-tools-pending', harness.terminal, { includeScrollback: true })
await renderAfter(harness, () => {
appendToolResult(harness.session, 'cordis-1', [{ type: 'text', text: '## tools\nrun_code\nworkflow\ncordis_mount\ncordis_unmount' }])
appendToolResult(harness.session, 'cordis-2', [{ type: 'text', text: 'mounted dyn-1 (plugin "snapshot-marker", state: active)' }])
appendToolResult(harness.session, 'cordis-3', [{ type: 'text', text: 'unmounted dyn-1 (plugin "snapshot-marker")' }])
})
await checkpoint('cordis-tools-complete', harness.terminal, { includeScrollback: true })
await disposeSnapshot(harness)
})