Skip to content

Print resume command on interactive TUI exit #5083

Backlog

Description

@aheritier

Goal

Print a copy-pasteable resume command when an interactive docker-agent TUI session exits cleanly, similar to Claude Code:

Resume this session with:
docker agent run ./agent.yaml --session <session-id>

Docker Agent already supports resuming sessions via --session <id> (and PR #5065 / #5062 adds automatic terminal restoration via OSC 7577 for unexpected terminal restarts), but exiting intentionally currently leaves no hint on screen. Printing the resume command on clean exit makes --session immediately discoverable and works in every terminal, including Docker CLI plugin mode, tmux, SSH, and Windows.

Scope & Requirements

  • Command formatting:
    • Use docker agent run ... when invoked as a Docker CLI plugin (DOCKER_CLI_PLUGIN_ORIGINAL_CLI_COMMAND) and docker-agent run ... when invoked standalone.
    • Preserve the agent reference when explicitly provided (e.g. ./agent.yaml, alias, OCI ref) and omit it when using the default agent.
    • Preserve location-critical flags if explicitly provided (--agent, --session-db, --data-dir, --config-dir, --remote), properly shell-quoted when arguments contain spaces or special characters.
    • Always print --session <session-id> (never --resume-instance, since intentional exit clears instance resume state).
  • When to print (and when to suppress):
    • Print only when the active session was actually persisted in the session store (skip empty/unpersisted sessions where the user exited before sending a message).
    • Support both the standard TUI and --lean TUI, as well as clean intentional exits after --resume-instance.
    • Suppress for non-interactive or special runs: --exec, --dry-run, --tour, --fake, --record, --exit-after-response, --session-read-only, non-TTY stdout, abnormal TUI errors, or when a temporary --worktree created for the run is deleted during exit cleanup.
  • Multi-tab TUI behavior:
    • Calling /exit closes only the current tab; when only one tab remains, /exit exits the process and displays the resume command for that last session (if persisted).
    • If the user exits the whole process directly with multiple tabs still open (e.g. confirmed quit / Ctrl+C), display the resume command for the active persisted tab (or suppress if none of the open tabs were persisted).
  • Tests:
    • Add unit tests covering command formatting (standalone vs plugin mode, agent ref, shell quoting, explicit flags), persisted vs unpersisted suppression, and --worktree cleanup behavior.

Acceptance Criteria

  • Exiting an interactive TUI after persisting a session prints a valid, copy-pasteable Resume this session with: command using --session <session-id>.
  • Running the printed command resumes that exact session.
  • Empty/unpersisted runs, --exec, non-TTY output, test/replay flags, and deleted temporary worktrees do not print a misleading or broken resume hint.
  • Works consistently across standalone and docker agent CLI plugin invocations, as well as standard and --lean TUIs.

Activity

  1. added
    area/tui
    area/sessions
    area/cli
    on Dec 1, 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

    area/cliarea/sessionsarea/tui

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions