Diagnostics: forward upstream events + errors to device as 'debug' envelopes

Coolify container logs aren't accessible from the dev sandbox, so the only
log surface we can read is the Pi journal. The relay now forwards every
upstream event type to the device as {type:'debug', message:'relay evt=<T>'}
and every mid-session upstream error event as {type:'error',code:'upstream_<C>'}.

The client's Session.dispatch handles 'debug' as an INFO log line. Updates
the wake-flow integration test's receive-loop to skip over the new debug
envelopes via a ReceiveUntil helper.
This commit is contained in:
2026-06-12 06:59:14 +00:00
parent 8bb0ce51b1
commit a42038b825
3 changed files with 49 additions and 3 deletions
+14 -2
View File
@@ -52,11 +52,11 @@ public class DeviceHubWakeFlowTests(ApiFactory factory) : IClassFixture<ApiFacto
});
FakeRealtimeSessionFactory.Upstream.Push(new JsonObject { ["type"] = "response.done" });
var done = await ReceiveJson(ws);
var done = await ReceiveUntil(ws, "assistant_done");
done.GetProperty("type").GetString().Should().Be("assistant_done");
await SendJson(ws, new { type = "cancel" });
var ended = await ReceiveJson(ws);
var ended = await ReceiveUntil(ws, "session_ended");
ended.GetProperty("type").GetString().Should().Be("session_ended");
}
@@ -114,4 +114,16 @@ public class DeviceHubWakeFlowTests(ApiFactory factory) : IClassFixture<ApiFacto
}
return JsonDocument.Parse(stream.ToArray()).RootElement.Clone();
}
// The relay forwards an upstream-event "debug" envelope for every event
// it sees, so envelopes the test cares about are interleaved with debugs.
private static async Task<JsonElement> ReceiveUntil(WebSocket ws, string type)
{
for (int i = 0; i < 50; i++)
{
var env = await ReceiveJson(ws);
if (env.GetProperty("type").GetString() == type) return env;
}
throw new TimeoutException($"never saw envelope type={type}");
}
}