Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 75 additions & 34 deletions web/src/components/cx/journeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}`;
Expand Down Expand Up @@ -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<SVGGElement | null>(null);

Expand Down Expand Up @@ -127,7 +162,7 @@ function Wave({
return (
<svg
viewBox={`0 0 ${W} ${H}`}
className={cn("block h-auto w-full", compact ? "min-w-[640px]" : "min-w-[760px]")}
className={cn("block h-auto w-full", compact ? "min-w-[640px]" : "min-w-[620px]")}
role="group"
aria-label={`${journey.name}, ${n} stops`}
>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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}
</text>
Expand All @@ -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}
</text>
Expand Down Expand Up @@ -330,14 +367,14 @@ function StopDetail({
? allFindings(repo).find((f) => f.rank === s.findingRank)
: undefined;
return (
<div className="grid gap-0 md:grid-cols-[1fr_1.1fr]" aria-live="polite">
<div className="flex min-w-0 flex-col gap-4 border-b p-5 md:border-r md:border-b-0">
<div className="flex min-w-0 flex-col" aria-live="polite">
<div className="flex min-w-0 flex-col gap-3 border-b p-5">
<p className="font-mono text-xs text-muted-foreground">
Stop {idx + 1} of {journey.stops.length}
<span className="mx-2 text-border">/</span>
{lanes[s.lane]}
</p>
<p className="text-lg leading-snug text-pretty">{s.caption}</p>
<p className="text-base leading-snug text-pretty md:text-[1.0625rem]">{s.caption}</p>
<div className="flex flex-col gap-1 rounded-md border bg-background px-3 py-2.5">
<code className="font-mono text-xs [overflow-wrap:anywhere]">{s.file}</code>
<span className="font-mono text-xs text-muted-foreground [overflow-wrap:anywhere]">
Expand Down Expand Up @@ -377,7 +414,7 @@ function StopDetail({
</Link>
)}
</div>
<div className="min-w-0 p-5">
<div className="min-w-0 p-5 pt-4">
<Payload stop={s} prev={prev} />
</div>
</div>
Expand Down Expand Up @@ -543,29 +580,33 @@ export function JourneyPlayer({
</button>
</div>
</div>
<div className="flex flex-col gap-0.5 border-b px-4 py-3">
<p className="font-semibold tracking-tight">{journey.name}</p>
<p className="text-sm text-muted-foreground">
{journey.stops.length} stops through {modules} modules
{findingSteps > 0 &&
`, ${findingSteps} ${findingSteps === 1 ? "step is a ranked finding" : "steps are ranked findings"}`}
.
</p>
</div>
<div className="overflow-x-auto border-b">
<Wave
lanes={bundle.lanes}
journey={journey}
idx={idx}
travelling={travelling}
onPick={go}
against={against}
/>
</div>
<div className="border-b px-4 py-2.5">
<Legend />
<div className="grid lg:grid-cols-[minmax(0,1.6fr)_minmax(0,1fr)]">
<div className="min-w-0 border-b lg:border-r lg:border-b-0">
<div className="flex flex-col gap-0.5 border-b px-4 py-3">
<p className="font-semibold tracking-tight">{journey.name}</p>
<p className="text-sm text-muted-foreground">
{journey.stops.length} stops through {modules} modules
{findingSteps > 0 &&
`, ${findingSteps} ${findingSteps === 1 ? "step is a ranked finding" : "steps are ranked findings"}`}
.
</p>
</div>
<div className="overflow-x-auto border-b">
<Wave
lanes={bundle.lanes}
journey={journey}
idx={idx}
travelling={travelling}
onPick={go}
against={against}
/>
</div>
<div className="px-4 py-2.5">
<Legend />
</div>
</div>
<StopDetail repo={repo} lanes={bundle.lanes} journey={journey} idx={idx} />
</div>
<StopDetail repo={repo} lanes={bundle.lanes} journey={journey} idx={idx} />
</div>
);
}
Expand Down
90 changes: 39 additions & 51 deletions web/src/routes/Change.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@ export function Change() {
useTitle(`Before and after · ${repo.name}`);
return (
<div className="flex flex-col gap-14">
<Header repo={repo} />
<section className="flex flex-col gap-5" aria-labelledby="impact">
<SectionHead title="The impact at a glance" id="impact" />
<Impact repo={repo} compareDate={repo.beforeDate} />
<div className="flex flex-col gap-1">
<h2 id="impact" className="text-3xl font-semibold tracking-tight text-balance">
Before and after {monthYear(repo.sponsorDate ?? repo.beforeDate)}
</h2>
<p className="text-lg leading-snug text-pretty text-muted-foreground">
Did the structure get better or worse once the team started using AI coding tools?
</p>
</div>
<Impact repo={repo} compareDate={repo.beforeDate} side={<KeyDates repo={repo} />} />
</section>
<Drift repo={repo} />
<StructuralEvents repo={repo} />
Expand All @@ -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 (
<div
className={cn(
"grid gap-8 lg:items-end",
series ? "lg:grid-cols-[1fr_380px]" : "lg:grid-cols-1",
)}
>
<div className="flex max-w-3xl flex-col gap-3">
<h2 className="text-3xl font-semibold tracking-tight text-balance">
Before and after {monthYear(compared)}
</h2>
<p className="text-lg leading-snug text-pretty">
Did the structure get better or worse once the team started using AI coding tools?
</p>
<p className="leading-relaxed text-muted-foreground">
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.
</p>
<dl className="flex flex-col gap-1 text-sm leading-relaxed text-muted-foreground">
<div className="flex flex-wrap gap-x-2">
<dt>Comparison date:</dt>
<dd className="font-mono text-foreground tabular">{compared}</dd>
<Panel className="flex flex-col gap-3 p-5">
<dl className="grid grid-cols-2 gap-x-6 gap-y-3 text-sm">
<div>
<dt className="text-muted-foreground">Compared from</dt>
<dd className="font-mono font-semibold tabular">{compared}</dd>
</div>
{repo.adoptionDate && (
<div>
<dt className="text-muted-foreground">AI tools adopted</dt>
<dd className="font-mono font-semibold tabular">{repo.adoptionDate}</dd>
</div>
{repo.adoptionDate && (
<div className="flex flex-wrap gap-x-2">
<dt>Detected adoption date:</dt>
<dd className="font-mono text-foreground tabular">{repo.adoptionDate}</dd>
</div>
)}
{repo.adoptionEvidence && (
<div className="flex flex-wrap items-baseline gap-x-2">
<dt>Adoption evidence:</dt>
<dd className="text-foreground">{repo.adoptionEvidence}</dd>
</div>
)}
</dl>
</div>
{series && (
<Panel className="flex flex-col gap-2 p-4">
)}
</dl>
{repo.adoptionEvidence && (
<p className="text-xs leading-relaxed text-muted-foreground">{repo.adoptionEvidence}</p>
)}
{series && series.length > 0 && (
<div className="flex flex-col gap-1.5 border-t pt-3">
<div className="flex items-baseline justify-between gap-3">
<p className="text-xs font-medium">Share of commits with an explicit AI marker</p>
{series.length > 0 && (
<p className="font-mono text-lg font-semibold tabular">
{pct(series.at(-1)!.value, 0)}
</p>
)}
<p className="text-xs font-medium">Commits with an explicit AI marker</p>
<p className="font-mono text-lg font-semibold tabular">
{pct(series.at(-1)!.value, 0)}
</p>
</div>
<SeriesChart
series={series}
sponsorDate={repo.sponsorDate}
adoptionDate={repo.adoptionDate}
height={56}
height={48}
domain={[0, Math.max(...series.map((p) => p.value), 0.1)]}
label="Share of commits with an explicit AI marker"
/>
</Panel>
</div>
)}
</div>
<p className="text-xs leading-relaxed text-muted-foreground">
Only commits with an explicit AI marker count as AI, so that share is a lower bound.
Everything else is no AI signal.
</p>
</Panel>
);
}

Expand Down
10 changes: 4 additions & 6 deletions web/src/routes/Journeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ export function Journeys() {
useTitle(`Journeys · ${repo.name}`);
if (!journeys) return <NotFound inRepo />;
return (
<div className="flex flex-col gap-6">
<div className="flex max-w-3xl flex-col gap-2">
<div className="flex flex-col gap-4">
<div className="flex flex-wrap items-baseline justify-between gap-x-6 gap-y-1">
<h2 className="text-2xl font-semibold tracking-tight text-balance">
Follow one request through the code
</h2>
<p className="text-pretty text-muted-foreground">
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.
<p className="text-sm text-muted-foreground">
A dip goes down into core code, a rise brings the result back. Press Play or pick a stop.
</p>
</div>
<JourneyPlayer repo={repo} bundle={journeys} start={start} />
Expand Down
6 changes: 5 additions & 1 deletion web/src/routes/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -31,7 +32,10 @@ export function Overview() {

return (
<div className="flex flex-col gap-14">
<FixFirst repo={repo} compareDate={compareDate} />
<div className="grid gap-8 lg:grid-cols-[minmax(0,1fr)_17.5rem] lg:items-start">
<FixFirst repo={repo} compareDate={compareDate} />
<AtAGlance repo={repo} compareDate={compareDate} />
</div>
<HowItFits repo={repo} journeys={journeys} />
<BeforeAfter repo={repo} compareDate={compareDate} />
<DecisionList repo={repo} />
Expand Down
Loading