Persist command completions when approval is declined or fails (#64341)

## Why

The app server completed command items for rejected approval responses
directly in the live stream. That bypassed core's history recording, so
clients could see a completed command live and lose it when reloading
the turn.

## What changed

Keep top-level command items with their pending approvals in core.
Record and emit the command completion before unblocking the turn.
Declines and cancellations produce a `declined` item, while invalid
responses and approval request failures produce a `failed` item.

## Testing

App-server integration tests cover cancellation, decline, and malformed
responses. They check that `item/completed` precedes `turn/completed`
and that paginated history returns the same command item after restart.

GitOrigin-RevId: d3d95272c8a6af2fa65fa980f312260313cc5e32
This commit is contained in:
jif
2026-11-27 15:31:18 +00:00
committed by copyberry
parent 57b493a648
commit 6bf1e3e687
10 changed files with 332 additions and 219 deletions
+1 -5
View File
@@ -1780,11 +1780,7 @@ impl EventMsg {
/// Stdin and network reviews have their own prompts for an existing operation.
pub fn command_approval_start(&self) -> Option<(&str, i64)> {
match self {
Self::ExecApprovalRequest(request)
if request.kind == crate::approvals::ExecApprovalKind::Command
&& request.approval_id.is_none()
&& request.network_approval_context.is_none() =>
{
Self::ExecApprovalRequest(request) if request.starts_command() => {
Some((&request.call_id, request.started_at_ms))
}
Self::GuardianAssessment(assessment)