Bug
When pressing Escape to cancel an in-progress LLM generation in the TUI, an unhandled promise rejection stack trace writes to stderr and corrupts the terminal display.
Root Cause
The abort HTTP endpoint at session.ts:384 calls SessionPrompt.cancel() without await or .catch(). cancel() internally calls cb.reject(new Error("Session cancelled")) to reject pending promises. Since the endpoint returns c.json(true) before cancel() completes, the rejection is unhandled and Bun writes the stack trace to stderr.
Two additional fire-and-forget calls in prompt/index.tsx also lack .catch():
sdk.client.session.abort() (line 262)
sdk.client.session.command() (line 654)
Reproduction
- Start a session in the TUI
- Send a message that triggers LLM generation
- Press Escape twice during generation
- Observe stack trace text bleeding over the TUI rendering
Fix
See sjawhar#1
Bug
When pressing Escape to cancel an in-progress LLM generation in the TUI, an unhandled promise rejection stack trace writes to stderr and corrupts the terminal display.
Root Cause
The abort HTTP endpoint at
session.ts:384callsSessionPrompt.cancel()withoutawaitor.catch().cancel()internally callscb.reject(new Error("Session cancelled"))to reject pending promises. Since the endpoint returnsc.json(true)beforecancel()completes, the rejection is unhandled and Bun writes the stack trace to stderr.Two additional fire-and-forget calls in
prompt/index.tsxalso lack.catch():sdk.client.session.abort()(line 262)sdk.client.session.command()(line 654)Reproduction
Fix
See sjawhar#1