Skip to content

feat(ui): host hooks for the evidence, report, decisions and usage surfaces - #6187

Merged
swati510 merged 8 commits into
mainfrom
feat/ui-host-props
Nov 23, 2026
Merged

swati510 merged 8 commits into
mainfrom
feat/ui-host-props

Conversation

@RaghavChamadiya

@RaghavChamadiya RaghavChamadiya commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

What

  • createRuntimeEvidenceApi(request, base) and createFirstLookApi(request, base) in @repowise-dev/api-client/runtime-evidence and /reports. Each takes a request function and the route root for a repository, and returns the same calls the package already exports.
  • ApiRequest, ApiRequestInit, apiRequest and withQuery in client.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.
  • DecisionAgentHero takes onCopy("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 so SavingsPageBody's usage) takes children in place of the token figures and table, for a host that bills from a ledger and records no tokens. fallback stays what it says: loading and errors.
  • PerformanceOpportunityEvidence.finding_id is string | 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.
  • FirstLookReport lists report.unavailable under "Not in this report", each section with core's reason, linked through hrefFor where the shell has the section's page, or through an optional unavailableHref. 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.
  • The existing exports (getEvidenceStatus, getMeasured, getFirstLook, markFirstLookItem, ...) are now the factories over apiRequest with the /api/repos/{id}/evidence and /api/repos/{id}/reports/first-look roots. Signatures and URLs are unchanged.

Why

An app that renders DecisionAgentHero and 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 but fallback.

An app that renders PerformanceView and FirstLookReport from 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:

  • PerformanceView with runtimeEvidence omitted shows no connect state, and with { connected: true } and no found shows none either (covered by performance-view.test.tsx and performance-measured.test.tsx).
  • FirstLookReport and RepoReportCard touch window and document only inside click handlers (copy link, print, export view, downloads). Both render with react-dom/server in a Node environment with no window.

Tests

CI ran on this PR and is green on the head commit; local evidence below.

  • packages/api-client: tsc --noEmit clean; vitest run 14 files, 227 passed. The evidence tests now assert the real URLs through the configured fetch; new reports.test.ts covers read, prompt, mark (PUT body), rewrite (POST) and a factory over a custom request and root.
  • packages/web: tsc --noEmit clean (rerun after the ui commit); reports, setup page and code-health component tests 5 files, 35 passed.
  • packages/ui: tsc --noEmit clean; full vitest run 3589 of 3590 passed. The one failure, dsm-matrix.test.tsx render budget, is a timing test in an untouched file and passes alone (2/2). New tests: the hero reports prompt then review_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 a false body ({cond && <Ledger />}) keeps the figures. Savings and decisions suites after the review fixes: 240 passed.
  • Later commits: performance view tests with a measured hotspot whose finding_id is null, and report tests for the unavailable block (reason, default link, host link, nothing when empty): ui tsc clean, report and performance suites 149 passed; web tsc clean, reports and message tests passed.
  • scripts/check-shared-imports.mjs clean.

Deploy order

No deploy step. Apps that consume the shared packages pick the factories up when they move their pin to the merge commit.

… 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.
@repowise-bot

repowise-bot Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Review before merge: AI review: nothing to fix; 10 changed contracts with callers outside this PR.

  1. 10 contracts changed in 2 files in ways their callers can notice: getFirstLook, firstLookMarkdownPath, getFirstLookPrompt, markFirstLookItem (+6 more). 4 callers outside this PR (review them)
  2. This PR introduces 3 new health notes across 3 files: 2× dry violation, 1× untested complexity (see all)

✅ 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.


View on Repowise
Plain markdown for agents · Reviews (7) · Last reviewed commit: fix(ui): the repo report names the sections it could not collect · Since the last review: 2 resolved (their code changed), 2 answered in their threads

Settings and updates

Since the last push: health 9.1 to 9.0, 7 more files
Silence one PR with [skip repowise] in the title · Bot settings
/repowise recheck reviews the current head again
/repowise review deep runs the deep review on it
/repowise remember <text> tells the reviewer what to leave out next time (reply on a finding to scope it to that file)
/repowise help lists the commands
⭐ Star Repowise · 📥 Install on another repo

…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.
@RaghavChamadiya RaghavChamadiya changed the title feat(api-client): build the evidence and report clients over a host's request feat(ui): host hooks for the evidence, report, decisions and usage surfaces Nov 22, 2026
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.
@swati510
swati510 merged commit 9ab6008 into main Nov 23, 2026
20 checks passed
@swati510
swati510 deleted the feat/ui-host-props branch November 23, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants