Skip to content

Web GUI: closing the workflow runner modal mid-workflow leaves the session hanging — wire abort-on-close and session cleanup #24

Closed

Description

@falbany

Summary

Closing the workflow runner modal (Escape key or the ✕ button) while the session waits for user input does not tell the server anything. The session stays alive in waiting_ask / waiting_notify / waiting_notice forever: the workflow never completes, the file is never launched, and nothing records the abandonment. The user believes they cancelled; the backend holds a dangling interactive session.

Reproduction

  1. Configure a workflow that pauses on user input (e.g. a step with ask: or notify with wait: true).
  2. Launch a matching file in the web UI — the modal opens and waits.
  3. Press Escape or click ✕.

Actual: the modal closes; server-side the session stays in its waiting state indefinitely. Reopening the launcher creates a new session — the old one is orphaned in memory.

Expected: closing the modal while the session is interactive aborts the session server-side (equivalent to the "No / Abort Launch" path), and finished sessions are eventually cleaned up.

Root cause

  • Frontend — src/profiles/web/src/components/WorkflowRunnerModal.tsx:
    • The Escape handler (~lines 168–178) and the ✕ button both just call onClose().
    • The unmount/effect cleanup (~lines 113–149) resets local state only; no session endpoint is called on close.
  • Backend — src/profiles/server/routes/workflow.py:
    • There is no abort/delete route — only POST /start, GET /{session_id} and POST /{session_id}/respond.
    • The in-memory store _sessions (~line 74) has no TTL or eviction: completed, aborted and orphaned sessions accumulate for the whole server lifetime.

Fix direction

  1. Add an abort endpoint, e.g. POST /api/workflow/{session_id}/abort (or DELETE /{session_id}): mark the session aborted, set final_message = "Aborted by user (modal closed).", mark the interrupted step record accordingly.
  2. Wire the modal to call it (fire-and-forget, errors suppressed) when it closes while the session is still interactive: Escape handler, ✕ button, and the effect cleanup for unmounts. Only for statuses running / waiting_ask / waiting_notify / waiting_notice — never for completed/aborted/failed.
  3. Session hygiene: purge terminal sessions (completed / aborted / failed) after a TTL, and/or cap the size of _sessions, so a long-running desktop process does not accumulate them.
  4. Tests: abort endpoint behavior (idempotent, 404 on unknown id); frontend test with vitest that closing the modal in waiting_ask triggers the abort call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions