Repository navigation
Backlog
Labels
area/cliCLI commands, flags, output formattingarea/sessionsFor features/issues/fixes related to session lifecycle (resume, persistence, export)area/tuiFor features/issues/fixes related to the TUI
Description
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) anddocker-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).
- Use
- 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
--leanTUI, 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--worktreecreated for the run is deleted during exit cleanup.
- Multi-tab TUI behavior:
- Calling
/exitcloses only the current tab; when only one tab remains,/exitexits 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).
- Calling
- Tests:
- Add unit tests covering command formatting (standalone vs plugin mode, agent ref, shell quoting, explicit flags), persisted vs unpersisted suppression, and
--worktreecleanup behavior.
- Add unit tests covering command formatting (standalone vs plugin mode, agent ref, shell quoting, explicit flags), persisted vs unpersisted suppression, and
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 agentCLI plugin invocations, as well as standard and--leanTUIs.
Metadata
Metadata
Assignees
Labels
area/cliCLI commands, flags, output formattingarea/sessionsFor features/issues/fixes related to session lifecycle (resume, persistence, export)area/tuiFor features/issues/fixes related to the TUI
Activity