[Feature]: Show and stop background tasks in Terminal UI sessions and the ao CLI
Context
Background tasks are coming to Chat sessions:
- PR #7550 adds a tab above the chat composer. It shows running shells with their elapsed time, and Claude Code tasks can be stopped from it.
- A follow-up PR will open a task in a Background tab beside Subagents, with its live output.
- #8322 (stop for other harnesses), #8326 (elapsed time after a restart) and #8327 (command and output data) cover the gaps found along the way.
All of that is Chat mode only. Someone working in a Terminal UI session, or from the ao CLI, still can't see or stop background work.
What's missing
1. Terminal UI sessions. When a session runs the agent's own CLI in Orchestrator's terminal, background work is invisible. The daemon reports a Terminal UI session as unavailable, and the renderer only asks for chat sessions (supportsLocalBackgroundTasks). Switching a session from Chat to Terminal also hides tasks that are still running.
2. The ao CLI. There is no command to list or stop a session's background tasks. Orchestrator agents and scripts can't check for a dev server that's still running before they ao session kill a session, and someone working in a terminal has to open the app to see one.
Proposal
- Terminal UI sessions: report background tasks with the same reading the chat tab uses, and show them in the session's UI. One lead for Claude Code: its
Stophook input carriesbackground_tasks, the in-flight background work of the session, and Orchestrator already runsao hooksfor Claude Code. Other CLIs need their own source, or stay unavailable. aoCLI, on the existing endpoints:ao session tasks <session-id>lists running and recently failed tasks with their state and elapsed time, plus a--jsonoutput for agents.ao session tasks stop <session-id> <task-id>stops a task where the harness supports it, and says so plainly where it doesn't.- Optionally,
ao session lsshows a running-task count per session.
Open questions
- Which part matters first: Terminal UI sessions, or the
aocommands? - Should actions that end running background work warn first? For example terminating the session, exiting the agent, or switching between Chat and Terminal.
- Is a Terminal UI session's reading allowed to be partial, as Codex's is in Chat?
Done when
- A Terminal UI session with a running background shell shows it, at least for Claude Code.
ao session taskslists the same tasks the chat tab shows, andao session tasks stopstops a Claude Code task.
Can I work on this?