RepoPulse: update frontend/src and backend/app (+4 areas)
Public changes compared with the previous published export: 19 files changed. Affected areas: - backend/app: 3 files - dependencies: 2 files - documentation: 1 file - frontend: 2 files - frontend/src: 10 files - tests: 1 file Changed files: - Updated: "backend/app/acquisition.py" - Added: "backend/app/icons.py" - Updated: "backend/app/main.py" - Added: "backend/tests/test_icons.py" - Updated: "docs/ARCHITECTURE.md" - Updated: "frontend/package-lock.json" - Updated: "frontend/package.json" - Updated: "frontend/playwright.config.ts" - Updated: "frontend/src/App.tsx" - Updated: "frontend/src/components/DashboardView.tsx" - Added: "frontend/src/components/HealthRing.tsx" - Updated: "frontend/src/components/HistoryView.tsx" - Added: "frontend/src/components/Icon.tsx" - Updated: "frontend/src/components/PortfolioAtlas.tsx" - Updated: "frontend/src/components/RemediationCenter.tsx" - Added: "frontend/src/components/RepoAvatar.tsx" - Updated: "frontend/src/main.tsx" - Updated: "frontend/src/styles.css" - Updated: "frontend/vite.config.ts" Export provenance/manifests refreshed; excluded from the change summary. Publish curated RepoPulse source from 7a60c53ee2c1daebecd66a01656e323f1db72e56
This commit is contained in:
1 parent
d5ab22ddf1
commit
787a2b1dc3
21 files changed
+1530
-746
No files matched your search
@@ -1,3 +1,3 @@
|
||||
# Public source export
|
||||
|
||||
This source snapshot was generated from the private canonical repository at revision `b1c0935a15f5b37e107c7e8764044711415f14e1`. It contains no private Git history or operational evidence. Changes are published from the canonical repository.
|
||||
This source snapshot was generated from the private canonical repository at revision `7a60c53ee2c1daebecd66a01656e323f1db72e56`. It contains no private Git history or operational evidence. Changes are published from the canonical repository.
|
||||
+54
-29
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"sourceRevision": "b1c0935a15f5b37e107c7e8764044711415f14e1",
|
||||
"sourceRevision": "7a60c53ee2c1daebecd66a01656e323f1db72e56",
|
||||
"files": [
|
||||
{
|
||||
"path": ".dockerignore",
|
||||
@@ -44,8 +44,8 @@
|
||||
},
|
||||
{
|
||||
"path": "backend/app/acquisition.py",
|
||||
"sha256": "1c1877d1d720c66d62a6a6f518a1752f649f6b0a2fa2fda766c093d39a4f6367",
|
||||
"bytes": 10499
|
||||
"sha256": "f5c10c027af35afbf47ffe21041fea5b74778e0411be3b582b7b8a224a9d09cc",
|
||||
"bytes": 10698
|
||||
},
|
||||
{
|
||||
"path": "backend/app/architecture.py",
|
||||
@@ -62,6 +62,11 @@
|
||||
"sha256": "e4795d7d60fe15fc133b2216a33b11b02086d86c4baa87de0d17d3e55ab0dbbb",
|
||||
"bytes": 13958
|
||||
},
|
||||
{
|
||||
"path": "backend/app/icons.py",
|
||||
"sha256": "405206f32bbb6556708b54efcfc8ca5426ce08292dfc776c1796edde89008e7b",
|
||||
"bytes": 6202
|
||||
},
|
||||
{
|
||||
"path": "backend/app/jobs.py",
|
||||
"sha256": "f4deb3732d995f602980f41623e16bba5255b7125cf1dff03534cea5f571a0b4",
|
||||
@@ -69,8 +74,8 @@
|
||||
},
|
||||
{
|
||||
"path": "backend/app/main.py",
|
||||
"sha256": "b8898a7ddb4d328b52d2e7141d50610f6ee4ac27eaa57276d095590cd4d708ba",
|
||||
"bytes": 20288
|
||||
"sha256": "06eb422e6a3a42add652557852e2a6ab55c1b63f843490c6788069e0317ecd52",
|
||||
"bytes": 21812
|
||||
},
|
||||
{
|
||||
"path": "backend/app/models.py",
|
||||
@@ -147,6 +152,11 @@
|
||||
"sha256": "33a4761b7982cf1cfe492ce27174e7bf8a9b4f73bb0c6a1e41ad32357c092300",
|
||||
"bytes": 8017
|
||||
},
|
||||
{
|
||||
"path": "backend/tests/test_icons.py",
|
||||
"sha256": "3e5edc43facb1366c1d8c81ec0b1a0f729eaff32f7c202a265a605ecf7aa731e",
|
||||
"bytes": 5010
|
||||
},
|
||||
{
|
||||
"path": "backend/tests/test_jobs.py",
|
||||
"sha256": "33917d488a72071412b524d4dc4f00fbce2035559227b3d1134f95d7337c9625",
|
||||
@@ -204,8 +214,8 @@
|
||||
},
|
||||
{
|
||||
"path": "docs/ARCHITECTURE.md",
|
||||
"sha256": "41253e1aa1f0a816316bdf2e0d559575beb3936c538509d4d7becd4e2cd7f012",
|
||||
"bytes": 15543
|
||||
"sha256": "55fde435a5ef76f520e85a9f5c7ffd7aeb6ed4bb6c327430482a1d45f5b39eef",
|
||||
"bytes": 16369
|
||||
},
|
||||
{
|
||||
"path": "docs/screenshots/demo-explorer.png",
|
||||
@@ -249,18 +259,18 @@
|
||||
},
|
||||
{
|
||||
"path": "frontend/package-lock.json",
|
||||
"sha256": "afeb669147a6a98f76c28f7f2a706595b05db881a0c76a0d7c15348c64717d4b",
|
||||
"bytes": 113084
|
||||
"sha256": "7f61db141dd820899f08365cee3986f9346f7416e4411f2e7454fc583676ad72",
|
||||
"bytes": 112965
|
||||
},
|
||||
{
|
||||
"path": "frontend/package.json",
|
||||
"sha256": "ac706aaddfd7774ce5f0b302b3640c7570eb06c2505709c0277d97a31cbfcb2c",
|
||||
"bytes": 724
|
||||
"sha256": "d73f1f5e655b78608a211b6ead339d2fb5b068a62688617458a7eadaef7762cb",
|
||||
"bytes": 768
|
||||
},
|
||||
{
|
||||
"path": "frontend/playwright.config.ts",
|
||||
"sha256": "7ab6930d8e7227cc1086e76a5f344e70291271a868ab72e1d36e060a7340e9d4",
|
||||
"bytes": 1277
|
||||
"sha256": "3e663809a4c076a9fc4a3db5a7a4b3e7183ca979a31dcc542c5d435302055b95",
|
||||
"bytes": 1445
|
||||
},
|
||||
{
|
||||
"path": "frontend/public/brand/repopulse-logo-light.svg",
|
||||
@@ -299,8 +309,8 @@
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/App.tsx",
|
||||
"sha256": "ff1d4c047772383148bc7a82a762fb5822ea1bfdb8814d97dfc0e980903f7fa3",
|
||||
"bytes": 46711
|
||||
"sha256": "6df7a0b9d20304af203300346ae49c795f71f481242523f568f990e584d07669",
|
||||
"bytes": 48190
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/FindingsView.test.tsx",
|
||||
@@ -349,8 +359,8 @@
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/DashboardView.tsx",
|
||||
"sha256": "d5992db6a78aa4ec5f69220bdb4ccc0f964d5180112a0a772e750322ead883a6",
|
||||
"bytes": 9042
|
||||
"sha256": "469c926bf27b13755431b15959588a7e93c517ee58a9dc2bef29b7ff9b7505a7",
|
||||
"bytes": 11534
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/DependenciesView.tsx",
|
||||
@@ -362,16 +372,26 @@
|
||||
"sha256": "020f8299012d53bcac643897ba01d3c463f10cdd76e034ddeeff0436cb52409f",
|
||||
"bytes": 4280
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/HealthRing.tsx",
|
||||
"sha256": "955ff28d691ef51cecc3ee9079b4a35fb8541892760da3f65721790197615233",
|
||||
"bytes": 2689
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/HistoryView.tsx",
|
||||
"sha256": "d440eb2e92a7932f35f4e80f51d41be775e82c94d1f2997f1c6a979078398816",
|
||||
"bytes": 4232
|
||||
"sha256": "f2a0a4f8494f8067daedb529d95a2a333ae125cc5f1e02554a9bc4c984896c9a",
|
||||
"bytes": 6885
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/HotspotsView.tsx",
|
||||
"sha256": "a47d2086e406d9c998f5c38a8b4cf721fb1fa0c1360f73e334da454ea7653453",
|
||||
"bytes": 1677
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/Icon.tsx",
|
||||
"sha256": "c2436035be6dcc10d62ed8ce3d8d5a6fa083cd42c5aeb4cb8af71601dbf7efce",
|
||||
"bytes": 3623
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/OverviewView.tsx",
|
||||
"sha256": "c882afcdccb2eda69f5303d6d5b09da4a0d025b858ecfc97892c58ea17a58e52",
|
||||
@@ -384,13 +404,18 @@
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/PortfolioAtlas.tsx",
|
||||
"sha256": "db41966552e858eb37d4491606e1acca2ba837e8fb5ee8ab24e41105c67c0a4a",
|
||||
"bytes": 5181
|
||||
"sha256": "e3e2e4c8dafc3c71c8dbf833d76f0aaca9b03ed30df5a298b2246af4cb5f9f76",
|
||||
"bytes": 4247
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/RemediationCenter.tsx",
|
||||
"sha256": "027dc97bd1240558bc464fb38afe5d6e5ca8cc48c7a0202a756701c90b51e543",
|
||||
"bytes": 2289
|
||||
"sha256": "961156d35c6e87aa42af0455a1cca9f8dad354545952081f4625c0a4c556a899",
|
||||
"bytes": 2458
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/RepoAvatar.tsx",
|
||||
"sha256": "78971cae26b5b9c05e4ca9336d4e78e5621fad5399f4d6cbb6bce2df285da32c",
|
||||
"bytes": 1780
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/RepositoryVisual.test.tsx",
|
||||
@@ -409,8 +434,8 @@
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/main.tsx",
|
||||
"sha256": "77aaa85d0a532963cd63d1c6171a833f73b608dd83b4085f855b279dbe922939",
|
||||
"bytes": 227
|
||||
"sha256": "328b81d8983b19d4c32324b3328beab2a616c08e862b60150bbc721662a22690",
|
||||
"bytes": 272
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/navigation.test.ts",
|
||||
@@ -424,8 +449,8 @@
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/styles.css",
|
||||
"sha256": "93418ab9fa63bde731c390890a17c1494cae0c96f383423c6160c25d74650a43",
|
||||
"bytes": 92024
|
||||
"sha256": "607e176f4c94c98c90015ea791020eb44bcdef4c5f16624272182d2bd9376ee6",
|
||||
"bytes": 74524
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/test-fixtures.ts",
|
||||
@@ -439,8 +464,8 @@
|
||||
},
|
||||
{
|
||||
"path": "frontend/vite.config.ts",
|
||||
"sha256": "6d4431025685e7e3a6e32ff65a93d7f203c36fa1be9227ad236885c15616d7a7",
|
||||
"bytes": 538
|
||||
"sha256": "92e303ee41b3664bac1b58cf85669e46e46ee5fce747d95a45a169e7fd12655a",
|
||||
"bytes": 759
|
||||
},
|
||||
{
|
||||
"path": "package-lock.json",
|
||||
|
||||
@@ -92,6 +92,10 @@ class GitAcquirer:
|
||||
safe = re.sub(r"[^A-Za-z0-9._-]", "_", identity)
|
||||
return self.mirrors_root / f"{safe}.git"
|
||||
|
||||
def mirror_path(self, repository: Repository) -> Path:
|
||||
"""Return the bare mirror location for read-only consumers such as icon discovery."""
|
||||
return self._mirror_path(repository)
|
||||
|
||||
def _worktree_path(self, job_id: str) -> Path:
|
||||
if not SAFE_JOB_ID.fullmatch(job_id):
|
||||
raise AcquisitionError("invalid_job", "Scan job identity is invalid")
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
"""Read-only project icon discovery from retained bare mirrors.
|
||||
|
||||
A repository's own favicon or logo makes it recognisable in the catalog. The icon is
|
||||
resolved from the existing mirror at an exact revision, never from a worktree and never
|
||||
by fetching: the scanned repository and the mirror are not modified. Candidates are
|
||||
ranked deterministically, size-bounded and content-checked before they are served.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import subprocess
|
||||
from collections import OrderedDict
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from threading import Lock
|
||||
|
||||
from .processes import git_environment, run_bounded
|
||||
|
||||
SAFE_REVISION = re.compile(r"^[0-9a-fA-F]{7,64}$")
|
||||
SAFE_OBJECT = re.compile(r"^[0-9a-f]{40,64}$")
|
||||
MAX_ICON_BYTES = 128 * 1024
|
||||
MAX_TREE_ENTRIES = 200_000
|
||||
MIN_RASTER_BYTES = 3 * 1024
|
||||
|
||||
_ICON_NAME = re.compile(r"^(favicon|icon|app-icon|logo|logo-mark|apple-touch-icon)([._-][a-z0-9-]*)?\.(svg|png|webp|ico)$", re.IGNORECASE)
|
||||
_EXCLUDED_SEGMENT = re.compile(
|
||||
r"^(node_modules|vendor|third_party|\.git|dist|build-cache|coverage|tests?|__tests__|fixtures?|examples?|screens|screenshots|mockups?|templates?)$",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
_PREFERRED_DIRECTORY = {"public": 0, "static": 1, "app": 1, "assets": 2, "icons": 2, "images": 3, "wwwroot": 1, "media": 3, "build": 4, "resources": 4, "build-resources": 4}
|
||||
_NAME_RANK = {"favicon": 0, "icon": 1, "app-icon": 1, "logo-mark": 2, "logo": 3, "apple-touch-icon": 4}
|
||||
_FORMAT_RANK = {"svg": 0, "png": 1, "webp": 2, "ico": 3}
|
||||
MEDIA_TYPES = {"svg": "image/svg+xml", "png": "image/png", "webp": "image/webp", "ico": "image/x-icon"}
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ProjectIcon:
|
||||
path: str
|
||||
media_type: str
|
||||
content: bytes
|
||||
|
||||
|
||||
def _rank(path: str, size: int) -> tuple[int, int, int, int, int, int, str] | None:
|
||||
parts = path.split("/")
|
||||
name = parts[-1]
|
||||
match = _ICON_NAME.fullmatch(name)
|
||||
if not match or size <= 0 or size > MAX_ICON_BYTES:
|
||||
return None
|
||||
directories = parts[:-1]
|
||||
if any(_EXCLUDED_SEGMENT.fullmatch(segment) for segment in directories):
|
||||
return None
|
||||
if len(directories) > 6:
|
||||
return None
|
||||
directory_rank = min((_PREFERRED_DIRECTORY.get(segment.casefold(), 6) for segment in directories), default=5)
|
||||
extension = match.group(3).casefold()
|
||||
sized_variant = 1 if match.group(2) and re.search(r"\d", match.group(2)) else 0
|
||||
# Tiny raster favicons (16/32 px) look blurry at avatar size; prefer a larger raster.
|
||||
low_resolution = 1 if extension != "svg" and size < MIN_RASTER_BYTES else 0
|
||||
return (
|
||||
_FORMAT_RANK[extension],
|
||||
low_resolution,
|
||||
_NAME_RANK[match.group(1).casefold()],
|
||||
directory_rank + sized_variant,
|
||||
len(directories),
|
||||
size,
|
||||
path,
|
||||
)
|
||||
|
||||
|
||||
def _looks_like(content: bytes, extension: str) -> bool:
|
||||
if extension == "png":
|
||||
return content.startswith(b"\x89PNG\r\n\x1a\n")
|
||||
if extension == "ico":
|
||||
return content[:4] == b"\x00\x00\x01\x00"
|
||||
if extension == "webp":
|
||||
return content[:4] == b"RIFF" and content[8:12] == b"WEBP"
|
||||
head = content[:2048].lstrip().lower()
|
||||
return head.startswith((b"<?xml", b"<svg", b"<!--")) and b"<svg" in content[:8192].lower()
|
||||
|
||||
|
||||
class ProjectIconResolver:
|
||||
"""Resolve and cache the most representative icon file at an exact revision."""
|
||||
|
||||
def __init__(self, mirrors_root: Path, *, timeout: float = 15, cache_size: int = 512) -> None:
|
||||
self.mirrors_root = mirrors_root
|
||||
self.timeout = timeout
|
||||
self.cache_size = cache_size
|
||||
self._cache: OrderedDict[tuple[str, str], ProjectIcon | None] = OrderedDict()
|
||||
self._lock = Lock()
|
||||
|
||||
def _git(self, mirror: Path, args: list[str]) -> bytes:
|
||||
result = run_bounded(["git", "--git-dir", str(mirror), *args], timeout=self.timeout, env=git_environment())
|
||||
return result.stdout
|
||||
|
||||
def resolve(self, mirror: Path, revision: str) -> ProjectIcon | None:
|
||||
if not SAFE_REVISION.fullmatch(revision):
|
||||
return None
|
||||
try:
|
||||
mirror.resolve().relative_to(self.mirrors_root.resolve())
|
||||
except (OSError, RuntimeError, ValueError):
|
||||
return None
|
||||
key = (str(mirror), revision.casefold())
|
||||
with self._lock:
|
||||
if key in self._cache:
|
||||
self._cache.move_to_end(key)
|
||||
return self._cache[key]
|
||||
icon = self._discover(mirror, revision) if mirror.is_dir() else None
|
||||
with self._lock:
|
||||
self._cache[key] = icon
|
||||
self._cache.move_to_end(key)
|
||||
while len(self._cache) > self.cache_size:
|
||||
self._cache.popitem(last=False)
|
||||
return icon
|
||||
|
||||
def _discover(self, mirror: Path, revision: str) -> ProjectIcon | None:
|
||||
try:
|
||||
listing = self._git(mirror, ["ls-tree", "-r", "-l", "--full-tree", "-z", f"{revision}^{{tree}}"])
|
||||
except (OSError, subprocess.SubprocessError):
|
||||
return None
|
||||
candidates: list[tuple[tuple[int, int, int, int, int, int, str], str, str]] = []
|
||||
for index, entry in enumerate(listing.split(b"\x00")):
|
||||
if index >= MAX_TREE_ENTRIES or not entry:
|
||||
continue
|
||||
try:
|
||||
meta, raw_path = entry.split(b"\t", 1)
|
||||
_mode, kind, obj, size = meta.split()
|
||||
path = raw_path.decode("utf-8")
|
||||
except ValueError:
|
||||
continue
|
||||
if kind != b"blob" or not size.isdigit():
|
||||
continue
|
||||
obj_id = obj.decode("ascii", errors="ignore")
|
||||
rank = _rank(path, int(size))
|
||||
if rank is not None and SAFE_OBJECT.fullmatch(obj_id):
|
||||
candidates.append((rank, obj_id, path))
|
||||
for _rank_key, obj_id, path in sorted(candidates)[:8]:
|
||||
try:
|
||||
content = self._git(mirror, ["cat-file", "blob", obj_id])
|
||||
except (OSError, subprocess.SubprocessError):
|
||||
continue
|
||||
extension = path.rsplit(".", 1)[-1].casefold()
|
||||
if len(content) <= MAX_ICON_BYTES and _looks_like(content, extension):
|
||||
return ProjectIcon(path=path, media_type=MEDIA_TYPES[extension], content=content)
|
||||
return None
|
||||
@@ -18,6 +18,8 @@ from starlette.types import Scope
|
||||
|
||||
from .acquisition import GitAcquirer
|
||||
from .gitea import GiteaClient
|
||||
from .icons import SAFE_REVISION as SAFE_ICON_REVISION
|
||||
from .icons import ProjectIconResolver
|
||||
from .jobs import ScanJobRunner
|
||||
from .models import (
|
||||
RepositoryDetail,
|
||||
@@ -56,6 +58,7 @@ MAX_CONCURRENT_SCANS = 1
|
||||
SCAN_SLOTS = BoundedSemaphore(MAX_CONCURRENT_SCANS)
|
||||
gitea_client = GiteaClient()
|
||||
repository_acquirer = GitAcquirer()
|
||||
project_icons = ProjectIconResolver(repository_acquirer.mirrors_root)
|
||||
job_runner: ScanJobRunner | None = None
|
||||
_api_mutation_lock = Lock()
|
||||
_MAINTENANCE_ENTER_PATH = "/api/v1/operator/maintenance/enter"
|
||||
@@ -280,6 +283,30 @@ def get_repository(repository_id: str) -> RepositoryDetail:
|
||||
return repository
|
||||
|
||||
|
||||
ICON_HEADERS = {
|
||||
"Cache-Control": "public, max-age=86400",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
# Repository-supplied SVG is untrusted: never allow script, network or embedding.
|
||||
"Content-Security-Policy": "default-src 'none'; style-src 'unsafe-inline'; img-src data:; sandbox",
|
||||
"Cross-Origin-Resource-Policy": "same-origin",
|
||||
}
|
||||
|
||||
|
||||
@app.get("/api/v1/repositories/{repository_id}/icon")
|
||||
def repository_icon(repository_id: str, rev: str | None = Query(default=None, max_length=64)) -> Response:
|
||||
"""Serve the project's own favicon or logo from its mirror at the retained revision."""
|
||||
|
||||
repository = store.get_repository(repository_id)
|
||||
if repository is None:
|
||||
raise HTTPException(status_code=404, detail="Repository not found")
|
||||
known = {value.casefold() for value in (repository.last_scan_revision, repository.latest_revision) if value}
|
||||
revision = rev if rev and SAFE_ICON_REVISION.fullmatch(rev) and rev.casefold() in known else repository.last_scan_revision or repository.latest_revision
|
||||
icon = project_icons.resolve(repository_acquirer.mirror_path(repository), revision) if revision else None
|
||||
if icon is None:
|
||||
return Response(status_code=status.HTTP_404_NOT_FOUND, headers={"Cache-Control": "public, max-age=3600"})
|
||||
return Response(icon.content, media_type=icon.media_type, headers=ICON_HEADERS)
|
||||
|
||||
|
||||
@app.get("/api/v1/repositories/{repository_id}/scans", response_model=list[ScanSummary])
|
||||
def list_repository_scans(
|
||||
repository_id: str,
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
from app.icons import MAX_ICON_BYTES, ProjectIconResolver
|
||||
|
||||
PNG = b"\x89PNG\r\n\x1a\n" + b"\x00" * 32
|
||||
SVG = b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 8"><rect width="8" height="8"/></svg>'
|
||||
|
||||
|
||||
def _mirror(tmp_path: Path, files: dict[str, bytes]) -> tuple[Path, Path, str]:
|
||||
source = tmp_path / "source"
|
||||
source.mkdir()
|
||||
for relative, content in files.items():
|
||||
target = source / relative
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
target.write_bytes(content)
|
||||
subprocess.run(["git", "init", "--quiet", str(source)], check=True)
|
||||
subprocess.run(["git", "-C", str(source), "config", "user.email", "test@example.com"], check=True)
|
||||
subprocess.run(["git", "-C", str(source), "config", "user.name", "RepoPulse Test"], check=True)
|
||||
subprocess.run(["git", "-C", str(source), "add", "."], check=True)
|
||||
subprocess.run(["git", "-C", str(source), "commit", "--quiet", "-m", "initial"], check=True)
|
||||
revision = subprocess.run(["git", "-C", str(source), "rev-parse", "HEAD"], check=True, capture_output=True, text=True).stdout.strip()
|
||||
mirrors = tmp_path / "mirrors"
|
||||
mirrors.mkdir()
|
||||
mirror = mirrors / "gitea-1.git"
|
||||
subprocess.run(["git", "clone", "--quiet", "--mirror", str(source), str(mirror)], check=True)
|
||||
return mirrors, mirror, revision
|
||||
|
||||
|
||||
def test_prefers_a_public_svg_favicon_over_logos_and_excluded_fixtures(tmp_path: Path) -> None:
|
||||
mirrors, mirror, revision = _mirror(tmp_path, {
|
||||
"README.md": b"# Demo\n",
|
||||
"docs/logo.png": PNG,
|
||||
"tests/fixtures/favicon.svg": SVG,
|
||||
"node_modules/pkg/favicon.svg": SVG,
|
||||
"frontend/public/favicon.svg": SVG,
|
||||
"frontend/public/icons.svg": SVG,
|
||||
})
|
||||
icon = ProjectIconResolver(mirrors).resolve(mirror, revision)
|
||||
assert icon is not None
|
||||
assert icon.path == "frontend/public/favicon.svg"
|
||||
assert icon.media_type == "image/svg+xml"
|
||||
assert icon.content == SVG
|
||||
|
||||
|
||||
def test_rejects_content_that_does_not_match_its_extension_and_oversized_files(tmp_path: Path) -> None:
|
||||
mirrors, mirror, revision = _mirror(tmp_path, {
|
||||
"public/favicon.svg": b"#!/bin/sh\necho not an image\n",
|
||||
"public/logo.png": b"not a png",
|
||||
"public/icon.png": PNG + b"\x00" * MAX_ICON_BYTES,
|
||||
"app/icon.png": PNG,
|
||||
})
|
||||
icon = ProjectIconResolver(mirrors).resolve(mirror, revision)
|
||||
assert icon is not None
|
||||
assert icon.path == "app/icon.png"
|
||||
assert icon.media_type == "image/png"
|
||||
|
||||
|
||||
def test_prefers_a_larger_raster_over_a_tiny_favicon(tmp_path: Path) -> None:
|
||||
mirrors, mirror, revision = _mirror(tmp_path, {
|
||||
"frontend/public/icons/favicon-16.png": PNG,
|
||||
"frontend/public/icons/apple-touch-icon.png": PNG + bytes(8000),
|
||||
})
|
||||
icon = ProjectIconResolver(mirrors).resolve(mirror, revision)
|
||||
assert icon is not None
|
||||
assert icon.path == "frontend/public/icons/apple-touch-icon.png"
|
||||
|
||||
|
||||
def test_missing_icons_unknown_revisions_and_foreign_mirrors_resolve_to_none(tmp_path: Path) -> None:
|
||||
mirrors, mirror, revision = _mirror(tmp_path, {"README.md": b"# Demo\n"})
|
||||
resolver = ProjectIconResolver(mirrors)
|
||||
assert resolver.resolve(mirror, revision) is None
|
||||
assert resolver.resolve(mirror, "not-a-revision") is None
|
||||
assert resolver.resolve(mirror, "0" * 40) is None
|
||||
assert resolver.resolve(tmp_path / "source" / ".git", revision) is None
|
||||
|
||||
|
||||
def test_icon_endpoint_serves_the_mirror_icon_with_strict_headers(tmp_path: Path, monkeypatch) -> None:
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app import main as main_module
|
||||
from app.models import Repository
|
||||
from app.store import ScanStore
|
||||
|
||||
mirrors, _mirror_path, revision = _mirror(tmp_path, {"public/favicon.svg": SVG})
|
||||
store = ScanStore(str(tmp_path / "history.db"))
|
||||
repository = Repository(id="gitea:1", provider="gitea", provider_repository_id="1", owner="Jens", name="Demo", full_name="Jens/Demo", latest_revision=revision)
|
||||
store.upsert_repository(repository)
|
||||
empty = Repository(id="gitea:2", provider="gitea", provider_repository_id="2", owner="Jens", name="Empty", full_name="Jens/Empty")
|
||||
store.upsert_repository(empty)
|
||||
monkeypatch.setattr(main_module, "store", store)
|
||||
monkeypatch.setattr(main_module, "project_icons", ProjectIconResolver(mirrors))
|
||||
monkeypatch.setattr(main_module.repository_acquirer, "mirrors_root", mirrors)
|
||||
client = TestClient(main_module.app)
|
||||
|
||||
response = client.get(f"/api/v1/repositories/gitea:1/icon?rev={revision}")
|
||||
assert response.status_code == 200
|
||||
assert response.content == SVG
|
||||
assert response.headers["content-type"].startswith("image/svg+xml")
|
||||
assert "sandbox" in response.headers["content-security-policy"]
|
||||
assert response.headers["x-content-type-options"] == "nosniff"
|
||||
|
||||
assert client.get("/api/v1/repositories/gitea:2/icon").status_code == 404
|
||||
assert client.get("/api/v1/repositories/gitea:404/icon").status_code == 404
|
||||
@@ -37,6 +37,8 @@ For a Gitea job, the requested SHA is captured at enqueue time. The acquirer use
|
||||
|
||||
## Scan boundary
|
||||
|
||||
Project icons are resolved read-only from the existing bare mirror at the repository's retained scan revision (`GET /api/v1/repositories/{id}/icon`). The resolver lists the tree with `git ls-tree`, ranks favicon/icon/logo candidates deterministically (SVG first, larger rasters over tiny favicons, `public`/`static`/`app` directories first, tests, fixtures, vendored and screenshot paths excluded), reads at most 128 KiB per blob with `git cat-file` and serves the file only when its content matches its extension. It never fetches, never touches a worktree and caches results per revision in memory. Responses carry `nosniff` and a sandboxing `Content-Security-Policy`, because repository-supplied SVG is untrusted; the frontend renders icons through `<img>` and falls back to readiness-tinted initials when no icon exists.
|
||||
|
||||
When `REPOPULSE_SCAN_ROOT` is configured, every local scan path is resolved and checked against that root before analysis. Compose sets the root to `/scan` and mounts the user-selected source directory read-only. The scanner then resolves every candidate file, rejects symlinked files and directories (including symlink ancestors), and requires the resolved file to remain below the scan root. This prevents the API from being used as a generic filesystem browser outside the configured analysis boundary. Gitea worktrees are acquired into `/data`, not `/scan`, and are controlled by repository-ID/job-ID validation.
|
||||
|
||||
## Persistence and deployment boundary
|
||||
|
||||
Generated
+25
-33
@@ -8,12 +8,13 @@
|
||||
"name": "repopulse-frontend",
|
||||
"version": "1.5.1",
|
||||
"dependencies": {
|
||||
"@fontsource-variable/inter": "^5.3.0",
|
||||
"@xyflow/react": "^12.8.5",
|
||||
"react": "^19.1.1",
|
||||
"react-dom": "^19.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.55.0",
|
||||
"@playwright/test": "^1.64.1",
|
||||
"@testing-library/dom": "^10.4.1",
|
||||
"@testing-library/react": "^16.3.3",
|
||||
"@types/react": "^19.1.12",
|
||||
@@ -983,6 +984,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@fontsource-variable/inter": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/inter/-/inter-5.3.0.tgz",
|
||||
"integrity": "sha512-OupL48va4JNofb97w6NYeF9S7W/kHNKM0Er8Dem5nqi4jeOLrVJDoE8tZEpnMJmtkvNbB1EIPPwHcdkF6b1oUA==",
|
||||
"license": "OFL-1.1",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ayuhito"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/gen-mapping": {
|
||||
"version": "0.3.13",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
|
||||
@@ -1054,19 +1064,19 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@playwright/test": {
|
||||
"version": "1.55.0",
|
||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.55.0.tgz",
|
||||
"integrity": "sha512-04IXzPwHrW69XusN/SIdDdKZBzMfOT9UNT/YiJit/xpy2VuAoB8NHc8Aplb96zsWDddLnbkPL3TsmrS04ZU2xQ==",
|
||||
"version": "1.64.1",
|
||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.64.1.tgz",
|
||||
"integrity": "sha512-IaYGml/nSOiZWROfPtuIL7neuu9qDOZ3TNvNljUIrhDMxiGTgPjzj/g9p9RxpS2tSepPDRY+UwAaEeiKtUvIAg==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright": "1.55.0"
|
||||
"playwright": "1.64.1"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/pluginutils": {
|
||||
@@ -2592,50 +2602,32 @@
|
||||
}
|
||||
},
|
||||
"node_modules/playwright": {
|
||||
"version": "1.55.0",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.55.0.tgz",
|
||||
"integrity": "sha512-sdCWStblvV1YU909Xqx0DhOjPZE4/5lJsIS84IfN9dAZfcl/CIZ5O8l3o0j7hPMjDvqoTF8ZUcc+i/GL5erstA==",
|
||||
"version": "1.64.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.64.1.tgz",
|
||||
"integrity": "sha512-HCrVhHr5QQuwYoswEUGTb7gGp522yflbv/ST8nF4sFWGuLjQCt17Q/EubpGGSNKYn1tsTCPZxqHhHCfVURu7UA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright-core": "1.55.0"
|
||||
"playwright-core": "1.64.1"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "2.3.2"
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright-core": {
|
||||
"version": "1.55.0",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.55.0.tgz",
|
||||
"integrity": "sha512-GvZs4vU3U5ro2nZpeiwyb0zuFaqb9sUiAJuyrWpcGouD8y9/HLgGbNRjIph7zU9D3hnPaisMl9zG9CgFi/biIg==",
|
||||
"version": "1.64.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.1.tgz",
|
||||
"integrity": "sha512-BC4s8y6SEVA6Q1rSxZTto8hI1KUI3xXlHGZgvGqP4IqPdI/a6FX9H29IDNz7vKo9l21b6LfYosScPL6M3xxyDQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"playwright-core": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright/node_modules/fsevents": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/postcss": {
|
||||
|
||||
@@ -11,12 +11,13 @@
|
||||
"test:e2e": "playwright test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fontsource-variable/inter": "^5.3.0",
|
||||
"@xyflow/react": "^12.8.5",
|
||||
"react": "^19.1.1",
|
||||
"react-dom": "^19.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.55.0",
|
||||
"@playwright/test": "^1.64.1",
|
||||
"@testing-library/dom": "^10.4.1",
|
||||
"@testing-library/react": "^16.3.3",
|
||||
"@types/react": "^19.1.12",
|
||||
|
||||
@@ -2,7 +2,7 @@ import { defineConfig, devices } from '@playwright/test'
|
||||
|
||||
export default defineConfig({
|
||||
testDir: './e2e',
|
||||
timeout: 30_000,
|
||||
timeout: 60_000, // one long end-to-end journey; cold Vite compiles on a loaded runner need headroom
|
||||
fullyParallel: false,
|
||||
workers: 6,
|
||||
reporter: 'list',
|
||||
@@ -30,7 +30,7 @@ export default defineConfig({
|
||||
command: 'node e2e/start-vite.mjs',
|
||||
url: 'http://127.0.0.1:4173',
|
||||
reuseExistingServer: false,
|
||||
timeout: 30_000,
|
||||
timeout: 60_000, // one long end-to-end journey; cold Vite compiles on a loaded runner need headroom
|
||||
},
|
||||
],
|
||||
})
|
||||
+21
-9
@@ -3,6 +3,9 @@ import { type FormEvent, lazy, Suspense, useCallback, useEffect, useMemo, useRef
|
||||
import { api, type AppMeta, type RepositorySummary, type ScanComparison, type ScanJob, type ScanReport, type ScanSummary, type TrendPoint } from './api'
|
||||
import { filterRepositories, orderSwitcherRepositories, paginateRepositories, readinessLabel, repositoryReadiness, sortRepositories, stateLabel, type CatalogFilters, type CatalogSort, type CatalogSortKey, type Readiness } from './catalog'
|
||||
import { BrandLockup, BrandMark } from './components/Brand'
|
||||
import { Icon, type IconName } from './components/Icon'
|
||||
import { HealthRing } from './components/HealthRing'
|
||||
import { RepoAvatar } from './components/RepoAvatar'
|
||||
import { DashboardView } from './components/DashboardView'
|
||||
import { DependenciesView } from './components/DependenciesView'
|
||||
import { FindingsView } from './components/FindingsView'
|
||||
@@ -40,7 +43,7 @@ function formatDate(value: string | null) { if (!value) return 'Never'; const da
|
||||
function formatRelativeDate(value: string | null) { if (!value) return 'Never scanned'; const difference = Date.now() - new Date(value).getTime(); if (Number.isNaN(difference)) return 'Unknown'; if (difference < 3_600_000) return `${Math.max(1, Math.floor(difference / 60_000))}m ago`; if (difference < 86_400_000) return `${Math.floor(difference / 3_600_000)}h ago`; return `${Math.floor(difference / 86_400_000)}d ago` }
|
||||
function downloadText(filename: string, content: string, mime: string) { const url = URL.createObjectURL(new Blob([content], { type: mime })); const anchor = document.createElement('a'); anchor.href = url; anchor.download = filename; anchor.style.display = 'none'; document.body.appendChild(anchor); anchor.click(); window.setTimeout(() => { anchor.remove(); URL.revokeObjectURL(url) }, 0) }
|
||||
function reportFilename(repositoryName: string, format: 'html' | 'json') { const safeName = repositoryName.replace(/[\u0000-\u001f\u007f<>:"/\\|?*]/g, '_').replace(/[ .]+$/g, '').slice(0, 100).replace(/[ .]+$/g, '') || 'repository'; return `repopulse-${safeName}.${format}` }
|
||||
function detailViewLabel(view: DetailView, report: ScanReport | null) { if (view === 'overview') return 'Overview'; if (view === 'findings') return `Findings (${report?.findings.filter((finding) => !finding.suppressed).length ?? 0})`; if (view === 'architecture') return `Architecture (${report?.architecture.nodes.length ?? 0})`; if (view === 'hotspots') return `Hotspots (${report?.hotspots.length ?? 0})`; if (view === 'dependencies') return 'Dependencies'; if (view === 'history') return 'History'; return 'Scan runs' }
|
||||
function detailViewLabel(view: DetailView, report: ScanReport | null) { if (view === 'overview') return 'Overview'; if (view === 'findings') return report ? `Findings (${report.findings.filter((finding) => !finding.suppressed).length})` : 'Findings'; if (view === 'architecture') return report ? `Architecture (${report.architecture.nodes.length})` : 'Architecture'; if (view === 'hotspots') return report ? `Hotspots (${report.hotspots.length})` : 'Hotspots'; if (view === 'dependencies') return 'Dependencies'; if (view === 'history') return 'History'; return 'Scan runs' }
|
||||
|
||||
export default function App() {
|
||||
const [route, setRoute] = useState<Route>(() => parseRoute(window.location.pathname))
|
||||
@@ -162,20 +165,29 @@ export default function App() {
|
||||
const selectScan = async (summary: ScanSummary) => { try { setBusy(true); setError(null); setReport(await api.repositoryScan(summary.repository_id, summary.id)); navigate({ page: 'repositories', repositoryId: summary.repository_id, view: 'overview' }) } catch (err) { setError(err instanceof Error ? err.message : 'Could not load the selected scan.') } finally { setBusy(false) } }
|
||||
const exportReport = async (format: 'html' | 'json') => { if (!report) return; try { downloadText(reportFilename(report.repository_name, format), await api.exportReport(report.id, format), format === 'html' ? 'text/html' : 'application/json') } catch (err) { setError(err instanceof Error ? err.message : 'Report export failed.') } }
|
||||
|
||||
const renderGlobalNav = () => <nav className="global-nav" aria-label="Primary navigation"><a className={route.page === 'dashboard' ? 'active' : ''} aria-current={route.page === 'dashboard' ? 'page' : undefined} href="/" onClick={(event) => handleNavigation(event, { page: 'dashboard' })}>Dashboard</a><a className={route.page === 'repositories' ? 'active' : ''} aria-current={route.page === 'repositories' ? 'page' : undefined} href="/repositories" onClick={(event) => handleNavigation(event, { page: 'repositories' })}>Repositories <span>{repositories.length || '—'}</span></a><a className={route.page === 'activity' ? 'active' : ''} aria-current={route.page === 'activity' ? 'page' : undefined} href="/activity" onClick={(event) => handleNavigation(event, { page: 'activity' })}>Activity</a><a className={route.page === 'queue' ? 'active' : ''} aria-current={route.page === 'queue' ? 'page' : undefined} href="/queue" onClick={(event) => handleNavigation(event, { page: 'queue' })}>Scan queue</a><a className={route.page === 'settings' ? 'active' : ''} aria-current={route.page === 'settings' ? 'page' : undefined} href="/settings" onClick={(event) => handleNavigation(event, { page: 'settings' })}>Settings</a></nav>
|
||||
const renderTopbar = () => <header className="app-header"><a className="brand-home" href="/" onClick={(event) => handleNavigation(event, { page: 'dashboard' })} aria-label="RepoPulse dashboard"><BrandLockup /></a>{renderGlobalNav()}<div className="header-actions"><button className="shortcut-button" type="button" onClick={() => setSwitcherOpen(true)} aria-keyshortcuts="Control+K Meta+K"><span>Quick switch</span><kbd>⌘K</kbd></button><button className="icon-button sync-icon" type="button" onClick={() => void syncCatalog()} disabled={catalogBusy} aria-label="Synchronize Gitea catalog" title="Synchronize Gitea catalog">↻</button></div></header>
|
||||
const navItems: { page: Route['page']; label: string; href: string; icon: IconName; count?: number }[] = [
|
||||
{ page: 'dashboard', label: 'Dashboard', href: '/', icon: 'dashboard' },
|
||||
{ page: 'repositories', label: 'Repositories', href: '/repositories', icon: 'repositories', count: repositories.length },
|
||||
{ page: 'activity', label: 'Activity', href: '/activity', icon: 'activity' },
|
||||
{ page: 'queue', label: 'Scan queue', href: '/queue', icon: 'queue', count: repositories.filter((repository) => repository.active_job_id || repository.state === 'queued' || repository.state === 'scanning').length || undefined },
|
||||
{ page: 'settings', label: 'Settings', href: '/settings', icon: 'settings' },
|
||||
]
|
||||
const lastSync = meta?.gitea.last_sync && typeof meta.gitea.last_sync === 'object' && 'synced_at' in meta.gitea.last_sync ? String(meta.gitea.last_sync.synced_at) : null
|
||||
const renderGlobalNav = () => <nav className="global-nav" aria-label="Primary navigation">{navItems.map((item) => <a key={item.page} className={route.page === item.page ? 'active' : ''} aria-current={route.page === item.page ? 'page' : undefined} href={item.href} title={item.label} onClick={(event) => handleNavigation(event, { page: item.page })}><Icon name={item.icon} size={18} /><span className="nav-label">{item.label}</span>{item.count != null && <span className="nav-count">{item.count || '—'}</span>}</a>)}</nav>
|
||||
const renderSidebar = () => <aside className="sidebar"><a className="brand-home" href="/" onClick={(event) => handleNavigation(event, { page: 'dashboard' })} aria-label="RepoPulse dashboard"><BrandLockup /></a>{renderGlobalNav()}<div className="sidebar-footer"><span className={`live-dot ${meta?.gitea.configured ? 'ok' : 'unknown'}`} aria-hidden="true" /><span><strong>{meta?.gitea.configured ? 'Gitea connected' : meta ? 'Gitea not configured' : 'Connecting…'}</strong><small>{lastSync ? `Synced ${formatRelativeDate(lastSync)}` : 'No sync recorded'}{meta?.version ? ` · v${meta.version}` : ''}</small></span></div></aside>
|
||||
const renderTopbar = () => <header className="app-header"><a className="brand-home mobile-brand" href="/" onClick={(event) => handleNavigation(event, { page: 'dashboard' })} aria-label="RepoPulse home"><BrandLockup compact /></a><button className="shortcut-button" type="button" onClick={() => setSwitcherOpen(true)} aria-keyshortcuts="Control+K Meta+K"><Icon name="search" /><span>Quick switch</span><kbd>Ctrl K</kbd></button><div className="header-actions"><button className="ghost sync-button" type="button" onClick={() => void syncCatalog()} disabled={catalogBusy} aria-label="Synchronize Gitea catalog" title="Synchronize Gitea catalog"><Icon name="refresh" className={catalogBusy ? 'spin' : ''} /><span>{catalogBusy ? 'Syncing…' : 'Sync'}</span></button></div></header>
|
||||
|
||||
const renderCatalogPage = () => <section className="page-content explorer-page" aria-labelledby="repositories-title"><div className="page-heading"><div><span className="eyebrow">Repository explorer</span><h1 id="repositories-title">Repositories <span className="count-badge">{repositories.length}</span></h1><p className="muted">High-density catalog controls when you need breadth; switch to visual identity tiles when you need pattern recognition.</p></div><div className="page-heading-actions"><button className="ghost" type="button" onClick={() => setSwitcherOpen(true)}>Quick switcher <kbd>⌘K</kbd></button><button type="button" onClick={() => void syncCatalog()} disabled={catalogBusy}>{catalogBusy ? 'Syncing…' : 'Sync Gitea catalog'}</button></div></div><section className="catalog-toolbar section-card" aria-label="Repository filters"><div className="search-control"><span className="search-glyph" aria-hidden="true">⌕</span><label className="sr-only" htmlFor="catalog-search">Search repositories</label><input id="catalog-search" value={catalogFilters.query} onChange={(event) => updateCatalogFilter('query', event.target.value)} placeholder="Search name, owner or full name" /><kbd>⌘K</kbd></div><div className="filter-grid"><label>State<select aria-label="Filter by state" value={catalogFilters.state} onChange={(event) => updateCatalogFilter('state', event.target.value as CatalogFilters['state'])}><option value="all">All states</option><option value="current">Current</option><option value="stale">Stale</option><option value="scanning">Scanning</option><option value="failed">Failed</option><option value="never_scanned">Never scanned</option><option value="archived">Archived</option></select></label><label>Readiness<select aria-label="Filter by readiness" value={catalogFilters.readiness} onChange={(event) => updateCatalogFilter('readiness', event.target.value as CatalogFilters['readiness'])}><option value="all">All readiness</option><option value="ready">Ready</option><option value="warnings">Warnings</option><option value="blocked">Blocked</option></select></label><label>Owner<select aria-label="Filter by owner" value={catalogFilters.owner} onChange={(event) => updateCatalogFilter('owner', event.target.value)}><option value="all">All owners</option>{ownerOptions.map((owner) => <option key={owner} value={owner}>{owner}</option>)}</select></label><label>Branch<select aria-label="Filter by branch" value={catalogFilters.branch} onChange={(event) => updateCatalogFilter('branch', event.target.value)}><option value="all">All branches</option>{branchOptions.map((branch) => <option key={branch} value={branch}>{branch}</option>)}</select></label><label>Visibility<select aria-label="Filter by visibility" value={catalogFilters.visibility} onChange={(event) => updateCatalogFilter('visibility', event.target.value as CatalogFilters['visibility'])}><option value="all">Any visibility</option><option value="private">Private</option><option value="public">Public</option></select></label><label>Lifecycle<select aria-label="Filter by lifecycle" value={catalogFilters.archived} onChange={(event) => updateCatalogFilter('archived', event.target.value as CatalogFilters['archived'])}><option value="active">Active only</option><option value="all">Active and archived</option><option value="archived">Archived only</option></select></label></div><div className="toolbar-footer"><span className="filter-result">{filteredRepositories.length} matching {repositories.length} repositories</span><div className="view-toggle" aria-label="Repository view"><button className={catalogView === 'table' ? 'active' : ''} type="button" onClick={() => setCatalogView('table')} aria-pressed={catalogView === 'table'}>Table</button><button className={catalogView === 'grid' ? 'active' : ''} type="button" onClick={() => setCatalogView('grid')} aria-pressed={catalogView === 'grid'}>Visual grid</button></div><button className="text-button" type="button" onClick={() => { setCatalogFilters(DEFAULT_FILTERS); setCatalogPage(1) }}>Reset filters</button></div></section>{catalogLoading ? <section className="catalog-loading" aria-label="Loading repository catalog"><span /><span /><span /><span /></section> : catalogWindow.items.length ? <>{catalogView === 'table' ? <section className="catalog-table-card section-card" aria-label="Repository catalog results"><div className="table-scroll"><table className="repository-table"><thead><tr><th><button className="sort-button" type="button" onClick={() => setCatalogSortKey('name')}>Repository <span>{catalogSort.key === 'name' ? catalogSort.direction === 'asc' ? '↑' : '↓' : '↕'}</span></button></th><th><button className="sort-button" type="button" onClick={() => setCatalogSortKey('state')}>State <span>{catalogSort.key === 'state' ? catalogSort.direction === 'asc' ? '↑' : '↓' : '↕'}</span></button></th><th>Readiness</th><th>Branch</th><th><button className="sort-button" type="button" onClick={() => setCatalogSortKey('last_sLine truncated
|
||||
const renderCatalogPage = () => <section className="page-content explorer-page" aria-labelledby="repositories-title"><div className="page-heading"><div><h1 id="repositories-title">Repositories <span className="count-badge">{repositories.length}</span></h1><p className="muted">Every repository RepoPulse discovered in Gitea, with its latest retained scan.</p></div><div className="page-heading-actions"><button type="button" onClick={() => void syncCatalog()} disabled={catalogBusy}><Icon name="refresh" className={catalogBusy ? 'spin' : ''} />{catalogBusy ? 'Syncing…' : 'Sync Gitea catalog'}</button></div></div><section className="catalog-toolbar section-card" aria-label="Repository filters"><div className="search-control"><span className="search-glyph" aria-hidden="true"><Icon name="search" /></span><label className="sr-only" htmlFor="catalog-search">Search repositories</label><input id="catalog-search" value={catalogFilters.query} onChange={(event) => updateCatalogFilter('query', event.target.value)} placeholder="Search name, owner or full name" /></div><div className="filter-grid"><label>State<select aria-label="Filter by state" value={catalogFilters.state} onChange={(event) => updateCatalogFilter('state', event.target.value as CatalogFilters['state'])}><option value="all">All states</option><option value="current">Current</option><option value="stale">Stale</option><option value="scanning">Scanning</option><option value="failed">Failed</option><option value="never_scanned">Never scanned</option><option value="archived">Archived</option></select></label><label>Readiness<select aria-label="Filter by readiness" value={catalogFilters.readiness} onChange={(event) => updateCatalogFilter('readiness', event.target.value as CatalogFilters['readiness'])}><option value="all">All readiness</option><option value="ready">Ready</option><option value="warnings">Warnings</option><option value="blocked">Blocked</option></select></label><label>Owner<select aria-label="Filter by owner" value={catalogFilters.owner} onChange={(event) => updateCatalogFilter('owner', event.target.value)}><option value="all">All owners</option>{ownerOptions.map((owner) => <option key={owner} value={owner}>{owner}</option>)}</select></label><label>Branch<select aria-label="Filter by branch" value={catalogFilters.branch} onChange={(event) => updateCatalogFilter('branch', event.target.value)}><option value="all">All branches</option>{branchOptions.map((branch) => <option key={branch} value={branch}>{branch}</option>)}</select></label><label>Visibility<select aria-label="Filter by visibility" value={catalogFilters.visibility} onChange={(event) => updateCatalogFilter('visibility', event.target.value as CatalogFilters['visibility'])}><option value="all">Any visibility</option><option value="private">Private</option><option value="public">Public</option></select></label><label>Lifecycle<select aria-label="Filter by lifecycle" value={catalogFilters.archived} onChange={(event) => updateCatalogFilter('archived', event.target.value as CatalogFilters['archived'])}><option value="active">Active only</option><option value="all">Active and archived</option><option value="archived">Archived only</option></select></label></div><div className="toolbar-footer"><span className="filter-result">{filteredRepositories.length} matching {repositories.length} repositories</span><div className="view-toggle" aria-label="Repository view"><button className={catalogView === 'table' ? 'active' : ''} type="button" onClick={() => setCatalogView('table')} aria-pressed={catalogView === 'table'}>Table</button><button className={catalogView === 'grid' ? 'active' : ''} type="button" onClick={() => setCatalogView('grid')} aria-pressed={catalogView === 'grid'}>Visual grid</button></div><button className="text-button" type="button" onClick={() => { setCatalogFilters(DEFAULT_FILTERS); setCatalogPage(1) }}>Reset filters</button></div></section>{catalogLoading ? <section className="catalog-loading" aria-label="Loading repository catalog"><span /><span /><span /><span /></section> : catalogWindow.items.length ? <>{catalogView === 'table' ? <section className="catalog-table-card section-card" aria-label="Repository catalog results"><div className="table-scroll"><table className="repository-table"><thead><tr><th><button className="sort-button" type="button" onClick={() => setCatalogSortKey('name')}>Repository <span>{catalogSort.key === 'name' ? catalogSort.direction === 'asc' ? '↑' : '↓' : '↕'}</span></button></th><th><button className="sort-button" type="button" onClick={() => setCatalogSortKey('state')}>State <span>{catalogSort.key === 'state' ? catalogSort.direction === 'asc' ? '↑' : '↓' : '↕'}</span></button></th><th>Readiness</th><th>Branch</th><th><button className="sort-button" type="button" onClick={() => setCatalogSortKey('last_scan')}>Last scan <span>{catalogSort.key === 'last_scan' ? catalogSort.direction === 'asc' ? '↑' : '↓' : '↕'}</span></button></th><th><buttoLine truncated
|
||||
|
||||
const renderDetailPage = () => {
|
||||
if (!selectedRepository) return <section className="page-content"><div className="empty-state section-card"><BrandMark size={38} label="" /><h1>This repository is not in the current catalog.</h1><p className="muted">It may have been archived, removed or the link may be stale.</p><a className="button-link" href="/repositories" onClick={(event) => handleNavigation(event, { page: 'repositories' })}>Back to repositories</a></div></section>
|
||||
const readiness = repositoryReadiness(selectedRepository); const revision = report?.source.actual_revision || selectedRepository.latest_revision
|
||||
return <section className="page-content detail-page" aria-labelledby="repository-title"><div className="breadcrumb-row"><a href="/repositories" onClick={(event) => handleNavigation(event, { page: 'repositories' })}>Repository explorer</a><span aria-hidden="true">/</span><button type="button" onClick={() => setSwitcherOpen(true)}>{selectedRepository.full_name} <span aria-hidden="true">⌄</span></button></div><section className="workspace-hero"><div className="workspace-identity"><div><span className="eyebrow">{selectedRepository.provider} repository · {selectedRepository.private ? 'private' : 'public'}</span><h1 id="repository-title">{selectedRepository.full_name}</h1><p>{selectedRepository.description || 'No repository description provided.'}</p><div className="workspace-facts"><span><code>{selectedRepository.default_branch}</code></span><span><code>{shortRevision(revision)}</code></span><span className={`readiness-label readiness-${readiness}`}><i aria-hidden="true" />{stateLabel(selectedRepository.state)}</span></div></div><div className="workspace-score"><strong>{report?.health_score ?? selectedRepository.last_scan_health ?? '—'}</strong><span>health score</span><small>{report?.release_readiness ?? readinessLabel(readiness)}</small></div></div><RepositoryVisual repository={selectedRepository} report={report} className="workspace-visual" /><div className="detail-actions"><button type="button" onClick={() => void analyzeRepository(selectedRepository)} disabled={busy || Boolean(activeJob)}>{activeJob ? 'Scanning…' : 'Scan now'}</button><details className="action-menu"><summary>Reports</summary><div className="menu-popover"><button type="button" onClick={() => void exportReport('html')} disabled={!report}>Export HTML</button><button type="button" onClick={() => void exportReport('json')} disabled={!report}>Export JSON</button></div></details><details className="action-menu"><summary>More</summary><div className="menu-popover"><button type="button" onClick={() => void analyzeRepository(selectedRepository, true)} disabled={busy || Boolean(activeJob)}>Force rescan</button><button type="button" onClick={() => navigate({ page: 'repositories', repositoryId: selectedRepository.id, view: 'scans' })}>View scan runs</button><button type="button" onClick={() => setAdvancedOpen((current) => !current)}>Advanced info</button></div></details><button className={`star-button header-star ${pinnedIds.includes(selectedRepository.id) ? 'pinned' : ''}`} type="button" onClick={() => togglePinned(selectedRepository.id)} aria-label={pinnedIds.includes(selectedRepository.id) ? 'Remove from pinned repositories' : 'Pin repository'} aria-pressed={pinnedIds.includes(selectedRepository.id)}><span aria-hidden="true">{pinnedIds.includes(selectedRepository.id) ? '★' : '☆'}</span></button></div></section>{error && <div className="error-banner" role="alert">{error}</div>}{notice && <div className="notice-banner" role="status">{notice}</div>}{activeJob && <div className="job-progress" role="status"><div><strong>{activeJob.message || 'Analysis in progress'}</strong><span>{activeJob.phase.replaceAll('_', ' ')} · {activeJob.progress}%</span></div><div className="progress-track"><i style={{ width: `${activeJob.progress}%` }} /></div></div>}<nav className="detail-tabs" aria-label="Repository analysis views">{DETAIL_VIEWS.map((view) => <a key={view} className={currentView === view ? 'active' : ''} aria-current={currentView === view ? 'page' : undefined} href={routePath({ page: 'repositories', repositoryId: selectedRepository.id, view })} onClick={(event) => handleNavigation(event, { page: 'repositories', repositoryId: selectedRepository.id, view })}>{detailViewLabel(view, report)}</a>)}</nav>{advancedOpen && <section className="section-card advanced-info"><div><span className="eyebrow">Advanced repository info</span><h2>Identity and policy</h2></div><div className="info-grid"><span><strong>Provider ID</strong><code>{selectedRepository.provider_repository_id}</code></span><span><strong>Visibility</strong>{selectedRepository.private ? 'Private' : 'Public'}</span><span><strong>Auto scan</strong>{selectedRepository.policy.auto_scan ? 'Enabled' : 'Disabled'}</span><span><strong>Minimum health</strong>{selectedRepository.policy.min_health_score}</span><span><strong>Latest revision</strong><code>{shortRevision(selectedRepository.latest_revision)}</code></span><span><strong>Catalog sync</strong>{formatDate(selectedRepository.last_synced_at)}</span></div></section>}{selectedDetailsLoading ? <section className="workspace-loading" role="status"><span /><span /><span /></section> : report ? <section className="detail-content">{currentView === 'overview' && <OverviewView report={report} comparison={comparison} />}{currentView === 'architecture' && <Suspense fallback={<p className="muted" role="status">Loading architecture view…</p>}><ArchitectureView report={report} /></Suspense>}{currentView === 'hotspots' && <HotspotsView report={report} />}{cLine truncated
|
||||
return <section className="page-content detail-page" aria-labelledby="repository-title"><div className="breadcrumb-row"><a href="/repositories" onClick={(event) => handleNavigation(event, { page: 'repositories' })}>Repositories</a><span aria-hidden="true"><Icon name="chevronRight" size={14} /></span><button type="button" onClick={() => setSwitcherOpen(true)}>{selectedRepository.full_name} <Icon name="chevronDown" size={14} /></button></div><section className="workspace-hero"><div className="workspace-identity"><RepoAvatar repository={selectedRepository} size="xl" /><div><span className="eyebrow">{selectedRepository.provider} repository · {selectedRepository.private ? 'private' : 'public'}</span><h1 id="repository-title">{selectedRepository.full_name}</h1><p>{selectedRepository.description || 'No repository description provided.'}</p><div className="workspace-facts"><span><Icon name="branch" /><code>{selectedRepository.default_branch}</code></span><span><Icon name="commit" /><code>{shortRevision(revision)}</code></span><span className={`status-label status-${statusClass(selectedRepository.state)}`}><i aria-hidden="true" />{stateLabel(selectedRepository.state)}</span></div></div><div className="workspace-score"><HealthRing value={report?.health_score ?? selectedRepository.last_scan_health} readiness={readiness} size={84} /><span>health score</span><small className={`chip ${readiness}`}>{report?.release_readiness ?? readinessLabel(readiness)}</small></div></div><RepositoryVisual repository={selectedRepository} report={report} className="workspace-visual" /><div className="detail-actions"><button type="button" onClick={() => void analyzeRepository(selectedRepository)} disabled={busy || Boolean(activeJob)}>{activeJob ? 'Scanning…' : 'Scan now'}</button><details className="action-menu"><summary><Icon name="download" />Reports</summary><div className="menu-popover"><button type="button" onClick={() => void exportReport('html')} disabled={!report}>Export HTML</button><button type="button" onClick={() => void exportReport('json')} disabled={!report}>Export JSON</button></div></details><details className="action-menu"><summary><Icon name="more" />More</summary><div className="menu-popover"><button type="button" onClick={() => void analyzeRepository(selectedRepository, true)} disabled={busy || Boolean(activeJob)}>Force rescan</button><button type="button" onClick={() => navigate({ page: 'repositories', repositoryId: selectedRepository.id, view: 'scans' })}>View scan runs</button><button type="button" onClick={() => setAdvancedOpen((current) => !current)}>Advanced info</button></div></details><button className={`star-button header-star ${pinnedIds.includes(selectedRepository.id) ? 'pinned' : ''}`} type="button" onClick={() => togglePinned(selectedRepository.id)} aria-label={pinnedIds.includes(selectedRepository.id) ? 'Remove from pinned repositories' : 'Pin repository'} aria-pressed={pinnedIds.includes(selectedRepository.id)}><span aria-hidden="true">{pinnedIds.includes(selectedRepository.id) ? '★' : '☆'}</span></button></div></section>{error && <div className="error-banner" role="alert">{error}</div>}{notice && <div className="notice-banner" role="status">{notice}</div>}{activeJob && <div className="job-progress" role="status"><div><strong>{activeJob.message || 'Analysis in progress'}</strong><span>{activeJob.phase.replaceAll('_', ' ')} · {activeJob.progress}%</span></div><div className="progress-track"><i style={{ width: `${activeJob.progress}%` }} /></div></div>}<nav className="detail-tabs" aria-label="Repository analysis views">{DETAIL_VIEWS.map((view) => <a key={view} className={currentView === view ? 'active' : ''} aria-current={currentView === view ? 'page' : undefined} href={routePath({ page: 'repositories', repositoryId: selectedRepository.id, view })} onClick={(event) => handleNavigation(event, { page: 'repositories', repositoryId: selectedRepository.id, view })}>{detailViewLabel(view, report)}</a>)}</nav>{advancedOpen && <section className="section-card advanced-info"><div><span className="eyebrow">Advanced repository info</span><h2>Identity and policy</h2></div><div className="info-grid"><span><strong>Provider ID</strong><code>{selectedRepository.provider_repository_id}</code></span><span><strong>Visibility</strong>{selectedRepository.private ? 'Private' : 'Public'}</span><span><strong>Auto scan</strong>{selectedRepository.policy.auto_scan ? 'Enabled' : 'Disabled'}</span><span><strong>Minimum health</strong>{selectedRepository.policy.min_health_score}</span><span><strong>Latest revision</strong><code>{shortRevision(selectedRepository.latest_revision)}</code></span><span><strong>Catalog sync</strong>{formatDate(selectedRepository.last_synced_at)}</span></div></section>}{selectedDetailsLoading ? <section className="workspace-loading" role="status"><span /><span /><span /></section> : report ? <section className="detail-content">{currentView === 'overview' && <OverviewView report={report} comparisLine truncated
|
||||
}
|
||||
|
||||
const renderActivityPage = () => { const activity = [...repositories].filter((repository) => repository.last_scan_at || repository.state === 'scanning' || repository.state === 'queued').sort((left, right) => (Date.parse(right.last_scan_at ?? '') || 0) - (Date.parse(left.last_scan_at ?? '') || 0)); return <section className="page-content activity-page" aria-labelledby="activity-title"><div className="page-heading"><div><span className="eyebrow">Operational timeline</span><h1 id="activity-title">Activity</h1><p className="muted">A visual event feed derived from actual catalog state and persisted scan activity.</p></div></div><div className="summary-strip"><div><span>Catalog</span><strong>{repositories.length}</strong></div><div><span>Current</span><strong>{repositories.filter((repository) => repository.state === 'current').length}</strong></div><div><span>Needs attention</span><strong>{repositories.filter((repository) => repositoryReadiness(repository) !== 'ready').length}</strong></div><div><span>Latest scan</span><strong>{activity[0] ? formatRelativeDate(activity[0].last_scan_at) : '—'}</strong></div></div><section className="activity-timeline section-card"><div className="section-heading"><div><span className="eyebrow">Latest changes</span><h2>Repository activity</h2></div><span className="section-note">Each event opens its repository workspace.</span></div>{activity.length ? activity.slice(0, 30).map((repository) => <button type="button" className="timeline-event" key={repository.id} onClick={() => selectRepository(repository)}><span className={`timeline-rail ${repositoryReadiness(repository)}`} /><RepositoryVisual repository={repository} compact /><span><strong>{repository.full_name}</strong><small>{repository.state === 'scanning' || repository.state === 'queued' ? `${stateLabel(repository.state)} · ${repository.default_branch}` : `Scan completed ${formatRelativeDate(repository.last_scan_at)} · ${repository.default_branch}`}</small></span><b>{repository.last_scan_health ?? '—'}</b></button>) : <div className="empty-state compact-empty"><BrandMark size={34} label="" /><h2>No activity yet</h2><p className="muted">Scan a repository to start building its operational timeline.</p></div>}</section></section> }
|
||||
const renderQueuePage = () => { const queue = repositories.filter((repository) => repository.active_job_id || repository.state === 'queued' || repository.state === 'scanning'); return <section className="page-content queue-page" aria-labelledby="queue-title"><div className="page-heading"><div><span className="eyebrow">Durable background work</span><h1 id="queue-title">Scan queue</h1><p className="muted">Exact revisions are retained while work moves through source acquisition, analysis and scoring.</p></div></div><div className="summary-strip"><div><span>Waiting</span><strong>{queue.filter((repository) => repository.state === 'queued').length}</strong></div><div><span>Active</span><strong>{queue.filter((repository) => repository.state === 'scanning' || repository.active_job_id).length}</strong></div><div><span>Completed</span><strong>{meta?.completed_jobs ?? '—'}</strong></div><div><span>Failed</span><strong>{meta?.failed_jobs ?? '—'}</strong></div></div><section className="queue-workspace section-card"><div className="section-heading"><div><span className="eyebrow">Live queue</span><h2>{queue.length ? 'Scans in progress' : 'Queue is clear'}</h2></div><span className="section-note">No misleading progress percentage is shown before the worker reports one.</span></div>{queue.length ? <div className="queue-list">{queue.map((repository) => <button type="button" className="queue-row" key={repository.id} onClick={() => selectRepository(repository)}><RepositoryVisual repository={repository} compact /><span><strong>{repository.full_name}</strong><small>{repository.default_branch} · {repository.active_job_id ? 'worker active' : 'waiting for worker'}</small></span><span className={`status-label status-${statusClass(repository.state)}`}><i aria-hidden="true" />{stateLabel(repository.state)}</span></button>)}</div> : <div className="queue-empty"><BrandMark size={48} label="" /><div><span className="eyebrow">All clear</span><h2>No scans are waiting</h2><p className="muted">The worker is healthy and the portfolio is up to date. Start a scan from a repository workspace whenever a fresh revision needs analysis.</p><a className="button-link" href="/repositories" onClick={(event) => handleNavigation(event, { page: 'repositories' })}>Browse repositories</a></div></div>}</section></section> }
|
||||
const renderSettingsPage = () => <section className="page-content settings-page" aria-labelledby="settings-title"><div className="page-heading"><div><span className="eyebrow">Workspace configuration</span><h1 id="settings-title">Settings</h1><p className="muted">Connection, scanning and local preferences are separated into concise operational sections.</p></div></div><div className="settings-sections"><section className="settings-section"><div><span className="eyebrow">Connections</span><h2>Gitea catalog</h2><p>Provider-backed repository discovery and exact revision acquisition.</p></div><dl><div><dt>Status</dt><dd><span className={`status-label status-${meta?.gitea.configured ? 'current' : 'failed'}`}><i aria-hidden="true" />{meta?.gitea.configured ? 'Configured' : 'Not configured'}</span></dd></div><div><dt>Repositories</dt><dd>{meta?.repository_count ?? repositories.length}</dd></div><div><dt>Last sync</dt><dd>{meta?.gitea.last_sync && typeof meta.gitea.last_sync === 'object' && 'synced_at' in meta.gitea.last_sync ? formatDate(String(meta.gitea.last_sync.synced_at)) : 'Not available'}</dd></div></dl><button className="ghost" type="button" onClick={() => void syncCatalog()} disabled={catalogBusy}>{catalogBusy ? 'Syncing…' : 'Sync catalog now'}</button></section><section className="settings-section"><div><span className="eyebrow">Scanning & analysis</span><h2>Safe source controls</h2><p>The normal repository flow stays Gitea-native. The advanced path remains available only for mounted local sources.</p></div><dl><div><dt>Scan root</dt><dd>{meta?.scan_root_restricted ? 'Restricted' : 'Configured by server'}</dd></div><div><dt>Concurrency</dt><dd>{meta?.max_concurrent_scans ?? '—'} worker</dd></div><div><dt>Automation</dt><dd>Scheduled discovery enabled</dd></div></dl><form className="local-form" onSubmit={scanLocal}><label><span>Advanced repository path</span><input aria-label="Repository path" value={path} onChange={(event) => setPath(event.target.value)} placeholder="/scan/my-project" required /></label><button disabled={busy}>{busy ? 'Analyzing…' : 'Analyze local source'}</button></form>{standaloneReport && <div className="local-result" role="status"><strong>{standaloneReport.repository_name}</strong><span>{standaloneReport.health_score}/100 · {standaloneReport.release_readiness} · {formatDate(standaloneReport.scanned_at)}</span></div>}</section><section className="settings-section appearance"><div><span className="eyebrow">Appearance</span><h2>Personal workspace preferences</h2><p>Dark signal topology is the primary theme. View modes and navigation preferences are stored locally in this browser.</p></div><dl><div><dt>Explorer view</dt><dd><div className="view-toggle"><button className={catalogView === 'table' ? 'active' : ''} type="button" onClick={() => setCatalogView('table')}>Table</button><button className={catalogView === 'grid' ? 'active' : ''} type="button" onClick={() => setCatalogView('grid')}>Visual grid</button></div></dd></div><div><dt>Pinned repositories</dt><dd>{pinnedIds.length}</dd></div><div><dt>Recent repositories</dt><dd>{recentIds.length}</dd></div></dl></section></div></section>
|
||||
const renderActivityPage = () => { const activity = [...repositories].filter((repository) => repository.last_scan_at || repository.state === 'scanning' || repository.state === 'queued').sort((left, right) => (Date.parse(right.last_scan_at ?? '') || 0) - (Date.parse(left.last_scan_at ?? '') || 0)); return <section className="page-content activity-page" aria-labelledby="activity-title"><div className="page-heading"><div><h1 id="activity-title">Activity</h1><p className="muted">Recent scans and running analysis across the catalog.</p></div></div><div className="summary-strip"><div><span>Catalog</span><strong>{repositories.length}</strong></div><div><span>Current</span><strong>{repositories.filter((repository) => repository.state === 'current').length}</strong></div><div><span>Needs attention</span><strong>{repositories.filter((repository) => !repository.archived && repositoryReadiness(repository) !== 'ready').length}</strong></div><div><span>Latest scan</span><strong>{activity[0] ? formatRelativeDate(activity[0].last_scan_at) : '—'}</strong></div></div><section className="activity-timeline section-card"><div className="section-heading"><div><span className="eyebrow">Latest changes</span><h2>Repository activity</h2></div><span className="section-note">Each event opens its repository workspace.</span></div>{activity.length ? activity.slice(0, 30).map((repository) => <button type="button" className="timeline-event" key={repository.id} onClick={() => selectRepository(repository)}><span className={`timeline-rail ${repositoryReadiness(repository)}`} /><RepoAvatar repository={repository} /><span><strong>{repository.full_name}</strong><small>{repository.state === 'scanning' || repository.state === 'queued' ? `${stateLabel(repository.state)} · ${repository.default_branch}` : `Scan completed ${formatRelativeDate(repository.last_scan_at)} · ${repository.default_branch}`}</small></span><HealthRing value={repository.last_scan_health} readiness={repositoryReadiness(repository)} size={36} /></button>) : <div className="empty-state compact-empty"><BrandMark size={34} label="" /><h2>No activity yet</h2><p className="muted">Scan a repository to start building its operational timeline.</p></div>}</section></section> }
|
||||
const renderQueuePage = () => { const queue = repositories.filter((repository) => repository.active_job_id || repository.state === 'queued' || repository.state === 'scanning'); return <section className="page-content queue-page" aria-labelledby="queue-title"><div className="page-heading"><div><h1 id="queue-title">Scan queue</h1><p className="muted">Background scans, pinned to an exact revision from acquisition to scoring.</p></div></div><div className="summary-strip"><div><span>Waiting</span><strong>{queue.filter((repository) => repository.state === 'queued').length}</strong></div><div><span>Active</span><strong>{queue.filter((repository) => repository.state === 'scanning' || repository.active_job_id).length}</strong></div><div><span>Completed</span><strong>{meta?.completed_jobs ?? '—'}</strong></div><div><span>Failed</span><strong>{meta?.failed_jobs ?? '—'}</strong></div></div><section className="queue-workspace section-card"><div className="section-heading"><div><span className="eyebrow">Live queue</span><h2>{queue.length ? 'Scans in progress' : 'Queue is clear'}</h2></div></div>{queue.length ? <div className="queue-list">{queue.map((repository) => <button type="button" className="queue-row" key={repository.id} onClick={() => selectRepository(repository)}><RepoAvatar repository={repository} /><span><strong>{repository.full_name}</strong><small>{repository.default_branch} · {repository.active_job_id ? 'worker active' : 'waiting for worker'}</small></span><span className={`status-label status-${statusClass(repository.state)}`}><i aria-hidden="true" />{stateLabel(repository.state)}</span></button>)}</div> : <div className="queue-empty"><BrandMark size={48} label="" /><div><h2>No scans are waiting</h2><p className="muted">The worker is healthy and the portfolio is up to date. Start a scan from a repository workspace whenever a fresh revision needs analysis.</p><a className="button-link" href="/repositories" onClick={(event) => handleNavigation(event, { page: 'repositories' })}>Browse repositories</a></div></div>}</section></section> }
|
||||
const renderSettingsPage = () => <section className="page-content settings-page" aria-labelledby="settings-title"><div className="page-heading"><div><h1 id="settings-title">Settings</h1><p className="muted">Connection, scanning and local preferences.</p></div></div><div className="settings-sections"><section className="settings-section"><div><span className="eyebrow">Connections</span><h2>Gitea catalog</h2><p>Provider-backed repository discovery and exact revision acquisition.</p></div><dl><div><dt>Status</dt><dd><span className={`status-label status-${meta?.gitea.configured ? 'current' : 'failed'}`}><i aria-hidden="true" />{meta?.gitea.configured ? 'Configured' : 'Not configured'}</span></dd></div><div><dt>Repositories</dt><dd>{meta?.repository_count ?? repositories.length}</dd></div><div><dt>Last sync</dt><dd>{meta?.gitea.last_sync && typeof meta.gitea.last_sync === 'object' && 'synced_at' in meta.gitea.last_sync ? formatDate(String(meta.gitea.last_sync.synced_at)) : 'Not available'}</dd></div></dl><button className="ghost" type="button" onClick={() => void syncCatalog()} disabled={catalogBusy}>{catalogBusy ? 'Syncing…' : 'Sync catalog now'}</button></section><section className="settings-section"><div><span className="eyebrow">Scanning & analysis</span><h2>Safe source controls</h2><p>The normal repository flow stays Gitea-native. The advanced path remains available only for mounted local sources.</p></div><dl><div><dt>Scan root</dt><dd>{meta?.scan_root_restricted ? 'Restricted' : 'Configured by server'}</dd></div><div><dt>Concurrency</dt><dd>{meta?.max_concurrent_scans ?? '—'} worker</dd></div><div><dt>Automation</dt><dd>Scheduled discovery enabled</dd></div></dl><form className="local-form" onSubmit={scanLocal}><label><span>Advanced repository path</span><input aria-label="Repository path" value={path} onChange={(event) => setPath(event.target.value)} placeholder="/scan/my-project" required /></label><button disabled={busy}>{busy ? 'Analyzing…' : 'Analyze local source'}</button></form>{standaloneReport && <div className="local-result" role="status"><strong>{standaloneReport.repository_name}</strong><span>{standaloneReport.health_score}/100 · {standaloneReport.release_readiness} · {formatDate(standaloneReport.scanned_at)}</span></div>}</section><section className="settings-section appearance"><div><span className="eyebrow">Appearance</span><h2>Personal workspace preferences</h2><p>View mode, pinned and recent repositories are stored locally in this browser.</p></div><dl><div><dt>Explorer view</dt><dd><div className="view-toggle"><button className={catalogView === 'table' ? 'active' : ''} type="button" onClick={() => setCatalogView('table')}>Table</button><button className={catalogView === 'grid' ? 'active' : ''} type="button" onClick={() => setCatalogView('grid')}>Visual grid</button></div></dd></div><div><dt>Pinned repositories</dt><dd>{pinnedIds.length}</dd></div><div><dt>Recent repositories</dt><dd>{recentIds.length}</dd></div></dl></section></div></section>
|
||||
|
||||
return <main className="app-shell">{renderTopbar()}{error && !route.repositoryId && <div className="error-banner global-banner" role="alert">{error}</div>}{notice && !route.repositoryId && <div className="notice-banner global-banner" role="status">{notice}</div>}{route.page === 'dashboard' && <DashboardView repositories={repositories} pinnedIds={pinnedIds} onOpenRepository={selectRepository} onExploreReadiness={exploreReadiness} onOpenExplorer={() => navigate({ page: 'repositories' })} />}{route.page === 'activity' && renderActivityPage()}{route.page === 'queue' && renderQueuePage()}{route.page === 'settings' && renderSettingsPage()}{route.page === 'repositories' && (route.repositoryId ? renderDetailPage() : renderCatalogPage())}{switcherOpen && <div className="modal-backdrop" role="presentation" onMouseDown={() => setSwitcherOpen(false)}><section className="switcher-modal" role="dialog" aria-modal="true" aria-labelledby="switcher-title" onMouseDown={(event) => event.stopPropagation()}><div className="switcher-heading"><div><span className="eyebrow">Repository navigation</span><h2 id="switcher-title">Quick switcher</h2></div><button className="icon-button" type="button" onClick={() => setSwitcherOpen(false)} aria-label="Close quick switcher">×</button></div><div className="command-row"><button type="button" onClick={() => { navigate({ page: 'dashboard' }); setSwitcherOpen(false) }}>Open dashboard</button><button type="button" onClick={() => { navigate({ page: 'queue' }); setSwitcherOpen(false) }}>Open scan queue</button><button type="button" onClick={() => void syncCatalog()} disabled={catalogBusy}>Sync Gitea</button></div><label className="switcher-search"><span className="sr-only">Search repositories</span><input ref={switcherInputRef} value={switcherQuery} onChange={(event) => { setSwitcherQuery(event.target.value); setSwitcherIndex(0) }} placeholder="Search repositories…" /><kbd>Esc</kbd></label>{switcherRepositories.length ? <div className="switcher-results" role="listbox" aria-label="Repositories">{switcherRepositories.map((repository, index) => <button className={index === switcherIndex ? 'switcher-item active' : 'switcher-item'} type="button" role="option" aria-selected={index === switcherIndex} key={repository.id} onMouseEnter={() => setSwitcherIndex(index)} onClick={() => { selectRepository(repository); setSwitcherOpen(false) }}><RepositoryVisual repository={repository} compact /><span><strong>{repository.full_name}</strong><small>{repository.owner} · {repository.default_branch} · {repository.last_scan_health ?? 'not scanned'}</small></span><span className={`readiness-label readiness-${repositoryReadiness(repository)}`}><i aria-hidden="true" />{readinessLabel(repositoryReadiness(repository))}</span></button>)}</div> : <div className="empty-state compact-empty"><h2>No repository matches</h2><p className="muted">Try the owner, repository name or branch.</p></div>}<div className="switcher-footer"><span><kbd>↑</kbd><kbd>↓</kbd> Navigate</span><span><kbd>Enter</kbd> Open</span><span><kbd>Esc</kbd> Close</span></div></section></div>}</main>
|
||||
return <div className="app-shell">{renderSidebar()}<main className="app-main">{renderTopbar()}{error && !route.repositoryId && <div className="error-banner global-banner" role="alert">{error}</div>}{notice && !route.repositoryId && <div className="notice-banner global-banner" role="status">{notice}</div>}{route.page === 'dashboard' && <DashboardView repositories={repositories} pinnedIds={pinnedIds} onOpenRepository={selectRepository} onExploreReadiness={exploreReadiness} onOpenExplorer={() => navigate({ page: 'repositories' })} loading={catalogLoading} />}{route.page === 'activity' && renderActivityPage()}{route.page === 'queue' && renderQueuePage()}{route.page === 'settings' && renderSettingsPage()}{route.page === 'repositories' && (route.repositoryId ? renderDetailPage() : renderCatalogPage())}</main>{switcherOpen && <div className="modal-backdrop" role="presentation" onMouseDown={() => setSwitcherOpen(false)}><section className="switcher-modal" role="dialog" aria-modal="true" aria-labelledby="switcher-title" onMouseDown={(event) => event.stopPropagation()}><div className="switcher-heading"><div><span className="eyebrow">Repository navigation</span><h2 id="switcher-title">Quick switcher</h2></div><button className="icon-button" type="button" onClick={() => setSwitcherOpen(false)} aria-label="Close quick switcher"><Icon name="close" /></button></div><div className="command-row"><button type="button" onClick={() => { navigate({ page: 'dashboard' }); setSwitcherOpen(false) }}>Open dashboard</button><button type="button" onClick={() => { navigate({ page: 'queue' }); setSwitcherOpen(false) }}>Open scan queue</button><button type="button" onClick={() => void syncCatalog()} disabled={catalogBusy}>Sync Gitea</button></div><label className="switcher-search"><span className="sr-only">Search repositories</span><input ref={switcherInputRef} value={switcherQuery} onChange={(event) => { setSwitcherQuery(event.target.value); setSwitcherIndex(0) }} placeholder="Search repositories…" /><kbd>Esc</kbd></label>{switcherRepositories.length ? <div className="switcher-results" role="listbox" aria-label="Repositories">{switcherRepositories.map((repository, index) => <button className={index === switcherIndex ? 'switcher-item active' : 'switcher-item'} type="button" role="option" aria-selected={index === switcherIndex} key={repository.id} onMouseEnter={() => setSwitcherIndex(index)} onClick={() => { selectRepository(repository); setSwitcherOpen(false) }}><RepoAvatar repository={repository} /><span><strong>{repository.full_name}</strong><small>{repository.owner} · {repository.default_branch} · {repository.last_scan_health ?? 'not scanned'}</small></span><span className={`readiness-label readiness-${repositoryReadiness(repository)}`}><i aria-hidden="true" />{readinessLabel(repositoryReadiness(repository))}</span></button>)}</div> : <div className="empty-state compact-empty"><h2>No repository matches</h2><p className="muted">Try the owner, repository name or branch.</p></div>}<div className="switcher-footer"><span><kbd>↑</kbd><kbd>↓</kbd> Navigate</span><span><kbd>Enter</kbd> Open</span><span><kbd>Esc</kbd> Close</span></div></section></div>}</div>
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
import type { RepositorySummary } from '../api'
|
||||
import { readinessLabel, repositoryReadiness, type Readiness } from '../catalog'
|
||||
import { CountUp, HealthRing } from './HealthRing'
|
||||
import { Icon, type IconName } from './Icon'
|
||||
import { PortfolioAtlas } from './PortfolioAtlas'
|
||||
import { RemediationCenter } from './RemediationCenter'
|
||||
import { RepositoryVisual } from './RepositoryVisual'
|
||||
import { RepoAvatar } from './RepoAvatar'
|
||||
|
||||
type DashboardViewProps = {
|
||||
repositories: RepositorySummary[]
|
||||
@@ -10,6 +12,7 @@ type DashboardViewProps = {
|
||||
onOpenRepository: (repository: RepositorySummary) => void
|
||||
onExploreReadiness: (readiness: Readiness) => void
|
||||
onOpenExplorer: () => void
|
||||
loading?: boolean
|
||||
}
|
||||
|
||||
function relativeTime(value: string | null) {
|
||||
@@ -35,61 +38,106 @@ function remediationPath(repository: RepositorySummary) {
|
||||
}
|
||||
|
||||
function changeContext(repository: RepositorySummary) {
|
||||
if (repository.last_scan_added_findings > 0) return `${repository.last_scan_added_findings} new signal${repository.last_scan_added_findings === 1 ? '' : 's'} since prior scan`
|
||||
if (repository.last_scan_resolved_findings > 0) return `${repository.last_scan_resolved_findings} resolved since prior scan`
|
||||
return repository.last_scan_health_delta == null ? 'baseline signal' : 'longstanding signal'
|
||||
// Only surface real movement; an unchanged signal adds noise to every row.
|
||||
if (repository.last_scan_added_findings > 0) return `+${repository.last_scan_added_findings} new`
|
||||
if (repository.last_scan_resolved_findings > 0) return `${repository.last_scan_resolved_findings} resolved`
|
||||
return null
|
||||
}
|
||||
|
||||
function triagePriority(repository: RepositorySummary) {
|
||||
return repository.last_scan_priority ?? 0
|
||||
}
|
||||
|
||||
function readinessDescription(readiness: Readiness) {
|
||||
if (readiness === 'blocked') return 'needs intervention'
|
||||
if (readiness === 'warnings') return 'needs review'
|
||||
return 'ready to ship'
|
||||
const KPI: Record<Readiness, { icon: IconName; description: string }> = {
|
||||
blocked: { icon: 'blocked', description: 'Need intervention' },
|
||||
warnings: { icon: 'warning', description: 'Need review' },
|
||||
ready: { icon: 'ready', description: 'Ready to ship' },
|
||||
}
|
||||
|
||||
export function DashboardView({ repositories, pinnedIds, onOpenRepository, onExploreReadiness, onOpenExplorer }: DashboardViewProps) {
|
||||
function percentage(part: number, total: number) {
|
||||
return total ? Math.round((part / total) * 100) : 0
|
||||
}
|
||||
|
||||
export function HealthScore({ value, readiness }: { value: number | null; readiness: Readiness }) {
|
||||
return <span className={`score-pill ${readiness}`} title={value == null ? 'Not scanned' : `${value} / 100 health`}>{value ?? '—'}</span>
|
||||
}
|
||||
|
||||
export function DashboardView({ repositories, pinnedIds, onOpenRepository, onExploreReadiness, onOpenExplorer, loading = false }: DashboardViewProps) {
|
||||
if (loading && !repositories.length) return <section className="page-content dashboard-page" aria-labelledby="dashboard-title" aria-busy="true"><div className="page-heading"><div><h1 id="dashboard-title">Dashboard</h1><p className="muted" role="status">Loading the repository catalog…</p></div></div><div className="catalog-loading" aria-hidden="true"><span /><span /><span /><span /></div><div className="dashboard-skeleton" aria-hidden="true"><span /><span /></div></section>
|
||||
const portfolio = repositories.filter((repository) => !repository.archived)
|
||||
const counts = portfolio.reduce<Record<Readiness, number>>((result, repository) => {
|
||||
result[repositoryReadiness(repository)] += 1
|
||||
return result
|
||||
}, { ready: 0, warnings: 0, blocked: 0 })
|
||||
const attention = [...portfolio].filter((repository) => repositoryReadiness(repository) !== 'ready').sort((left, right) => triagePriority(right) - triagePriority(left) || (left.last_scan_health ?? -1) - (right.last_scan_health ?? -1) || (Date.parse(right.last_scan_at ?? '') || 0) - (Date.parse(left.last_scan_at ?? '') || 0)).slice(0, 5)
|
||||
const recent = [...portfolio].filter((repository) => repository.last_scan_at).sort((left, right) => (Date.parse(right.last_scan_at ?? '') || 0) - (Date.parse(left.last_scan_at ?? '') || 0)).slice(0, 4)
|
||||
const pinned = pinnedIds.map((id) => portfolio.find((repository) => repository.id === id)).filter((repository): repository is RepositorySummary => Boolean(repository)).slice(0, 3)
|
||||
const attention = [...portfolio].filter((repository) => repositoryReadiness(repository) !== 'ready').sort((left, right) => triagePriority(right) - triagePriority(left) || (left.last_scan_health ?? -1) - (right.last_scan_health ?? -1) || (Date.parse(right.last_scan_at ?? '') || 0) - (Date.parse(left.last_scan_at ?? '') || 0)).slice(0, 8)
|
||||
const recent = [...portfolio].filter((repository) => repository.last_scan_at).sort((left, right) => (Date.parse(right.last_scan_at ?? '') || 0) - (Date.parse(left.last_scan_at ?? '') || 0)).slice(0, 5)
|
||||
const pinned = pinnedIds.map((id) => portfolio.find((repository) => repository.id === id)).filter((repository): repository is RepositorySummary => Boolean(repository)).slice(0, 4)
|
||||
const nextRepository = attention[0] ?? recent[0]
|
||||
const scannedToday = portfolio.filter((repository) => repository.last_scan_at && Date.now() - Date.parse(repository.last_scan_at) < 86_400_000).length
|
||||
const scored = portfolio.filter((repository) => repository.last_scan_health != null)
|
||||
const averageHealth = scored.length ? Math.round(scored.reduce((sum, repository) => sum + (repository.last_scan_health ?? 0), 0) / scored.length) : null
|
||||
|
||||
return (
|
||||
<section className="page-content dashboard-page cockpit-page" aria-labelledby="dashboard-title">
|
||||
<h1 id="dashboard-title" className="sr-only">Dashboard</h1>
|
||||
<section className="page-content dashboard-page" aria-labelledby="dashboard-title">
|
||||
<div className="page-heading">
|
||||
<div>
|
||||
<h1 id="dashboard-title">Dashboard</h1>
|
||||
<p className="muted">{portfolio.length} active repositories · {scannedToday} scanned in the last 24 h{averageHealth != null ? ` · average health ${averageHealth}` : ''}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<nav className="dashboard-readiness-rail" aria-label="Portfolio readiness summary">
|
||||
{(['blocked', 'warnings', 'ready'] as Readiness[]).map((readiness, index) => <button key={readiness} type="button" className={`readiness-rail-segment ${readiness}`} onClick={() => onExploreReadiness(readiness)} aria-label={`Open ${counts[readiness]} ${readinessLabel(readiness).toLowerCase()} repositories in Explorer`}><span>{String(index + 1).padStart(2, '0')} / {readinessLabel(readiness)}</span><strong>{counts[readiness]}</strong><small>{readinessDescription(readiness)} <b>→</b></small></button>)}
|
||||
<button type="button" className="readiness-rail-segment all" onClick={onOpenExplorer}><span>04 / Catalog</span><strong>{portfolio.length}</strong><small>Open repository explorer <b>→</b></small></button>
|
||||
<nav className="kpi-grid" aria-label="Portfolio readiness summary">
|
||||
{(['blocked', 'warnings', 'ready'] as Readiness[]).map((readiness) => <button key={readiness} type="button" className={`kpi-card ${readiness}`} onClick={() => onExploreReadiness(readiness)} aria-label={`Open ${counts[readiness]} ${readinessLabel(readiness).toLowerCase()} repositories in Explorer`}>
|
||||
<span className="kpi-label"><Icon name={KPI[readiness].icon} />{readinessLabel(readiness)}</span>
|
||||
<strong><CountUp value={counts[readiness]} /></strong>
|
||||
<small>{KPI[readiness].description} · {percentage(counts[readiness], portfolio.length)}%</small>
|
||||
</button>)}
|
||||
<button type="button" className="kpi-card all" onClick={onOpenExplorer}>
|
||||
<span className="kpi-label"><Icon name="catalog" />Catalog</span>
|
||||
<strong><CountUp value={portfolio.length} /></strong>
|
||||
<span className="distribution-bar" aria-hidden="true">{(['blocked', 'warnings', 'ready'] as Readiness[]).map((readiness) => <i key={readiness} className={readiness} style={{ flexGrow: counts[readiness] }} />)}</span>
|
||||
<small>Open repository explorer</small>
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<div className="cockpit-focus-grid">
|
||||
<section className="dashboard-section attention-section" aria-labelledby="attention-title">
|
||||
<div className="section-heading"><div><span className="eyebrow">Triage, in priority order</span><h2 id="attention-title">Why attention is needed</h2></div><button className="text-button" type="button" onClick={() => onExploreReadiness('blocked')}>Open blocked lane</button></div>
|
||||
{attention.length ? <div className="attention-list">{attention.map((repository, index) => <button type="button" className="attention-row" key={repository.id} onClick={() => onOpenRepository(repository)}><span className="attention-rank">{String(index + 1).padStart(2, '0')}</span><RepositoryVisual repository={repository} compact /><span className="attention-copy"><strong>{repository.full_name}</strong><small>{attentionReason(repository)}</small><span className="attention-context"><i>{repository.last_scan_primary_signal?.category ?? readinessLabel(repositoryReadiness(repository))}</i><em>{changeContext(repository)}</em></span></span><span className="attention-score"><b>{repository.last_scan_health ?? '—'}</b><small>{relativeTime(repository.last_scan_at)}</small></span></button>)}</div> : <p className="empty-inline">No repository needs attention right now.</p>}
|
||||
<div className="dashboard-grid">
|
||||
<section className="panel attention-section" aria-labelledby="attention-title">
|
||||
<div className="panel-heading"><h2 id="attention-title">Why attention is needed</h2><button className="text-button" type="button" onClick={() => onExploreReadiness('blocked')}>View all blocked <Icon name="chevronRight" /></button></div>
|
||||
{attention.length ? <div className="attention-list">{attention.map((repository) => <button type="button" className="attention-row" key={repository.id} onClick={() => onOpenRepository(repository)}>
|
||||
<RepoAvatar repository={repository} />
|
||||
<span className="attention-copy"><strong>{repository.full_name}</strong><small>{attentionReason(repository)}</small></span>
|
||||
<span className="attention-context"><i className={`chip ${repositoryReadiness(repository)}`}>{repository.last_scan_primary_signal?.category ?? readinessLabel(repositoryReadiness(repository))}</i>{changeContext(repository) && <em className={repository.last_scan_added_findings > 0 ? 'worse' : 'better'}>{changeContext(repository)}</em>}</span>
|
||||
<span className="attention-score"><HealthRing value={repository.last_scan_health} readiness={repositoryReadiness(repository)} size={38} /><small>{relativeTime(repository.last_scan_at)}</small></span>
|
||||
</button>)}</div> : <p className="empty-inline">No repository needs attention right now.</p>}
|
||||
</section>
|
||||
|
||||
<section className="dashboard-section next-move" aria-labelledby="next-move-title">
|
||||
<span className="eyebrow">Recommended next move</span><h2 id="next-move-title">{nextRepository ? nextRepository.full_name : 'Portfolio is clear'}</h2>
|
||||
{nextRepository ? <button type="button" className="next-move-action" onClick={() => onOpenRepository(nextRepository)}><RepositoryVisual repository={nextRepository} /><span><strong>{nextRepository.last_scan_health ?? '—'} health</strong><small>{attentionReason(nextRepository)}</small><em className="next-move-context"><i>{nextRepository.last_scan_primary_signal?.category ?? 'Portfolio signal'}</i>{remediationPath(nextRepository)}</em><b>Open workspace →</b></span></button> : <p className="muted">Keep the next immutable scan as the portfolio baseline.</p>}
|
||||
<div className="dashboard-side">
|
||||
<section className="panel next-move" aria-labelledby="next-move-title">
|
||||
<span className="panel-kicker">Recommended next move</span>
|
||||
<h2 id="next-move-title">{nextRepository ? nextRepository.full_name : 'Portfolio is clear'}</h2>
|
||||
{nextRepository ? <button type="button" className="next-move-action" onClick={() => onOpenRepository(nextRepository)}>
|
||||
<span className="next-move-meta"><RepoAvatar repository={nextRepository} size="lg" /><span><strong>{nextRepository.last_scan_primary_signal?.category ?? readinessLabel(repositoryReadiness(nextRepository))}</strong><small>{relativeTime(nextRepository.last_scan_at)} · {nextRepository.default_branch}</small></span><HealthRing value={nextRepository.last_scan_health} readiness={repositoryReadiness(nextRepository)} size={52} /></span>
|
||||
<small>{attentionReason(nextRepository)}</small>
|
||||
<em className="next-move-context"><Icon name="wrench" />{remediationPath(nextRepository)}</em>
|
||||
<b>Open workspace <Icon name="arrowRight" /></b>
|
||||
</button> : <p className="muted">Keep the next immutable scan as the portfolio baseline.</p>}
|
||||
</section>
|
||||
|
||||
<section className="panel pinned-section" aria-labelledby="pinned-title">
|
||||
<div className="panel-heading"><h2 id="pinned-title">Pinned repositories</h2></div>
|
||||
{pinned.length ? <div className="compact-list">{pinned.map((repository) => <button key={repository.id} type="button" className="compact-row" onClick={() => onOpenRepository(repository)}><RepoAvatar repository={repository} size="sm" /><span><strong>{repository.name}</strong><small>{readinessLabel(repositoryReadiness(repository))}</small></span><HealthScore value={repository.last_scan_health} readiness={repositoryReadiness(repository)} /></button>)}</div> : <div className="pin-empty"><Icon name="star" /><span>Pin repositories in the explorer to keep them here.</span><button className="text-button" type="button" onClick={onOpenExplorer}>Browse repositories</button></div>}
|
||||
</section>
|
||||
|
||||
<section className="panel activity-section" aria-labelledby="recent-title">
|
||||
<div className="panel-heading"><h2 id="recent-title">Recently scanned</h2><button className="text-button" type="button" onClick={onOpenExplorer}>Explorer <Icon name="chevronRight" /></button></div>
|
||||
{recent.length ? <div className="compact-list">{recent.map((repository) => <button type="button" key={repository.id} className="compact-row" onClick={() => onOpenRepository(repository)}><RepoAvatar repository={repository} size="sm" /><span><strong>{repository.full_name}</strong><small>{repository.state === 'scanning' ? 'Analysis in progress' : relativeTime(repository.last_scan_at)} · {repository.default_branch}</small></span><HealthScore value={repository.last_scan_health} readiness={repositoryReadiness(repository)} /></button>)}</div> : <p className="empty-inline">No retained scans yet.</p>}
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<RemediationCenter repositories={portfolio} onOpenRepository={onOpenRepository} />
|
||||
|
||||
<PortfolioAtlas repositories={portfolio} onOpenRepository={onOpenRepository} />
|
||||
|
||||
<div className="dashboard-bottom-grid">
|
||||
<section className="dashboard-section activity-section" aria-labelledby="recent-title"><div className="section-heading"><div><span className="eyebrow">Change feed</span><h2 id="recent-title">Recently scanned</h2></div><button className="text-button" type="button" onClick={onOpenExplorer}>Open explorer</button></div><div className="activity-rail">{recent.map((repository) => <button type="button" key={repository.id} className="activity-rail-item" onClick={() => onOpenRepository(repository)}><span className={`status-orb ${repositoryReadiness(repository)}`} /><span><strong>{repository.full_name}</strong><small>{repository.state === 'scanning' ? 'Analysis in progress' : `Retained scan ${relativeTime(repository.last_scan_at)}`} · {repository.default_branch}</small></span><b>{repository.last_scan_health ?? '—'}</b></button>)}</div></section>
|
||||
<section className="dashboard-section pinned-section" aria-labelledby="pinned-title"><div className="section-heading"><div><span className="eyebrow">Your focus</span><h2 id="pinned-title">Pinned repositories</h2></div></div>{pinned.length ? <div className="pinned-grid">{pinned.map((repository) => <button key={repository.id} type="button" className="pinned-tile" onClick={() => onOpenRepository(repository)}><RepositoryVisual repository={repository} compact /><span><strong>{repository.name}</strong><small>{repository.last_scan_health ?? '—'} health · {readinessLabel(repositoryReadiness(repository))}</small></span><b>→</b></button>)}</div> : <div className="pin-empty"><span>Pin repositories in Explorer to keep active work in this command deck.</span><button className="text-button" type="button" onClick={onOpenExplorer}>Browse repositories</button></div>}</section>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
import type { Readiness } from '../catalog'
|
||||
|
||||
function prefersReducedMotion() {
|
||||
try { return window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false } catch { return false }
|
||||
}
|
||||
|
||||
/** Animate a number from 0 to its value once; static when reduced motion is requested. */
|
||||
export function useCountUp(value: number, duration = 700) {
|
||||
const [display, setDisplay] = useState(() => (prefersReducedMotion() || typeof window.requestAnimationFrame !== 'function' ? value : 0))
|
||||
useEffect(() => {
|
||||
if (prefersReducedMotion() || typeof window.requestAnimationFrame !== 'function') { setDisplay(value); return }
|
||||
let frame = 0
|
||||
let synchronous = true
|
||||
const start = performance.now()
|
||||
const tick = () => {
|
||||
// Some environments run animation callbacks synchronously; settle immediately there.
|
||||
if (synchronous) { setDisplay(value); return }
|
||||
const progress = Math.max(0, Math.min(1, (performance.now() - start) / duration))
|
||||
const eased = 1 - Math.pow(1 - progress, 3)
|
||||
setDisplay(Math.round(value * eased))
|
||||
if (progress < 1) frame = window.requestAnimationFrame(tick)
|
||||
}
|
||||
frame = window.requestAnimationFrame(tick)
|
||||
synchronous = false
|
||||
return () => window.cancelAnimationFrame(frame)
|
||||
}, [value, duration])
|
||||
return display
|
||||
}
|
||||
|
||||
export function CountUp({ value }: { value: number }) {
|
||||
return <>{useCountUp(value)}</>
|
||||
}
|
||||
|
||||
/** A compact health gauge: the arc follows the retained 0–100 score, coloured by readiness. */
|
||||
export function HealthRing({ value, readiness, size = 40, label = true }: { value: number | null; readiness: Readiness; size?: number; label?: boolean }) {
|
||||
const stroke = size >= 64 ? 5 : 3.5
|
||||
const radius = (size - stroke) / 2
|
||||
const circumference = 2 * Math.PI * radius
|
||||
const score = value == null ? 0 : Math.max(0, Math.min(100, value))
|
||||
return (
|
||||
<span className={`health-ring ${readiness} ${value == null ? 'unknown' : ''}`} style={{ width: size, height: size }} title={value == null ? 'Not scanned' : `${value} / 100 health`}>
|
||||
<svg viewBox={`0 0 ${size} ${size}`} width={size} height={size} aria-hidden="true">
|
||||
<circle className="health-ring-track" cx={size / 2} cy={size / 2} r={radius} strokeWidth={stroke} fill="none" />
|
||||
<circle className="health-ring-value" cx={size / 2} cy={size / 2} r={radius} strokeWidth={stroke} fill="none" strokeLinecap="round" strokeDasharray={circumference} strokeDashoffset={circumference * (1 - score / 100)} transform={`rotate(-90 ${size / 2} ${size / 2})`} style={{ ['--ring-length' as string]: circumference }} />
|
||||
</svg>
|
||||
{label && <b>{value ?? '—'}</b>}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@@ -1,24 +1,60 @@
|
||||
import type { ScanComparison, ScanSummary, TrendPoint } from '../api'
|
||||
|
||||
function chronological(trend: TrendPoint[]) {
|
||||
return [...trend].sort((left, right) => Date.parse(left.scanned_at) - Date.parse(right.scanned_at))
|
||||
}
|
||||
|
||||
function shortDate(value: string) {
|
||||
const date = new Date(value)
|
||||
return Number.isNaN(date.getTime()) ? '—' : date.toLocaleDateString([], { day: 'numeric', month: 'short' })
|
||||
}
|
||||
|
||||
function TrendDelta({ trend }: { trend: TrendPoint[] }) {
|
||||
const points = chronological(trend)
|
||||
const delta = points[points.length - 1].health_score - points[0].health_score
|
||||
return <span className={`trend-delta ${delta > 0 ? 'positive' : delta < 0 ? 'negative' : ''}`}>{delta > 0 ? '+' : ''}{delta} since {shortDate(points[0].scanned_at)}</span>
|
||||
}
|
||||
|
||||
/** Health per persisted snapshot as an area chart; the y-domain hugs the observed range. */
|
||||
function TrendChart({ trend }: { trend: TrendPoint[] }) {
|
||||
const points = chronological(trend)
|
||||
const scores = points.map((point) => point.health_score)
|
||||
const low = Math.max(0, Math.floor((Math.min(...scores) - 6) / 5) * 5)
|
||||
const high = Math.min(100, Math.ceil((Math.max(...scores) + 6) / 5) * 5)
|
||||
const span = Math.max(1, high - low)
|
||||
const x = (index: number) => (points.length === 1 ? 50 : (index / (points.length - 1)) * 100)
|
||||
const y = (score: number) => 100 - ((score - low) / span) * 100
|
||||
const line = points.map((point, index) => `${index ? 'L' : 'M'}${x(index).toFixed(2)} ${y(point.health_score).toFixed(2)}`).join(' ')
|
||||
const area = `${line} L${x(points.length - 1).toFixed(2)} 100 L${x(0).toFixed(2)} 100 Z`
|
||||
const last = points[points.length - 1]
|
||||
const ticks = [high, Math.round((high + low) / 2), low]
|
||||
return (
|
||||
<div className="trend-chart" role="img" aria-label={`Repository health trend: ${points.length} snapshots from ${scores[0]} to ${last.health_score}`}>
|
||||
<div className="trend-axis" aria-hidden="true">{ticks.map((tick) => <span key={tick}>{tick}</span>)}</div>
|
||||
<div className="trend-plot">
|
||||
<svg viewBox="0 0 100 100" preserveAspectRatio="none" aria-hidden="true">
|
||||
<defs><linearGradient id="trend-fill" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stopColor="var(--accent)" stopOpacity=".32" /><stop offset="1" stopColor="var(--accent)" stopOpacity="0" /></linearGradient></defs>
|
||||
{[0, 50, 100].map((grid) => <line key={grid} className="trend-grid" x1="0" x2="100" y1={grid} y2={grid} vectorEffect="non-scaling-stroke" />)}
|
||||
<path className="trend-area" d={area} fill="url(#trend-fill)" />
|
||||
<path className="trend-line" d={line} vectorEffect="non-scaling-stroke" />
|
||||
</svg>
|
||||
<span className="trend-marker" style={{ left: `${x(points.length - 1)}%`, top: `${y(last.health_score)}%` }} aria-hidden="true"><b>{last.health_score}</b></span>
|
||||
<div className="trend-hits">{points.map((point) => <span key={point.scan_id} title={`${new Date(point.scanned_at).toLocaleString()} · ${point.health_score}/100 · ${point.findings} finding(s)`} />)}</div>
|
||||
</div>
|
||||
<div className="trend-dates" aria-hidden="true"><span>{shortDate(points[0].scanned_at)}</span>{points.length > 2 && <span>{shortDate(points[Math.floor(points.length / 2)].scanned_at)}</span>}<span>{shortDate(last.scanned_at)}</span></div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function HistoryView({ trend, comparison, scanSummaries = [], currentScanId, onSelectScan }: { trend: TrendPoint[]; comparison: ScanComparison | null; scanSummaries?: ScanSummary[]; currentScanId?: string; onSelectScan?: (summary: ScanSummary) => void }) {
|
||||
return (
|
||||
<div className="view-stack">
|
||||
<section className="section-card">
|
||||
<div className="section-heading">
|
||||
<div><span className="eyebrow">History</span><h3>Repository health over time</h3></div>
|
||||
<span className="section-note">Each bar is one persisted scan snapshot.</span>
|
||||
<div><h3>Repository health over time</h3><p className="panel-subtitle">{trend.length} persisted scan snapshot{trend.length === 1 ? '' : 's'}</p></div>
|
||||
{trend.length > 1 && <TrendDelta trend={trend} />}
|
||||
</div>
|
||||
{trend.length ? (
|
||||
<div className="trend-chart" aria-label="Repository health trend">
|
||||
{trend.map((point) => (
|
||||
<div className="trend-column" key={point.scan_id} title={`${new Date(point.scanned_at).toLocaleString()} · ${point.health_score}/100`}>
|
||||
<span>{point.health_score}</span>
|
||||
<div className="trend-track"><i style={{ height: `${Math.max(4, point.health_score)}%` }} /></div>
|
||||
<small>{new Date(point.scanned_at).toLocaleDateString()}</small>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : <div className="empty-inline">Run multiple scans of the same repository to build a trend.</div>}
|
||||
{trend.length ? <TrendChart trend={trend} /> : <div className="empty-inline">Run multiple scans of the same repository to build a trend.</div>}
|
||||
</section>
|
||||
|
||||
<section className="comparison-grid">
|
||||
@@ -53,7 +89,7 @@ export function HistoryView({ trend, comparison, scanSummaries = [], currentScan
|
||||
|
||||
<section className="section-card scan-run-card">
|
||||
<div className="section-heading">
|
||||
<div><span className="eyebrow">Persisted snapshots</span><h3>Scan runs</h3></div>
|
||||
<div><h3>Scan runs</h3></div>
|
||||
<span className="section-note">Select a revision to inspect its report.</span>
|
||||
</div>
|
||||
{scanSummaries.length ? (
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* A small inline icon set. Paths follow the Lucide icon set (ISC licence) so
|
||||
* the interface gets consistent 24px line icons without a runtime dependency.
|
||||
*/
|
||||
const PATHS = {
|
||||
dashboard: ['M3 3h7v9H3z', 'M14 3h7v5h-7z', 'M14 12h7v9h-7z', 'M3 16h7v5H3z'],
|
||||
repositories: ['M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z'],
|
||||
activity: ['M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2'],
|
||||
queue: ['M3 12h.01', 'M3 18h.01', 'M3 6h.01', 'M8 12h13', 'M8 18h13', 'M8 6h13'],
|
||||
settings: ['M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z', 'M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0z'],
|
||||
search: ['M21 21l-4.34-4.34', 'M19 11a8 8 0 1 1-16 0 8 8 0 0 1 16 0z'],
|
||||
refresh: ['M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8', 'M21 3v5h-5', 'M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16', 'M8 16H3v5'],
|
||||
arrowRight: ['M5 12h14', 'M12 5l7 7-7 7'],
|
||||
chevronRight: ['M9 18l6-6-6-6'],
|
||||
chevronDown: ['M6 9l6 6 6-6'],
|
||||
blocked: ['M12 8v4', 'M12 16h.01', 'M15.31 2a2 2 0 0 1 1.42.59l4.68 4.68A2 2 0 0 1 22 8.69v6.62a2 2 0 0 1-.59 1.42l-4.68 4.68a2 2 0 0 1-1.42.59H8.69a2 2 0 0 1-1.42-.59l-4.68-4.68A2 2 0 0 1 2 15.31V8.69a2 2 0 0 1 .59-1.42l4.68-4.68A2 2 0 0 1 8.69 2z'],
|
||||
warning: ['M21.73 18l-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3', 'M12 9v4', 'M12 17h.01'],
|
||||
ready: ['M21.8 10A10 10 0 1 1 17 3.34', 'M9 11l3 3L22 4'],
|
||||
catalog: ['M12 2 2 7l10 5 10-5-10-5z', 'M2 17l10 5 10-5', 'M2 12l10 5 10-5'],
|
||||
clock: ['M12 6v6l4 2', 'M22 12a10 10 0 1 1-20 0 10 10 0 0 1 20 0z'],
|
||||
wrench: ['M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z'],
|
||||
star: ['M11.53 2.3a.53.53 0 0 1 .95 0l2.31 4.68a2.12 2.12 0 0 0 1.6 1.16l5.16.76a.53.53 0 0 1 .3.9l-3.74 3.64a2.12 2.12 0 0 0-.61 1.88l.88 5.14a.53.53 0 0 1-.77.56l-4.62-2.43a2.12 2.12 0 0 0-1.97 0L6.4 21.01a.53.53 0 0 1-.77-.56l.88-5.13a2.12 2.12 0 0 0-.61-1.88L2.16 9.8a.53.53 0 0 1 .29-.9l5.17-.76a2.12 2.12 0 0 0 1.6-1.16z'],
|
||||
branch: ['M6 3v12', 'M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z', 'M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z', 'M18 9a9 9 0 0 1-9 9'],
|
||||
commit: ['M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z', 'M3 12h6', 'M15 12h6'],
|
||||
close: ['M18 6 6 18', 'M6 6l12 12'],
|
||||
download: ['M12 15V3', 'M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4', 'M7 10l5 5 5-5'],
|
||||
more: ['M12 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2z', 'M19 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2z', 'M5 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2z'],
|
||||
play: ['M6 4l14 8-14 8z'],
|
||||
} as const
|
||||
|
||||
export type IconName = keyof typeof PATHS
|
||||
|
||||
export function Icon({ name, size = 16, className = '' }: { name: IconName; size?: number; className?: string }) {
|
||||
return (
|
||||
<svg className={`icon ${className}`} width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" focusable="false">
|
||||
{PATHS[name].map((d) => <path key={d} d={d} />)}
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -10,9 +10,9 @@ type PortfolioAtlasProps = {
|
||||
const laneOrder: Readiness[] = ['blocked', 'warnings', 'ready']
|
||||
|
||||
const laneCopy: Record<Readiness, { title: string; description: string }> = {
|
||||
blocked: { title: 'Intervention lane', description: 'Release-blocking repository signals' },
|
||||
warnings: { title: 'Review lane', description: 'Warnings worth resolving before the next release' },
|
||||
ready: { title: 'Clear lane', description: 'Repositories with a clear release signal' },
|
||||
blocked: { title: 'Blocked', description: 'Release-blocking signals' },
|
||||
warnings: { title: 'Warnings', description: 'Worth resolving before the next release' },
|
||||
ready: { title: 'Ready', description: 'Clear release signal' },
|
||||
}
|
||||
|
||||
function scanRhythm(repository: RepositorySummary) {
|
||||
@@ -26,10 +26,6 @@ function scanRhythm(repository: RepositorySummary) {
|
||||
return `scanned ${Math.floor(difference / 86_400_000)}d ago`
|
||||
}
|
||||
|
||||
function signalStrength(repository: RepositorySummary) {
|
||||
return Math.max(16, Math.min(100, repository.last_scan_health ?? 36))
|
||||
}
|
||||
|
||||
export function PortfolioAtlas({ repositories, onOpenRepository }: PortfolioAtlasProps) {
|
||||
const ordered = [...repositories].sort((left, right) => {
|
||||
const lane = laneOrder.indexOf(repositoryReadiness(left)) - laneOrder.indexOf(repositoryReadiness(right))
|
||||
@@ -38,38 +34,35 @@ export function PortfolioAtlas({ repositories, onOpenRepository }: PortfolioAtla
|
||||
const density = ordered.length > 160 ? 'compact' : ordered.length > 96 ? 'dense' : 'comfortable'
|
||||
|
||||
return (
|
||||
<section className="portfolio-atlas dashboard-section" aria-labelledby="atlas-title" data-density={density}>
|
||||
<div className="section-heading atlas-heading">
|
||||
<div><span className="eyebrow">Portfolio topology</span><h2 id="atlas-title">Repository signal landscape</h2></div>
|
||||
<span className="section-note">{ordered.length} repositories · every signal opens its workspace</span>
|
||||
<section className="portfolio-atlas panel" aria-labelledby="atlas-title" data-density={density}>
|
||||
<div className="panel-heading">
|
||||
<div>
|
||||
<h2 id="atlas-title">Portfolio health map</h2>
|
||||
<p className="panel-subtitle">{ordered.length} repositories, lowest health first. Select a cell to open its workspace.</p>
|
||||
</div>
|
||||
<p className="atlas-legend" aria-hidden="true"><span><i className="swatch stale" />Stale scan</span><span><i className="swatch scanning" />Scanning</span></p>
|
||||
</div>
|
||||
<div className="atlas-field">
|
||||
<svg className="atlas-contours" viewBox="0 0 1200 330" aria-hidden="true" preserveAspectRatio="none"><path d="M-20 270C118 216 190 318 335 246S525 172 656 230s250 38 390-55 154 3 210-38" /><path d="M-30 178c127-71 214 32 350-44s283 9 425-53 248 24 478-72" /><path d="M-10 90c156 27 230-67 390-8s209-18 362 24 252-56 475-13" /></svg>
|
||||
<div className="atlas-bands">
|
||||
{laneOrder.map((lane, laneIndex) => {
|
||||
{laneOrder.map((lane) => {
|
||||
const laneRepositories = ordered.filter((repository) => repositoryReadiness(repository) === lane)
|
||||
const copy = laneCopy[lane]
|
||||
return <section className={`atlas-band ${lane}`} key={lane} aria-labelledby={`atlas-${lane}-title`} data-lane={lane}>
|
||||
<header><i className="atlas-lane-beacon" aria-hidden="true" /><span>{String(laneIndex + 1).padStart(2, '0')} / {copy.title}</span><strong id={`atlas-${lane}-title`}>{laneRepositories.length}</strong><small>{copy.description}</small></header>
|
||||
<div className="atlas-river"><ol className="atlas-tiles" aria-label={`${readinessLabel(lane)} repositories`}>
|
||||
{laneRepositories.map((repository, index) => {
|
||||
<header><i className={`status-orb ${lane}`} aria-hidden="true" /><span id={`atlas-${lane}-title`}>{copy.title}</span><strong>{laneRepositories.length}</strong><small>{copy.description}</small></header>
|
||||
{laneRepositories.length ? <ol className="atlas-tiles" aria-label={`${readinessLabel(lane)} repositories`}>
|
||||
{laneRepositories.map((repository) => {
|
||||
const health = repository.last_scan_health ?? 0
|
||||
const style = { '--signal-strength': `${signalStrength(repository)}%`, '--signal-index': index, '--signal-phase': index % 7 } as CSSProperties
|
||||
const style = { '--health': `${Math.max(0, Math.min(100, health))}` } as CSSProperties
|
||||
const primary = repository.last_scan_primary_signal
|
||||
const signalDetail = primary ? `${primary.count} ${primary.category.toLowerCase()} signal${primary.count === 1 ? '' : 's'}` : 'no primary finding retained'
|
||||
return <li key={repository.id}><button type="button" className={`atlas-repository ${repository.stale ? 'stale' : ''} ${repository.state === 'scanning' ? 'scanning' : ''}`} onClick={() => onOpenRepository(repository)} style={style} aria-label={`Open ${repository.full_name}: ${health || 'not scanned'} health, ${readinessLabel(lane)}, ${signalDetail}, ${scanRhythm(repository)}`}>
|
||||
<span className="atlas-repository-orbit" aria-hidden="true" />
|
||||
<span className="atlas-repository-name">{repository.name.slice(0, 3).toUpperCase()}</span>
|
||||
return <li key={repository.id}><button type="button" className={`atlas-repository ${repository.stale ? 'stale' : ''} ${repository.state === 'scanning' ? 'scanning' : ''}`} onClick={() => onOpenRepository(repository)} style={style} title={`${repository.full_name} · ${health || '—'} health`} aria-label={`Open ${repository.full_name}: ${health || 'not scanned'} health, ${readinessLabel(lane)}, ${signalDetail}, ${scanRhythm(repository)}`}>
|
||||
<span className="atlas-repository-health">{health || '—'}</span>
|
||||
<i aria-hidden="true" />
|
||||
<span className="atlas-repository-name">{repository.name}</span>
|
||||
</button></li>
|
||||
})}
|
||||
</ol></div>
|
||||
</ol> : <p className="empty-inline">No repositories in this lane.</p>}
|
||||
</section>
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
<p className="atlas-legend"><span><i className="blocked" />Health bar height follows the retained score.</span><span><i className="stale" />A dashed frame means the scan needs refreshing.</span><span><i className="scanning" />A live ring means analysis is in progress.</span></p>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import type { RepositorySummary } from '../api'
|
||||
import { repositoryReadiness } from '../catalog'
|
||||
import { Icon } from './Icon'
|
||||
import { RepoAvatar } from './RepoAvatar'
|
||||
|
||||
type RemediationCenterProps = {
|
||||
repositories: RepositorySummary[]
|
||||
@@ -15,13 +17,12 @@ export function RemediationCenter({ repositories, onOpenRepository }: Remediatio
|
||||
if (!candidates.length) return null
|
||||
|
||||
return (
|
||||
<section className="dashboard-section remediation-center" aria-labelledby="remediation-center-title">
|
||||
<div className="section-heading">
|
||||
<section className="panel remediation-center" aria-labelledby="remediation-center-title">
|
||||
<div className="panel-heading">
|
||||
<div>
|
||||
<span className="eyebrow">Backend-ranked candidates</span>
|
||||
<h2 id="remediation-center-title">Remediation Center</h2>
|
||||
<p className="panel-subtitle">Highest-priority fixes, ranked by the backend from retained scan evidence.</p>
|
||||
</div>
|
||||
<span className="remediation-live">retained evidence</span>
|
||||
</div>
|
||||
<ol className="remediation-list">
|
||||
{candidates.map((repository) => {
|
||||
@@ -31,14 +32,14 @@ export function RemediationCenter({ repositories, onOpenRepository }: Remediatio
|
||||
return (
|
||||
<li key={repository.id}>
|
||||
<button type="button" className="remediation-row" onClick={() => onOpenRepository(repository)}>
|
||||
<span className="remediation-priority" aria-label={`Priority ${repository.last_scan_priority ?? 0}`}>{repository.last_scan_priority ?? 0}</span>
|
||||
<RepoAvatar repository={repository} />
|
||||
<span className="remediation-copy">
|
||||
<strong>{repository.full_name}</strong>
|
||||
<span className="remediation-title"><strong>{repository.full_name}</strong><span className="remediation-priority" aria-label={`Priority ${repository.last_scan_priority ?? 0}`}>P{repository.last_scan_priority ?? 0}</span></span>
|
||||
<small>{guidance?.remediation_class ?? signal.category} · {guidance?.confidence ?? 'review'} confidence</small>
|
||||
<em>{guidance?.why ?? signal.message}</em>
|
||||
<b>{guidance?.recommended_action ?? 'Open the retained evidence and select the smallest safe next action.'}</b>
|
||||
<b><Icon name="wrench" />{guidance?.recommended_action ?? 'Open the retained evidence and select the smallest safe next action.'}</b>
|
||||
</span>
|
||||
<span className="remediation-arrow" aria-hidden="true">→</span>
|
||||
<span className="remediation-arrow" aria-hidden="true"><Icon name="chevronRight" /></span>
|
||||
</button>
|
||||
</li>
|
||||
)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import { useState } from 'react'
|
||||
|
||||
import type { RepositorySummary } from '../api'
|
||||
import { repositoryReadiness } from '../catalog'
|
||||
|
||||
// Repositories without a usable icon answer 404 once; remember that for this session.
|
||||
const missingIcons = new Set<string>()
|
||||
|
||||
export function repositoryIconUrl(repository: RepositorySummary) {
|
||||
const revision = repository.last_scan_revision ?? repository.latest_revision
|
||||
return revision ? `/api/v1/repositories/${encodeURIComponent(repository.id)}/icon?rev=${encodeURIComponent(revision)}` : null
|
||||
}
|
||||
|
||||
function initialsFor(name: string) {
|
||||
const words = name.replace(/([a-z])([A-Z])/g, '$1 $2').split(/[\s_.-]+/).filter(Boolean)
|
||||
return (words.length > 1 ? `${words[0][0]}${words[1][0]}` : name.slice(0, 2)).toUpperCase()
|
||||
}
|
||||
|
||||
/** The project's own favicon or logo from its retained revision, with honest initials as fallback. */
|
||||
export function RepoAvatar({ repository, size = 'md' }: { repository: RepositorySummary; size?: 'sm' | 'md' | 'lg' | 'xl' }) {
|
||||
const url = repositoryIconUrl(repository)
|
||||
const [failed, setFailed] = useState(() => !url || missingIcons.has(url))
|
||||
const [loaded, setLoaded] = useState(false)
|
||||
const showIcon = Boolean(url) && !failed
|
||||
return (
|
||||
<span className={`repo-avatar repo-avatar-${size} ${repositoryReadiness(repository)} ${repository.state === 'scanning' ? 'scanning' : ''} ${showIcon && loaded ? 'has-icon' : ''}`} aria-hidden="true">
|
||||
{(!showIcon || !loaded) && <span className="repo-avatar-initials">{initialsFor(repository.name)}</span>}
|
||||
{showIcon && url && <img src={url} alt="" loading="lazy" decoding="async" draggable={false} onLoad={() => setLoaded(true)} onError={() => { missingIcons.add(url); setFailed(true) }} style={loaded ? undefined : { opacity: 0 }} />}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import App from './App'
|
||||
import '@fontsource-variable/inter/wght.css'
|
||||
import './styles.css'
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
|
||||
+862
-595
File diff suppressed because it is too large.
Load diff
@@ -8,6 +8,9 @@ export default defineConfig(({ mode }) => {
|
||||
|
||||
return {
|
||||
plugins: [react()],
|
||||
// The Architecture view is lazy-loaded; pre-bundle React Flow so the dev server never
|
||||
// re-optimizes and reloads mid-session when that chunk is first requested.
|
||||
optimizeDeps: { include: ['@xyflow/react'] },
|
||||
server: {
|
||||
port: 5174,
|
||||
proxy: {
|
||||
|
||||
Reference in new issue
Block a user