Skip to content

feat(tui): terminate the selected subagent with double-Esc #187

Closed

Description

@mdev34-lab

Problem

There is currently no way to manually terminate one running subagent. Ctrl+C terminates the entire AlphaCode process, so it cannot be used as a child-only cancellation control.

The TUI already lets the user select/view an individual subagent's trace. That is the natural scope for a child-only stop action.

Proposal

When the user is viewing the trace of a selected running subagent, make double-Esc terminate that subagent.

Conceptually:

Main session
  └─ Working
      └─ Review subagent  ← selected / trace open

Press Esc twice within the existing double-Esc interaction window:

Subagent: Review
Status: Cancelling…

Then:

Subagent: Review
Status: Cancelled

Semantics

  • Double-Esc targets only the subagent whose trace is currently being viewed.
  • The parent AlphaCode session remains running.
  • Other parallel subagents remain running.
  • Ctrl+C keeps its existing process-wide semantics.
  • Do not add a confirmation dialog for the normal case; the double keypress is the deliberate confirmation.
  • If the selected subagent has already terminated, double-Esc must not affect the parent session.
  • Cancellation must be a real execution cancellation, not merely a TUI state change: terminate/abort the underlying child execution and clean up its resources.
  • The parent must receive a typed cancellation result/state so it can continue orchestration without treating the child as successful.
  • Keep execution mode separate from termination reason. This should work for both background and synchronous subagent execution where cancellation is supported.
  • Prefer the existing TUI double-Esc handling/seam rather than introducing a new global keyboard mechanism.

Result contract

Cancellation should be distinguishable from normal finish outcomes. If the current termination-reason work (#172) is the shared contract, extend it consistently rather than encoding cancellation in free-form text.

The observable result should communicate that the user cancelled the child, for example:

reason: "cancelled"

The exact enum/type should follow the repository's current termination contract.

UX details

  • The trace view should expose the action in its footer/help text, e.g. Esc Esc Stop subagent.
  • While cancellation is being processed, show Cancelling… rather than immediately pretending the process is gone.
  • Once the child actually exits, show Cancelled.
  • The trace should remain inspectable after cancellation so the user can see where it stopped.
  • A later selection of another active subagent must make double-Esc target that child instead.

Acceptance criteria

  • Double-Esc while viewing an active subagent trace cancels that subagent only.
  • Parent AlphaCode execution continues.
  • Other subagents are unaffected.
  • Ctrl+C remains process-wide.
  • Underlying child execution is actually aborted and resources are cleaned up.
  • Cancellation propagates through a typed termination/result state.
  • TUI shows Cancelling… and then Cancelled.
  • Trace remains viewable after cancellation.
  • Double-Esc on an already-finished/non-subagent trace does not cancel the parent.
  • Focused tests prove target isolation and that cancellation reaches the actual execution handle.
  • Existing double-Esc behavior outside the selected subagent trace is unchanged.

Related

Activity

  1. added
    enhancement
    on Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions