From ee3752022f033b5c5f40cba325f440ab9c0bcf99 Mon Sep 17 00:00:00 2001 From: Viraj5503 Date: Sun, 29 Nov 2026 08:33:29 +0100 Subject: [PATCH] Put the most important part of each tab on the first screen --- web/src/components/cx/journeys.tsx | 109 ++++++++++++------ web/src/routes/Change.tsx | 90 +++++++-------- web/src/routes/Journeys.tsx | 10 +- web/src/routes/Overview.tsx | 6 +- web/src/routes/Trust.tsx | 57 +++------- web/src/routes/change/impact.tsx | 152 ++++++++++++++++++-------- web/src/routes/overview/AtAGlance.tsx | 116 ++++++++++++++++++++ web/src/routes/trust/pipeline.tsx | 80 ++++++++++++++ web/src/routes/trust/ranking.tsx | 113 +++++++++++++------ web/src/routes/trust/stages.tsx | 6 +- 10 files changed, 521 insertions(+), 218 deletions(-) create mode 100644 web/src/routes/overview/AtAGlance.tsx create mode 100644 web/src/routes/trust/pipeline.tsx diff --git a/web/src/components/cx/journeys.tsx b/web/src/components/cx/journeys.tsx index ec07f89f..ae0a86a4 100644 --- a/web/src/components/cx/journeys.tsx +++ b/web/src/components/cx/journeys.tsx @@ -11,10 +11,11 @@ import type { Journey, JourneyBundle, JourneyStop } from "../../data/journeys"; import { FOCUS, cn } from "./cn"; import { allFindings } from "./finding-fix"; -const W = 1000; -const X0 = 190; -const X1 = 950; -const LANE_H = 72; +// The player sits in the left two thirds of the page, so it draws on a narrower, taller canvas +// than the wide preview on the report page. +const WIDE = { W: 1000, X0: 190, X1: 950 }; +const NARROW = { W: 820, X0: 170, X1: 780 }; +const LANE_H = 86; /** How long the packet takes along one edge, and how long a stop stays open while playing. */ const TRAVEL_MS = 1000; @@ -42,6 +43,38 @@ function shortName(name: string): string { type Pt = { x: number; y: number }; +/** A thin outline in the card colour so a label stays readable where a line crosses it. */ +const HALO = { + paintOrder: "stroke", + stroke: "var(--card)", + strokeWidth: 4, + strokeLinejoin: "round", +} as const; + +/** + * Whether each stop's labels go above its node. Lane numbers grow downward. Labels go above on + * the way down and at peaks, below on the way up and in valleys, so neighbours never stack; + * two stops in the same lane take opposite sides. + */ +function labelsAbove(stops: JourneyStop[]): boolean[] { + const out: boolean[] = []; + stops.forEach((s, i) => { + const prev = i > 0 ? stops[i - 1].lane : null; + const next = i < stops.length - 1 ? stops[i + 1].lane : null; + const L = s.lane; + let above: boolean; + if (prev !== null && prev === L) above = !out[i - 1]; + else if (prev === null) above = next === null || next >= L; + else if (next === null) above = prev > L; + else if (prev < L && next < L) above = false; + else if (prev > L && next > L) above = true; + else if (next === L) above = prev > L; + else above = next > L; + out.push(above); + }); + return out; +} + function edgePath(a: Pt, b: Pt): string { const mx = (a.x + b.x) / 2; return `M${a.x},${a.y} C${mx},${a.y} ${mx},${b.y} ${b.x},${b.y}`; @@ -86,13 +119,15 @@ function Wave({ const stops = journey.stops; const n = stops.length; // The still preview packs the lanes closer so the drawing stays short on the report page. + const { W, X0, X1 } = compact ? WIDE : NARROW; const laneH = compact ? 50 : LANE_H; - const laneY = (i: number) => (compact ? 54 : 46) + i * laneH; + const laneY = (i: number) => (compact ? 54 : 56) + i * laneH; const pts = stops.map((s, i) => ({ x: X0 + (i * (X1 - X0)) / Math.max(1, n - 1), y: laneY(s.lane), })); - const H = laneY(lanes.length - 1) + (compact ? 46 : 54); + const H = laneY(lanes.length - 1) + (compact ? 46 : 60); + const sides = labelsAbove(stops); const pathRefs = useRef<(SVGPathElement | null)[]>([]); const packet = useRef(null); @@ -127,7 +162,7 @@ function Wave({ return ( @@ -172,7 +207,7 @@ function Wave({ })} {stops.map((s, i) => { const p = pts[i]; - const up = i % 2 === 0; + const up = sides[i]; const on = i === idx && travelling === null; const future = i > idx; const flag = !!s.findingRank; @@ -214,6 +249,7 @@ function Wave({ y={up ? p.y - 20 : p.y + 30} textAnchor="middle" className="fill-foreground font-mono text-[13px] font-semibold" + style={HALO} > {s.module} @@ -222,6 +258,7 @@ function Wave({ y={up ? p.y - 36 : p.y + 46} textAnchor="middle" className="fill-muted-foreground text-[12.5px]" + style={HALO} > {s.label} @@ -330,14 +367,14 @@ function StopDetail({ ? allFindings(repo).find((f) => f.rank === s.findingRank) : undefined; return ( -
-
+
+

Stop {idx + 1} of {journey.stops.length} / {lanes[s.lane]}

-

{s.caption}

+

{s.caption}

{s.file} @@ -377,7 +414,7 @@ function StopDetail({ )}
-
+
@@ -543,29 +580,33 @@ export function JourneyPlayer({
-
-

{journey.name}

-

- {journey.stops.length} stops through {modules} modules - {findingSteps > 0 && - `, ${findingSteps} ${findingSteps === 1 ? "step is a ranked finding" : "steps are ranked findings"}`} - . -

-
-
- -
-
- +
+
+
+

{journey.name}

+

+ {journey.stops.length} stops through {modules} modules + {findingSteps > 0 && + `, ${findingSteps} ${findingSteps === 1 ? "step is a ranked finding" : "steps are ranked findings"}`} + . +

+
+
+ +
+
+ +
+
+
-
); } diff --git a/web/src/routes/Change.tsx b/web/src/routes/Change.tsx index 09a19b7e..46dd04dc 100644 --- a/web/src/routes/Change.tsx +++ b/web/src/routes/Change.tsx @@ -34,10 +34,16 @@ export function Change() { useTitle(`Before and after · ${repo.name}`); return (
-
- - +
+

+ Before and after {monthYear(repo.sponsorDate ?? repo.beforeDate)} +

+

+ Did the structure get better or worse once the team started using AI coding tools? +

+
+ } />
@@ -50,68 +56,50 @@ export function Change() { ); } -function Header({ repo }: { repo: RepoBundle }) { +/** The dates the comparison rests on, and the share of AI-marked commits where it is stored. */ +function KeyDates({ repo }: { repo: RepoBundle }) { const series = repo.aiShareSeries; const compared = repo.sponsorDate ?? repo.beforeDate; return ( -
-
-

- Before and after {monthYear(compared)} -

-

- Did the structure get better or worse once the team started using AI coding tools? -

-

- This page shows what changed between the two dates. It does not blame any change on AI: - only commits with an explicit AI marker are counted as AI, so that share is a lower bound, - and everything else is no AI signal. -

-
-
-
Comparison date:
-
{compared}
+ +
+
+
Compared from
+
{compared}
+
+ {repo.adoptionDate && ( +
+
AI tools adopted
+
{repo.adoptionDate}
- {repo.adoptionDate && ( -
-
Detected adoption date:
-
{repo.adoptionDate}
-
- )} - {repo.adoptionEvidence && ( -
-
Adoption evidence:
-
{repo.adoptionEvidence}
-
- )} -
-
- {series && ( - + )} +
+ {repo.adoptionEvidence && ( +

{repo.adoptionEvidence}

+ )} + {series && series.length > 0 && ( +
-

Share of commits with an explicit AI marker

- {series.length > 0 && ( -

- {pct(series.at(-1)!.value, 0)} -

- )} +

Commits with an explicit AI marker

+

+ {pct(series.at(-1)!.value, 0)} +

p.value), 0.1)]} label="Share of commits with an explicit AI marker" /> - +
)} -
+

+ Only commits with an explicit AI marker count as AI, so that share is a lower bound. + Everything else is no AI signal. +

+ ); } diff --git a/web/src/routes/Journeys.tsx b/web/src/routes/Journeys.tsx index a222a67a..646f5a39 100644 --- a/web/src/routes/Journeys.tsx +++ b/web/src/routes/Journeys.tsx @@ -16,15 +16,13 @@ export function Journeys() { useTitle(`Journeys · ${repo.name}`); if (!journeys) return ; return ( -
-
+
+

Follow one request through the code

-

- Each journey starts with something a person does in the browser and follows it through the - modules that handle it. The height of the line is the layer: a dip goes down into core - code, a rise brings the result back up. Press Play or pick any stop. +

+ A dip goes down into core code, a rise brings the result back. Press Play or pick a stop.

diff --git a/web/src/routes/Overview.tsx b/web/src/routes/Overview.tsx index 4b394927..9a6bdb73 100644 --- a/web/src/routes/Overview.tsx +++ b/web/src/routes/Overview.tsx @@ -9,6 +9,7 @@ import { repoPath } from "../cx/address"; import { STATUS, STATUS_ORDER, statusCounts } from "../cx/meta"; import type { JourneyBundle } from "../data/journeys"; import type { RepoBundle, Status } from "../cx/types"; +import { AtAGlance } from "./overview/AtAGlance"; import { BeforeAfter } from "./overview/BeforeAfter"; import { FixFirst } from "./overview/FixFirst"; import { MainModules } from "./overview/Structure"; @@ -31,7 +32,10 @@ export function Overview() { return (
- +
+ + +
diff --git a/web/src/routes/Trust.tsx b/web/src/routes/Trust.tsx index e6f8586e..55931f75 100644 --- a/web/src/routes/Trust.tsx +++ b/web/src/routes/Trust.tsx @@ -8,7 +8,8 @@ import { commitLink, fmt, pct } from "../cx/meta"; import type { RepoBundle, StabilityRow } from "../cx/types"; import { ShowMoreButton, useShowMore } from "./decisions/show-more"; import { useRepo } from "./RepoLayout"; -import { AiUse, usd } from "./trust/ai-use"; +import { AiUse } from "./trust/ai-use"; +import { Pipeline } from "./trust/pipeline"; import { Ranking } from "./trust/ranking"; import { Stages } from "./trust/stages"; @@ -42,54 +43,24 @@ const TESTS: Record = { export function Trust() { const repo = useRepo(); useTitle(`Approach · ${repo.name}`); - const files = repo.coverage.reduce((s, c) => s + c.files, 0); - const cost = repo.usage.reduce((s, u) => s + u.cost, 0); - const rerun = repo.stability.find((r) => r.test === "identical_rerun"); - // Only the tiles whose value the bundle holds. - const tiles: [string, string][] = [ - ...(repo.coverage.length > 0 ? [["files read", fmt(files)] as [string, string]] : []), - ...(rerun - ? [ - ["top 10 unchanged on an identical re-run", `${Math.round(rerun.top10 * 10)} of 10`] as [ - string, - string, - ], - ] - : []), - ...(repo.usage.length > 0 ? [["AI cost", usd(cost)] as [string, string]] : []), - ]; - return (
-
-
-

Approach

-

- How this report was made, where an AI model is used, and how much of it stays the same - when the run is repeated. +

+
+

+ Approach +

+

+ The facts come from the code and its history. The AI sits on top of the facts, not + instead of them.

- {tiles.length > 0 && ( -
- {tiles.map(([k, v]) => ( -
-
{k}
-
{v}
-
- ))} -
- )} -
- - - + + + + diff --git a/web/src/routes/change/impact.tsx b/web/src/routes/change/impact.tsx index 133fff87..cd32ad66 100644 --- a/web/src/routes/change/impact.tsx +++ b/web/src/routes/change/impact.tsx @@ -1,6 +1,7 @@ // The impact at a glance: each stored measure at the comparison date against now, drawn as two // dots on one line, with whether that is better or worse and how fast it moved before and after. // Every value is a stored series point; this file only compares two of them. +import type { ReactNode } from "react"; import { ComputedMark } from "../../components/cx/badges"; import { cn } from "../../components/cx/cn"; import { allFindings } from "../../components/cx/finding-fix"; @@ -110,6 +111,13 @@ function rowsOf(repo: RepoBundle, compareDate: string): Row[] { }); } +/** How many stored measures got worse, better or stayed about the same since the date. */ +export function impactCounts(repo: RepoBundle, compareDate: string) { + const rows = rowsOf(repo, compareDate); + const n = (v: Verdict) => rows.filter((r) => r.verdict === v).length; + return { total: rows.length, worse: n("worse"), better: n("better"), same: n("same") }; +} + const VERDICT_TEXT: Record = { worse: "Worse", better: "Better", @@ -185,11 +193,28 @@ function momentum(row: Row): string | null { return "same pace as before"; } -function MeasureRow({ row, compact }: { row: Row; compact: boolean }) { +/** Row columns: measure, then, the two dots, now, verdict. Dense rows sit in a narrower column. */ +const COLS = "md:grid-cols-[minmax(0,1.1fr)_5rem_minmax(8rem,1fr)_5rem_10.5rem]"; +const COLS_DENSE = "md:grid-cols-[minmax(0,1.5fr)_3.75rem_minmax(5rem,1fr)_4.25rem_9.5rem]"; + +function MeasureRow({ + row, + compact, + dense = false, +}: { + row: Row; + compact: boolean; + dense?: boolean; +}) { const { m, before, now, verdict } = row; - const pace = compact ? null : paceText(row); + const pace = compact || dense ? null : paceText(row); return ( -
  • +
  • {m.label}

    @@ -233,7 +258,7 @@ const TREND_PARTS: { key: Finding["trend"]["status"]; label: string; color: stri ]; /** Every ranked problem, split by how it moved over the snapshots. */ -function ProblemTrend({ repo }: { repo: RepoBundle }) { +function ProblemTrend({ repo, top = true }: { repo: RepoBundle; top?: boolean }) { const all = allFindings(repo); if (all.length === 0) return null; const counts = TREND_PARTS.map((p) => ({ @@ -241,7 +266,7 @@ function ProblemTrend({ repo }: { repo: RepoBundle }) { n: all.filter((f) => f.trend.status === p.key).length, })); return ( -

    +

    The {fmt(all.length)} problems found, by how they moved

    0 ? (sizeNow.value - sizeBefore.value) / sizeBefore.value : null; + const table = ( +
    +
    + measure + {compareDate} + + + + + then + + + + now + + {nowDate} + since then +
    +
      + {rows.map((r) => ( + + ))} +
    + {!compact && !side && } +
    + ); + const note = ( +

    + {grew !== null && grew > 0.05 && ( + <> + The code itself grew: links between modules went from {fmt(sizeBefore!.value)} to{" "} + {fmt(sizeNow!.value)} ({sign(grew)} + {Math.round(Math.abs(grew) * 100)}%). Backward links and rule breaks per 1,000 lines are + rates, so they already allow for that.{" "} + + )} + These are stored measurements at two dates. They show what changed, not that AI caused it.{" "} + +

    + ); + if (side) { + return ( +
    + +
    + {table} +
    +
    + +
    + {side} + {note} +
    +
    +
    + ); + } return (
    -
    -
    - measure - {compareDate} - - - - - then - - - - now - - {nowDate} - since then -
    -
      - {rows.map((r) => ( - - ))} -
    - {!compact && } -
    -

    - {grew !== null && grew > 0.05 && ( - <> - The code itself grew: links between modules went from {fmt(sizeBefore!.value)} to{" "} - {fmt(sizeNow!.value)} ({sign(grew)} - {Math.round(Math.abs(grew) * 100)}%). Backward links and rule breaks per 1,000 lines are - rates, so they already allow for that.{" "} - - )} - These are stored measurements at two dates. They show what changed, not that AI caused it.{" "} - -

    + {table} + {note}
    ); } diff --git a/web/src/routes/overview/AtAGlance.tsx b/web/src/routes/overview/AtAGlance.tsx new file mode 100644 index 00000000..5c5c9322 --- /dev/null +++ b/web/src/routes/overview/AtAGlance.tsx @@ -0,0 +1,116 @@ +// The report's side column: one line per judging point, each from a stored value and each a link +// to the tab that explains it, so the first screen of the report answers all of them. +import { ArrowUpRight } from "lucide-react"; +import type { ReactNode } from "react"; +import { Link } from "react-router"; +import { FOCUS, cn } from "../../components/cx/cn"; +import { allFindings } from "../../components/cx/finding-fix"; +import { type RepoTab, repoPath } from "../../cx/address"; +import { STATUS, fmt, statusCounts } from "../../cx/meta"; +import type { RepoBundle } from "../../cx/types"; +import { impactCounts } from "../change/impact"; +import { monthYear } from "./BeforeAfter"; + +function Item({ + to, + label, + value, + detail, +}: { + to: string; + label: string; + value: ReactNode; + detail: ReactNode; +}) { + return ( +
  • + + + {label} + + + {value} + {detail} + +
  • + ); +} + +export function AtAGlance({ repo, compareDate }: { repo: RepoBundle; compareDate: string }) { + const path = (tab?: RepoTab) => repoPath(repo.id, tab); + const total = allFindings(repo).length; + const counts = statusCounts(repo.decisions); + const holding = counts.holding + counts.mostly_holding; + const impact = impactCounts(repo, compareDate); + const rerun = repo.stability.find((s) => s.test === "identical_rerun"); + const calls = repo.usage.reduce((s, u) => s + u.calls, 0); + const cost = repo.usage.reduce((s, u) => s + u.cost, 0); + + return ( + + ); +} diff --git a/web/src/routes/trust/pipeline.tsx b/web/src/routes/trust/pipeline.tsx new file mode 100644 index 00000000..a839c773 --- /dev/null +++ b/web/src/routes/trust/pipeline.tsx @@ -0,0 +1,80 @@ +// The seven stages as one row, the five computed ones apart from the two on top, each with the +// number this run stored for it. The same seven stages the challenge brief names. +import { ChevronRight } from "lucide-react"; +import { AiBadge } from "../../components/cx/badges"; +import { cn } from "../../components/cx/cn"; +import { fmt } from "../../cx/meta"; +import type { RepoBundle } from "../../cx/types"; +import { COMPUTED, ON_TOP, type Stage } from "./stages"; + +const SHORT: Record = { + 1: "History, dated snapshots, AI markers", + 2: "Every file, any language, one grammar each", + 3: "Modules, files, functions per snapshot", + 4: "This page: map, close-ups, code", + 5: "Decisions, pressure points, drift", + 6: "Reads decisions, judges exceptions", + 7: "Ranks by arithmetic, writes the report", +}; + +function Box({ repo, s, last }: { repo: RepoBundle; s: Stage; last: boolean }) { + const num = s.numbers(repo)[0]; + return ( +
  • +
    +
    + {s.n} + {s.ai && } +
    +

    {s.name}

    +

    {SHORT[s.n]}

    + {num && ( +

    + {fmt(num[0])}{" "} + {num[1]} +

    + )} +
    + {!last && ( + + )} +
  • + ); +} + +export function Pipeline({ repo }: { repo: RepoBundle }) { + const all = [...COMPUTED, ...ON_TOP]; + return ( +
    +
      + {all.map((s, i) => ( + + ))} +
    +
    +
    + + + Stages 1 to 5: deterministic engineering, no AI model + +
    +
    + + Stages 6 and 7: AI on top of the facts +
    +
    +

    + Stages 1 to 5 are deterministic engineering with no AI model. Stages 6 and 7 sit on top of + the facts. +

    +
    + ); +} diff --git a/web/src/routes/trust/ranking.tsx b/web/src/routes/trust/ranking.tsx index f793c5fd..a33eb58a 100644 --- a/web/src/routes/trust/ranking.tsx +++ b/web/src/routes/trust/ranking.tsx @@ -1,48 +1,97 @@ -// How the rank is computed, with the weights stored with the run. +// How the rank is computed: the formula with the weights stored with the run, what each letter +// means, and the formula worked through with the stored numbers of the rank-1 finding. +import { Link } from "react-router"; import { ComputedMark } from "../../components/cx/badges"; +import { FOCUS, cn } from "../../components/cx/cn"; import { weightOf } from "../../components/cx/finding-fix"; -import { Panel, SectionHead } from "../../components/cx/primitives"; +import { SectionHead } from "../../components/cx/primitives"; +import { findingPath } from "../../cx/address"; import type { RepoBundle } from "../../cx/types"; /** One decimal, or a dash when the weight is not stored. */ const w = (v: number | null) => (v === null ? "–" : v.toFixed(1)); +const n2 = (v: number) => v.toFixed(2); -const LETTERS = [ - ["S", "Size"], - ["R", "Reach"], - ["P", "Change pressure"], - ["A", "Authority"], - ["ease", "Ease"], -] as const; +const TERMS: { k: "S" | "R" | "P" | "A" | "ease"; name: string; means: string }[] = [ + { + k: "A", + name: "Authority", + means: "How firmly the rule is written down. 0.8 for pressure points.", + }, + { k: "S", name: "Size", means: "How big the problem is, against others of its kind." }, + { k: "R", name: "Reach", means: "How many files a change here can affect." }, + { k: "P", name: "Change pressure", means: "How often the code around it changed in 12 months." }, + { + k: "ease", + name: "Ease", + means: "Cheap fixes first: 1.0 for 1 to 3 places, 0.8 for 4 to 20, 0.6 above.", + }, +]; + +const term = "rounded-md bg-muted px-1.5 py-0.5"; export function Ranking({ repo }: { repo: RepoBundle }) { + const ws = weightOf(repo, "S"); + const wr = weightOf(repo, "R"); + const wp = weightOf(repo, "P"); + const top = repo.findings[0]; + const p = top?.priority; + const impact = + p && ws !== null && wr !== null && wp !== null ? p.A * (ws * p.S + wr * p.R + wp * p.P) : null; + return ( -
    - } /> - -
    -

    - impact = A × ({w(weightOf(repo, "S"))}·S + {w(weightOf(repo, "R"))}·R +{" "} - {w(weightOf(repo, "P"))}·P) +

    + } /> +
    +
    +

    + priority = A × ({w(ws)}·S +{" "} + {w(wr)}·R + {w(wp)}·P) ×{" "} + ease

    -

    priority = impact × ease, rounded to 2 places

    -

    order: priority, then finding id

    -
    -
    -
    - {LETTERS.map(([k, label]) => ( -
    -
    {k}
    -
    {label}
    -
    - ))} -
    -

    - The weights are stored with the run; they are a judgement, not a standard. The top 10 - then holds at most 3 findings of one type and 2 from one module. +

    + Plain arithmetic on stored facts. No AI model changes the order; ties go by finding id. + The top 10 then holds at most 3 findings of one type and 2 from one module.

    - +
    + {TERMS.map((t) => ( +
    +
    + {t.k} + {t.name} +
    +
    {t.means}
    +
    + ))} +
    + {top && p && impact !== null && ( +
    +

    + Worked through for{" "} + + finding #{top.rank} + + , {top.title}: +

    +

    + {n2(p.A)} × ({w(ws)}·{n2(p.S)} + {w(wr)}·{n2(p.R)} + {w(wp)}·{n2(p.P)}) × {n2(p.ease)} + {" = "} + + {n2(p.score)} + +

    + {Math.abs(impact * p.ease - p.score) > 0.006 && ( +

    + The stored score is shown; the inputs above are rounded to 2 places. +

    + )} +
    + )} +
    ); } diff --git a/web/src/routes/trust/stages.tsx b/web/src/routes/trust/stages.tsx index 1e9f0f79..c7bccad1 100644 --- a/web/src/routes/trust/stages.tsx +++ b/web/src/routes/trust/stages.tsx @@ -6,7 +6,7 @@ import { Chip, Panel, SectionHead } from "../../components/cx/primitives"; import { fmt } from "../../cx/meta"; import type { RepoBundle } from "../../cx/types"; -interface Stage { +export interface Stage { n: number; name: string; does: string; @@ -21,7 +21,7 @@ const plural = (n: number, one: string, many: string) => (n === 1 ? one : many); const when = (ok: boolean, value: number, noun: string): [number, string][] => ok ? [[value, noun]] : []; -const COMPUTED: Stage[] = [ +export const COMPUTED: Stage[] = [ { n: 1, name: "Repository", @@ -77,7 +77,7 @@ const COMPUTED: Stage[] = [ }, ]; -const ON_TOP: Stage[] = [ +export const ON_TOP: Stage[] = [ { n: 6, name: "LLM Judge",