Skip to content

TUI Esc abort can leave stale optimistic busy state #86199

@RomneyDa

Description

@RomneyDa

Summary

The TUI can remain stuck in the busy-submit path after pressing Esc to abort a pending run. The first Esc successfully aborts the backend run, but the local optimistic submit flag remains set, so the next normal prompt is blocked with:

agent is busy — press Esc to abort before sending a new message

Pressing Esc again then reports:

no active run

because both tracked run ids are already clear while pendingOptimisticUserMessage is still true.

Current behavior

The TUI submit guard treats pendingOptimisticUserMessage as busy state. abortActive() clears pendingChatRunId after a successful abort, but it does not clear pendingOptimisticUserMessage.

That can leave the TUI in a contradictory local state:

  • no active chat run id
  • no pending chat run id
  • optimistic user message still pending
  • prompt submission blocked as busy
  • second Esc cannot abort anything and shows no active run

Expected behavior

After a successful Esc abort of the active or pending TUI run, the TUI should clear all local pending-submit state for that run so the next prompt can be sent normally.

Expected behavior:

  • pendingChatRunId is cleared
  • pendingOptimisticUserMessage is cleared
  • activity status becomes aborted
  • the next normal prompt is not blocked by stale optimistic state
  • repeated Esc after the abort does not become the only way to discover there is no tracked run

Notes

Relevant paths:

  • src/tui/tui-command-handlers.ts blocks normal submits when pendingOptimisticUserMessage is set.
  • src/tui/tui-session-actions.ts clears pendingChatRunId on successful abort, but currently leaves pendingOptimisticUserMessage set.
  • This is distinct from TUI can show error status without surfacing the run error #85782, which covers lifecycle/provider errors leaving active-run state stuck.

Acceptance criteria

  • A successful Esc abort clears stale optimistic submit state.
  • Switching sessions also clears stale optimistic submit state along with the other run-state fields.
  • Add focused regression coverage for aborting while both pendingChatRunId and pendingOptimisticUserMessage are set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.bugSomething isn't workingclawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.maintainerMaintainer-authored PR

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions