Skip to content

Web: before and after (the bonus screen) #32

Done

Description

@Pranav-Mathad

Owner: Viraj · Priority: P1 · Blocked by: #1, #27

Parallel work: Needs MatrixCanvas from #27 (imports it, does not edit it). Parallel with #28-#31 and #33.

1. Goal

The sponsor's bonus question, "better or worse after AI?", answered on one stable picture (spec §10.2 screen 5, §12): the same grid at two dates with a switch, every structural change labelled with its evidence, and each decision's conformance over time.

2. Scope & File Boundaries

Create or edit

  • web/src/screens/BeforeAfter.tsx (replace the stub)
  • New folder web/src/screens/beforeafter/: Switch.tsx, Changes.tsx, DecisionSeries.tsx, compare.ts, beforeafter.css, beforeafter.test.ts

Do not touch

  • Anything not listed above. In particular: web/src/App.tsx, web/src/screens.ts, web/src/data/**, web/src/contracts/**, web/public/bundles/**, web/package.json, web/package-lock.json, and every other screen's files.
  • No new npm packages: everything needed is already installed (d3-hierarchy, d3-scale, d3-scale-chromatic, cytoscape, elkjs, shiki).
  • Nothing outside web/.
  • If something outside your files has to change, comment on this issue instead of editing it.

3. Contracts / Inputs & Outputs

Read first: AGENTS.md, spec.md §12.3 and §12.4, web/src/screens/BeforeAfter.tsx, web/src/screens/grid/MatrixCanvas.tsx (props only), web/public/bundles/fixture-wide/before_after.json.

bundle.beforeAfter: BeforeAfterFile
interface BeforeAfterFile {
  before: { date: string; sha: string; role: string };
  after:  { date: string; sha: string; role: string };
  adoption_date: string | null;            // the repo's own detected adoption date
  module_order: string[];                  // ONE order for both dates: switching must not move anything
  cells: { src: string; dst: string; before: number; after: number }[];
  changes: { id: string; title: string;
             kind: "restructuring" | "link_added" | "link_removed" | "module_added" | "module_removed";
             label: "planned" | "no_stated_intent";
             basis: "same_code_old_layout" | "restructuring_commit" | "decision_document" | "pr_goal" | null;
             source: "ai" | "computed"; evidence: Evidence[] }[];
  yardsticks: { name: string; series: { snapshot_date: string; value: number }[] }[];
}
bundle.decisions.checks   // DecisionCheck[] per decision per snapshot: the conformance series
// compare.ts: pure, unit-tested
export function cellsAt(file: BeforeAfterFile, which: "before" | "after"): MatrixCell[];   // zero-count cells dropped
export function changedCells(file: BeforeAfterFile): Map<string, { before: number; after: number }>;

The side shown is useView().snapshot (the before or the after date; default after).

Rules for every screen (from AGENTS.md and .impeccable/surfaces/prototype-codexray-demo.md):

  • Colours and fonts come from web/src/styles/tokens.css. Vermilion (--against-decision) marks code that goes against a decision and is used for nothing else: not buttons, not links, not selection.
  • Every AI-written sentence carries the "AI" badge; everything else is "Computed". The app never calls a model and loads static files only.
  • Cross-screen state lives in the address bar through useView / useSetView / viewLink from web/src/data/view.ts, so every view has a permanent link.
  • Scores use cividis (interpolateCividis from d3-scale-chromatic); categories use the Okabe-Ito tokens. It must read on a projector.

4. Implementation Steps

  1. compare.ts with tests.
  2. Switch: two buttons with the two dates; it calls setView({ snapshot }). Only colours change; the layout stays (spec §10.4).
  3. Draw MatrixCanvas with order = module_order, cells = cellsAt(...), changed = changedCells(...).
  4. Changes: the list of changes. Labels in words: "Planned" with its basis ("same code under the old layout", "restructuring commit", "decision document", "stated goal of the pull request") or "No stated intent". The word "unplanned" never appears. A change with source: "ai" carries the AI badge. Evidence rows link to the code pane.
  5. DecisionSeries: per decision, conformance at each snapshot date as a small line, with two vertical markers: 2025-03-01 and adoption_date when present. Then the yardstick series the same way.
  6. One sentence under the heading: the panel describes what changed and does not show cause. Do not write "AI caused" or "x% AI-written" anywhere (spec §12.4).

5. Acceptance Criteria & Verification

  • #/fixture-wide/before-after: switching between the two dates changes cell colours and the change markers while every module label stays where it was; the address bar holds snapshot=<date> and survives a reload.
  • Each change shows "Planned" with a basis or "No stated intent"; grep -ri "unplanned\|AI caused\|AI-written" web/src/screens/beforeafter web/src/screens/BeforeAfter.tsx finds nothing.
  • Both the 2025-03-01 marker and the adoption-date marker are drawn when adoption_date is set.
  • beforeafter.test.ts covers cellsAt and changedCells.
  • cd web && npm run typecheck && npm test && npm run build passes.

Branch: viraj/32-web-before-and-after-the. Open a pull request whose description says Closes #32. The specification is spec.md; the working rules are in AGENTS.md and CONTRIBUTING.md.

Activity

  1. added
    owner:viraj
    P1
    on Nov 28, 2026
  2. Pranav-Mathad commented on Nov 28, 2026

    @Pranav-Mathad
    OwnerAuthor

    PR #68 (closes #10) fills before_after.json with real data, so the screen now gets:

    • changes: 134 entries on Artemis (87 Shopware, 65 Graylog), each with a label, a basis and evidence. Evidence is commits, or lines that open in the code pane.
    • module_order and cells for every module at either date (89 on Artemis: 73 at END plus 16 that exist only at 2025-03-01). Modules that exist only at the earlier date are not nodes in map.json.

    Three things noticed in the web app while checking the screen, left for you since they are in web/:

    1. web/src/screens/BeforeAfter.tsx line 32 labels a module that is not in map.json with its full id minus M:, so the 16 earlier-only modules show their whole path on the axis instead of a short name.
    2. Finding.origin.note is never shown. In web/src/screens/decisions/FixFirst.tsx a 0 AI share reads "no AI signal" and a 0 share reads "0% of lines"; for a run without line origin, or a finding with no line evidence, the note is what says it was not measured.
    3. "Arrived after March 2025" (FixFirst.tsx) and "After 1 Mar 2025" (StatsTable.tsx) are literal text; the date is in the bundle (before_after.before.date).

    To try it: codexray report --repo artemis, then make bundle REPO=artemis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1owner:viraj

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions