You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GET /api/v1/subnets/{netuid}/event-summary (handler handleSubnetEventSummary in workers/request-handlers/entities.mjs:2785) returns one windowed rollup card for a subnet: event_kinds[] and categories[] aggregates (counts, distinct hotkey_count/coldkey_count, amount_tao/alpha_amount sums, first/last block+timestamp bounds), plus total_events, kind_count, category_count, and a small newest-first recent_events[] evidence slice — over a window of 7d/30d/90d. This is consolidation, not new data: it's the dashboard-friendly companion to the raw per-event feed the Activity tab already renders. Today the subnet masthead (apps/ui/src/components/metagraphed/subnet-masthead.tsx) has no on-chain-activity tile at all — the stat spine covers identity, participants, endpoints, surfaces, uptime, latency, completeness, and evidence-link count, but nothing summarizing recent chain events.
Requirement
Add one stat tile to the subnet masthead's stat spine that renders the windowed event-summary rollup (total event count + a compact kind/category breakdown) using the single event-summary endpoint, in place of what would otherwise require stitching together several separate per-kind or per-category calls.
Backend
Endpoint: GET /api/v1/subnets/{netuid}/event-summary?window=7d|30d|90d&limit=<n> — confirmed live in workers/request-handlers/entities.mjs:2785, route pattern registered in workers/config.mjs:109, response schema SubnetEventSummaryArtifact documented in public/metagraph/types.d.ts:6168-6186 (mirrors packages/contract/index.d.ts:6169).
Query function: none exists.apps/ui/src/lib/metagraphed/queries.ts has no subnetEventSummaryQuery (confirmed by search — zero matches for event-summary/eventSummary/EventSummary in that file). This PR must add it, following the exact queryOptions/apiFetch/staleTime pattern already used by sibling subnet queries in the same file, e.g. subnetHealthPercentilesQuery (apps/ui/src/lib/metagraphed/queries.ts:2760-2775) and subnetTrajectoryQuery (:2829-2839):
exportconstsubnetEventSummaryQuery=(netuid: number,window="7d")=>queryOptions({queryKey: k("subnet-event-summary",netuid,window),queryFn: async({ signal })=>{constres=awaitapiFetch<Partial<SubnetEventSummary>>(`/api/v1/subnets/${netuid}/event-summary`,{params: { window }, signal },);return{data: res.data,meta: res.meta,url: res.url};},staleTime: STALE_SHORT,});
Both the typed query function and the UI wiring must land in this one PR — a data-layer-only PR is exactly the failure mode this rewrite exists to prevent.
Deliverable
File(s) to change:
apps/ui/src/lib/metagraphed/queries.ts — add subnetEventSummaryQuery(netuid, window) (new function; confirmed no pre-existing one to extend).
apps/ui/src/components/metagraphed/subnet-masthead.tsx — add one new tile to the stat spine (confirmed current file: 557 lines, SubnetMasthead exported at line 147; stat spine grid at lines 403-554, currently 7 StatWithSpark tiles — Netuid, Participants, Endpoints, Surfaces, Uptime, Latency p50, Completeness, Evidence — inside <div className="mt-5 grid grid-cols-[repeat(auto-fit,minmax(150px,1fr))] divide-x divide-border rounded-xl border border-border bg-card overflow-hidden">).
Exact anchor: add const { data: summaryRes } = useQuery(subnetEventSummaryQuery(netuid)); alongside the existing useQuery calls at lines 167-170 (trajRes, uptimeRes, endpointsRes, pctRes), then append one more <StatWithSpark> tile immediately after the "Evidence" tile (currently the last, ending line 553) inside the same stat-spine grid.
What to render: label "Activity" (or "Events"), value={formatNumber(summaryRes?.data?.total_events)}, hint summarizing the top categories (e.g. join the top 2-3 categories[] entries by event_count as "<count> <category>", matching the existing hint={stackSegments.map(...).join(" · ")} idiom used on the Endpoints tile at lines 437-441), full="Windowed on-chain event rollup for this subnet (registrations, stake, serving, transfers, etc.)", updatedAt={summaryRes?.meta?.generated_at ?? generatedAt}, windowLabel={summaryRes?.data?.window ?? "7d"}, and a viz using the existing MiniStack primitive (apps/ui/src/components/metagraphed/charts/stat-with-spark.tsx:101, prop shape segments: Array<{ label; value; color }>) fed from categories[], mirroring how the Endpoints tile already builds stackSegments from per-kind counts (lines 212-216).
Diff touches at least one file under apps/ui/src/routes/ or apps/ui/src/components/ (not just queries.ts/types.ts) — specifically apps/ui/src/components/metagraphed/subnet-masthead.tsx
subnet-masthead.tsx imports and calls the new subnetEventSummaryQuery function via useQuery (matching the existing useQuery(subnetTrajectoryQuery(netuid)) etc. pattern already in the same component)
The new tile renders total_events as its headline value and a kind/category breakdown (via MiniStack or equivalent) sourced from categories[] or event_kinds[] — not a hardcoded/placeholder value
Loading + empty + error states handled matching the masthead's existing convention: tiles render "—" while data is undefined/loading (see the latP50 != null ? ... : "—" and completenessPct != null ? ... : "—" patterns already in the file) and degrade gracefully to a dash/zero state when total_events is 0, with no unhandled query-error state bubbling past the page's existing QueryErrorBoundary
Does not touch or duplicate the Activity tab's raw event table (ActivityPanel/subnetEventsQuery) — this issue is scoped to the masthead's compact summary tile only.
Does not add a dedicated "Activity" drill-down page or new route — the rollup card lives in the existing stat spine, nothing new to navigate to.
Size
Size: S — keep this PR small (aim for ≤10 files / ≤1000 LOC).
Context
GET /api/v1/subnets/{netuid}/event-summary(handlerhandleSubnetEventSummaryinworkers/request-handlers/entities.mjs:2785) returns one windowed rollup card for a subnet:event_kinds[]andcategories[]aggregates (counts, distincthotkey_count/coldkey_count,amount_tao/alpha_amountsums, first/last block+timestamp bounds), plustotal_events,kind_count,category_count, and a small newest-firstrecent_events[]evidence slice — over awindowof7d/30d/90d. This is consolidation, not new data: it's the dashboard-friendly companion to the raw per-event feed the Activity tab already renders. Today the subnet masthead (apps/ui/src/components/metagraphed/subnet-masthead.tsx) has no on-chain-activity tile at all — the stat spine covers identity, participants, endpoints, surfaces, uptime, latency, completeness, and evidence-link count, but nothing summarizing recent chain events.Requirement
Add one stat tile to the subnet masthead's stat spine that renders the windowed event-summary rollup (total event count + a compact kind/category breakdown) using the single
event-summaryendpoint, in place of what would otherwise require stitching together several separate per-kind or per-category calls.Backend
GET /api/v1/subnets/{netuid}/event-summary?window=7d|30d|90d&limit=<n>— confirmed live inworkers/request-handlers/entities.mjs:2785, route pattern registered inworkers/config.mjs:109, response schemaSubnetEventSummaryArtifactdocumented inpublic/metagraph/types.d.ts:6168-6186(mirrorspackages/contract/index.d.ts:6169).apps/ui/src/lib/metagraphed/queries.tshas nosubnetEventSummaryQuery(confirmed by search — zero matches forevent-summary/eventSummary/EventSummaryin that file). This PR must add it, following the exactqueryOptions/apiFetch/staleTimepattern already used by sibling subnet queries in the same file, e.g.subnetHealthPercentilesQuery(apps/ui/src/lib/metagraphed/queries.ts:2760-2775) andsubnetTrajectoryQuery(:2829-2839):Deliverable
apps/ui/src/lib/metagraphed/queries.ts— addsubnetEventSummaryQuery(netuid, window)(new function; confirmed no pre-existing one to extend).apps/ui/src/components/metagraphed/subnet-masthead.tsx— add one new tile to the stat spine (confirmed current file: 557 lines,SubnetMastheadexported at line 147; stat spine grid at lines 403-554, currently 7StatWithSparktiles — Netuid, Participants, Endpoints, Surfaces, Uptime, Latency p50, Completeness, Evidence — inside<div className="mt-5 grid grid-cols-[repeat(auto-fit,minmax(150px,1fr))] divide-x divide-border rounded-xl border border-border bg-card overflow-hidden">).const { data: summaryRes } = useQuery(subnetEventSummaryQuery(netuid));alongside the existinguseQuerycalls at lines 167-170 (trajRes,uptimeRes,endpointsRes,pctRes), then append one more<StatWithSpark>tile immediately after the "Evidence" tile (currently the last, ending line 553) inside the same stat-spine grid.value={formatNumber(summaryRes?.data?.total_events)},hintsummarizing the top categories (e.g. join the top 2-3categories[]entries byevent_countas"<count> <category>", matching the existinghint={stackSegments.map(...).join(" · ")}idiom used on the Endpoints tile at lines 437-441),full="Windowed on-chain event rollup for this subnet (registrations, stake, serving, transfers, etc.)",updatedAt={summaryRes?.meta?.generated_at ?? generatedAt},windowLabel={summaryRes?.data?.window ?? "7d"}, and avizusing the existingMiniStackprimitive (apps/ui/src/components/metagraphed/charts/stat-with-spark.tsx:101, prop shapesegments: Array<{ label; value; color }>) fed fromcategories[], mirroring how the Endpoints tile already buildsstackSegmentsfrom per-kind counts (lines 212-216).subnet-masthead.tsx) and stat-spine grid. If Add registration/deregistration event-volume counters to the subnet masthead #3483 lands first, this PR's new tile must slot in without duplicating the registration/deregistration counters it adds — the event-summary tile here is the aggregate rollup across all categories/kinds, not a registration-specific counter. Rebase against whichever of Add registration/deregistration event-volume counters to the subnet masthead #3483/Replace several subnet-detail calls with the single windowed event-summary rollup on the subnet masthead #3486 merges first to avoid a stat-spine merge conflict. This is also distinct fromActivityPanel/ActivityTableLoader(apps/ui/src/routes/subnets.$netuid.tsx:459-474, backed bysubnetEventsQuery), which renders the raw per-event table in the Activity tab — this masthead tile is a compact rollup, not a duplicate of that table.Acceptance criteria
apps/ui/src/routes/orapps/ui/src/components/(not justqueries.ts/types.ts) — specificallyapps/ui/src/components/metagraphed/subnet-masthead.tsxsubnet-masthead.tsximports and calls the newsubnetEventSummaryQueryfunction viauseQuery(matching the existinguseQuery(subnetTrajectoryQuery(netuid))etc. pattern already in the same component)total_eventsas its headline value and a kind/category breakdown (viaMiniStackor equivalent) sourced fromcategories[]orevent_kinds[]— not a hardcoded/placeholder value"—"while data is undefined/loading (see thelatP50 != null ? ... : "—"andcompletenessPct != null ? ... : "—"patterns already in the file) and degrade gracefully to a dash/zero state whentotal_eventsis 0, with no unhandled query-error state bubbling past the page's existingQueryErrorBoundaryNon-goals
ActivityPanel/subnetEventsQuery) — this issue is scoped to the masthead's compact summary tile only.Size
Size: S — keep this PR small (aim for ≤10 files / ≤1000 LOC).
Part of #2542.