feat(ui): add trajectory inspection ledger

This commit is contained in:
_Kerman
2026-07-27 15:47:44 +08:00
parent 79eb3a9035
commit 628c1bffe0
42 changed files with 4549 additions and 178 deletions

View File

@@ -124,17 +124,24 @@ describe('web e2e: navigation & panes over a rich seeded session', () => {
await expect.poll(() => page.locator('[role="treeitem"]').count(), { timeout: 10_000 }).toBeGreaterThanOrEqual(1)
}, 60_000)
it.skipIf(MODE === 'record')('renders the trajectory tab with turn sections and step cells', async () => {
it.skipIf(MODE === 'record')('renders the trajectory ledger and opens its local record inspector', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-navigation-trajectory'))
await page.getByRole('tab', { name: 'Trajectory' }).click()
// Two sticky turn sections; turn 1's step group summarizes its tool mix
// (bash + the two parallel reads collapse to 'bash read×2').
await expect.poll(() => page.getByText('Turn 1', { exact: true }).count(), { timeout: 15_000 }).toBe(1)
await expect.poll(() => page.getByText('Turn 2', { exact: true }).count(), { timeout: 10_000 }).toBe(1)
await expect.poll(() => page.getByText('bash read×2', { exact: false }).count(), { timeout: 10_000 }).toBe(1)
// Thick row rules mark the two turns; compact inline markers identify
// each step without introducing dedicated group rows.
await expect.poll(() => page.locator('tr[data-turn-start="true"]').count(), { timeout: 15_000 }).toBe(2)
await expect.poll(() => page.locator('[aria-label^="Step "]').count(), { timeout: 10_000 }).toBe(3)
await expect.poll(() => page.getByRole('columnheader', { name: 'Tokens' }).count(), { timeout: 10_000 }).toBe(0)
await expect.poll(() => page.getByRole('columnheader', { name: '耗时' }).count(), { timeout: 10_000 }).toBe(0)
await page.locator('tr[data-kind="tool"]').first().click()
await expect.poll(() => page.getByRole('complementary', { name: '记录详情' }).count(), { timeout: 10_000 }).toBe(1)
await page.getByRole('tab', { name: '输出' }).click()
await expect.poll(() => page.getByText('NAVIGATION_OK', { exact: false }).count(), { timeout: 10_000 }).toBeGreaterThanOrEqual(1)
const snapshot = (await captureStableAria(page, '[class*="viewArea"]', scaffold.workspaceCwd))
.split(SEED_ID).join('{{seededId}}')
await compareOrRefreshGolden(TRAJECTORY_EXPECTED, snapshot, MODE)
await page.getByRole('complementary', { name: '记录详情' })
.getByRole('button', { name: '关闭详情' }).click()
}, 60_000)
it.skipIf(MODE === 'record')('renders the waterfall tab with span stats and one lane per span', async () => {

View File

@@ -1 +1,57 @@
- text: "Turn 1 Message {{duration}} #1 User NavScenario: first run bash to print exactly NAVIGATION_OK, then read nav-a.md and nav-b.md using two read calls in ONE assistant message, then reply with the single word FIRST_DONE and stop. +{{duration}} Step 1 {{duration}} bash read×2 #2 Tool bash · {\"command\": \"echo NAVIGATION_OK\", \"description\": \"Print NAVIGATION_OK\"} +{{duration}} #3 Tool read · {\"file_path\": \"nav-a.md\"} +{{duration}} #4 Tool read · {\"file_path\": \"nav-b.md\"} +{{duration}} Step 2 {{duration}} #5 Message FIRST_DONE 349 56 51 +{{duration}} Turn 2 Message {{duration}} #6 User Reply in markdown with: a level-2 heading \"Navigation Summary\", a bulleted list of exactly two items, and a fenced code block containing echo WATERFALL. Then stop. +{{duration}} Step 1 {{duration}} #7 Message ## Navigation Summary - alpha nav - beta nav ``` echo WATERFALL ``` 141 36 16 +{{duration}}"
- toolbar "轨迹工具栏":
- text: 轨迹
- strong: "8"
- text: 条记录
- strong: "2"
- text: 轮
- strong: "3"
- text: 次工具
- button "收起记录"
- table:
- rowgroup:
- row "# 事件 内容":
- columnheader "#"
- columnheader "事件"
- columnheader "内容"
- rowgroup:
- 'row "记录 1USERNavScenario: first run bash to print exactly NAVIGATION_OK, then read nav-a.md and nav-b.md using two read calls in ONE assistant message, then reply with the single word FIRST_DONE and stop."':
- cell "#1"
- cell "USER"
- 'cell "NavScenario: first run bash to print exactly NAVIGATION_OK, then read nav-a.md and nav-b.md using two read calls in ONE assistant message, then reply with the single word FIRST_DONE and stop."'
- row "记录 2ASSISTANT请求调用 bash、read×2":
- cell "#2"
- cell "Step 1 ASSISTANT": S1 ASSISTANT
- cell "请求调用 bash、read×2"
- 'row "记录 3TOOLbash · {\"command\": \"echo NAVIGATION_OK\", \"description\": \"Print NAVIGATION_OK\"}" [selected]':
- cell "#3"
- cell "TOOL"
- 'cell "bash · {\"command\": \"echo NAVIGATION_OK\", \"description\": \"Print NAVIGATION_OK\"}→NAVIGATION_OK"'
- 'row "记录 4TOOLread · {\"file_path\": \"nav-a.md\"}"':
- cell "#4"
- cell "TOOL"
- 'cell "read · {\"file_path\": \"nav-a.md\"}→<path>{{cwd}}/nav-a.md</path> <type>file</type> <content> 1: # alpha nav (End of file - total 1 lines) </content>"'
- 'row "记录 5TOOLread · {\"file_path\": \"nav-b.md\"}"':
- cell "#5"
- cell "TOOL"
- 'cell "read · {\"file_path\": \"nav-b.md\"}→<path>{{cwd}}/nav-b.md</path> <type>file</type> <content> 1: # beta nav (End of file - total 1 lines) </content>"'
- row "记录 6ASSISTANTFIRST_DONE":
- cell "#6"
- cell "Step 2 ASSISTANT": S2 ASSISTANT
- cell "FIRST_DONE"
- 'row "记录 7USERReply in markdown with: a level-2 heading \"Navigation Summary\", a bulleted list of exactly two items, and a fenced code block containing echo WATERFALL. Then stop."':
- cell "#7"
- cell "USER"
- 'cell "Reply in markdown with: a level-2 heading \"Navigation Summary\", a bulleted list of exactly two items, and a fenced code block containing echo WATERFALL. Then stop."'
- 'row "记录 8ASSISTANT## Navigation Summary - alpha nav - beta nav ``` echo WATERFALL ```"':
- cell "#8"
- cell "Step 1 ASSISTANT": S1 ASSISTANT
- 'cell "## Navigation Summary - alpha nav - beta nav ``` echo WATERFALL ```"'
- complementary "记录详情":
- text: "TOOL 记录 #3 Turn 1 · Step 1"
- button "关闭详情"
- tablist "记录详情":
- tab "概览"
- tab "输入"
- tab "输出" [selected]
- tab "计时"
- tabpanel "输出": NAVIGATION_OK