fix(pty): keep the controlled prompt so persistent bash settles fast

tool-bash-persistent overwrote the backend's PS1, so terminal-bash prompt
readiness never matched and every send degraded to the 3.5s silence tier
(idleSilenceMs + handoffGraceMs) under production defaults.

The controlled PROMPT_COMMAND now re-asserts PS1 before every prompt, so an
in-shell override never survives to the next prompt. The tool initializes
with stty -echo alone and detects the no-end-marker fallback through the
seam's stdin_read wait reason instead of matching its own prompt text.

Tool calls drop from 7180/3560/3566 ms to 355/88/91 ms (spawn+init+echo,
echo, pwd; darwin, production defaults). The loader composition suite now
pins the fast path by pushing idleSilenceMs beyond the send bound, and a
real-PTY case proves PS1 self-healing.

Fixes #2585
This commit is contained in:
Yichen Jiang
2026-08-15 11:06:57 +08:00
parent 5bb600f9fb
commit a8dc6f9776
18 changed files with 145 additions and 40 deletions

View File

@@ -84,7 +84,10 @@ suite('persistent Bash through a real cordis.yml Loader composition', () => {
' config:',
' pollIntervalMs: 10',
' exactProbeAfterMs: 20',
' idleSilenceMs: 100',
// The silence tier is pushed beyond the send bound, so no send below can
// settle as inferred_idle: every case proves the controlled-prompt fast
// path that the production defaults (3.5s silence) would otherwise mask.
' idleSilenceMs: 30000',
' handoffGraceMs: 100',
' scrollbackLines: 20000',
' timeoutMs: 2000',
@@ -154,6 +157,12 @@ suite('persistent Bash through a real cordis.yml Loader composition', () => {
expect(large).toContain('<response clipped>')
expect(large).not.toContain('beginning of this command output was dropped')
// `exec` replaces the wrapper before its end marker prints; the seam's
// stdin_read readiness is what returns the replacement shell's prompt
// instead of spinning until the tool deadline.
const execed = text(await execute('exec-replacement', 'exec bash --noprofile --norc -i'))
expect(execed).toBe('dsh> ')
const exited = text(await execute('exit', 'exit'))
expect(exited).toContain('next bash call starts from the workspace')
expect(text(await execute('after-exit', 'printf "%s\\n" "$PWD"'))).toBe(root)