bake: make the landing scan say what it saw, so a no-answer names its own cause

Splits Ignore into unreadable vs not-a-request and counts every verdict; the report prints only when the pass answered nobody, so its absence proves the action never ran.
This commit is contained in:
2026-08-02 08:00:19 -04:00
parent 7f3b00a646
commit 41ca833b86
7 changed files with 196 additions and 33 deletions
+23 -8
View File
@@ -272,22 +272,34 @@ void RunResampleBake(ReaSamplerSession& session) {
const std::int64_t nowSec = static_cast<std::int64_t>(std::time(nullptr));
std::vector<Answer> answers;
int landedCount = 0;
wire::BakeScanTally tally; // every verdict below is counted, skips included
Undo_BeginBlock2(nullptr);
for (const OpenProject& open : openProjects()) {
++tally.tabsScanned;
const bool activeTab = static_cast<const void*>(open.proj) == active;
for (const std::string& key : pendingBakeKeys(open.proj)) {
++tally.keysFound;
if (activeTab) ++tally.activeTabKeys;
const std::optional<std::string> raw = readKey(open.proj, key);
const std::optional<BakeRequest> request =
raw ? wire::decodeBakeRequest(*raw) : std::nullopt;
const wire::BakeScanKey scanKey{
request.has_value(), request ? request->generation : 0,
raw.has_value(), request.has_value(), request ? request->generation : 0,
static_cast<const void*>(open.proj) == loaded};
const wire::BakeScanVerdict verdict =
wire::classifyBakeScan(scanContext, scanKey, nowSec);
// Leave it — the writing instance owns clearing its own key.
if (verdict == wire::BakeScanVerdict::Ignore) continue;
if (verdict == wire::BakeScanVerdict::IgnoreUnreadable) {
++tally.unreadable;
continue;
}
if (verdict == wire::BakeScanVerdict::IgnoreNotARequest) {
++tally.notARequest;
continue;
}
if (verdict == wire::BakeScanVerdict::ClearStale) {
++tally.staleCleared;
answers.push_back(Answer{open.proj, key, std::string{}, std::string{}});
continue;
}
@@ -300,17 +312,17 @@ void RunResampleBake(ReaSamplerSession& session) {
request->generation);
} else {
outcome = landOne(session, open.dir, *request);
if (outcome.status == BakeStatus::Ok) ++landedCount;
if (outcome.status == BakeStatus::Ok) ++tally.landed;
}
++tally.answered;
// A WrongProject request left sitting in a tab this call did not come from
// prints again on every OTHER tab's bake, since the scan revisits every open
// project each time. `active` is this call's own proxy for "the invoking tab" —
// only that tab's own refusal is fresh feedback to a user who just clicked
// bake; every other one is a rescan repeat.
const bool ownRequest = static_cast<const void*>(open.proj) == active;
std::string console;
if (outcome.status != BakeStatus::Ok &&
(outcome.status != BakeStatus::WrongProject || ownRequest)) {
(outcome.status != BakeStatus::WrongProject || activeTab)) {
console = "ReaSampler resample: " + outcome.message + ".\n";
}
answers.push_back(
@@ -318,7 +330,7 @@ void RunResampleBake(ReaSamplerSession& session) {
}
}
if (landedCount > 0) {
if (tally.landed > 0) {
// A bake changes what a live instance would play, so the generation bump rides the
// persist — every other open instance refreshes hands-free.
session.bumpBankGeneration();
@@ -338,7 +350,10 @@ void RunResampleBake(ReaSamplerSession& session) {
answer.wire.c_str());
if (!answer.console.empty()) ShowConsoleMsg(answer.console.c_str());
}
if (landedCount > 0) bankPanelRefresh();
// Empty unless the pass answered nobody, so a bake that spoke for itself stays quiet.
const std::string report = wire::describeBakeScan(tally);
if (!report.empty()) ShowConsoleMsg(report.c_str());
if (tally.landed > 0) bankPanelRefresh();
}
} // namespace reasampler::capture