Skip to content

TUI: Esc does not stop a turn the client did not start (scheduled task or another client) #2635

Closed

Description

@argszero

What happens

Open any session in the TUI with /resume or /task-session, while a turn is already running in it, and press Esc: nothing happens.

The session opens and the elapsed timer counts up, so the client knows a turn is in flight — but the keystroke does nothing. The same session in the GUI shows a stop button and stops on Esc.

This is most visible with a scheduled task: the task's turn runs inside its session, and the only ways to stop it are to open the GUI or to kill the daemon.

Why it happens

emrg/client/app.py gates the Esc branch on busy alone:

if data == b"\x1b" and busy:
    await request_cancel(conn, session_id)
    return True

busy is this client's own send in flight, so a turn started by a scheduled task, or by another client, is invisible to it. The client already carries the other fact, turn_running, which is fed by the daemon's turn_start / done frames and the resume snapshot, and is what the elapsed timer runs on.

What it must do

  1. Esc stops the running turn of the session on screen, whoever started it.
  2. "A turn is running" is the daemon's fact, not "did this client send a request".
  3. Esc still only sends a cancel request; the client does not declare the interruption itself. The "stopped" line still comes from the daemon's receipt.
  4. The GUI keeps its behaviour; it gains a test pinning that a turn it did not start can be stopped, so the property cannot regress.

Acceptance

  • The decision is one named predicate, asked by the Esc branch, so it can be tested without a terminal: true when either this client's send is in flight or the session's turn is running.
  • tests/test_app_cancel_session.py and tests/test_app_turn_timer.py green, with the existing Esc-branch assertions updated to the new judgement and not narrowed; a new test that a cancel is sent when only the session's turn is running, naming the session id.
  • Mutation checks: remove the session-turn half from the predicate → the new test reddens; drop session_id from the cancel frame → an existing test reddens; remove the per-session busy assignment from the GUI store fixture → the new GUI test reddens.
  • CI green on both Test legs (ubuntu-latest, windows-2025), GUI tests included.

Activity

  1. argszero commented on Oct 29, 2026

    @argszero
    OwnerAuthor

    Handled by #2636

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions