From 9af9222871ead15b64871b8d57e7dba3f351c9bf Mon Sep 17 00:00:00 2001 From: Turtle Date: Thu, 30 Jul 2026 15:35:21 +0800 Subject: [PATCH] test(tui): stabilize workdir snapshot output --- .../source-checkout-workdir/terminal.expected.txt | 4 ++-- examples/tui-agent/tests/tui.snapshot.ts | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/examples/tui-agent/tests/snapshots/source-checkout-workdir/terminal.expected.txt b/examples/tui-agent/tests/snapshots/source-checkout-workdir/terminal.expected.txt index 81103c12bd..b9ecb5a553 100644 --- a/examples/tui-agent/tests/snapshots/source-checkout-workdir/terminal.expected.txt +++ b/examples/tui-agent/tests/snapshots/source-checkout-workdir/terminal.expected.txt @@ -26,8 +26,8 @@ buffer style 0-46 fg=green 12| "$ pwd " style 0-4 dim -13| "/workspace/project " - style 0-59 dim +13| "/workspace/project " + style 0-17 dim 14| "[exit 0] " style 0-7 dim 15| "Model wait 0.0s ยท Completed 2026-07-21 12:00:00 " diff --git a/examples/tui-agent/tests/tui.snapshot.ts b/examples/tui-agent/tests/tui.snapshot.ts index b96aaaf691..81cdfd6f22 100644 --- a/examples/tui-agent/tests/tui.snapshot.ts +++ b/examples/tui-agent/tests/tui.snapshot.ts @@ -56,6 +56,8 @@ interface Scenario { seedWorkspace?: boolean /** Add the launcher's model-visible DSH source checkout at this fixed path. */ harnessSourceRoot?: string + /** Replace the real `pwd` result with a portable fixed-length workspace path. */ + normalizePwdResult?: boolean /** * Load the opt-in `todo_write` tool for this scenario. The shipped tui-agent * config omits it, so only the todo-plan scenario (the enabled-path proof) @@ -103,6 +105,7 @@ const SCENARIOS: Scenario[] = [ expectedTools: ['bash'], recorded: true, harnessSourceRoot: '/opt/dsh-source', + normalizePwdResult: true, }, { name: 'parallel-file-reads', @@ -323,6 +326,14 @@ async function runScenario(scenario: Scenario): Promise { await cp(source, cwd, { recursive: true }) } ctx = await mountScenarioContext(scenario, cwd, displayCwd, fixtureFile, childFiles, replayRoot) + if (scenario.normalizePwdResult === true) { + ctx.on('tools/post-execute', async (exec, result, next) => { + const args = exec.arguments as { command?: unknown } + return exec.name === 'bash' && args.command === 'pwd' && !result.isError + ? { kind: 'accept', content: [{ type: 'text', text: '/workspace/project\n' }] } + : next() + }) + } const disposedSessions: Session[] = [] ctx.on('session/disposed', (session) => { disposedSessions.push(session) }) const workflowEvents: string[] = []