fix(session): report the frame a pause began at

Frames go on counting while paused, since Pump still runs, but status
gave no pause frame and `wait --paused` replied with the current one.
A wait that came minutes after `pause --on-check` caught a failure at
frame 237 said "paused at frame 5475", which an agent takes for when
the check failed.

The session records the frame in PauseNow, and status and the paused
wait report it as pausedAt. The client prints "PAUSED since frame N",
and "paused at frame N (now M)" when the two differ.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-11-01 03:21:41 +01:00
commit 2c77cdcfab
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
3 changed files with 29 additions and 5 deletions

View file

@ -474,8 +474,11 @@ namespace {
const Value& s = *result;
const bool paused = s.Find("paused")->AsBool();
const std::string reason = s.Find("pauseReason") ? s.Find("pauseReason")->AsString() : std::string();
const Value* pausedAt = s.Find("pausedAt");
Out() << std::format("{} frame {} {:.1f} fps {}\n", s.Find("name")->AsString(), s.Find("frame")->Dump(), s.Find("fps")->AsNumber(),
paused ? std::format("PAUSED ({})", reason) : std::string("running"));
!paused ? std::string("running")
: pausedAt != nullptr ? std::format("PAUSED since frame {} ({})", pausedAt->Dump(), reason)
: std::format("PAUSED ({})", reason));
std::string armed;
if (const Value* when = s.Find("armed")->Find("when")) armed += std::format(" pause armed: when '{}'", when->AsString());
if (s.Find("armed")->Find("onCheck") != nullptr) armed += " pause armed: on the next failing check";
@ -703,7 +706,11 @@ namespace {
} else if (const Value* event = r.Find("event")) {
Out() << std::format("{} at frame {}: {}\n", event->AsString(), r.Find("frame")->Dump(), Display(*r.Find("payload")));
} else if (const Value* reason = r.Find("reason")) {
Out() << std::format("paused at frame {}: {}\n", r.Find("frame")->Dump(), reason->AsString());
// When it stopped, not when this wait looked: frames go on
// counting while paused.
const Value* pausedAt = r.Find("pausedAt");
const std::string since = pausedAt != nullptr ? pausedAt->Dump() : r.Find("frame")->Dump();
Out() << std::format("paused at frame {}{}: {}\n", since, since != r.Find("frame")->Dump() ? std::format(" (now {})", r.Find("frame")->Dump()) : std::string(), reason->AsString());
} else {
Out() << std::format("frame {}\n", r.Find("frame")->Dump());
}