diff --git a/worker/src/components/dashboard/dashboard-shell.tsx b/worker/src/components/dashboard/dashboard-shell.tsx index 58c4e75..c60bdb2 100644 --- a/worker/src/components/dashboard/dashboard-shell.tsx +++ b/worker/src/components/dashboard/dashboard-shell.tsx @@ -254,35 +254,57 @@ export function DashboardShell() { /> - {/* Map + Traffic trend */} + {/* Traffic breakdown */} - Reporter Locations - - Approximate locations from Cloudflare edge nodes, not device GPS. - + Traffic Breakdown + Observed traffic composition across all reporting nodes - - + + {comp && compTotal > 0 ? ( + <> + + + + + + + + + {comp.human.toLocaleString()} + Messages + + + + {comp.acks.toLocaleString()} + Acks + + + + {comp.overhead.toLocaleString()} + Overhead + + + > + ) : ( + + )} - Observations Over Time + Messages vs Protocol Overhead - Per-node average observations per {summary?.filter.bucket ?? "time"} bucket. - Normalizing by reporter count removes the bias of more nodes = higher numbers. + Human messages (text + group text) compared to protocol overhead (acks, advertisements, routing, control) over time. - {isLoading && !summary ? ( - - ) : summary?.chartPoints.length ? ( - + {summary?.compositionOverTime.length ? ( + ) : ( - + )} @@ -340,91 +362,67 @@ export function DashboardShell() { - - - Path Routing Modes - - Path hash byte length determines routing precision. - Longer hashes allow more specific multi-hop paths. - - - - {activePathModes.length ? ( - - {activePathModes.map((entry) => { - const pct = totalPackets > 0 ? ((entry.total / totalPackets) * 100).toFixed(1) : "0"; - return ( - - - {PATH_MODE_ICONS[entry.key] ?? "?"} - - {entry.total.toLocaleString()} - {entry.label} - {pct}% - - ); - })} - - ) : ( - - )} - - - - - - {/* Messages vs Overhead over time */} - - Messages vs Protocol Overhead + Path Routing Modes - Human messages (text + group text) compared to protocol overhead (acks, advertisements, routing, control) over time. + Path hash byte length determines routing precision. + Longer hashes allow more specific multi-hop paths. - {summary?.compositionOverTime.length ? ( - + {activePathModes.length ? ( + + {activePathModes.map((entry) => { + const pct = totalPackets > 0 ? ((entry.total / totalPackets) * 100).toFixed(1) : "0"; + return ( + + + {PATH_MODE_ICONS[entry.key] ?? "?"} + + {entry.total.toLocaleString()} + {entry.label} + {pct}% + + ); + })} + ) : ( - + )} + + + {/* Map + Traffic trend */} + + + + Reporter Locations + + Approximate locations from Cloudflare edge nodes, not device GPS. + + + + + + - Traffic Breakdown - Observed traffic composition across all reporting nodes + Observations Over Time + + Per-node average observations per {summary?.filter.bucket ?? "time"} bucket. + Normalizing by reporter count removes the bias of more nodes = higher numbers. + - - {comp && compTotal > 0 ? ( - <> - {/* stacked bar */} - - - - - - - - - {comp.human.toLocaleString()} - Messages - - - - {comp.acks.toLocaleString()} - Acks - - - - {comp.overhead.toLocaleString()} - Overhead - - - > + + {isLoading && !summary ? ( + + ) : summary?.chartPoints.length ? ( + ) : ( - + )} @@ -500,8 +498,8 @@ function CompositionChart({ points }: { points: CompositionPoint[] }) { setHover(null)} > @@ -626,8 +624,8 @@ function TrafficChart({ points, maxValue: _rawMax }: { points: ChartPoint[]; max setHover(null)} > diff --git a/worker/worker/index.ts b/worker/worker/index.ts index ddc3b71..0d316e4 100644 --- a/worker/worker/index.ts +++ b/worker/worker/index.ts @@ -105,7 +105,9 @@ async function handleDashboard(request: Request, env: Env): Promise { } const url = new URL(request.url); - const summary = await loadDashboardSummary(env, url.searchParams.get("window")); + const windowParam = url.searchParams.get("window"); + const summary = await loadDashboardSummary(env, windowParam); + const cacheTtl = windowParam === "7d" || windowParam === "30d" ? 86400 : 60; return Response.json( { generatedAt: new Date().toISOString(), @@ -114,8 +116,8 @@ async function handleDashboard(request: Request, env: Env): Promise { { headers: { ...jsonHeaders, - "cache-control": "public, max-age=60, s-maxage=60", - "cdn-cache-control": "max-age=60", + "cache-control": `public, max-age=${cacheTtl}, s-maxage=${cacheTtl}`, + "cdn-cache-control": `max-age=${cacheTtl}`, }, }, );