diff --git a/docs/screenshots/ui-audit-fixes/d05c-react-scrolled-after.webp b/docs/screenshots/ui-audit-fixes/d05c-react-scrolled-after.webp new file mode 100644 index 0000000..0947f5f Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d05c-react-scrolled-after.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d05c-react-scrolled-before.webp b/docs/screenshots/ui-audit-fixes/d05c-react-scrolled-before.webp new file mode 100644 index 0000000..f3b919d Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d05c-react-scrolled-before.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d06-compare-after.webp b/docs/screenshots/ui-audit-fixes/d06-compare-after.webp new file mode 100644 index 0000000..9e40a96 Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d06-compare-after.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d06-compare-before.webp b/docs/screenshots/ui-audit-fixes/d06-compare-before.webp new file mode 100644 index 0000000..24f6cfc Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d06-compare-before.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d10-paths-after.webp b/docs/screenshots/ui-audit-fixes/d10-paths-after.webp new file mode 100644 index 0000000..363ce6c Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d10-paths-after.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d10-paths-before.webp b/docs/screenshots/ui-audit-fixes/d10-paths-before.webp new file mode 100644 index 0000000..ef5b01c Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d10-paths-before.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d13-learning-after.webp b/docs/screenshots/ui-audit-fixes/d13-learning-after.webp new file mode 100644 index 0000000..711195c Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d13-learning-after.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d13-learning-before.webp b/docs/screenshots/ui-audit-fixes/d13-learning-before.webp new file mode 100644 index 0000000..ae233ec Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d13-learning-before.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d14-shortcuts-after.webp b/docs/screenshots/ui-audit-fixes/d14-shortcuts-after.webp new file mode 100644 index 0000000..e57f627 Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d14-shortcuts-after.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d14-shortcuts-before.webp b/docs/screenshots/ui-audit-fixes/d14-shortcuts-before.webp new file mode 100644 index 0000000..726bc2c Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d14-shortcuts-before.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d16-xray-result-after.webp b/docs/screenshots/ui-audit-fixes/d16-xray-result-after.webp new file mode 100644 index 0000000..ff66e90 Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d16-xray-result-after.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d16-xray-result-before.webp b/docs/screenshots/ui-audit-fixes/d16-xray-result-before.webp new file mode 100644 index 0000000..01c8a38 Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d16-xray-result-before.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d16b-xray-result-bottom-after.webp b/docs/screenshots/ui-audit-fixes/d16b-xray-result-bottom-after.webp new file mode 100644 index 0000000..d0a65ed Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d16b-xray-result-bottom-after.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d16b-xray-result-bottom-before.webp b/docs/screenshots/ui-audit-fixes/d16b-xray-result-bottom-before.webp new file mode 100644 index 0000000..4e44998 Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d16b-xray-result-bottom-before.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d18-role-backend-after.webp b/docs/screenshots/ui-audit-fixes/d18-role-backend-after.webp new file mode 100644 index 0000000..1834724 Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d18-role-backend-after.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d18-role-backend-before.webp b/docs/screenshots/ui-audit-fixes/d18-role-backend-before.webp new file mode 100644 index 0000000..3009f69 Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d18-role-backend-before.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d19-app-discord-after.webp b/docs/screenshots/ui-audit-fixes/d19-app-discord-after.webp new file mode 100644 index 0000000..c3b3d00 Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d19-app-discord-after.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d19-app-discord-before.webp b/docs/screenshots/ui-audit-fixes/d19-app-discord-before.webp new file mode 100644 index 0000000..23720bc Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d19-app-discord-before.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d20-stack-result-after.webp b/docs/screenshots/ui-audit-fixes/d20-stack-result-after.webp new file mode 100644 index 0000000..434ff6e Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d20-stack-result-after.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d20-stack-result-before.webp b/docs/screenshots/ui-audit-fixes/d20-stack-result-before.webp new file mode 100644 index 0000000..fe1ac8e Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d20-stack-result-before.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d21-path-step1-after.webp b/docs/screenshots/ui-audit-fixes/d21-path-step1-after.webp new file mode 100644 index 0000000..9f2a41c Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d21-path-step1-after.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d21-path-step1-before.webp b/docs/screenshots/ui-audit-fixes/d21-path-step1-before.webp new file mode 100644 index 0000000..e0ceeff Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d21-path-step1-before.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d22-rail-domains-after.webp b/docs/screenshots/ui-audit-fixes/d22-rail-domains-after.webp new file mode 100644 index 0000000..dc865d2 Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d22-rail-domains-after.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d22-rail-domains-before.webp b/docs/screenshots/ui-audit-fixes/d22-rail-domains-before.webp new file mode 100644 index 0000000..2f4691c Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d22-rail-domains-before.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d26-click-backend-after.webp b/docs/screenshots/ui-audit-fixes/d26-click-backend-after.webp new file mode 100644 index 0000000..0743687 Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d26-click-backend-after.webp differ diff --git a/docs/screenshots/ui-audit-fixes/d26-click-backend-before.webp b/docs/screenshots/ui-audit-fixes/d26-click-backend-before.webp new file mode 100644 index 0000000..b241673 Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/d26-click-backend-before.webp differ diff --git a/docs/screenshots/ui-audit-fixes/l05-xray-light-after.webp b/docs/screenshots/ui-audit-fixes/l05-xray-light-after.webp new file mode 100644 index 0000000..58b5749 Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/l05-xray-light-after.webp differ diff --git a/docs/screenshots/ui-audit-fixes/l05-xray-light-before.webp b/docs/screenshots/ui-audit-fixes/l05-xray-light-before.webp new file mode 100644 index 0000000..2f68097 Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/l05-xray-light-before.webp differ diff --git a/docs/screenshots/ui-audit-fixes/m04-roles-after.webp b/docs/screenshots/ui-audit-fixes/m04-roles-after.webp new file mode 100644 index 0000000..654b815 Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/m04-roles-after.webp differ diff --git a/docs/screenshots/ui-audit-fixes/m04-roles-before.webp b/docs/screenshots/ui-audit-fixes/m04-roles-before.webp new file mode 100644 index 0000000..d816e9f Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/m04-roles-before.webp differ diff --git a/docs/screenshots/ui-audit-fixes/m05-xray-after.webp b/docs/screenshots/ui-audit-fixes/m05-xray-after.webp new file mode 100644 index 0000000..130ff5f Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/m05-xray-after.webp differ diff --git a/docs/screenshots/ui-audit-fixes/m05-xray-before.webp b/docs/screenshots/ui-audit-fixes/m05-xray-before.webp new file mode 100644 index 0000000..a5bc846 Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/m05-xray-before.webp differ diff --git a/docs/screenshots/ui-audit-fixes/t02-atlas-after.webp b/docs/screenshots/ui-audit-fixes/t02-atlas-after.webp new file mode 100644 index 0000000..9a4665a Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/t02-atlas-after.webp differ diff --git a/docs/screenshots/ui-audit-fixes/t02-atlas-before.webp b/docs/screenshots/ui-audit-fixes/t02-atlas-before.webp new file mode 100644 index 0000000..d945c88 Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/t02-atlas-before.webp differ diff --git a/docs/screenshots/ui-audit-fixes/t03-react-after.webp b/docs/screenshots/ui-audit-fixes/t03-react-after.webp new file mode 100644 index 0000000..4406514 Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/t03-react-after.webp differ diff --git a/docs/screenshots/ui-audit-fixes/t03-react-before.webp b/docs/screenshots/ui-audit-fixes/t03-react-before.webp new file mode 100644 index 0000000..bd13817 Binary files /dev/null and b/docs/screenshots/ui-audit-fixes/t03-react-before.webp differ diff --git a/docs/ui-conventions.md b/docs/ui-conventions.md new file mode 100644 index 0000000..3fa027c --- /dev/null +++ b/docs/ui-conventions.md @@ -0,0 +1,82 @@ +# UI conventions + +One page of rules for anything that adds or changes UI. Most problems found in the +2026-11-23 UI audit were inconsistencies between features, so new work should follow +these rules instead of inventing a local variant. If a rule doesn't fit, change it here +first. + +## Names + +| Thing | Call it | Not | +|---|---|---| +| The home view with every cluster | **the atlas** ("Back to atlas") | Universe, Explore, Universe View | +| A top-level grouping (Backend, Security…) | **field** | domain (code and data still say `domain`) | +| A field nested in another (Generative AI) | **sub-field** | subdomain | +| Nodes inside a field | **members** (same noun in the panel and the hover card) | connections | +| X-Ray statuses | Found in code · Listed as a dependency · Guessed from related files · Related to the stack | Confirmed / Declared / Inferred | + +Counts always use thousands separators: `n.toLocaleString("en-US")` (3,122, not 3122). + +## Panels + +- **Left side** (beside the rail, `left: 72px`, same width and padding): tool panels the + reader opens from the toolbar. Fields, Stack, Roles, Apps, Guided paths, Learning map, + Outline. +- **Right side**: what is selected. Node details, Repo X-Ray results. +- **Bottom centre**: a followed path's step card. +- **Modal**: only Keyboard shortcuts and the shared report card. Nothing else dims the atlas. +- **Phones** (≤ 640 px): left-side tool panels become bottom sheets (max 58% height) so + the map stays visible above them. +- Panels are opaque (`background: var(--panel)`); atlas text must never show through. +- When a panel highlights nodes, the camera frames them inside the space the panel + leaves (`frameNodes` / `usableRect` in `graph-canvas/framing.ts`). Add new panels to + `OVERLAY_SELECTORS` there and to the heading `panels` list in `headings.ts`. + +## Toolbar + +- Labels never change with state. Show "open" with `aria-pressed="true"`, not with a + different word ("Exit compare", "← Back to Explore"). +- 1101 px and up: every tool has a label. 701–1100 px: the five main tools keep labels and + the utilities move under **More**. Phones: icons only, with `aria-label`. + +## Buttons and links + +- One primary (filled) button per panel at most: the action most people want next + (Open report card, Start with Python). +- A whole list row is the button. Don't repeat an "Open" button on every row; use a + trailing `→` chevron for "opens in place". +- `↗` only for links that leave TechAtlas (GitHub, official sites, Wikipedia). +- "Copy link" is a bordered button like its neighbours, never bare text. +- Lists that switch items have one stepper (← prev · n / N · next →) and one breadcrumb + at the top ("← All roles"). No extra ` setQuery(e.target.value)} /> - -
+
+
{categories.map(([c, n]) => ( ))}
- +
{shown.length === 0 &&

No app matches “{query}”{category ? ` in ${category}` : ""}.

} @@ -101,11 +101,6 @@ export function AppsPanel({ graph, appId, onAppChange, onPick, onHighlight, onCl position={`${all.findIndex((a) => a.id === app.id) + 1} / ${all.length}`} prev={prevApp && goPrev ? { label: prevApp.name, onGo: goPrev, icon: } : null} next={nextApp && goNext ? { label: nextApp.name, onGo: goNext, icon: } : null} /> -

{app.summary}

{resolved.layers.map((layer) => (
@@ -126,7 +121,6 @@ export function AppsPanel({ graph, appId, onAppChange, onPick, onHighlight, onCl })}. Stacks change; this is what the company has written about publicly.

-
} diff --git a/frontend/src/components/DomainLegend.test.tsx b/frontend/src/components/DomainLegend.test.tsx new file mode 100644 index 0000000..918f56c --- /dev/null +++ b/frontend/src/components/DomainLegend.test.tsx @@ -0,0 +1,26 @@ +import { afterEach, describe, expect, it, vi } from "vitest"; +import { cleanup, fireEvent, render, screen } from "@testing-library/react"; +import { DomainLegend } from "./DomainLegend"; +import { emptyFilter } from "../graph/filters"; +import type { DomainSummary } from "../api/types"; + +afterEach(cleanup); + +const domains: DomainSummary[] = [ + { id: "domain:backend", slug: "backend", name: "Backend Development", short_description: "", color: "#0f0", node_count: 1172 }, + { id: "domain:cms", slug: "cms", name: "CMS & E-commerce", short_description: "", color: "#0f0", node_count: 33, parent_id: "domain:backend" } as DomainSummary, +]; + +describe("DomainLegend (Fields panel)", () => { + it("lists fields with sub-fields, focuses on click and filters with the checkbox", () => { + const onPick = vi.fn(), onFilterChange = vi.fn(); + render( {}} + filter={emptyFilter()} onFilterChange={onFilterChange} />); + expect(screen.getByText("1 field · 1 sub-field")).toBeTruthy(); + expect(screen.getByText("1,172")).toBeTruthy(); + fireEvent.click(screen.getByRole("button", { name: /CMS & E-commerce/ })); + expect(onPick).toHaveBeenCalledWith("cms"); + fireEvent.click(screen.getByRole("checkbox", { name: /Backend Development/ })); + expect(onFilterChange.mock.calls[0][0].domains.has("domain:backend")).toBe(true); + }); +}); diff --git a/frontend/src/components/DomainLegend.tsx b/frontend/src/components/DomainLegend.tsx index c517e2a..46f4465 100644 --- a/frontend/src/components/DomainLegend.tsx +++ b/frontend/src/components/DomainLegend.tsx @@ -1,76 +1,97 @@ import { Fragment } from "react"; -import type { DomainSummary } from "../api/types"; +import type { DomainSummary, NodeType } from "../api/types"; +import { emptyFilter, isEmptyFilter, type FilterState } from "../graph/filters"; interface Props { domains: DomainSummary[]; onPick: (slugOrId: string) => void; - // Currently selected node id (so a selected domain row reads as active and the legend - // visually links to the highlighted sector on the canvas — redesign §18/§19). + // Currently selected node id, so a selected field row reads as active. selectedId?: string | null; - // UI-C: collapsed state is controlled by the parent so it can auto-minimize during - // Repo X-Ray (freeing canvas space) while staying reopenable. + // Collapsed state is controlled by the parent so it can minimize during Repo X-Ray. collapsed: boolean; onToggle: () => void; + /** Field and type filters live in the same panel (one list of fields, not two). */ + filter?: FilterState; + onFilterChange?: (next: FilterState) => void; } -/** Curated atlas legend / domain navigator. Lists the 14 TOP-LEVEL domains, with the three - * canonical subdomains nested under their parent (hierarchy honest). Doubles as a - * keyboard-accessible jump list; a selected row links to the highlighted sector. */ -export function DomainLegend({ domains, onPick, selectedId, collapsed, onToggle }: Props) { +const NODE_TYPES: { value: NodeType; label: string }[] = [ + { value: "domain", label: "Field hubs" }, + { value: "concept", label: "Concepts" }, + { value: "technology", label: "Technologies" }, +]; + +function toggle(set: Set, value: T): Set { + const next = new Set(set); + if (next.has(value)) next.delete(value); else next.add(value); + return next; +} + +/** + * The Fields panel: every field with its sub-fields indented under it. Clicking a name + * focuses that field on the atlas; the checkbox narrows the atlas to the checked fields. + * Replaces the separate Domains list and Filters panel, which listed the same 40 rows twice. + */ +export function DomainLegend({ domains, onPick, selectedId, collapsed, onToggle, filter, onFilterChange }: Props) { + const filtering = !!filter && !isEmptyFilter(filter); if (collapsed) { return ( - ); } const topLevel = domains.filter((d) => !d.parent_id); const childrenOf = (id: string) => domains.filter((d) => d.parent_id === id); + const subCount = domains.length - topLevel.length; const row = (d: DomainSummary, nested: boolean) => (
  • - +
    + {filter && onFilterChange && ( + onFilterChange({ ...filter, domains: toggle(filter.domains, d.id) })} /> + )} + +
  • ); return ( -
    +
    -

    Domains

    - {topLevel.length} top-level areas +

    Fields

    + {topLevel.length} {topLevel.length === 1 ? "field" : "fields"} · {subCount} {subCount === 1 ? "sub-field" : "sub-fields"}
    - + {filtering && onFilterChange && ( + + )} +
    + {filter && onFilterChange && ( +
    + Show only: + {NODE_TYPES.map((nt) => ( + + ))} +
    + )}
      {topLevel.map((d) => ( @@ -79,7 +100,7 @@ export function DomainLegend({ domains, onPick, selectedId, collapsed, onToggle ))}
    -

    Colour groups by domain; click a domain to focus its members.

    +

    Click a name to focus it. Tick boxes to show only those fields.

    ); } diff --git a/frontend/src/components/FilterPanel.tsx b/frontend/src/components/FilterPanel.tsx deleted file mode 100644 index cc3db86..0000000 --- a/frontend/src/components/FilterPanel.tsx +++ /dev/null @@ -1,86 +0,0 @@ -// Phase 1B filter controls (requirements 1.6–1.10). Keyboard-accessible toggles for -// node type and domain. Emits a new FilterState; the actual hiding happens in -// GraphCanvas via Sigma reducers (no relayout). - -import type { DomainSummary, NodeType } from "../api/types"; -import { emptyFilter, isEmptyFilter, type FilterState } from "../graph/filters"; - -interface Props { - domains: DomainSummary[]; - filter: FilterState; - onChange: (next: FilterState) => void; - // UI-E: on mobile the panel is a bottom sheet hidden until the Filters control opens it. - // Desktop ignores this (CSS keeps the panel visible regardless). - mobileOpen?: boolean; -} - -const NODE_TYPES: { value: NodeType; label: string }[] = [ - { value: "domain", label: "Domains" }, - { value: "concept", label: "Concepts" }, - { value: "technology", label: "Technologies" }, -]; - -function toggle(set: Set, value: T): Set { - const next = new Set(set); - if (next.has(value)) next.delete(value); - else next.add(value); - return next; -} - -export function FilterPanel({ domains, filter, onChange, mobileOpen = false }: Props) { - const active = !isEmptyFilter(filter); - - return ( -
    -
    -

    Filters

    - -
    - -
    - Type - {NODE_TYPES.map((nt) => ( - - ))} -
    - -
    - Domain - {domains.map((d) => ( - - ))} -
    -
    - ); -} diff --git a/frontend/src/components/GraphCanvas.tsx b/frontend/src/components/GraphCanvas.tsx index 050a527..8b43b8c 100644 --- a/frontend/src/components/GraphCanvas.tsx +++ b/frontend/src/components/GraphCanvas.tsx @@ -1,4 +1,5 @@ -import { useEffect } from "react"; +import { useEffect, useState } from "react"; +import { arrowNav } from "../util/arrowNav"; import type { DetectionStatus, GraphResponse } from "../api/types"; import type { SharedCamera } from "../graph/shareView"; import { useCanvasRefs } from "./graph-canvas/refs"; @@ -14,6 +15,8 @@ interface Props { data: GraphResponse; theme?: "dark" | "light"; journeyNodeIds?: string[]; + /** Number the highlighted nodes in order (a guided path's stops). */ + numberedStops?: boolean; journeyEdgeIds?: string[]; initialCamera?: SharedCamera | null; onCameraChange?: (camera: SharedCamera) => void; @@ -47,6 +50,9 @@ interface Props { // Explore "Home" reframe: bump this nonce to smoothly re-fit the default atlas camera // (used when returning from Repo X-Ray so the homepage camera is fully restored). exploreNonce?: number; + // A highlighted set to frame inside the area the open panels leave visible. A new key + // re-frames (e.g. a different role, app, stack pick or path step). + frameSet?: { ids: string[]; key: string } | null; // Top-level domain metadata (id/name/color) for the Explore sector backplates + legend // sync. Only used to DRAW the atmospheric overlay — never alters graph data. domains?: { id: string; name: string; color: string; node_count: number }[] | null; @@ -73,6 +79,7 @@ export function GraphCanvas({ data, theme = "dark", journeyNodeIds = EMPTY_IDS, + numberedStops = false, journeyEdgeIds = EMPTY_IDS, initialCamera = null, onCameraChange, @@ -91,16 +98,22 @@ export function GraphCanvas({ stackPositions = null, stackHeadings = null, exploreNonce = 0, + frameSet = null, domains = null, }: Props) { const refs = useCanvasRefs({ journeyNodeIds, journeyEdgeIds, selectedId, selectedEdgeId, previewEdgeId, visibleNodes, visibleEdges, scanStatusByNode, scanHighlightEdges, scanContextEdges, onCameraChange, onSelect, onSelectEdge, domains, }); - const { containerRef, sigmaRef, onCameraChangeRef, journeyNodesRef, journeyEdgesRef } = refs; + const { containerRef, sigmaRef, onCameraChangeRef, journeyNodesRef, journeyEdgesRef, journeyStopsRef } = refs; useEffect(() => { sigmaRef.current?.setSetting("labelColor", { color: theme === "light" ? "#26364d" : "#c8d0e8" }); sigmaRef.current?.refresh(); }, [theme]); // also re-runs node fades useEffect(() => { onCameraChangeRef.current = onCameraChange; }, [onCameraChange]); - useEffect(() => { journeyNodesRef.current = new Set(journeyNodeIds); journeyEdgesRef.current = new Set(journeyEdgeIds); sigmaRef.current?.refresh(); }, [journeyNodeIds, journeyEdgeIds]); + useEffect(() => { + journeyNodesRef.current = new Set(journeyNodeIds); journeyEdgesRef.current = new Set(journeyEdgeIds); + // A followed path numbers its stops on the map ("1. DNS", "2. HTTP"…). + journeyStopsRef.current = numberedStops ? new Map(journeyNodeIds.map((id, i) => [id, i + 1])) : null; + sigmaRef.current?.refresh(); + }, [journeyNodeIds, journeyEdgeIds, numberedStops]); // Effect order matters (React runs them in call order): build the renderer first, then // sync props into it, then the camera and overlay effects that read its state. @@ -108,8 +121,9 @@ export function GraphCanvas({ useSelectionSync(refs, selectedId, selectedEdgeId, previewEdgeId, visibleNodes, visibleEdges, scanStatusByNode, scanHighlightEdges, scanContextEdges); useStackProjection(refs, stackPositions, stackHeadings); - useCameraControl(refs, fitSignal, exploreNonce, focusId); + useCameraControl(refs, fitSignal, exploreNonce, focusId, frameSet); const headingScreens = useStackHeadings(refs, stackHeadings, stackPositions, fitSignal?.nonce); + const [headingStop, setHeadingStop] = useState(null); const backdrop = useAtlasBackdrop(refs, data, domains, exploreNonce, stackPositions, scanStatusByNode, visibleNodes); useKeyboardNav(refs); @@ -148,10 +162,15 @@ export function GraphCanvas({ tabIndex={0} aria-label="Technology graph. Arrow keys move to the connected node in that direction, Shift plus arrows pans, plus and minus zoom, 0 resets the view, Escape clears the selection. Search and the domain list reach every node." /> - {backdrop.headings.map((h) => ( + {/* Field names are one tab stop: Tab lands on one, arrow keys move between them in + reading order (top to bottom, left to right), then Tab leaves the map. */} +
    + {[...backdrop.headings].sort((a, b) => Math.round(a.top / 40) - Math.round(b.top / 40) || a.left - b.left).map((h, i, list) => ( ))} +
    {hoverPreview && (() => { const node = data.nodes.find((n) => n.id === hoverPreview.id); if (!node) return null; - const connections = new Set(data.edges.filter((edge) => edge.source === node.id || edge.target === node.id).map((edge) => edge.source === node.id ? edge.target : edge.source)).size; + // A field counts members, the same noun and number as its panel; a node counts links. + const field = node.node_type === "domain" ? domains?.find((d) => d.id === node.id) : undefined; + const connections = field ? field.node_count : new Set(data.edges.filter((edge) => edge.source === node.id || edge.target === node.id).map((edge) => edge.source === node.id ? edge.target : edge.source)).size; return ; })()} diff --git a/frontend/src/components/LearningPanel.tsx b/frontend/src/components/LearningPanel.tsx index d0ab77d..1946488 100644 --- a/frontend/src/components/LearningPanel.tsx +++ b/frontend/src/components/LearningPanel.tsx @@ -8,10 +8,13 @@ interface Props { graph: GraphResponse; onPick: (id: string) => void; onClose: () => void; + /** Next steps offered when the map is still empty. */ + onPickRole?: () => void; + onOpenPaths?: () => void; } /** "My learning map": what the viewer marked, plus what to learn next. Stored locally. */ -export function LearningPanel({ graph, onPick, onClose }: Props) { +export function LearningPanel({ graph, onPick, onClose, onPickRole, onOpenPaths }: Props) { const [map, setStatus] = useLearningMap(); const labels = useMemo(() => new Map(graph.nodes.map((n) => [n.id, n.label])), [graph]); const suggestions = useMemo(() => suggestNext(map, graph), [map, graph]); @@ -22,7 +25,12 @@ export function LearningPanel({ graph, onPick, onClose }: Props) {

    My learning map

    {marked === 0 ? ( -

    Open any technology or concept and mark it as Known, Learning or a Goal. Suggestions for what to learn next appear here. Saved only in this browser.

    + <>

    Open any technology or concept and mark it as Known, Learning or a Goal. Suggestions for what to learn next appear here. Saved only in this browser.

    + {(onPickRole || onOpenPaths) &&
    + {onPickRole && } + {onOpenPaths && } +
    } + ) : ( <> {suggestions.length > 0 && <> diff --git a/frontend/src/components/NodeDetailsPanel.tsx b/frontend/src/components/NodeDetailsPanel.tsx index 9e953f9..871d9e6 100644 --- a/frontend/src/components/NodeDetailsPanel.tsx +++ b/frontend/src/components/NodeDetailsPanel.tsx @@ -37,6 +37,8 @@ export function NodeDetailsPanel({ slugOrId, onClose, onNavigate, nodeId = null, const [wikiSummary, setWikiSummary] = useState(null); const [copied, setCopied] = useState(false); const [learning, setLearning] = useLearningMap(); + const [savedNote, setSavedNote] = useState(""); + useEffect(() => { setSavedNote(""); }, [slugOrId]); const panelRef = useRef(null); // Focus management (UI-C/UI-D req 1): capture the element that opened the panel (the @@ -130,11 +132,19 @@ export function NodeDetailsPanel({ slugOrId, onClose, onNavigate, nodeId = null,
    {detail.node_type !== "domain" && ( -
    - {LEARNING_OPTIONS.map(([value, label]) => ( - - ))} +
    + Track in my learning map +
    + {LEARNING_OPTIONS.map(([value, label]) => ( + + ))} +
    + {savedNote}
    )} - ))}
    ))} -
    + } {detail.node_type === "technology" && (

    @@ -296,6 +307,66 @@ export function NodeDetailsPanel({ slugOrId, onClose, onNavigate, nodeId = null, ); } +const MEMBER_PREVIEW = 12; + +/** + * A field's members, grouped by kind and sorted by importance (node size), with the top + * 12 of each group shown and a filter box: Backend has ~175, too many for a flat list. + */ +function FieldMembers({ neighbors, onNavigate, onPreview }: { + neighbors: NeighborEdge[]; onNavigate: (slugOrId: string) => void; onPreview: (n: NeighborEdge | null) => void; +}) { + const [query, setQuery] = useState(""); + const [expanded, setExpanded] = useState>(new Set()); + const q = query.trim().toLowerCase(); + // Members are the nodes that belong to the field (the same set and count as the header + // and the hover card); sub-fields, the parent field and other links are listed apart. + const members = neighbors.filter((n) => n.relationship_type === "belongs_to_domain"); + const match = (n: NeighborEdge) => !q || n.node.label.toLowerCase().includes(q); + const bySize = (a: NeighborEdge, b: NeighborEdge) => (b.node.size ?? 0) - (a.node.size ?? 0) || a.node.label.localeCompare(b.node.label); + const groups = [ + { type: "sub", title: "Sub-fields", items: neighbors.filter((n) => n.relationship_type === "has_subdomain" && n.direction === "out") }, + { type: "technology", title: "Technologies", items: members.filter((n) => n.node.node_type === "technology") }, + { type: "concept", title: "Concepts", items: members.filter((n) => n.node.node_type === "concept") }, + { type: "parent", title: "Part of", items: neighbors.filter((n) => n.relationship_type === "has_subdomain" && n.direction === "in") }, + { type: "other", title: "Other links", items: neighbors.filter((n) => n.relationship_type !== "has_subdomain" && n.relationship_type !== "belongs_to_domain") }, + ].map((g) => ({ ...g, items: g.items.filter(match).sort(bySize) })).filter((g) => g.items.length > 0); + const total = groups.reduce((sum, g) => sum + g.items.length, 0); + return ( +

    +

    Members ({members.length.toLocaleString("en-US")})

    + setQuery(e.target.value)} /> + {q &&

    {total} {total === 1 ? "match" : "matches"}

    } + {groups.map((g) => { + const all = q || expanded.has(g.type); + const shown = all ? g.items : g.items.slice(0, MEMBER_PREVIEW); + return ( +
    +

    {g.title} ({g.items.length})

    +
      {shown.map((n) => ( +
    • + +
    • + ))}
    + {!all && g.items.length > MEMBER_PREVIEW && ( + + )} +
    + ); + })} +
    + ); +} + function groupNeighbors(neighbors: NeighborEdge[]): [string, NeighborEdge[]][] { const map = new Map(); for (const n of neighbors) { @@ -309,10 +380,10 @@ function groupNeighbors(neighbors: NeighborEdge[]): [string, NeighborEdge[]][] { const STATUS_TEXT: Record = { - confirmed: "Confirmed in source", - declared: "Declared dependency", - inferred: "Inferred from evidence", - related: "Related", + confirmed: "Found in code", + declared: "Listed as a dependency", + inferred: "Guessed from related files", + related: "Related to the stack", }; /** "Found in this repository" — evidence for the open node when a scan is active. */ diff --git a/frontend/src/components/OutlineView.test.tsx b/frontend/src/components/OutlineView.test.tsx index a7711c2..9536fa9 100644 --- a/frontend/src/components/OutlineView.test.tsx +++ b/frontend/src/components/OutlineView.test.tsx @@ -20,9 +20,9 @@ const nodes = [ describe("OutlineView", () => { it("lists every node under its domain and filters by name", () => { render( {}} />); - expect(screen.getByText("3 nodes")).toBeTruthy(); + expect(screen.getByText("3 technologies and concepts in 2 fields")).toBeTruthy(); fireEvent.change(screen.getByLabelText("Filter the outline by name"), { target: { value: "post" } }); - expect(screen.getByText("1 node")).toBeTruthy(); + expect(screen.getByText("1 technology or concept in 1 field")).toBeTruthy(); expect(screen.queryByText("Frontend Development")).toBeNull(); }); diff --git a/frontend/src/components/OutlineView.tsx b/frontend/src/components/OutlineView.tsx index c0954bb..f7ab020 100644 --- a/frontend/src/components/OutlineView.tsx +++ b/frontend/src/components/OutlineView.tsx @@ -53,7 +53,9 @@ export function OutlineView({ nodes, domains, onPick, onClose, fallback = false {onClose && } setQuery(e.target.value)} /> -

    {total} {total === 1 ? "node" : "nodes"}

    +

    + {total.toLocaleString("en-US")} {total === 1 ? "technology or concept" : "technologies and concepts"} in {groups.length} {groups.length === 1 ? "field" : "fields"} +

    {groups.map(({ domain, members }) => ( diff --git a/frontend/src/components/PathsLibrary.test.tsx b/frontend/src/components/PathsLibrary.test.tsx index 15be2f6..2a9b49a 100644 --- a/frontend/src/components/PathsLibrary.test.tsx +++ b/frontend/src/components/PathsLibrary.test.tsx @@ -26,7 +26,7 @@ function setup(overrides = {}) { describe("PathsLibrary", () => { it("shows featured paths and every path, and starts one on click", () => { const { onStart } = setup(); - const dialog = screen.getByRole("dialog", { name: "Guided paths" }); + const dialog = screen.getByRole("region", { name: "Guided paths" }); expect(within(dialog).getByText("Start here")).toBeTruthy(); fireEvent.click(within(dialog).getAllByRole("button", { name: /Containers, step by step/ })[0]); expect(onStart).toHaveBeenCalledWith(1); @@ -38,7 +38,7 @@ describe("PathsLibrary", () => { expect(screen.queryByText("Start here")).toBeNull(); expect(screen.getByText("1 matching path")).toBeTruthy(); fireEvent.click(screen.getByRole("button", { name: "Clear filters" })); - expect(screen.getByText("All paths")).toBeTruthy(); + expect(screen.getByText("Start here")).toBeTruthy(); }); it("filters by progress and shows status badges", () => { diff --git a/frontend/src/components/PathsLibrary.tsx b/frontend/src/components/PathsLibrary.tsx index 9892c59..a3eda88 100644 --- a/frontend/src/components/PathsLibrary.tsx +++ b/frontend/src/components/PathsLibrary.tsx @@ -33,14 +33,21 @@ export function PathsLibrary({ entries, done, progress, activeIndex, onStart, on const fields = useMemo(() => pathFields(entries), [entries]); const featured = useMemo(() => featuredPaths(entries), [entries]); - const results = useMemo(() => filterPaths(entries, filter, done, progress), [entries, filter, done, progress]); const filtering = JSON.stringify(filter) !== JSON.stringify(EMPTY_PATH_FILTER); + // "Start here" cards are not repeated in "All paths" below them; a search covers every path. + const results = useMemo(() => { + const all = filterPaths(entries, filter, done, progress); + if (filtering) return all; + const shown = new Set(featured.map((e) => e.slug)); + return all.filter((e) => !shown.has(e.slug)); + }, [entries, filter, done, progress, featured, filtering]); const doneCount = entries.filter((e) => done.has(e.title)).length; const set = (patch: Partial) => setFilter((f) => ({ ...f, ...patch })); return ( -
    { if (e.target === e.currentTarget) onClose(); }}> -
    + // A left side panel like Stack, Roles and Apps (not a modal): the atlas stays visible + // and usable beside it, and a started path is framed in the space the panel leaves. +

    Guided paths

    @@ -74,9 +81,9 @@ export function PathsLibrary({ entries, done, progress, activeIndex, onStart, on
    )} -
    + {(filtering || results.length > 0) &&

    - {filtering ? `${results.length} matching ${results.length === 1 ? "path" : "paths"}` : "All paths"} + {filtering ? `${results.length} matching ${results.length === 1 ? "path" : "paths"}` : "More paths"} {filtering && }

    {results.length === 0 ? ( @@ -87,10 +94,9 @@ export function PathsLibrary({ entries, done, progress, activeIndex, onStart, on active={activeIndex === e.index} onStart={onStart} />)} )} -
    +
    }
    - -
    + ); } diff --git a/frontend/src/components/RepoXrayPanel.test.tsx b/frontend/src/components/RepoXrayPanel.test.tsx index c065524..818df53 100644 --- a/frontend/src/components/RepoXrayPanel.test.tsx +++ b/frontend/src/components/RepoXrayPanel.test.tsx @@ -69,7 +69,7 @@ describe("RepoXrayPanel", () => { const onFocusNode = vi.fn(); render(); expect(screen.getByText("Frontend Development", { selector: "h4" })).toBeTruthy(); - expect(screen.getByRole("region", { name: "Scan statistics" })).toBeTruthy(); + expect(screen.getByLabelText("Scan statistics")).toBeTruthy(); const tech = screen.getByRole("button", { name: /React/ }); fireEvent.click(tech); expect(onFocusNode).toHaveBeenCalledWith("technology:react"); @@ -110,7 +110,7 @@ describe("RepoXrayPanel", () => { render(); expect(screen.getByRole("note").textContent).toMatch(/Example scan of commit abcdef1/); - fireEvent.click(screen.getByRole("button", { name: "More examples" })); + fireEvent.click(screen.getByRole("button", { name: "More example scans" })); expect(onAnalyzeAnother).toHaveBeenCalled(); }); }); diff --git a/frontend/src/components/RepoXrayPanel.tsx b/frontend/src/components/RepoXrayPanel.tsx index 66698a3..1c1987c 100644 --- a/frontend/src/components/RepoXrayPanel.tsx +++ b/frontend/src/components/RepoXrayPanel.tsx @@ -14,7 +14,7 @@ import type { } from "../api/types"; import type { ScanPhase } from "../graph/useRepoScan"; import { safeHttpUrl } from "../util/safeUrl"; -import { CONFIDENCE_ORDER, computeScanStats, pct, scanSummaryMarkdown } from "../graph/scanStats"; +import { CONFIDENCE_ORDER, computeScanStats, scanSummaryMarkdown } from "../graph/scanStats"; import { EXAMPLE_SCANS, findExample, type ExampleScanMeta } from "../api/exampleScans"; import { ReportCard } from "./ReportCard"; @@ -41,10 +41,10 @@ interface Props { } const STATUS_LABEL: Record = { - confirmed: "Confirmed in source", - declared: "Declared dependency", - inferred: "Inferred", - related: "Related", + confirmed: "Found in code", + declared: "Listed as a dependency", + inferred: "Guessed from related files", + related: "Related to the stack", }; // Client-side URL check mirrors the server allowlist (server still re-validates). @@ -94,11 +94,9 @@ export function RepoXrayPanel({ ? phase.kind === "done" ? "▴ View scan results" : "▴ Expand" : "▾ Minimize"} - {phase.kind !== "idle" && phase.kind !== "done" && ( - - )} +
    {phase.kind !== "done" && ( <> @@ -258,7 +256,7 @@ function DetectionGroups({ title={`${STATUS_LABEL[d.detection_status]} — open details`} > - {node?.label ?? d.node_id} + {node?.label ?? labelFromId(d.node_id)} {cls ? {cls} : null} {STATUS_LABEL[d.detection_status]} @@ -277,7 +275,62 @@ function DetectionGroups({ const UNMAPPED_CAP = 50; function plural(n: number, one: string, many: string): string { - return `${n} ${n === 1 ? one : many}`; + return `${n.toLocaleString("en-US")} ${n === 1 ? one : many}`; +} + +/** A readable name for an id the atlas doesn't know (e.g. a renamed node): "technology:foo-bar" -> "Foo bar". */ +export function labelFromId(id: string): string { + const slug = id.includes(":") ? id.slice(id.indexOf(":") + 1) : id; + const words = slug.replace(/[-_]+/g, " ").trim(); + return words ? words[0].toUpperCase() + words.slice(1) : id; +} + +/** Thousands separators inside scanner notes ("22021 additional source files" -> "22,021 …"). */ +export function formatCounts(text: string): string { + return text.replace(/\b\d{4,}\b/g, (n) => Number(n).toLocaleString("en-US")); +} + +/** + * The scan's counts, computed once from the detections so the summary line, the report + * card and the by-field bars can never disagree. + */ +export function scanCounts(scan: RepoScan, nodesById: Map) { + let technologies = 0, concepts = 0; + const fields = new Set(); + for (const d of scan.detections) { + if (d.node_type === "concept") concepts++; else technologies++; + const node = nodesById.get(d.node_id); + if (node && d.node_type !== "concept") fields.add(node.primary_domain ?? "domain:other"); + } + return { technologies, concepts, fields: fields.size }; +} + +/** Copy a markdown summary or download the scan as JSON (in the "More" menu). */ +function CopyAndDownload({ scan, nodesById, domainsById }: { + scan: RepoScan; nodesById: Map; domainsById: Map; +}) { + const [copied, setCopied] = useState<"" | "summary" | "json">(""); + const flash = (k: "summary" | "json") => { setCopied(k); window.setTimeout(() => setCopied(""), 1500); }; + const copySummary = () => { + const stats = computeScanStats(scan, nodesById, domainsById); + const text = scanSummaryMarkdown(scan, stats, nodesById, domainsById, window.location.href); + void navigator.clipboard?.writeText(text).then(() => flash("summary"), () => undefined); + }; + const downloadJson = () => { + const stats = computeScanStats(scan, nodesById, domainsById); + const blob = new Blob([JSON.stringify({ repository: scan.repository, scanner_version: scan.scanner_version, + summary: scan.summary, stats, detections: scan.detections, unmapped: scan.unmapped }, null, 2)], { type: "application/json" }); + const a = document.createElement("a"); + a.href = URL.createObjectURL(blob); + a.download = `${scan.repository.owner}-${scan.repository.name}-xray.json`; + a.click(); + window.setTimeout(() => URL.revokeObjectURL(a.href), 1000); + flash("json"); + }; + return <> + + + ; } function ExampleGallery({ examples, onPick, heading }: { @@ -309,7 +362,7 @@ function ExampleGallery({ examples, onPick, heading }: { function Results({ scan, example, liveEnabled, nodesById, domainsById, learnNext, onFocusStack, onFocusNode, - onAnalyzeAnother, onExit, view, onViewChange, examples = [], onLoadExample, + onAnalyzeAnother, view, onViewChange, examples = [], onLoadExample, }: { examples?: ExampleScanMeta[]; onLoadExample?: (slug: string) => void; @@ -339,6 +392,7 @@ function Results({ const nodeIds = useMemo(() => scan.detections.map((d) => d.node_id), [scan]); const exampleMeta = findExample(example); const { tools, concepts } = groupSplit(scan.detections, nodesById); + const counts = useMemo(() => scanCounts(scan, nodesById), [scan, nodesById]); const repoUrl = safeHttpUrl(repo.url); const partial = scan.status === "partial"; // ← / → (and [ / ]) step through the example scans when this result is one of them. @@ -385,84 +439,51 @@ function Results({

    )} - {/* Section G (surfaced high): always-visible partial-scan warning */} + {/* Partial scans: one line that opens for the details, never pinned over the results. */} {partial && ( -
    - Partial scan. Some files were not inspected, so not every - technology in this repository was necessarily detected. +
    + Partial scan: some files were skipped. +

    Not every technology in this repository was necessarily detected.

    {scan.coverage.notes.length > 0 && (
      - {scan.coverage.notes.map((n, i) =>
    • {n}
    • )} + {scan.coverage.notes.map((n, i) =>
    • {formatCounts(n)}
    • )}
    )} -
    + )} - {/* Section C: compact source-backed summary metrics */} -
    -
    - {scan.summary.matched_technology_count} - technologies -
    -
    - {scan.summary.matched_concept_count} - concepts -
    -
    - {scan.summary.unmapped_package_count} - unmapped -
    -
    - - + {/* The one summary line; its numbers are the ones the report card and fields use too. */} +

    + {noMatches ? "No atlas technologies found." : <> + {plural(counts.technologies, "technology", "technologies")} + {" "}across {plural(counts.fields, "field", "fields")} + {counts.concepts > 0 ? <>, plus {plural(counts.concepts, "concept", "concepts")} : null} + {scan.summary.unmapped_package_count > 0 + ? · {plural(scan.summary.unmapped_package_count, "package", "packages")} not in the atlas yet : null} + } +

    - {/* Section D: primary actions (Focus on Stack primary; others secondary) */} + {/* One primary action (the shareable card), the map view switch, and a small menu. */}
    - -
    - {!noMatches && } - {repoUrl && ( - Open GitHub - )} - - + {!noMatches && } +
    + +
    -
    - - {learnNext.length > 0 &&
    -

    What to learn next

    -

    Technologies connected to your detected stack.

    -
      {learnNext.map((item) =>
    • )}
    -
    } - - {/* Stack View / Universe View switch (X-Ray UX correction). Both views share the - same scan, evidence, and selection; switching never rescans. */} -
    - - +
    + More ▾ + {/* Choosing an item closes the menu so it never covers the results below. */} +
    (e.currentTarget.closest("details") as HTMLDetailsElement | null)?.removeAttribute("open")}> + + {repoUrl && Open on GitHub ↗} + + +
    +
    {/* Section E/F: detected stack — tools (technologies) first, then concepts */} @@ -492,6 +513,14 @@ function Results({ )} + {learnNext.length > 0 &&
    +

    What to learn next

    +

    Technologies connected to your detected stack.

    +
      {learnNext.map((item) =>
    • )}
    +
    } + + + {/* Section F: unmapped dependencies — collapsed, capped display, full list retained */} {scan.unmapped.length > 0 && (
    @@ -538,36 +567,18 @@ function ScanStatsPanel({ scan, nodesById, domainsById }: { scan: RepoScan; nodesById: Map; domainsById: Map; }) { const stats = useMemo(() => computeScanStats(scan, nodesById, domainsById), [scan, nodesById, domainsById]); - const [copied, setCopied] = useState<"" | "summary" | "json">(""); if (stats.detected === 0) return null; const max = Math.max(...stats.fields.map((f) => f.count), 1); - const flash = (k: "summary" | "json") => { setCopied(k); window.setTimeout(() => setCopied(""), 1500); }; - const copySummary = () => { - const text = scanSummaryMarkdown(scan, stats, nodesById, domainsById, window.location.href); - void navigator.clipboard?.writeText(text).then(() => flash("summary"), () => undefined); - }; - const downloadJson = () => { - const blob = new Blob([JSON.stringify({ repository: scan.repository, scanner_version: scan.scanner_version, - summary: scan.summary, stats, detections: scan.detections, unmapped: scan.unmapped }, null, 2)], { type: "application/json" }); - const a = document.createElement("a"); - a.href = URL.createObjectURL(blob); - a.download = `${scan.repository.owner}-${scan.repository.name}-xray.json`; - a.click(); - window.setTimeout(() => URL.revokeObjectURL(a.href), 1000); - flash("json"); - }; return ( -
    -

    Stack statistics

    +
    + How this stack breaks down
    -
    {stats.fieldsTouched}/{stats.fieldsTotal}fields touched
    -
    {pct(stats.atlasCoverage, 1)}of the atlas
    -
    {stats.mappedShare === null ? "–" : pct(stats.mappedShare)}deps mapped
    -
    {stats.evidenceCount}signals in {stats.evidenceFiles} files
    +
    {stats.fieldsTouched} of {stats.fieldsTotal}fields of the atlas
    +
    {stats.evidenceFiles.toLocaleString("en-US")}files it was found in
    -

    Confidence

    -
    `${stats.confidence[k]} ${k}`).join(", ")}> +

    How sure the scan is

    +
    `${stats.confidence[k]} ${STATUS_LABEL[k].toLowerCase()}`).join(", ")}> {CONFIDENCE_ORDER.filter((k) => stats.confidence[k]).map((k) => )}
    @@ -576,7 +587,7 @@ function ScanStatsPanel({ scan, nodesById, domainsById }: {
  • {STATUS_LABEL[k]} {stats.confidence[k]}
  • )} -

    By field

    +

    By field (technologies and concepts)

      {stats.fields.map((f) => (
    • @@ -589,16 +600,11 @@ function ScanStatsPanel({ scan, nodesById, domainsById }: { {stats.ecosystems.length > 0 && <>

      Package ecosystems

      -

      {stats.ecosystems.map((e) => {e.name} {e.count})}

      +

      {stats.ecosystems.map((e) => {e.name} {e.count.toLocaleString("en-US")})}

      } {(stats.direct > 0 || stats.transitive > 0) && (

      {stats.direct} direct · {stats.transitive} transitive dependencies

      )} - -
      - - -
      -
    +
    ); } diff --git a/frontend/src/components/RepoXrayPanel.uib.test.tsx b/frontend/src/components/RepoXrayPanel.uib.test.tsx index 69b6838..fb592e7 100644 --- a/frontend/src/components/RepoXrayPanel.uib.test.tsx +++ b/frontend/src/components/RepoXrayPanel.uib.test.tsx @@ -49,18 +49,19 @@ function base(overrides = {}) { describe("RepoXrayPanel UI-B hierarchy", () => { it("renders source-backed summary metrics (R16)", () => { render(); - const metrics = screen.getByLabelText("Scan summary"); - expect(within(metrics).getByText("2")).toBeTruthy(); // technologies - expect(within(metrics).getByText("1")).toBeTruthy(); // concepts - expect(within(metrics).getByText("3")).toBeTruthy(); // unmapped + // One headline sentence carries the numbers (the report card and fields use the same ones). + const text = screen.getByLabelText("Scan summary").textContent ?? ""; + expect(text).toContain("2 technologies"); + expect(text).toContain("1 concept"); + expect(text).toContain("3 packages not in the atlas yet"); }); - it("shows Focus on Stack as the primary action (R17)", () => { + it("makes the report card the one primary action; the rest sit under More (R17)", () => { const onFocusStack = vi.fn(); render(); - const btn = screen.getByRole("button", { name: "Focus on Stack" }); - expect(btn.className).toContain("primary"); - fireEvent.click(btn); + expect(screen.getByRole("button", { name: "Open report card" }).className).toContain("primary"); + expect(document.querySelectorAll(".xray-actions .primary").length).toBe(1); + fireEvent.click(screen.getByRole("button", { name: "Re-centre the map on the stack" })); expect(onFocusStack).toHaveBeenCalled(); }); diff --git a/frontend/src/components/RolePanel.tsx b/frontend/src/components/RolePanel.tsx index dfd2d68..104070b 100644 --- a/frontend/src/components/RolePanel.tsx +++ b/frontend/src/components/RolePanel.tsx @@ -52,6 +52,8 @@ export function RolePanel({ graph, roleId, onRoleChange, onPick, onHighlight, on return (
    + {/* One way back to the list, at the top where people look for it (not below 30 rows). */} + {role && } {role ? (
    {roleEmoji(role.id)} @@ -78,11 +80,6 @@ export function RolePanel({ graph, roleId, onRoleChange, onPick, onHighlight, on position={`${all.findIndex((r) => r.id === role.id) + 1} / ${all.length}`} prev={prevRole && goPrev ? { label: prevRole.title, onGo: goPrev, icon: {roleEmoji(prevRole.id)} } : null} next={nextRole && goNext ? { label: nextRole.title, onGo: goNext, icon: {roleEmoji(nextRole.id)} } : null} /> -

    {role.summary}

    @@ -120,7 +117,6 @@ export function RolePanel({ graph, roleId, onRoleChange, onPick, onHighlight, on {unmarked.length > 0 && } -
    }
    diff --git a/frontend/src/components/SearchCommand.tsx b/frontend/src/components/SearchCommand.tsx index 021aef6..77227c5 100644 --- a/frontend/src/components/SearchCommand.tsx +++ b/frontend/src/components/SearchCommand.tsx @@ -140,7 +140,7 @@ export function SearchCommand({ onPick, domainsById, lookup }: Props) { ref={inputRef} type="text" className="search-input" - placeholder="Search technologies, concepts, domains… ( / )" + placeholder="Search the atlas ( / )" aria-label="Search the technology graph" role="combobox" aria-expanded={open} diff --git a/frontend/src/components/ShortcutsHelp.tsx b/frontend/src/components/ShortcutsHelp.tsx index c4a6e45..7fbb695 100644 --- a/frontend/src/components/ShortcutsHelp.tsx +++ b/frontend/src/components/ShortcutsHelp.tsx @@ -1,16 +1,19 @@ import { useEffect, useRef } from "react"; -const SHORTCUTS: [string, string][] = [ - ["/", "Search"], - ["← → ↑ ↓", "Move between connected nodes"], - ["← → ↑ ↓", "In a toolbar, list or grid: move between its buttons (Home / End: first / last)"], - ["[ ]", "Previous / next app, role, guided-path step or example scan"], - ["Esc", "Close the open panel"], - ["F", "Fullscreen"], - ["O", "Atlas outline (list view)"], - ["M", "My learning map"], - ["P", "Guided paths library"], - ["?", "This help"], +// Grouped by where they work, so the arrow keys (which mean different things on the map +// and in a toolbar) are listed once under each place instead of twice with no context. +const GROUPS: { title: string; items: [string, string][] }[] = [ + { title: "Anywhere", items: [ + ["/", "Search"], ["Esc", "Close the open panel"], ["F", "Fullscreen"], ["O", "Atlas outline (list view)"], + ["M", "My learning map"], ["P", "Guided paths"], ["?", "This help"], + ] }, + { title: "On the map", items: [ + ["← → ↑ ↓", "Move between connected nodes"], + ["[ ]", "Previous / next app, role, guided-path step or example scan"], + ] }, + { title: "In lists and toolbars", items: [ + ["← → ↑ ↓", "Move between buttons"], ["Home End", "First / last button"], + ] }, ]; export function ShortcutsHelp({ onClose }: { onClose: () => void }) { @@ -27,11 +30,16 @@ export function ShortcutsHelp({ onClose }: { onClose: () => void }) {
    e.stopPropagation()}>

    Keyboard shortcuts

    -
    - {SHORTCUTS.map(([keys, what]) => ( -
    {keys}
    {what}
    - ))} -
    + {GROUPS.map((g) => ( +
    +

    {g.title}

    +
    + {g.items.map(([keys, what]) => ( +
    {keys}
    {what}
    + ))} +
    +
    + ))}

    Tip: Compare two technologies side by side, or follow a guided path from the toolbar.

    diff --git a/frontend/src/components/StackPanel.tsx b/frontend/src/components/StackPanel.tsx index f4a5d68..1dc95ae 100644 --- a/frontend/src/components/StackPanel.tsx +++ b/frontend/src/components/StackPanel.tsx @@ -116,12 +116,15 @@ export function StackPanel({ graph, params, onParamsChange, currentLabel, onPick
    {p.slot.label} - {SOURCE_LABEL[p.source]} + {/* Only picks that came from the reader get a badge; "Suggested" on every row said nothing. */} + {p.source !== "recommended" && {SOURCE_LABEL[p.source]}}
    - {expanded &&

    {p.slot.role}

    diff --git a/frontend/src/components/XrayLegend.tsx b/frontend/src/components/XrayLegend.tsx index e3fa61b..a0f208f 100644 --- a/frontend/src/components/XrayLegend.tsx +++ b/frontend/src/components/XrayLegend.tsx @@ -8,22 +8,23 @@ import { useState } from "react"; const ITEMS: { status: string; short: string; label: string; cls: string }[] = [ - { status: "confirmed", short: "Confirmed", label: "Confirmed in source", cls: "status-confirmed" }, - { status: "declared", short: "Declared", label: "Declared dependency", cls: "status-declared" }, - { status: "inferred", short: "Inferred", label: "Inferred concept", cls: "status-inferred" }, - { status: "related", short: "Related", label: "Related (not detected)", cls: "status-related" }, + // Same words as the results panel (one vocabulary for the four statuses). + { status: "confirmed", short: "In code", label: "Found in code", cls: "status-confirmed" }, + { status: "declared", short: "Dependency", label: "Listed as a dependency", cls: "status-declared" }, + { status: "inferred", short: "Guessed", label: "Guessed from related files", cls: "status-inferred" }, + { status: "related", short: "Related", label: "Related to the stack (not detected)", cls: "status-related" }, ]; export function XrayLegend() { const [open, setOpen] = useState(false); return (
    setOpen(true)} onMouseLeave={() => setOpen(false)} > - Detection + Key {ITEMS.map((it) => ( diff --git a/frontend/src/components/graph-canvas/colors.ts b/frontend/src/components/graph-canvas/colors.ts index 70876bf..b8888e1 100644 --- a/frontend/src/components/graph-canvas/colors.ts +++ b/frontend/src/components/graph-canvas/colors.ts @@ -49,3 +49,15 @@ export const SCAN_CONTEXT_EDGE = "rgba(150,165,205,0.20)"; // 0.15-0.30 conte // Unrelated edges are the overwhelming majority (hundreds); even a tiny alpha accumulates // into a visible web where they overlap, so they are effectively hidden (UI-A R3.3). export const SCAN_DIM_EDGE = "rgba(120,130,150,0.0)"; + +/** Theme-aware X-Ray / dim colours. The dark values above stay the reference; the light + * theme gets inks that read on the pale page instead of near-white dots and lines. */ +const isLight = () => typeof document !== "undefined" && document.documentElement.dataset.theme === "light"; +export const dimNode = () => (isLight() ? "rgb(205,214,224)" : DIM_NODE); +export const scanDimNode = () => (isLight() ? "rgb(214,222,231)" : SCAN_DIM_NODE); +export const scanHiliteEdge = () => (isLight() ? "rgba(36,58,98,0.75)" : SCAN_HILITE_EDGE); +export const scanContextEdge = () => (isLight() ? "rgba(60,80,130,0.28)" : SCAN_CONTEXT_EDGE); +const STATUS_RING_LIGHT: Record = { + confirmed: "#15803d", declared: "#1d4ed8", inferred: "#b45309", related: "#475569", +}; +export const statusRing = (s: DetectionStatus) => (isLight() ? STATUS_RING_LIGHT[s] : STATUS_RING[s]); diff --git a/frontend/src/components/graph-canvas/drawNodeLabel.test.ts b/frontend/src/components/graph-canvas/drawNodeLabel.test.ts new file mode 100644 index 0000000..c57dd98 --- /dev/null +++ b/frontend/src/components/graph-canvas/drawNodeLabel.test.ts @@ -0,0 +1,22 @@ +import { describe, expect, it } from "vitest"; +import { placeLabel } from "./drawNodeLabel"; + +describe("placeLabel", () => { + it("puts a label right of its node by default", () => { + const spot = placeLabel(100, 100, 5, 40, 12, []); + expect(spot!.tx).toBe(109); + }); + it("moves to the left when the right side is taken", () => { + const right = placeLabel(100, 100, 5, 40, 12, [])!; + const spot = placeLabel(100, 100, 5, 40, 12, [right])!; + expect(spot.tx).toBeLessThan(100); + }); + it("never runs off the canvas edge", () => { + const spot = placeLabel(40, 100, 5, 50, 12, [], { w: 100, h: 200 }); + expect(spot!.x0).toBeGreaterThanOrEqual(0); + expect(spot!.x1).toBeLessThanOrEqual(100); + }); + it("gives up (null) when nothing fits", () => { + expect(placeLabel(10, 10, 5, 500, 12, [], { w: 100, h: 100 })).toBeNull(); + }); +}); diff --git a/frontend/src/components/graph-canvas/drawNodeLabel.ts b/frontend/src/components/graph-canvas/drawNodeLabel.ts new file mode 100644 index 0000000..90ab713 --- /dev/null +++ b/frontend/src/components/graph-canvas/drawNodeLabel.ts @@ -0,0 +1,72 @@ +import type { NodeLabelDrawingFunction } from "sigma/rendering"; + +// Node labels that never draw on top of each other. Sigma's own grid drops colliding +// labels, but highlighted sets (a role, an app, a stack, X-Ray detections) force their +// labels on, and those used to pile into one unreadable blob. Each label now tries a few +// spots around its node and takes the first free one; if none is free it is skipped +// (hovering the node still shows it). The occupied list resets before every frame. + +interface Box { x0: number; y0: number; x1: number; y1: number } +let taken: Box[] = []; +let hidden = 0; +/** Label boxes only (no node discs), with the node they name: read by the e2e overview proof. */ +let drawn: (Box & { id: string })[] = []; + +/** Call on Sigma's "beforeRender" so each frame starts with an empty page. */ +export function resetLabelSpace(): void { taken = []; drawn = []; hidden = 0; } +export function drawnLabels(): readonly (Box & { id: string })[] { return drawn; } +/** How many labels the last frame could not place (for tests and debugging). */ +export function hiddenLabelCount(): number { return hidden; } +/** Boxes the last frame's labels took, so DOM field headings can keep clear of them. */ +export function labelBoxes(): readonly Box[] { return taken; } + +const overlaps = (a: Box, b: Box) => a.x0 < b.x1 && a.x1 > b.x0 && a.y0 < b.y1 && a.y1 > b.y0; + +/** Pure placement: the first candidate box around (x, y) that doesn't hit `used`, or null. */ +export function placeLabel(x: number, y: number, r: number, w: number, h: number, used: Box[], + bounds?: { w: number; h: number }): Box & { tx: number; ty: number } | null { + const gap = 4; + const candidates = [ + { tx: x + r + gap, ty: y }, // right (the default) + { tx: x - r - gap - w, ty: y }, // left + { tx: x - w / 2, ty: y - r - gap - h / 2 }, // above + { tx: x - w / 2, ty: y + r + gap + h / 2 }, // below + { tx: x + r + gap, ty: y - h }, // upper right + { tx: x + r + gap, ty: y + h }, // lower right + ]; + for (const c of candidates) { + const box = { x0: c.tx - 2, y0: c.ty - h / 2 - 1, x1: c.tx + w + 2, y1: c.ty + h / 2 + 1 }; + // Labels stay inside the canvas: a name cut off at the edge ("ional Databases") is worse + // than the next spot around the node. + if (bounds && (box.x0 < 0 || box.x1 > bounds.w || box.y0 < 0 || box.y1 > bounds.h)) continue; + if (!used.some((b) => overlaps(b, box))) return { ...box, ...c }; + } + return null; +} + +export const drawNodeLabel: NodeLabelDrawingFunction = (context, data, settings) => { + if (!data.label) return; + // Sub-field names (domain nodes nested in a field) read as map captions: smaller, in + // the field's own colour, so they never compete with the field headings or node names. + const sub = (data as { nodeType?: string }).nodeType === "domain"; + const size = sub ? settings.labelSize - 1 : settings.labelSize; + context.font = `${sub ? 600 : settings.labelWeight} ${size}px ${settings.labelFont}`; + const w = context.measureText(data.label).width; + // The node's own disc is occupied too, so a neighbour's label never covers it. + const ratio = window.devicePixelRatio || 1; + const spot = placeLabel(data.x, data.y, data.size, w, size + 2, taken, + { w: context.canvas.width / ratio, h: context.canvas.height / ratio }); + if (!spot) { hidden++; return; } + drawn.push({ x0: spot.x0, y0: spot.y0, x1: spot.x1, y1: spot.y1, id: (data as { key?: string }).key ?? data.label }); + taken.push(spot, { x0: data.x - data.size, y0: data.y - data.size, x1: data.x + data.size, y1: data.y + data.size }); + const light = document.documentElement.dataset.theme === "light"; + // A thin halo in the background colour keeps the text readable over dots and lines. + context.lineJoin = "round"; + context.lineWidth = 3; + context.strokeStyle = light ? "rgba(237,242,247,0.9)" : "rgba(8,13,24,0.85)"; + context.strokeText(data.label, spot.tx, spot.ty + size / 3); + const c = settings.labelColor; + context.fillStyle = sub && typeof data.color === "string" && !light ? data.color + : ("color" in c ? c.color : undefined) ?? (light ? "#26364d" : "#c8d0e8"); + context.fillText(data.label, spot.tx, spot.ty + size / 3); +}; diff --git a/frontend/src/components/graph-canvas/framing.ts b/frontend/src/components/graph-canvas/framing.ts index 2fb79ef..6f125ab 100644 --- a/frontend/src/components/graph-canvas/framing.ts +++ b/frontend/src/components/graph-canvas/framing.ts @@ -129,7 +129,12 @@ export function fitExplore(renderer: Sigma, prefersReduced: boolean): number { mnX -= padX; mxX += padX; mnY -= padY; mxY += padY; const vh = el.clientHeight || window.innerHeight; const cr = el.getBoundingClientRect(); - const gpx = Math.max((mxX - mnX) / Math.max(vw, 1), (mxY - mnY) / Math.max(vh, 1)); + const fitW = (mxX - mnX) / Math.max(vw, 1), fitH = (mxY - mnY) / Math.max(vh, 1); + // Portrait tablets and phones: the atlas is wider than tall, so fitting its full width + // left half the screen empty above and below. Let the sides run off-screen a little + // (people pan sideways easily) so the map fills most of the height instead. + const portrait = vw < 1024 && vh > vw * 1.05; + const gpx = portrait ? Math.max(fitW * (narrow ? 0.62 : 0.7), fitH) : Math.max(fitW, fitH); let leftW = 0, rightW = 0; if (vw >= 641) { const q = (sel: string) => { @@ -145,8 +150,14 @@ export function fitExplore(renderer: Sigma, prefersReduced: boolean): number { else rightW = Math.max(rightW, cr.right - panel.left); } } - const bMinX = mnX - leftW * gpx; - const bMaxX = mxX + rightW * gpx; + let bMinX = mnX - leftW * gpx; + let bMaxX = mxX + rightW * gpx; + if (portrait) { + // Sigma fits the box by its constraining side, so crop the box itself to the width + // the viewport shows at this scale; nodes past it still render and can be panned to. + const cx = (bMinX + bMaxX) / 2, half = (vw * gpx) / 2; + bMinX = cx - half; bMaxX = cx + half; + } renderer.setCustomBBox({ x: [bMinX, bMaxX], y: [mnY, mxY] }); if (prefersReduced) { renderer.getCamera().setState({ x: 0.5, y: 0.5, ratio: 1, angle: 0 }); @@ -157,3 +168,89 @@ export function fitExplore(renderer: Sigma, prefersReduced: boolean): number { // Layout units are px at the reference fit; scale drawn sizes to this viewport's fit. return Math.max(0.42, Math.min(1.25, 1 / gpx)); } + +/** The part of the canvas that no open panel covers, in container pixels. */ +export interface UsableRect { left: number; top: number; right: number; bottom: number } + +// Panels that float over the canvas. Left tools, right details/X-Ray, the path card and +// phone bottom sheets all count; anything at least 85% of the width is treated as a sheet. +const OVERLAY_SELECTORS = [".details", ".xray-panel", ".stack-panel", ".outline-view:not(.is-fallback)", + ".learning-panel", ".journey-panel", ".compare-panel", ".paths-library"]; + +export function usableRect(container: HTMLElement): UsableRect { + const cr = container.getBoundingClientRect(); + const vw = container.clientWidth || window.innerWidth; + const vh = container.clientHeight || window.innerHeight; + const r: UsableRect = { left: 0, top: 0, right: vw, bottom: vh }; + for (const sel of OVERLAY_SELECTORS) { + for (const el of Array.from(document.querySelectorAll(sel)) as HTMLElement[]) { + const p = el.getBoundingClientRect(); + if (p.width <= 0 || p.height <= 0) continue; + const left = p.left - cr.left, right = p.right - cr.left, top = p.top - cr.top; + if (p.width >= vw * 0.85 || (sel === ".journey-panel" && p.width < vw * 0.6 && left > vw * 0.2)) { + // Bottom sheet, or the centred path card: the usable band is above it. + if (top > vh * 0.3) r.bottom = Math.min(r.bottom, top - 8); + continue; + } + if (left + p.width / 2 < vw / 2) r.left = Math.max(r.left, right + 8); + else r.right = Math.min(r.right, left - 8); + } + } + // Never shrink the usable area to nothing on tiny screens. + if (r.right - r.left < 160) { r.left = 0; r.right = vw; } + if (r.bottom - r.top < 140) { r.top = 0; r.bottom = vh; } + return r; +} + +/** + * Frame a set of nodes inside the usable rectangle (canvas minus open panels), by camera + * state only: no custom bbox, so semantic zoom and sizes stay as they are. With one node + * the zoom is `singleRatio` (or the current zoom when already closer) and the node lands + * in the centre of the usable area instead of the centre of the canvas. + */ +export function frameNodes(renderer: Sigma, ids: string[], opts: { + prefersReduced: boolean; singleRatio?: number; minRatio?: number; padding?: number; duration?: number; +}): boolean { + const pts = ids.map((id) => renderer.getNodeDisplayData(id)).filter((d): d is NonNullable => !!d && !d.hidden); + if (pts.length === 0) return false; + const container = renderer.getContainer(); + const vw = container.clientWidth || window.innerWidth; + const vh = container.clientHeight || window.innerHeight; + const base = { x: 0.5, y: 0.5, ratio: 1, angle: 0 }; + const toPx = (p: { x: number; y: number }) => renderer.framedGraphToViewport(p, { cameraState: base }); + let mnX = Infinity, mnY = Infinity, mxX = -Infinity, mxY = -Infinity, cx = 0, cy = 0; + for (const p of pts) { + const v = toPx(p); + mnX = Math.min(mnX, v.x - p.size); mxX = Math.max(mxX, v.x + p.size); + mnY = Math.min(mnY, v.y - p.size); mxY = Math.max(mxY, v.y + p.size); + cx += p.x; cy += p.y; + } + // Pixels per framed-graph unit at ratio 1 (y is flipped on screen). + const o = toPx({ x: 0.5, y: 0.5 }); + const kx = Math.abs(toPx({ x: 0.6, y: 0.5 }).x - o.x) / 0.1 || 1; + const ky = Math.abs(toPx({ x: 0.5, y: 0.6 }).y - o.y) / 0.1 || 1; + const u = usableRect(container); + const uw = u.right - u.left, uh = u.bottom - u.top; + const pad = opts.padding ?? 0.22; + const camera = renderer.getCamera(); + let ratio: number; + if (pts.length === 1) { + ratio = Math.min(camera.getState().ratio, opts.singleRatio ?? 0.35); + } else { + // Labels hang to the right of nodes; leave them room. + const spanW = (mxX - mnX) + 110, spanH = (mxY - mnY) + 40; + ratio = Math.max(spanW / (uw * (1 - pad)), spanH / (uh * (1 - pad)), opts.minRatio ?? 0.12); + ratio = Math.min(ratio, 1.15); + } + // Centre of the set in framed units (bbox centre for sets, the node for one). + let bx = cx / pts.length, by = cy / pts.length; + if (pts.length > 1) { + bx = 0.5 + ((mnX + mxX) / 2 - o.x) / kx; + by = 0.5 - ((mnY + mxY) / 2 - o.y) / ky; + } + // Put that centre on the usable rectangle's centre, not the canvas centre. + const dx = (u.left + uw / 2) - vw / 2, dy = (u.top + uh / 2) - vh / 2; + const target = { x: bx - (dx * ratio) / kx, y: by + (dy * ratio) / ky, ratio }; + void camera.animate(target, { duration: opts.prefersReduced ? 0 : (opts.duration ?? 560), easing: "cubicInOut" }); + return true; +} diff --git a/frontend/src/components/graph-canvas/headings.ts b/frontend/src/components/graph-canvas/headings.ts index 5119f5e..f386c7a 100644 --- a/frontend/src/components/graph-canvas/headings.ts +++ b/frontend/src/components/graph-canvas/headings.ts @@ -71,7 +71,7 @@ export class Obstacles { */ export function placeHeadings(headings: Heading[], container: HTMLElement, domains: { id: string; node_count: number }[], selected: string | null, - obstacles: Obstacles, ringLike: boolean): Heading[] { + obstacles: Obstacles, ringLike: boolean, labels: readonly { x0: number; y0: number; x1: number; y1: number }[] = []): Heading[] { headingCtx ??= document.createElement("canvas").getContext("2d"); if (!headingCtx) return headings; const vw = container.clientWidth, vh = container.clientHeight; @@ -82,7 +82,8 @@ export function placeHeadings(headings: Heading[], container: HTMLElement, const gap = phone ? 2 : 6; const crect = container.getBoundingClientRect(); const panels = [".legend", "#graph-filters", ".filter-panel", ".relationship-legend", ".details", ".hero", - ".atlas-rail", ".journey-panel", ".compare-panel"] + ".atlas-rail", ".journey-panel", ".compare-panel", ".paths-library", ".stack-panel", ".outline-view", + ".learning-panel", ".xray-panel", ".xray-legend"] .map((sel) => document.querySelector(sel)?.getBoundingClientRect()) .filter((r): r is DOMRect => !!r && r.width > 0 && r.height > 0 && r.width < vw * 0.85) .map((r) => ({ x: r.left - crect.left, y: r.top - crect.top, w: r.width, h: r.height })); @@ -129,6 +130,9 @@ export function placeHeadings(headings: Heading[], container: HTMLElement, const box = { x: px - w / 2 + (dx * w) / 2, y: py - bh / 2 + (dy * bh) / 2, w, h: bh }; if (box.x < 4 || box.y < 2 || box.x + w > vw - 4 || box.y + bh > vh - 2) continue; if (panels.some((p) => hits(box, p)) || placed.some((p) => hits(box, p.box))) continue; + // A heading on top of a drawn node name reads as one garbled line: never place it + // there (with nowhere else to go, the field name is left out until the view changes). + if (labels.some((l) => box.x < l.x1 + 2 && box.x + w > l.x0 - 2 && box.y < l.y1 && box.y + bh > l.y0)) continue; if (strict && phone && headings.some((o) => o.id !== h.id && o.disc && discHits(box, o.disc, 0.7))) continue; const { nodes, curves, own, ownNodes } = obstacles.count(box, h.id); // Ring compositions read best with names on the outer rim; maps prefer above. diff --git a/frontend/src/components/graph-canvas/reducers.ts b/frontend/src/components/graph-canvas/reducers.ts index de873e9..acc8763 100644 --- a/frontend/src/components/graph-canvas/reducers.ts +++ b/frontend/src/components/graph-canvas/reducers.ts @@ -2,15 +2,19 @@ import type Graph from "graphology"; import type { Attributes } from "graphology-types"; import type { EdgeDisplayData, NodeDisplayData } from "sigma/types"; import { bandOf, labelVisibleAtRatio } from "../../graph/semanticZoom"; -import { crossLinkColor, DIM_NODE, RING_ALPHA, SCAN_CONTEXT_EDGE, SCAN_DIM_EDGE, SCAN_DIM_NODE, - SCAN_HILITE_EDGE, STATUS_RING, fadeNode, withAlpha } from "./colors"; +import { crossLinkColor, dimNode, RING_ALPHA, scanContextEdge, SCAN_DIM_EDGE, scanDimNode, + scanHiliteEdge, statusRing, fadeNode, withAlpha } from "./colors"; import type { CanvasRefs } from "./refs"; /** * Node styling for every mode (Explore, guided path, edge focus, Repo X-Ray Universe and * Stack View). Runs per node per frame, so it only reads precomputed refs. */ +/** Camera ratio below which sub-field names are drawn (the overview fit is ratio 1). */ +const SUBFIELD_LABEL_RATIO = 0.85; + export function createNodeReducer(graph: Graph, refs: CanvasRefs): (node: string, dataIn: Attributes) => Partial { + const { journeyStopsRef } = refs; const { activeRef, focusFadeRef, hoveredRef, journeyNodesRef, neighborSetRef, persistentLabelsRef, ratioRef, scanStatusRef, selectedEdgeRef, sizeScaleRef, stackActiveRef, visibleNodesRef } = refs; // Which nodes may show labels at the current zoom (Task 8) — pure logic imported // from semanticZoom.ts and fed the live camera ratio. On NARROW (mobile) viewports the @@ -37,7 +41,12 @@ export function createNodeReducer(graph: Graph, refs: CanvasRefs): (node: string if (journeyNodesRef.current.size && !scanStatusRef.current) { res.size = (dataIn.size as number) * sizeScaleRef.current; - if (journeyNodesRef.current.has(node)) { res.forceLabel = true; res.zIndex = 4; return res; } + if (journeyNodesRef.current.has(node)) { + res.forceLabel = true; res.zIndex = 4; + const stop = journeyStopsRef.current?.get(node); + if (stop) res.label = `${stop}. ${dataIn.label as string}`; + return res; + } res.color = fadeNode(dataIn.color, 0.28); res.label = ""; res.zIndex = 0; return res; } @@ -54,7 +63,7 @@ export function createNodeReducer(graph: Graph, refs: CanvasRefs): (node: string const status = scan.get(node); if (status) { res.type = "bordered"; - res.borderColor = STATUS_RING[status]; + res.borderColor = statusRing(status); res.borderSize = 3; res.zIndex = 2; // keep domain color (res.color unchanged) and size; show a PERSISTENT label for @@ -79,7 +88,7 @@ export function createNodeReducer(graph: Graph, refs: CanvasRefs): (node: string res.hidden = true; return res; } - res.color = SCAN_DIM_NODE; + res.color = scanDimNode(); res.label = ""; res.zIndex = 0; return res; @@ -93,7 +102,7 @@ export function createNodeReducer(graph: Graph, refs: CanvasRefs): (node: string res.highlighted = true; res.zIndex = 2; } else { - res.color = DIM_NODE; + res.color = dimNode(); res.label = ""; res.size = Math.min(dataIn.size as number, 2.2); } @@ -104,10 +113,15 @@ export function createNodeReducer(graph: Graph, refs: CanvasRefs): (node: string // anchors never carry a competing WebGL label. const isDomain = dataIn.nodeType === "domain"; const ring = (dataIn.ring as number | undefined) ?? 0; - // Nested subdomain names join the labels once the camera reaches detail zoom. + // Nested sub-field names (GenAI, Observability, Graphics…) show from the default atlas + // zoom on, so every cluster on the map has a name; only the far-out universe band hides them. if (!labelVisible(dataIn.nodeType as string, dataIn.size as number) || (isDomain && ring === 0) - || (isDomain && bandOf(ratioRef.current) <= 1)) { + // Sub-field names appear from the first zoom step in; at the overview fit the field + // headings own the space and a sub-field is named on hover. + || (isDomain && ratioRef.current > SUBFIELD_LABEL_RATIO && hoveredRef.current !== node)) { res.label = ""; + } else if (isDomain && !active) { + res.forceLabel = true; } // One size table in every state: emphasis is color and alpha, never a size jump. res.size = (dataIn.size as number) * sizeScaleRef.current; @@ -169,14 +183,14 @@ export function createEdgeReducer(graph: Graph, refs: CanvasRefs, scanClearEdges const [source, target] = graph.extremities(edge); if (source === active || target === active) { const cross = graph.getNodeAttribute(source, "primaryDomain") !== graph.getNodeAttribute(target, "primaryDomain"); - return { ...dataIn, color: cross ? "rgba(251,191,36,.9)" : SCAN_HILITE_EDGE, size: 1.6, zIndex: 3 }; + return { ...dataIn, color: cross ? "rgba(251,191,36,.9)" : scanHiliteEdge(), size: 1.6, zIndex: 3 }; } } return { ...dataIn, hidden: true }; } if (activeRef.current || !scanClearEdges.has(edge)) return { ...dataIn, hidden: true }; - if (scanEdges.has(edge)) return { ...dataIn, color: SCAN_HILITE_EDGE, size: 1.5, zIndex: 2 }; - if (scanContextRef.current?.has(edge)) return { ...dataIn, color: SCAN_CONTEXT_EDGE, size: 0.7, zIndex: 1 }; + if (scanEdges.has(edge)) return { ...dataIn, color: scanHiliteEdge(), size: 1.5, zIndex: 2 }; + if (scanContextRef.current?.has(edge)) return { ...dataIn, color: scanContextEdge(), size: 0.7, zIndex: 1 }; // Unrelated edges: hide outright. They are the majority and only add noise in a // scan read; hiding (not just alpha~0) also saves overdraw (perf R30). return { ...dataIn, hidden: true, color: SCAN_DIM_EDGE, zIndex: 0 }; @@ -200,8 +214,13 @@ export function createEdgeReducer(graph: Graph, refs: CanvasRefs, scanClearEdges } const set = neighborSetRef.current; const domainFocus = graph.getNodeAttribute(active, "nodeType") === "domain"; + // A field's spokes (field node to each member, ~175 for Backend) carry no information at + // that density: its members are already lit in the field's colour, so they are skipped. + // The ~400 links among its members are the same hairball one level down, so a selected + // field shows only its backbone bridges to other fields. + if (domainFocus && (source === active || target === active || !cross)) return { ...dataIn, hidden: true }; const related = domainFocus - // A clicked or hovered field shows its whole internal network, every edge among its members. + // A clicked field shows the links among its members, not a hairball from its centre. ? !!set && ((set.has(source) && set.has(target)) // A tapped field also reveals its backbone links out to other fields. || (cross && backbone && (set.has(source) || set.has(target)))) diff --git a/frontend/src/components/graph-canvas/refs.ts b/frontend/src/components/graph-canvas/refs.ts index c276e93..688a340 100644 --- a/frontend/src/components/graph-canvas/refs.ts +++ b/frontend/src/components/graph-canvas/refs.ts @@ -40,6 +40,8 @@ export function useCanvasRefs(p: CanvasRefInputs) { const graphRef = useRef(null); const journeyNodesRef = useRef(new Set(p.journeyNodeIds)); + /** Stop number per node while a guided path is followed (labels read "1. DNS"). */ + const journeyStopsRef = useRef | null>(null); const journeyEdgesRef = useRef(new Set(p.journeyEdgeIds)); const hoveredRef = useRef(null); // Members of a hovered domain, so hovering a field's main dot previews its whole network. @@ -85,7 +87,7 @@ export function useCanvasRefs(p: CanvasRefInputs) { return { containerRef, onCameraChangeRef, onSelectRef, onSelectEdgeRef, sigmaRef, graphRef, - journeyNodesRef, journeyEdgesRef, hoveredRef, hoverDomainSetRef, descriptionsRef, + journeyNodesRef, journeyStopsRef, journeyEdgesRef, hoveredRef, hoverDomainSetRef, descriptionsRef, pendingDescriptionsRef, selectedRef, selectedEdgeRef, previewEdgeRef, activeRef, neighborSetRef, visibleNodesRef, visibleEdgesRef, scanStatusRef, scanEdgesRef, scanContextRef, persistentLabelsRef, savedCoordsRef, focusBBoxRef, stackAnimRef, diff --git a/frontend/src/components/graph-canvas/useAtlasBackdrop.ts b/frontend/src/components/graph-canvas/useAtlasBackdrop.ts index 47cc9ff..7ce3372 100644 --- a/frontend/src/components/graph-canvas/useAtlasBackdrop.ts +++ b/frontend/src/components/graph-canvas/useAtlasBackdrop.ts @@ -1,6 +1,7 @@ import { useEffect, useState } from "react"; import type { GraphResponse } from "../../api/types"; import { curvePoint } from "../../graph/buildGraph"; +import { labelBoxes } from "./drawNodeLabel"; import { Obstacles, placeHeadings, type Heading } from "./headings"; import type { CanvasRefs } from "./refs"; @@ -43,6 +44,7 @@ function orbitRadii(graph: import("graphology").default): Map [d.id, d.color])); const project = () => { - // Suppress the atlas backdrop entirely during Repo X-Ray (Stack View owns the canvas). - if (stackActiveRef.current || scanStatusRef.current) { setBackdrop(EMPTY); return; } + // Stack View owns the canvas. The X-Ray overlay on the full atlas drops the tints and + // orbits but keeps the names of the fields that have detections, so "Rust" sits in a + // place the reader can name. + if (stackActiveRef.current) { setBackdrop(EMPTY); return; } + const scan = scanStatusRef.current; + const scanFields = scan ? new Set([...scan.keys()].filter((id) => graph.hasNode(id)) + .map((id) => graph.getNodeAttribute(id, "territory") as string)) : null; + // A highlighted role, app, stack or path names only the fields it touches, so the + // names of its nodes have room (all 23 field names plus 27 node names don't fit a phone). + const lit = journeyNodesRef.current; + const litFields = !scan && lit.size ? new Set([...lit].filter((id) => graph.hasNode(id)) + .map((id) => graph.getNodeAttribute(id, "territory") as string)) : null; const geom = domainGeomRef.current!; let ax = 0, ay = 0; for (const g of geom.values()) { ax += g.gx / geom.size; ay += g.gy / geom.size; } @@ -114,8 +126,10 @@ export function useAtlasBackdrop(refs: CanvasRefs, data: GraphResponse, domains: const c = renderer.graphToViewport({ x: g.gx, y: g.gy }); const rim = renderer.graphToViewport({ x: g.gx + g.gr, y: g.gy }); const r = Math.hypot(rim.x - c.x, rim.y - c.y); - sectors.push({ id: d.id, color: d.color, cx: c.x, cy: c.y, r: r * 1.12 }); + if (!scanFields) sectors.push({ id: d.id, color: d.color, cx: c.x, cy: c.y, r: r * 1.12 }); if (vis && !vis.has(d.id)) continue; + if (scanFields && !scanFields.has(d.id)) continue; + if (litFields && !litFields.has(d.id)) continue; headings.push({ id: d.id, label: d.name, color: d.color, left: c.x, top: c.y, align: "box", disc: { x: c.x, y: c.y, r: r * (g.hr / (g.gr || 1)) } }); } @@ -127,6 +141,11 @@ export function useAtlasBackdrop(refs: CanvasRefs, data: GraphResponse, domains: const v = renderer.graphToViewport({ x: attrs.x as number, y: attrs.y as number }); obstacles.add(v.x, v.y, renderer.scaleSize(dd.size), true, attrs.territory as string); }); + // Node names drawn this frame: a field heading on top of "Software Versioning" reads + // as one garbled line, so every label box counts as a foreign node for every heading. + for (const b of labelBoxes()) { + for (let x = b.x0; x <= b.x1; x += 8) obstacles.add(x, (b.y0 + b.y1) / 2, (b.y1 - b.y0) / 2, true, ""); + } graph.forEachEdge((id, attrs, source, target) => { const shown = renderer.getEdgeDisplayData(id); if (!shown || shown.hidden) return; @@ -142,6 +161,7 @@ export function useAtlasBackdrop(refs: CanvasRefs, data: GraphResponse, domains: }); const orbits: Backdrop["orbits"] = []; for (const [id, o] of orbitGeom) { + if (scanFields) break; if (vis && !vis.has(id)) continue; const c = renderer.graphToViewport({ x: o.gx, y: o.gy }); const u = renderer.graphToViewport({ x: o.gx + 1, y: o.gy }); @@ -149,13 +169,19 @@ export function useAtlasBackdrop(refs: CanvasRefs, data: GraphResponse, domains: orbits.push({ id, color: colorOf.get(id) ?? "#8a93ab", cx: c.x, cy: c.y, rs: o.rs.map((r) => r * k) }); } setBackdrop({ sectors, orbits, headings: placeHeadings(headings, renderer.getContainer(), topLevel, - selectedRef.current, obstacles, ringLike) }); + selectedRef.current, obstacles, ringLike, labelBoxes()) }); }; // Re-project after every render: Sigma renders with the camera's final state, while // "updated" can be emitted mid-animation and leave headings on stale positions. project(); renderer.on("afterRender", project); - return () => { renderer.removeListener("afterRender", project); }; + // A side panel opening or closing changes where headings may go without a re-render, + // so re-place them whenever the stage's panels change. + const stage = renderer.getContainer().closest("main"); + let raf = 0; + const observer = stage ? new MutationObserver(() => { cancelAnimationFrame(raf); raf = requestAnimationFrame(project); }) : null; + if (stage) observer!.observe(stage, { childList: true }); + return () => { renderer.removeListener("afterRender", project); observer?.disconnect(); cancelAnimationFrame(raf); }; }, [domains, data, exploreNonce, stackPositions, scanStatusByNode, visibleNodes]); return backdrop; } diff --git a/frontend/src/components/graph-canvas/useCameraControl.ts b/frontend/src/components/graph-canvas/useCameraControl.ts index c6b6a3b..42acd78 100644 --- a/frontend/src/components/graph-canvas/useCameraControl.ts +++ b/frontend/src/components/graph-canvas/useCameraControl.ts @@ -1,12 +1,14 @@ import { useEffect, useRef } from "react"; import { computeFit } from "../../graph/cameraFit"; -import { fitExplore, fitStack } from "./framing"; +import { fitExplore, fitStack, frameNodes } from "./framing"; import type { CanvasRefs } from "./refs"; /** Camera moves driven by props: Focus Stack, the Explore home reframe, and node focus. */ export function useCameraControl(refs: CanvasRefs, fitSignal: { ids: string[]; nonce: number; sidebarWidthPx?: number } | null, - exploreNonce: number, focusId: string | null) { + exploreNonce: number, focusId: string | null, frameSet: { ids: string[]; key: string } | null = null) { const { containerRef, focusBBoxRef, graphRef, sigmaRef, sizeScaleRef, stackActiveRef, stackHeadingsRef, stackPositionsRef } = refs; + const frameSetRef = useRef(frameSet); + frameSetRef.current = frameSet; // "Focus Stack" — frame the detected nodes' bounding region with padding, keeping // labels readable (never zoom so far the graph is unusable). Uses the precomputed // coordinates; never relayouts. @@ -95,6 +97,8 @@ export function useCameraControl(refs: CanvasRefs, fitSignal: { ids: string[]; n ).matches; const display = renderer.getNodeDisplayData(focusId); if (!display) return; + // A framed set (role, app, stack, path) that already contains this node owns the camera. + if (frameSetRef.current?.ids.includes(focusId)) return; const camera = renderer.getCamera(); const container = renderer.getContainer(); const narrow = container.clientWidth < 641; @@ -154,11 +158,30 @@ export function useCameraControl(refs: CanvasRefs, fitSignal: { ids: string[]; n } return; } - // starting a new animation implicitly supersedes the previous target; calling - // animate again is safe, but we null-out the callback timer by not chaining. - camera.animate( - { x: targetX, y: targetY, ratio }, - { duration: prefersReducedMotion ? 0 : 520, easing: "cubicInOut" }, - ); + // Land the node in the middle of the area the open panels leave visible. + // Two frames later: the details panel has laid out (so its width is measured) and the + // first-load atlas fit, which also animates the camera, has already started. + let raf2 = 0; + const raf1 = requestAnimationFrame(() => { raf2 = requestAnimationFrame(() => { + renderer.refresh(); + if (!frameNodes(renderer, [focusId], { prefersReduced: prefersReducedMotion, singleRatio: ratio, duration: 520 })) { + camera.animate({ x: targetX, y: targetY, ratio }, { duration: prefersReducedMotion ? 0 : 520, easing: "cubicInOut" }); + } + }); }); + return () => { cancelAnimationFrame(raf1); cancelAnimationFrame(raf2); }; }, [focusId]); + + // Frame a highlighted set (role, app, stack pick, followed path) inside the visible area. + // Runs after the panel that owns the set has rendered, so its width is measured, not assumed. + useEffect(() => { + const renderer = sigmaRef.current; + if (!renderer || !frameSet || frameSet.ids.length === 0 || stackActiveRef.current) return; + const prefersReduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches; + const raf = requestAnimationFrame(() => { + if (focusBBoxRef.current) { focusBBoxRef.current = false; renderer.setCustomBBox(null); + sizeScaleRef.current = fitExplore(renderer, true); } + frameNodes(renderer, frameSet.ids, { prefersReduced }); + }); + return () => cancelAnimationFrame(raf); + }, [frameSet?.key]); } diff --git a/frontend/src/components/graph-canvas/useSigmaRenderer.ts b/frontend/src/components/graph-canvas/useSigmaRenderer.ts index e67f4b7..9a95687 100644 --- a/frontend/src/components/graph-canvas/useSigmaRenderer.ts +++ b/frontend/src/components/graph-canvas/useSigmaRenderer.ts @@ -1,3 +1,4 @@ +import { drawNodeLabel, drawnLabels, resetLabelSpace } from "./drawNodeLabel"; import { useEffect, useState } from "react"; import Sigma from "sigma"; import { createNodeBorderProgram } from "@sigma/node-border"; @@ -39,6 +40,7 @@ export function useSigmaRenderer(refs: CanvasRefs, data: GraphResponse, initialC enableEdgeEvents: true, labelColor: { color: "#c8d0e8" }, defaultDrawNodeHover: drawNodeHover, + defaultDrawNodeLabel: drawNodeLabel, labelFont: "Inter, system-ui, sans-serif", labelSize: 12, // UI-C: reduce Universe label collisions. Larger grid cells + lower density mean @@ -66,6 +68,7 @@ export function useSigmaRenderer(refs: CanvasRefs, data: GraphResponse, initialC }, }); sigmaRef.current = renderer; + renderer.on("beforeRender", resetLabelSpace); // Sidebar-aware INITIAL framing (Explore redesign §11): optically centre the atlas in // the USABLE canvas (viewport minus the left legend + right filter panels), not the raw @@ -84,6 +87,7 @@ export function useSigmaRenderer(refs: CanvasRefs, data: GraphResponse, initialC // so no internal renderer reference is ever exposed to shipped users. if (import.meta.env.VITE_TEST_HOOKS === "true" && typeof window !== "undefined") { (window as unknown as { __ta_sigma?: unknown }).__ta_sigma = renderer; + (window as unknown as { __ta_labels?: unknown }).__ta_labels = drawnLabels; } // Compute the highlight set once whenever the active node changes. diff --git a/frontend/src/graph/relationships.ts b/frontend/src/graph/relationships.ts index 22233cd..00d8649 100644 --- a/frontend/src/graph/relationships.ts +++ b/frontend/src/graph/relationships.ts @@ -31,7 +31,8 @@ export function relationshipPhrase(type: string, direction: EdgeDirection): stri // Node-type labels shown as text so classification never relies on color alone. export function nodeTypeLabel(nodeType: string, subtype: string | null): string { - const base = nodeType.charAt(0).toUpperCase() + nodeType.slice(1); + // The UI calls domains "fields" everywhere (Fields panel, headings, hover card). + const base = nodeType === "domain" ? "Field" : nodeType.charAt(0).toUpperCase() + nodeType.slice(1); if (!subtype) return base; const pretty = subtype.replace(/_/g, " "); return `${base} · ${pretty}`; diff --git a/frontend/src/styles.css b/frontend/src/styles.css index b8e04df..f1d5dfb 100644 --- a/frontend/src/styles.css +++ b/frontend/src/styles.css @@ -730,7 +730,6 @@ body { .xray-repo-desc { margin: 4px 0; } .xray-commit { font-size: 11px; } .xray-partial { - position: sticky; top: 0; z-index: 2; margin: 10px 0; padding: 8px 10px; border-radius: 8px; background: rgba(45, 38, 16, 0.96); border: 1px solid rgba(251, 191, 36, 0.5); color: #f4d58a; font-size: 12px; backdrop-filter: blur(4px); @@ -1088,15 +1087,15 @@ body { .journey-panel .journey-step { margin: 2px 0 0; color: #fff; font-size: 16px; } .journey-done { margin: 8px 0 0; padding: 8px 10px; border-radius: 8px; background: rgba(74, 222, 128, 0.1); font-size: 12px; } .journey-done strong { color: #4ade80; } -.journey-actions .journey-share { border-color: transparent; color: var(--text-dim); } -.journey-actions .journey-share:hover { color: var(--text); } +/* "Copy link" is a button like its neighbours, one level quieter. */ +.journey-actions .journey-share { color: var(--text-dim); } +.journey-actions .journey-share:hover { color: var(--text); border-color: var(--accent); } .path-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; } /* Guided-paths library: every path, searchable and filterable. */ -.paths-backdrop { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-start; justify-content: center; - padding: 72px 16px 16px; background: rgba(5, 7, 12, 0.55); backdrop-filter: blur(2px); } -.paths-library { display: flex; flex-direction: column; width: min(920px, 100%); max-height: calc(100vh - 88px); max-height: calc(100dvh - 88px); - background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45); +.paths-library { position: absolute; z-index: 30; left: 72px; top: 14px; display: flex; flex-direction: column; + width: min(400px, calc(100% - 88px)); max-height: calc(100% - 28px); + background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3); animation: panel-in 220ms cubic-bezier(.2,.7,.2,1); } .paths-head { position: relative; padding: 18px 18px 12px; border-bottom: 1px solid var(--panel-border); } .paths-head h2 { margin: 0; font-size: 18px; color: #fff; } @@ -1119,7 +1118,7 @@ body { text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); } .paths-clear { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; text-transform: none; letter-spacing: 0; cursor: pointer; } .paths-empty { color: var(--text-dim); font-size: 13px; } -.paths-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; } +.paths-grid { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 0; padding: 0; list-style: none; } .path-card { position: relative; display: flex; flex-direction: column; gap: 4px; width: 100%; height: 100%; padding: 10px 12px 12px; border: 1px solid var(--panel-border); border-radius: 10px; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; overflow: hidden; } .path-card:hover { border-color: var(--accent); background: rgba(122, 162, 247, 0.06); } @@ -1136,8 +1135,7 @@ body { .path-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--panel-border); } .path-progress span { display: block; height: 100%; background: var(--accent); } @media (max-width: 640px) { - .paths-backdrop { padding: 0; align-items: stretch; } - .paths-library { max-height: none; height: 100%; border-radius: 0; border: 0; } + .paths-library { left: 8px; right: 8px; top: 8px; width: auto; max-height: calc(100% - 16px); } .paths-head { padding: 14px 14px 10px; } .paths-body { padding: 4px 14px 14px; } .paths-controls select { flex: 1 1 100%; } @@ -1147,7 +1145,6 @@ body { } :root[data-theme="light"] .paths-head h2, :root[data-theme="light"] .path-title, :root[data-theme="light"] .journey-panel .journey-step { color: #1d3046; } -:root[data-theme="light"] .paths-backdrop { background: rgba(30, 45, 65, 0.25); } :root[data-theme="light"] .path-badge.is-done, :root[data-theme="light"] .journey-done strong { color: #17803d; } /* Hero: a second line of featured paths (or "continue" for returning visitors). */ @@ -1223,7 +1220,9 @@ body { :root[data-theme="light"] .atlas-rail button:hover, :root[data-theme="light"] .atlas-rail button[aria-pressed="true"] { color: #1d3046; } :root[data-theme="light"] .xray-input { background: #fff; color: var(--text); } -.topbar, .legend, .filter-panel, .details, .xray-panel, .journey-panel, .compare-panel { font-variant-numeric: tabular-nums; } +/* Tabular figures only where numbers line up in columns: Inter's tnum also widens hyphens + and punctuation, so it must not apply to whole panels of prose. */ +.topbar-meta, .xray-stat-value, .xray-legend, .stat-num, .count-badge, .filter-count, .rail-count { font-variant-numeric: tabular-nums; } h1, h2, h3, .brand-name { letter-spacing: -.025em; } @media (max-width: 640px) { @@ -1284,7 +1283,20 @@ h1, h2, h3, .brand-name { letter-spacing: -.025em; } @media (max-width: 1279px) { .topbar-meta, .brand-sub { display: none; } } /* With six atlas modes the toolbar needs the room: drop the tagline first so search stays usable. */ @media (min-width: 1024px) and (max-width: 1599px) { .brand-sub { display: none; } .search { min-width: 180px; } } -@media (max-width: 1100px) { .topbar-tools .tool span { display: none; } .topbar-tools .tool { padding: 0 8px; } } +.tools-more { display: contents; } +.tools-more-toggle { display: none !important; } +/* Tablets and small laptops: main tools keep short labels; utilities go under "More". */ +@media (max-width: 1100px) { + .topbar-tools .tool { padding: 0 8px; } + .tools-more-toggle { display: inline-flex !important; } + .tools-more { display: none; position: fixed; z-index: 80; flex-direction: column; align-items: stretch; min-width: 200px; padding: 4px; + border: 1px solid var(--panel-border); border-radius: 10px; background: var(--panel); box-shadow: 0 12px 32px rgba(0,0,0,.35); } + .tools-more.is-open { display: flex; } + .tools-more .tool { justify-content: flex-start; height: 34px; } + .tools-more .tool span { display: inline !important; } + .tools-more .tool-icon::after { content: attr(aria-label); } +} +@media (max-width: 700px) { .topbar-tools > .tool span:not([aria-hidden]) { display: none; } } @media (max-width: 640px) { .topbar { display: grid; grid-template-columns: 1fr auto auto; row-gap: 8px; column-gap: 8px; padding: 10px 12px; } .topbar .search { grid-column: 1 / -1; max-width: none; } @@ -1478,8 +1490,8 @@ h1, h2, h3, .brand-name { letter-spacing: -.025em; } .stack-pick.is-recommended .stack-source { color: var(--accent); } .stack-why { display: flex; gap: 8px; width: calc(100% - 120px); margin: 2px 0 0 120px; padding: 0; border: 0; background: transparent; color: var(--text-dim); font: inherit; font-size: 11.5px; line-height: 1.4; text-align: left; cursor: pointer; } -.stack-why > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } -.stack-why[aria-expanded="true"] > span:first-child { white-space: normal; } +.stack-reason { margin: 2px 0 0 120px; color: var(--text-dim); font-size: 12px; line-height: 1.4; } +.stack-why { width: auto; color: var(--accent); font-size: 12px; } .stack-why:hover { color: var(--text); } .stack-chevron { flex: none; color: var(--accent); font-size: 10.5px; } .stack-detail { margin: 6px 0 0 120px; } @@ -1503,7 +1515,7 @@ h1, h2, h3, .brand-name { letter-spacing: -.025em; } @media (max-width: 820px) { .stack-panel { left: 8px; right: 8px; width: auto; top: 8px; max-height: calc(100% - 16px); } .stack-slot { flex-basis: 92px; } - .stack-why, .stack-detail { margin-left: 100px; } + .stack-why, .stack-detail, .stack-reason { margin-left: 100px; } .stack-why { width: calc(100% - 100px); } } @@ -1685,3 +1697,124 @@ h1, h2, h3, .brand-name { letter-spacing: -.025em; } :root[data-theme="light"] .scroll-arrow { box-shadow: 0 2px 6px rgba(0,0,0,.12); } :root[data-theme="light"] .xray-line { border-top-color: rgba(60,80,130,.8); } :root[data-theme="light"] .xray-line.is-faint { border-top-color: rgba(60,80,130,.3); } + +/* ---- UI audit fixes ---------------------------------------------------------------- */ +.xray-entry[aria-pressed="true"] { background: rgba(122, 162, 247, 0.32); border-color: var(--accent); } +.tool[aria-pressed="true"] { color: var(--text); background: rgba(122, 162, 247, 0.16); } +.xray-exit { + margin-left: auto; height: 30px; padding: 0 12px; border-radius: 8px; font-weight: 600; font-size: 12.5px; + border: 1px solid var(--panel-border); background: transparent; color: var(--text); cursor: pointer; +} +.xray-exit:hover { background: rgba(122, 162, 247, 0.16); } +.xray-exit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } +.xray-partial > summary { cursor: pointer; list-style: none; } +.xray-partial > summary::-webkit-details-marker { display: none; } +.xray-partial > summary::after { content: " Show details"; text-decoration: underline; opacity: .8; } +.xray-partial[open] > summary::after { content: " Hide"; } +.xray-headline { margin: 10px 0 8px; font-size: 14px; line-height: 1.45; color: var(--text); } +.xray-headline strong { font-weight: 700; } +.xray-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 14px; position: relative; } +.xray-more { position: relative; } +.xray-more > summary { + list-style: none; cursor: pointer; height: 30px; display: inline-flex; align-items: center; padding: 0 10px; + border: 1px solid var(--panel-border); border-radius: 8px; font-size: 12.5px; color: var(--text); +} +.xray-more > summary::-webkit-details-marker { display: none; } +.xray-more > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } +.xray-more-menu { + position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; min-width: 200px; display: flex; flex-direction: column; + padding: 4px; border-radius: 10px; border: 1px solid var(--panel-border); background: var(--panel); + box-shadow: 0 10px 30px rgba(0, 0, 0, .35); +} +.xray-more-menu > * { text-align: left; padding: 8px 10px; border-radius: 6px; border: 0; background: transparent; + color: var(--text); font: inherit; font-size: 13px; cursor: pointer; text-decoration: none; } +.xray-more-menu > *:hover, .xray-more-menu > *:focus-visible { background: rgba(122, 162, 247, 0.16); outline: none; } +.xray-stats > summary { cursor: pointer; } +.rel-chevron { margin-left: auto; padding-left: 8px; color: var(--text-dim); transition: transform .15s; } +.rel-link:hover .rel-chevron, .rel-link:focus-visible .rel-chevron { transform: translateX(2px); color: var(--text); } +.learning-track { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0; } +.learning-label { font-size: 12px; color: var(--text-dim); } +.learning-note { font-size: 12px; color: #9ece6a; min-height: 1em; } + +/* Opaque panels: text over a busy canvas must stay readable (WCAG 1.4.3). */ +.details, .xray-panel, .journey-panel, .compare-panel, .stack-panel, .learning-panel, .outline-view { background: var(--panel); } + +/* Light theme: everything that had a dark colour hard-coded. */ +:root[data-theme="light"] .xray-legend { background: rgba(255, 255, 255, .94); color: var(--text); } +:root[data-theme="light"] .xray-tech { background: #fff; border-color: #d5dde8; color: var(--text); } +:root[data-theme="light"] .xray-section-title, :root[data-theme="light"] .xray-group h3 { color: #3b4b61; } +:root[data-theme="light"] .xray-partial { background: #fff7e0; border-color: #e0b43c; color: #6b4a00; } +:root[data-theme="light"] .xray-repo-title a { color: #1f4f9c; } +:root[data-theme="light"] .xray-more-menu { background: #fff; box-shadow: 0 10px 30px rgba(20, 30, 50, .15); } +:root[data-theme="light"] .xray-entry[aria-pressed="true"] { background: #cfe0ff; } +:root[data-theme="light"] .learning-note { color: #2f6b12; } +:root[data-theme="light"] .rel-link { color: #1d3046; } +:root[data-theme="light"] .xray-viewswitch button[aria-pressed="true"] { background: #215db1; color: #fff; } + +/* Phones: field headings get a 24px hit area (WCAG 2.5.8) without changing the type. */ +@media (max-width: 640px) { + .atlas-heading::before { content: ""; position: absolute; inset: -5px -2px; } +} +.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } +:root[data-theme="light"] .xray-class.class-direct { color: #166534; border-color: #86c79b; } +:root[data-theme="light"] .xray-class.class-transitive { color: #1e40af; border-color: #93b4ec; } +:root[data-theme="light"] .xray-focus.primary { background: #215db1; color: #fff; } +:root[data-theme="light"] .xray-focus.primary:hover { background: #1a4c94; color: #fff; } +:root[data-theme="light"] .xray-partial strong { color: #6b4a00; } +:root[data-theme="light"] .xray-viewswitch button.active { background: #215db1; color: #fff; } + +/* Roles and Apps: one stepper plus a breadcrumb back to the list; nothing truncated. */ +.panel-crumb { display: inline-flex; align-items: center; margin: -2px 0 8px; padding: 2px 0; border: 0; background: none; + color: var(--accent); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; } +.panel-crumb:hover { text-decoration: underline; } +.panel-crumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; } +.role-label { white-space: normal; text-overflow: clip; line-height: 1.3; } +.role-stage ul { align-items: start; } +.chip-row.is-wrapping { flex-wrap: wrap; width: auto; } +.apps-card-text strong { white-space: normal; overflow: visible; line-height: 1.25; } +.apps-card-n { white-space: nowrap; } +.shortcuts-group { margin: 12px 0 4px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-dim); } + +/* Fields panel (Domains list + Filters merged). */ +.legend { width: 270px; max-height: calc(100% - 28px); display: flex; flex-direction: column; background: var(--panel); } +.legend ul { max-height: none; overflow-y: auto; flex: 1 1 auto; min-height: 0; } +.legend-h { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); } +.legend-head .filter-clear { margin-left: auto; margin-right: 6px; padding: 2px 6px; border: 0; background: none; color: var(--accent); font: inherit; font-size: 12px; cursor: pointer; } +.legend-row { display: flex; align-items: center; gap: 4px; } +.legend-row .legend-item { flex: 1; min-width: 0; } +.legend-check { flex: none; width: 15px; height: 15px; margin: 0 2px; accent-color: var(--accent); cursor: pointer; } +.legend-sub .legend-row { padding-left: 16px; } +.legend-name { flex: 1; min-width: 0; } +.legend-count { font-variant-numeric: tabular-nums; } +.legend-types { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 4px 0 8px; padding-bottom: 8px; border-bottom: 1px solid var(--panel-border); font-size: 12.5px; } +.legend-types .filter-check { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; } +.field-members-filter { box-sizing: border-box; width: 100%; margin: 0 0 6px; padding: 6px 9px; border: 1px solid var(--panel-border); border-radius: 8px; + background: var(--bg); color: var(--text); font: inherit; font-size: 13px; } +.field-members-more { margin: 4px 0 0; padding: 2px 0; border: 0; background: none; color: var(--accent); font: inherit; font-size: 12.5px; cursor: pointer; } +.field-members-more:hover { text-decoration: underline; } +.field-members h4 { text-transform: none; } +@media (min-width: 821px) { .legend, .paths-library { max-height: calc(100% - 76px); } } +.legend-types-label { color: var(--text-dim); font-size: 12px; width: 100%; } +h2[tabindex="-1"]:focus:not(:focus-visible) { outline: none; } +/* Phones: the X-Ray key is one small "Key ?" chip until opened, so it never wraps over + the Fields chip or the map. */ +@media (max-width: 640px) { + .xray-legend:not(.is-open) .xray-legend-item, .xray-legend:not(.is-open) .xray-legend-sep { display: none; } + .xray-legend:not(.is-open) { padding: 4px 6px 4px 10px; right: auto; width: auto; } + .xray-legend-help { width: 24px; height: 24px; } +} + +/* Phones: tool panels are bottom sheets (map above, list below) instead of covering the + whole map; the camera frames the highlighted set in the space above the sheet. */ +@media (max-width: 640px) { + .stack-panel, .paths-library, .compare-panel.learning-panel { + top: auto; bottom: 0; left: 0; right: 0; width: auto; max-height: 58%; + border-radius: 16px 16px 0 0; border-bottom: 0; box-shadow: 0 -12px 32px rgba(0,0,0,.35); + } + .stack-panel::before, .paths-library::before, .compare-panel.learning-panel::before { + content: ""; display: block; width: 36px; height: 4px; margin: -6px auto 8px; border-radius: 2px; background: var(--panel-border); + } +} +@media (max-width: 640px) { + main:has(.stack-panel) .legend-reopen, main:has(.paths-library) .legend-reopen, main:has(.learning-panel) .legend-reopen { display: none; } +} diff --git a/frontend/src/util/usePanelFocus.ts b/frontend/src/util/usePanelFocus.ts new file mode 100644 index 0000000..e4d111c --- /dev/null +++ b/frontend/src/util/usePanelFocus.ts @@ -0,0 +1,30 @@ +import { useEffect, useRef } from "react"; + +/** + * Moves keyboard focus into a panel when it opens (to its heading, so a screen reader + * announces it) and back to whatever opened it when it closes, unless the reader has + * already moved focus somewhere else on purpose. + */ +export function usePanelFocus(open: boolean, selector: string) { + const opener = useRef(null); + useEffect(() => { + if (open) { + opener.current = document.activeElement as HTMLElement | null; + const raf = requestAnimationFrame(() => { + const heading = document.querySelector(`${selector} h2`); + if (!heading) return; + // Don't steal focus from a field the panel focused itself (e.g. a search box). + const panel = heading.closest(selector); + if (panel && panel.contains(document.activeElement)) return; + if (!heading.hasAttribute("tabindex")) heading.setAttribute("tabindex", "-1"); + heading.focus({ preventScroll: true }); + }); + return () => cancelAnimationFrame(raf); + } + const back = opener.current; + opener.current = null; + const active = document.activeElement; + if (back && back.isConnected && (!active || active === document.body)) back.focus({ preventScroll: true }); + return undefined; + }, [open, selector]); +}