Repository navigation
feat(ui): host hooks for the evidence, report, decisions and usage surfaces - #6187
Conversation
… request
createRuntimeEvidenceApi and createFirstLookApi take a request function and
the route root, so an app with its own fetch layer and routes reuses the
paths, query names and types instead of keeping a second client. The
existing functions are those factories over apiRequest with the
/api/repos/{id} roots, so every URL and signature stays the same.
|
🟡 Review before merge: AI review: nothing to fix; 10 changed contracts with callers outside this PR.
✅ Health of changed files: 8.99 → 9.00 (+0.01; structure +0.01) Average full file score (structure and history) of 16 changed code files, weighted by size before this PR; not the repository score.
Settings and updatesSince the last push: health 9.1 to 9.0, 7 more files |
…sage
DecisionAgentHero takes onCopy("prompt" | "review_all"), called when either
copy button is clicked, so a host counts the handoff without reading the
button label. RepowiseUsage takes children in place of the token figures
and table, for a host that bills from a ledger and records no tokens;
fallback stays for loading and errors.
FirstLookReport dropped report.unavailable, so a section core could not read looked like one with nothing found. It now lists each one under "Not in this report" with core's reason, linked through hrefFor where the shell has the section's page, or through an optional unavailableHref. Nothing renders when every section was read.
What
createRuntimeEvidenceApi(request, base)andcreateFirstLookApi(request, base)in@repowise-dev/api-client/runtime-evidenceand/reports. Each takes a request function and the route root for a repository, and returns the same calls the package already exports.ApiRequest,ApiRequestInit,apiRequestandwithQueryinclient.ts: the request shape the factories need (path with its query, optional PUT or POST with a JSON body), and this client's own implementation of it.DecisionAgentHerotakesonCopy("prompt" | "review_all"), called when either copy button is clicked, so a host can count the handoff without matching the button's label.RepowiseUsage(and soSavingsPageBody'susage) takeschildrenin place of the token figures and table, for a host that bills from a ledger and records no tokens.fallbackstays what it says: loading and errors.PerformanceOpportunityEvidence.finding_idisstring | null: a measured hotspot's evidence row comes from runtime evidence and has no static finding. The one shared reader (the raw observations row key) already fell back to the index.FirstLookReportlistsreport.unavailableunder "Not in this report", each section with core's reason, linked throughhrefForwhere the shell has the section's page, or through an optionalunavailableHref. Before, an uncollected section was dropped and read like one with nothing found. Nothing renders when every section was read, so the web page is unchanged in that case. Two copy keys (notInReport,openSection) are added to the copy type and both web locales.getEvidenceStatus,getMeasured,getFirstLook,markFirstLookItem, ...) are now the factories overapiRequestwith the/api/repos/{id}/evidenceand/api/repos/{id}/reports/first-lookroots. Signatures and URLs are unchanged.Why
An app that renders
DecisionAgentHeroand wants a copy count had to match the label in a capture handler, which breaks on a relabel or the "Copied" swap. An app whose spend has no token rows had nowhere to put its figures butfallback.An app that renders
PerformanceViewandFirstLookReportfrom its own backend has its own fetch layer (auth, timeouts, error mapping) and its own route prefixes. Today it has to restate every path, query name and response type in a second client, which drifts. With the factories it passes its request wrapper and its root and keeps one definition.Checked and left alone, since both already work for a server-rendered host:
PerformanceViewwithruntimeEvidenceomitted shows no connect state, and with{ connected: true }and nofoundshows none either (covered byperformance-view.test.tsxandperformance-measured.test.tsx).FirstLookReportandRepoReportCardtouchwindowanddocumentonly inside click handlers (copy link, print, export view, downloads). Both render withreact-dom/serverin a Node environment with nowindow.Tests
CI ran on this PR and is green on the head commit; local evidence below.
packages/api-client:tsc --noEmitclean;vitest run14 files, 227 passed. The evidence tests now assert the real URLs through the configured fetch; newreports.test.tscovers read, prompt, mark (PUT body), rewrite (POST) and a factory over a custom request and root.packages/web:tsc --noEmitclean (rerun after the ui commit); reports, setup page and code-health component tests 5 files, 35 passed.packages/ui:tsc --noEmitclean; fullvitest run3589 of 3590 passed. The one failure,dsm-matrix.test.tsxrender budget, is a timing test in an untouched file and passes alone (2/2). New tests: the hero reportspromptthenreview_all(the callback runs after the copy and its feedback); the usage section shows a host body with no token figures and no grouping control, and afalsebody ({cond && <Ledger />}) keeps the figures. Savings and decisions suites after the review fixes: 240 passed.finding_idis null, and report tests for the unavailable block (reason, default link, host link, nothing when empty): uitscclean, report and performance suites 149 passed; webtscclean, reports and message tests passed.scripts/check-shared-imports.mjsclean.Deploy order
No deploy step. Apps that consume the shared packages pick the factories up when they move their pin to the merge commit.