Skip to content

WASM hosted reports: embed network.ndjson into the bundle so the Network tab appears #125

@handstandsam

Description

@handstandsam

Context

The Compose Multiplatform desktop app surfaces a "Network" tab in the bottom log panel for sessions that have a <session-dir>/network.ndjson artifact (captured by Playwright via --capture-network). The wiring lives in SessionLogsPanel + NetworkLogSource and works on the JVM target — loadNetworkLogs reads the file from disk.

On the WASM target (hosted HTML reports generated by WasmReport) the loadNetworkLogs actual returns null today because the report bundle doesn't embed a network_logs/<sessionId> entry. The Network tab therefore never appears on hosted reports — it works only on the local desktop app.

The parallel device_logs codepath shows what the wiring should look like — see WasmReport.kt (the device_logs: block in createCompressedDataBlock) and the index.html dispatcher branch under key.startsWith("device_logs/").

Scope

Three small pieces, no new logic.

1. WasmReport.kt — accept and emit network logs

Add a compressedNetworkLogs: Map<String, String> = emptyMap() parameter to createCompressedDataBlock and writeCompressedDataBlock, mirroring the existing compressedDeviceLogs. Emit a network_logs: { … } JSON block alongside the existing device_logs block in both functions.

2. index.html dispatcher — recognize the network_logs/ key prefix

Add a branch alongside the existing device-logs lookup:

else if (key.startsWith("network_logs/")) {
    const sessionId = key.substring("network_logs/".length);
    if (window.trailblaze_report_compressed.network_logs) {
        compressedData = window.trailblaze_report_compressed.network_logs[sessionId];
    }
}

3. Populate compressedNetworkLogs at the report-generation call site

Wherever createCompressedDataBlock / writeCompressedDataBlock is invoked with compressedDeviceLogs populated, do the same for network.ndjson files. Read <session-dir>/network.ndjson per session, JSON-encode the raw text the same way device logs are, and pass through the existing compression pipeline.

Out of scope

  • No changes to the JVM loadNetworkLogs actual — already works.
  • No changes to the parser, panel, or schema.
  • Body-file embedding (bodies/req_<id>.bin and future bodies/res_<id>.bin) is a separate decision — they're referenced from NDJSON via relative paths but aren't part of the NDJSON itself. Likely deferred until response-body capture lands.

Why a separate issue

This is referenced from a TODO comment in ActualsWasm.kt's loadNetworkLogs so a future maintainer hitting "no Network tab on the hosted report" can find it.

Estimated diff

~30 LOC in WasmReport.kt + ~5 lines of JS in index.html + ~10 LOC in the call site that reads ndjson per session. Single PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions