Draw a background task as what it ran, and go there on a tap

A card in the session's panel said "background command" under every
description -- and for Codex, which names a terminal by a process id and
gives no description at all, that phrase was the whole of every card.

Both halves of the answer are in the transcript rather than in what the
provider says: a driver now reports which tool call its task belongs to
(Claude's `task_started` carries the `tool_use_id`, Codex's terminal list
the `itemId`), and `LiveSession::background_tasks` resolves those ids
against the transcript into a sequence number and, where the provider said
nothing, the command the call was made with. So the card draws the command,
and the kind shrinks to a mark beside it whose name is what a screen reader
is given.

Tapping one goes to that call in the transcript, opened, which is where a
backgrounded command's output already lands -- rather than drawing a second
copy of it beside the panel. The journey is the one a reopened session
already makes to put a reader back where they stopped, now one function
(`travelTo`). It has to release the held backlog first: events arriving
while the reader is away from the newest end are held rather than applied,
so a task started since they scrolled back was in no row at all and the tap
looked like it had done nothing.

Verified against the sandbox on the emulator: the panel draws
`sleep 120 && echo done` for an echo session's `/background`, and tapping
it lands on that Bash card with its output showing.
This commit is contained in:
iris-ai committed 2026-09-20 18:46:22 -04:00
1 parent 3b309766d7
commit cedb18e8c1
18 files changed
+635 -151

No files matched your search

@@ -322,8 +322,18 @@ data class BackgroundTaskSummary(
val description: String?,
/** `agent`, `command`, `workflow`, or `other` for a kind this build has not heard of. */
val kind: String,
/**
* Where the call that started this is in the transcript, for the reader who taps the card.
*
* Null is a provider that does not say which call a task belongs to, or a call the transcript
* no longer holds -- the card is then something to read rather than something to open.
*/
val call: CallSite?,
)
/** Where one thing is in a transcript: the sequence number of the event that is it. */
data class CallSite(val seq: Long)
/**
* What [sessionId] has running in the background right now.
*
@@ -344,6 +354,10 @@ fun fetchBackgroundTasks(
description =
if (row.isNull("description")) null else row.getString("description"),
kind = row.getString("kind"),
call =
row.optJSONObject("call")?.let { call ->
CallSite(seq = call.getLong("seq"))
},
)
}
}