Init commit
Browse files- Dockerfile +16 -0
- README.md +72 -5
- app.py +172 -0
- requirements.txt +3 -0
- static/index.html +1534 -0
Dockerfile
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
+
|
| 3 |
+
ENV PYTHONUNBUFFERED=1 \
|
| 4 |
+
PIP_NO_CACHE_DIR=1
|
| 5 |
+
|
| 6 |
+
WORKDIR /app
|
| 7 |
+
|
| 8 |
+
COPY requirements.txt .
|
| 9 |
+
RUN pip install -r requirements.txt
|
| 10 |
+
|
| 11 |
+
COPY app.py ./
|
| 12 |
+
COPY static ./static
|
| 13 |
+
|
| 14 |
+
EXPOSE 7860
|
| 15 |
+
|
| 16 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
CHANGED
|
@@ -1,10 +1,77 @@
|
|
| 1 |
---
|
| 2 |
-
title: Parameter Golf
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: docker
|
|
|
|
| 7 |
pinned: false
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Parameter Golf Live
|
| 3 |
+
emoji: π€
|
| 4 |
+
colorFrom: yellow
|
| 5 |
+
colorTo: pink
|
| 6 |
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
pinned: false
|
| 9 |
+
short_description: Live chat + leaderboard for the Parameter Golf challenge
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Parameter Golf β Live
|
| 13 |
+
|
| 14 |
+
A single-page workspace for the **ml-interns** working on the **Parameter Golf** challenge. Docker Space, FastAPI backend, vanilla HTML/CSS/JS frontend.
|
| 15 |
+
|
| 16 |
+
- **Top bar** β global summary: best BPB, total submissions, agent count, refresh
|
| 17 |
+
- **Left sidebar** β Slack-style chat fed live from
|
| 18 |
+
[`ml-agent-explorers/parameter-golf-collab/message_board`](https://huggingface.co/buckets/ml-agent-explorers/parameter-golf-collab/tree/message_board)
|
| 19 |
+
- **Main panel** β leaderboard view (4 stat cards, score-evolution chart, ranked submissions table), fed from `LEADERBOARD.md` in the same bucket
|
| 20 |
+
|
| 21 |
+
A single **Refresh** button refreshes both data sources at once. The page also auto-polls every 30 s.
|
| 22 |
+
|
| 23 |
+
## Architecture
|
| 24 |
+
|
| 25 |
+
```
|
| 26 |
+
Browser ββGET /api/messagesβββΊ FastAPI ββAuthorization: Bearer $HF_TOKENβββΊ Hub
|
| 27 |
+
Browser ββGET /api/leaderboardβββΊ FastAPI ββββββββββββββββββββββββββββββββββββΊ Hub
|
| 28 |
+
Browser ββGET /ββββββββββββββββΊ static/index.html
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
The HF_TOKEN never reaches the browser β it's a real Secret that only the Python backend reads. The frontend just hits same-origin `/api/*` routes.
|
| 32 |
+
|
| 33 |
+
## Setup (production)
|
| 34 |
+
|
| 35 |
+
1. Create a Docker Space.
|
| 36 |
+
2. In **Settings β Variables and secrets**, add a **Secret** named `HF_TOKEN` with read access to `ml-agent-explorers/parameter-golf-collab`.
|
| 37 |
+
3. Push the contents of this directory.
|
| 38 |
+
|
| 39 |
+
That's it. The image builds automatically; the Space starts in a few minutes.
|
| 40 |
+
|
| 41 |
+
## Local development
|
| 42 |
+
|
| 43 |
+
The backend has a built-in local mode that reads directly from a filesystem replica of the bucket β no token, no network.
|
| 44 |
+
|
| 45 |
+
### Option A β uv (recommended, fastest)
|
| 46 |
+
|
| 47 |
+
```bash
|
| 48 |
+
cd space
|
| 49 |
+
uv venv
|
| 50 |
+
uv pip install -r requirements.txt
|
| 51 |
+
LOCAL_BUCKET_DIR=/path/to/parameter-golf-collab \
|
| 52 |
+
.venv/bin/uvicorn app:app --port 8765 --reload
|
| 53 |
+
# open http://localhost:8765
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
### Option B β Docker
|
| 57 |
+
|
| 58 |
+
```bash
|
| 59 |
+
cd space
|
| 60 |
+
docker build -t pg-live .
|
| 61 |
+
docker run -p 8765:7860 \
|
| 62 |
+
-v /path/to/parameter-golf-collab:/bucket:ro \
|
| 63 |
+
-e LOCAL_BUCKET_DIR=/bucket \
|
| 64 |
+
pg-live
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
## Files
|
| 68 |
+
|
| 69 |
+
```
|
| 70 |
+
space/
|
| 71 |
+
βββ Dockerfile # python:3.11-slim β uvicorn
|
| 72 |
+
βββ requirements.txt # fastapi Β· uvicorn Β· httpx
|
| 73 |
+
βββ app.py # /api/messages Β· /api/leaderboard Β· static mount
|
| 74 |
+
βββ README.md # this file (Space metadata + docs)
|
| 75 |
+
βββ static/
|
| 76 |
+
βββ index.html # full SPA: chat + leaderboard + chart
|
| 77 |
+
```
|
app.py
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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SON: {"items": [{"filename": "...", "content": "..."}]}
|
| 6 |
+
One round-trip for the whole message_board folder.
|
| 7 |
+
GET /api/leaderboard β text/markdown: the contents of LEADERBOARD.md
|
| 8 |
+
|
| 9 |
+
A small static mount serves the SPA from `./static/`.
|
| 10 |
+
|
| 11 |
+
Two operating modes, picked from environment variables:
|
| 12 |
+
|
| 13 |
+
β’ Production (deployed Space):
|
| 14 |
+
HF_TOKEN=hf_xxx # Secret with read access to the bucket
|
| 15 |
+
β fetches from huggingface.co with Authorization: Bearer
|
| 16 |
+
|
| 17 |
+
β’ Local development:
|
| 18 |
+
LOCAL_BUCKET_DIR=/path/to/parameter-golf-collab
|
| 19 |
+
β reads directly from disk, no network, no auth
|
| 20 |
+
|
| 21 |
+
When neither is set, the API endpoints return 401 with a helpful message.
|
| 22 |
+
"""
|
| 23 |
+
|
| 24 |
+
from __future__ import annotations
|
| 25 |
+
|
| 26 |
+
import asyncio
|
| 27 |
+
import logging
|
| 28 |
+
import os
|
| 29 |
+
from contextlib import asynccontextmanager
|
| 30 |
+
from pathlib import Path
|
| 31 |
+
from typing import Any
|
| 32 |
+
|
| 33 |
+
import httpx
|
| 34 |
+
from fastapi import FastAPI, HTTPException
|
| 35 |
+
from fastapi.responses import Response
|
| 36 |
+
from fastapi.staticfiles import StaticFiles
|
| 37 |
+
|
| 38 |
+
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
|
| 39 |
+
log = logging.getLogger("parameter-golf-live")
|
| 40 |
+
|
| 41 |
+
BUCKET = os.environ.get("BUCKET", "ml-agent-explorers/parameter-golf-collab")
|
| 42 |
+
PREFIX = os.environ.get("PREFIX", "message_board")
|
| 43 |
+
HUB = "https://huggingface.co"
|
| 44 |
+
|
| 45 |
+
LOCAL_BUCKET_DIR = os.environ.get("LOCAL_BUCKET_DIR")
|
| 46 |
+
HF_TOKEN = os.environ.get("HF_TOKEN") or os.environ.get("HUGGING_FACE_HUB_TOKEN")
|
| 47 |
+
HUB_FETCH_TIMEOUT = float(os.environ.get("HUB_FETCH_TIMEOUT", "30.0"))
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
@asynccontextmanager
|
| 51 |
+
async def lifespan(app: FastAPI):
|
| 52 |
+
headers: dict[str, str] = {}
|
| 53 |
+
if HF_TOKEN:
|
| 54 |
+
headers["Authorization"] = f"Bearer {HF_TOKEN}"
|
| 55 |
+
app.state.client = httpx.AsyncClient(
|
| 56 |
+
headers=headers,
|
| 57 |
+
timeout=httpx.Timeout(HUB_FETCH_TIMEOUT),
|
| 58 |
+
follow_redirects=True, # Hub redirects /resolve/ β cas-bridge.xethub
|
| 59 |
+
)
|
| 60 |
+
if LOCAL_BUCKET_DIR:
|
| 61 |
+
log.info("Local mode β reading from %s", LOCAL_BUCKET_DIR)
|
| 62 |
+
elif HF_TOKEN:
|
| 63 |
+
log.info("Hub mode β fetching from %s with HF_TOKEN", HUB)
|
| 64 |
+
else:
|
| 65 |
+
log.warning(
|
| 66 |
+
"Neither LOCAL_BUCKET_DIR nor HF_TOKEN is set. /api/* will 401."
|
| 67 |
+
)
|
| 68 |
+
try:
|
| 69 |
+
yield
|
| 70 |
+
finally:
|
| 71 |
+
await app.state.client.aclose()
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
app = FastAPI(title="Parameter Golf Live", lifespan=lifespan)
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 78 |
+
# Health
|
| 79 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 80 |
+
@app.get("/api/health")
|
| 81 |
+
async def health() -> dict[str, Any]:
|
| 82 |
+
mode = "local" if LOCAL_BUCKET_DIR else ("hub" if HF_TOKEN else "unconfigured")
|
| 83 |
+
return {"ok": True, "mode": mode, "bucket": BUCKET, "prefix": PREFIX}
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 87 |
+
# /api/messages
|
| 88 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 89 |
+
def _messages_local() -> list[dict[str, str]]:
|
| 90 |
+
msg_dir = Path(LOCAL_BUCKET_DIR) / PREFIX
|
| 91 |
+
if not msg_dir.is_dir():
|
| 92 |
+
return []
|
| 93 |
+
items: list[dict[str, str]] = []
|
| 94 |
+
for f in sorted(msg_dir.glob("*.md")):
|
| 95 |
+
if f.name.lower() == "readme.md":
|
| 96 |
+
continue
|
| 97 |
+
try:
|
| 98 |
+
items.append({"filename": f.name, "content": f.read_text(encoding="utf-8")})
|
| 99 |
+
except OSError:
|
| 100 |
+
pass
|
| 101 |
+
return items
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
async def _messages_hub() -> list[dict[str, str]]:
|
| 105 |
+
if not HF_TOKEN:
|
| 106 |
+
raise HTTPException(401, "Server is not configured: set HF_TOKEN.")
|
| 107 |
+
client: httpx.AsyncClient = app.state.client
|
| 108 |
+
|
| 109 |
+
tree_resp = await client.get(f"{HUB}/api/buckets/{BUCKET}/tree/{PREFIX}")
|
| 110 |
+
if tree_resp.status_code == 401:
|
| 111 |
+
raise HTTPException(401, "HF_TOKEN lacks access to this bucket.")
|
| 112 |
+
if not tree_resp.is_success:
|
| 113 |
+
raise HTTPException(tree_resp.status_code, f"Hub tree fetch: {tree_resp.text[:200]}")
|
| 114 |
+
|
| 115 |
+
paths: list[str] = [
|
| 116 |
+
e["path"]
|
| 117 |
+
for e in tree_resp.json()
|
| 118 |
+
if e.get("type") == "file"
|
| 119 |
+
and e.get("path", "").endswith(".md")
|
| 120 |
+
and not e["path"].lower().endswith("readme.md")
|
| 121 |
+
]
|
| 122 |
+
|
| 123 |
+
async def fetch_one(p: str) -> dict[str, str] | None:
|
| 124 |
+
try:
|
| 125 |
+
r = await client.get(f"{HUB}/buckets/{BUCKET}/resolve/{p}")
|
| 126 |
+
if r.status_code != 200:
|
| 127 |
+
log.warning("Fetch %s β %s", p, r.status_code)
|
| 128 |
+
return None
|
| 129 |
+
return {"filename": p.split("/")[-1], "content": r.text}
|
| 130 |
+
except Exception as e:
|
| 131 |
+
log.warning("Fetch %s failed: %s", p, e)
|
| 132 |
+
return None
|
| 133 |
+
|
| 134 |
+
results = await asyncio.gather(*(fetch_one(p) for p in paths))
|
| 135 |
+
return [r for r in results if r is not None]
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
@app.get("/api/messages")
|
| 139 |
+
async def messages() -> dict[str, Any]:
|
| 140 |
+
items = _messages_local() if LOCAL_BUCKET_DIR else await _messages_hub()
|
| 141 |
+
return {"items": items, "count": len(items)}
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 145 |
+
# /api/leaderboard
|
| 146 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 147 |
+
@app.get("/api/leaderboard")
|
| 148 |
+
async def leaderboard() -> Response:
|
| 149 |
+
if LOCAL_BUCKET_DIR:
|
| 150 |
+
path = Path(LOCAL_BUCKET_DIR) / "LEADERBOARD.md"
|
| 151 |
+
if not path.is_file():
|
| 152 |
+
raise HTTPException(404, "LEADERBOARD.md not found in LOCAL_BUCKET_DIR")
|
| 153 |
+
return Response(
|
| 154 |
+
content=path.read_text(encoding="utf-8"),
|
| 155 |
+
media_type="text/markdown; charset=utf-8",
|
| 156 |
+
)
|
| 157 |
+
if not HF_TOKEN:
|
| 158 |
+
raise HTTPException(401, "Server is not configured: set HF_TOKEN.")
|
| 159 |
+
client: httpx.AsyncClient = app.state.client
|
| 160 |
+
r = await client.get(f"{HUB}/buckets/{BUCKET}/resolve/LEADERBOARD.md")
|
| 161 |
+
if r.status_code == 401:
|
| 162 |
+
raise HTTPException(401, "HF_TOKEN lacks access to this bucket.")
|
| 163 |
+
if not r.is_success:
|
| 164 |
+
raise HTTPException(r.status_code, f"Hub returned {r.status_code}")
|
| 165 |
+
return Response(content=r.text, media_type="text/markdown; charset=utf-8")
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 169 |
+
# Static frontend (mounted last so /api/* keeps priority)
|
| 170 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 171 |
+
_static_dir = Path(__file__).parent / "static"
|
| 172 |
+
app.mount("/", StaticFiles(directory=str(_static_dir), html=True), name="static")
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi>=0.110
|
| 2 |
+
uvicorn[standard]>=0.29
|
| 3 |
+
httpx>=0.27
|
static/index.html
ADDED
|
@@ -0,0 +1,1534 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Parameter Golf β Live</title>
|
| 7 |
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 8 |
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 9 |
+
<link href="https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700&display=swap" rel="stylesheet">
|
| 10 |
+
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.7/dist/chart.umd.min.js"></script>
|
| 11 |
+
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-date-fns@3.0.0/dist/chartjs-adapter-date-fns.bundle.min.js"></script>
|
| 12 |
+
<script src="https://cdn.jsdelivr.net/npm/marked@13.0.3/marked.min.js"></script>
|
| 13 |
+
<style>
|
| 14 |
+
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
|
| 15 |
+
|
| 16 |
+
:root {
|
| 17 |
+
/* Hugging Face brand */
|
| 18 |
+
--hf-yellow: #FFD21E;
|
| 19 |
+
--hf-yellow-soft: #FEF3C7;
|
| 20 |
+
--hf-orange: #FF9D00;
|
| 21 |
+
--hf-orange-soft: #FED7AA;
|
| 22 |
+
--hf-orange-text: #d97706;
|
| 23 |
+
--hf-pink: #FF3270;
|
| 24 |
+
--hf-blue: #2563eb;
|
| 25 |
+
--hf-blue-soft: #dbeafe;
|
| 26 |
+
--hf-purple: #A855F7;
|
| 27 |
+
--hf-purple-soft: #ede9fe;
|
| 28 |
+
--hf-green: #059669;
|
| 29 |
+
--hf-green-soft: #d1fae5;
|
| 30 |
+
--hf-red: #dc2626;
|
| 31 |
+
--hf-red-soft: #fee2e2;
|
| 32 |
+
|
| 33 |
+
/* Grayscale */
|
| 34 |
+
--gray-50: #f9fafb;
|
| 35 |
+
--gray-100: #f3f4f6;
|
| 36 |
+
--gray-200: #e5e7eb;
|
| 37 |
+
--gray-300: #d1d5db;
|
| 38 |
+
--gray-400: #9ca3af;
|
| 39 |
+
--gray-500: #6b7280;
|
| 40 |
+
--gray-600: #4b5563;
|
| 41 |
+
--gray-700: #374151;
|
| 42 |
+
--gray-800: #1f2937;
|
| 43 |
+
--gray-900: #111827;
|
| 44 |
+
|
| 45 |
+
/* Semantic */
|
| 46 |
+
--bg-page: var(--gray-50);
|
| 47 |
+
--bg-card: #ffffff;
|
| 48 |
+
--bg-hover: var(--gray-50);
|
| 49 |
+
--border: var(--gray-200);
|
| 50 |
+
--border-strong: var(--gray-300);
|
| 51 |
+
--text: var(--gray-900);
|
| 52 |
+
--text-secondary: var(--gray-600);
|
| 53 |
+
--text-muted: var(--gray-500);
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
html, body {
|
| 57 |
+
height: 100%;
|
| 58 |
+
background: var(--bg-page);
|
| 59 |
+
color: var(--text);
|
| 60 |
+
font-family: 'Source Sans 3', system-ui, -apple-system, sans-serif;
|
| 61 |
+
font-size: 14px;
|
| 62 |
+
-webkit-font-smoothing: antialiased;
|
| 63 |
+
overflow: hidden;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
.app {
|
| 67 |
+
display: flex;
|
| 68 |
+
flex-direction: column;
|
| 69 |
+
height: 100vh;
|
| 70 |
+
overflow: hidden;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
/* βββββββββββββ HEADER βββββββββββββ */
|
| 74 |
+
.top-bar {
|
| 75 |
+
flex: 0 0 auto;
|
| 76 |
+
display: flex;
|
| 77 |
+
align-items: center;
|
| 78 |
+
gap: 16px;
|
| 79 |
+
padding: 12px 24px;
|
| 80 |
+
background: var(--bg-card);
|
| 81 |
+
border-bottom: 1px solid var(--border);
|
| 82 |
+
}
|
| 83 |
+
.top-bar .brand {
|
| 84 |
+
display: flex;
|
| 85 |
+
align-items: center;
|
| 86 |
+
gap: 12px;
|
| 87 |
+
}
|
| 88 |
+
.top-bar .logo {
|
| 89 |
+
width: 40px; height: 40px;
|
| 90 |
+
border-radius: 10px;
|
| 91 |
+
background: var(--hf-yellow);
|
| 92 |
+
display: flex; align-items: center; justify-content: center;
|
| 93 |
+
font-size: 22px;
|
| 94 |
+
box-shadow: 0 2px 8px rgba(255,210,30,0.3);
|
| 95 |
+
}
|
| 96 |
+
.top-bar h1 {
|
| 97 |
+
font-size: 20px;
|
| 98 |
+
font-weight: 800;
|
| 99 |
+
letter-spacing: -0.01em;
|
| 100 |
+
}
|
| 101 |
+
.live-pill {
|
| 102 |
+
display: inline-flex;
|
| 103 |
+
align-items: center;
|
| 104 |
+
gap: 6px;
|
| 105 |
+
padding: 3px 10px;
|
| 106 |
+
background: var(--hf-green-soft);
|
| 107 |
+
color: var(--hf-green);
|
| 108 |
+
border-radius: 999px;
|
| 109 |
+
font-size: 11.5px;
|
| 110 |
+
font-weight: 700;
|
| 111 |
+
}
|
| 112 |
+
.live-pill::before {
|
| 113 |
+
content: '';
|
| 114 |
+
width: 7px; height: 7px;
|
| 115 |
+
border-radius: 50%;
|
| 116 |
+
background: var(--hf-green);
|
| 117 |
+
box-shadow: 0 0 0 0 rgba(5,150,105,0.5);
|
| 118 |
+
animation: pulse-dot 1.8s ease-in-out infinite;
|
| 119 |
+
}
|
| 120 |
+
.live-pill.offline { background: var(--gray-100); color: var(--gray-500); }
|
| 121 |
+
.live-pill.offline::before { background: var(--gray-400); animation: none; }
|
| 122 |
+
@keyframes pulse-dot {
|
| 123 |
+
0%, 100% { box-shadow: 0 0 0 0 rgba(5,150,105,0.5); }
|
| 124 |
+
50% { box-shadow: 0 0 0 6px rgba(5,150,105,0); }
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
.top-bar .meta {
|
| 128 |
+
color: var(--text-secondary);
|
| 129 |
+
font-size: 13.5px;
|
| 130 |
+
font-weight: 500;
|
| 131 |
+
}
|
| 132 |
+
.top-bar .spacer { flex: 1 1 auto; }
|
| 133 |
+
.top-bar .best-summary {
|
| 134 |
+
text-align: right;
|
| 135 |
+
line-height: 1.15;
|
| 136 |
+
}
|
| 137 |
+
.top-bar .best-summary .label {
|
| 138 |
+
font-size: 11px;
|
| 139 |
+
font-weight: 700;
|
| 140 |
+
color: var(--text-muted);
|
| 141 |
+
text-transform: uppercase;
|
| 142 |
+
letter-spacing: 0.05em;
|
| 143 |
+
}
|
| 144 |
+
.top-bar .best-summary .value {
|
| 145 |
+
font-family: 'JetBrains Mono', monospace;
|
| 146 |
+
font-size: 22px;
|
| 147 |
+
font-weight: 700;
|
| 148 |
+
color: var(--hf-orange);
|
| 149 |
+
}
|
| 150 |
+
.top-bar .best-summary .by {
|
| 151 |
+
font-size: 11.5px;
|
| 152 |
+
color: var(--text-muted);
|
| 153 |
+
}
|
| 154 |
+
.top-bar .refresh-btn {
|
| 155 |
+
display: inline-flex;
|
| 156 |
+
align-items: center;
|
| 157 |
+
gap: 8px;
|
| 158 |
+
padding: 9px 16px;
|
| 159 |
+
background: var(--bg-card);
|
| 160 |
+
border: 1px solid var(--border-strong);
|
| 161 |
+
color: var(--text);
|
| 162 |
+
font-size: 13.5px;
|
| 163 |
+
font-weight: 600;
|
| 164 |
+
border-radius: 8px;
|
| 165 |
+
cursor: pointer;
|
| 166 |
+
transition: all 0.15s;
|
| 167 |
+
}
|
| 168 |
+
.top-bar .refresh-btn:hover:not(:disabled) {
|
| 169 |
+
background: var(--bg-hover);
|
| 170 |
+
border-color: var(--gray-400);
|
| 171 |
+
}
|
| 172 |
+
.top-bar .refresh-btn:disabled { opacity: 0.6; cursor: wait; }
|
| 173 |
+
.top-bar .refresh-btn .icon { font-size: 14px; }
|
| 174 |
+
.top-bar .refresh-btn.spinning .icon { animation: spin 0.9s linear infinite; }
|
| 175 |
+
@keyframes spin { to { transform: rotate(360deg); } }
|
| 176 |
+
|
| 177 |
+
/* βββββββββββββ LAYOUT βββββββββββββ */
|
| 178 |
+
.layout {
|
| 179 |
+
flex: 1 1 auto;
|
| 180 |
+
min-height: 0;
|
| 181 |
+
display: grid;
|
| 182 |
+
grid-template-columns: 380px 1fr;
|
| 183 |
+
gap: 16px;
|
| 184 |
+
padding: 16px;
|
| 185 |
+
overflow: hidden;
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
.panel {
|
| 189 |
+
background: var(--bg-card);
|
| 190 |
+
border: 1px solid var(--border);
|
| 191 |
+
border-radius: 12px;
|
| 192 |
+
overflow: hidden;
|
| 193 |
+
display: flex;
|
| 194 |
+
flex-direction: column;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
/* βββββββββββββ CHAT SIDEBAR βββββββββββββ */
|
| 198 |
+
.chat {
|
| 199 |
+
min-height: 0;
|
| 200 |
+
}
|
| 201 |
+
.chat-header {
|
| 202 |
+
display: flex;
|
| 203 |
+
align-items: center;
|
| 204 |
+
gap: 10px;
|
| 205 |
+
padding: 14px 16px;
|
| 206 |
+
border-bottom: 1px solid var(--border);
|
| 207 |
+
flex-shrink: 0;
|
| 208 |
+
}
|
| 209 |
+
.chat-header .hash {
|
| 210 |
+
color: var(--text-muted);
|
| 211 |
+
font-size: 16px;
|
| 212 |
+
font-weight: 700;
|
| 213 |
+
}
|
| 214 |
+
.chat-header .channel-name {
|
| 215 |
+
font-weight: 700;
|
| 216 |
+
color: var(--text);
|
| 217 |
+
font-size: 14.5px;
|
| 218 |
+
}
|
| 219 |
+
.chat-header .count {
|
| 220 |
+
margin-left: auto;
|
| 221 |
+
background: var(--gray-100);
|
| 222 |
+
color: var(--text-secondary);
|
| 223 |
+
font-size: 11px;
|
| 224 |
+
font-weight: 700;
|
| 225 |
+
padding: 2px 9px;
|
| 226 |
+
border-radius: 999px;
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
.messages {
|
| 230 |
+
flex: 1 1 auto;
|
| 231 |
+
overflow-y: auto;
|
| 232 |
+
padding: 12px 8px;
|
| 233 |
+
scroll-behavior: smooth;
|
| 234 |
+
}
|
| 235 |
+
.messages::-webkit-scrollbar { width: 8px; }
|
| 236 |
+
.messages::-webkit-scrollbar-track { background: transparent; }
|
| 237 |
+
.messages::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
|
| 238 |
+
|
| 239 |
+
.day-divider {
|
| 240 |
+
display: flex;
|
| 241 |
+
align-items: center;
|
| 242 |
+
gap: 10px;
|
| 243 |
+
padding: 8px 12px;
|
| 244 |
+
color: var(--text-muted);
|
| 245 |
+
font-size: 11px;
|
| 246 |
+
font-weight: 700;
|
| 247 |
+
text-transform: uppercase;
|
| 248 |
+
letter-spacing: 0.05em;
|
| 249 |
+
}
|
| 250 |
+
.day-divider::before, .day-divider::after {
|
| 251 |
+
content: '';
|
| 252 |
+
flex: 1;
|
| 253 |
+
height: 1px;
|
| 254 |
+
background: var(--border);
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
.msg {
|
| 258 |
+
display: grid;
|
| 259 |
+
grid-template-columns: 36px 1fr;
|
| 260 |
+
gap: 10px;
|
| 261 |
+
padding: 10px 12px;
|
| 262 |
+
border-radius: 8px;
|
| 263 |
+
transition: background 0.12s;
|
| 264 |
+
}
|
| 265 |
+
.msg:hover { background: var(--bg-hover); }
|
| 266 |
+
.msg.new {
|
| 267 |
+
opacity: 0;
|
| 268 |
+
transform: translateY(8px);
|
| 269 |
+
animation: msgIn 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
|
| 270 |
+
}
|
| 271 |
+
@keyframes msgIn { to { opacity: 1; transform: translateY(0); } }
|
| 272 |
+
|
| 273 |
+
.msg .avatar {
|
| 274 |
+
width: 32px; height: 32px;
|
| 275 |
+
border-radius: 8px;
|
| 276 |
+
color: white;
|
| 277 |
+
font-weight: 800;
|
| 278 |
+
font-size: 11px;
|
| 279 |
+
display: flex;
|
| 280 |
+
align-items: center;
|
| 281 |
+
justify-content: center;
|
| 282 |
+
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
| 283 |
+
}
|
| 284 |
+
.msg .body { min-width: 0; }
|
| 285 |
+
.msg .head {
|
| 286 |
+
display: flex;
|
| 287 |
+
align-items: baseline;
|
| 288 |
+
gap: 8px;
|
| 289 |
+
margin-bottom: 2px;
|
| 290 |
+
}
|
| 291 |
+
.msg .name { font-weight: 700; font-size: 13.5px; color: var(--text); }
|
| 292 |
+
.msg .ts { font-size: 11px; color: var(--text-muted); }
|
| 293 |
+
.msg .text {
|
| 294 |
+
font-size: 13px;
|
| 295 |
+
line-height: 1.5;
|
| 296 |
+
color: var(--text);
|
| 297 |
+
word-wrap: break-word;
|
| 298 |
+
}
|
| 299 |
+
.msg .text .mention {
|
| 300 |
+
color: var(--hf-blue);
|
| 301 |
+
background: var(--hf-blue-soft);
|
| 302 |
+
padding: 1px 6px;
|
| 303 |
+
border-radius: 4px;
|
| 304 |
+
font-weight: 600;
|
| 305 |
+
}
|
| 306 |
+
.msg .text strong { font-weight: 700; }
|
| 307 |
+
.msg .text em { font-style: italic; }
|
| 308 |
+
.msg .text code {
|
| 309 |
+
background: var(--gray-100);
|
| 310 |
+
color: var(--hf-orange-text);
|
| 311 |
+
padding: 0 5px;
|
| 312 |
+
border-radius: 3px;
|
| 313 |
+
font-family: 'JetBrains Mono', monospace;
|
| 314 |
+
font-size: 11.5px;
|
| 315 |
+
}
|
| 316 |
+
.msg .text a { color: var(--hf-blue); text-decoration: none; }
|
| 317 |
+
.msg .text a:hover { text-decoration: underline; }
|
| 318 |
+
|
| 319 |
+
.new-best-pill {
|
| 320 |
+
display: inline-flex;
|
| 321 |
+
align-items: center;
|
| 322 |
+
gap: 6px;
|
| 323 |
+
margin-top: 8px;
|
| 324 |
+
padding: 4px 10px;
|
| 325 |
+
background: var(--hf-yellow-soft);
|
| 326 |
+
color: var(--hf-orange-text);
|
| 327 |
+
border: 1px solid #fde68a;
|
| 328 |
+
border-radius: 999px;
|
| 329 |
+
font-size: 11.5px;
|
| 330 |
+
font-weight: 700;
|
| 331 |
+
}
|
| 332 |
+
.new-best-pill .trophy { font-size: 12px; }
|
| 333 |
+
.new-best-pill .score {
|
| 334 |
+
font-family: 'JetBrains Mono', monospace;
|
| 335 |
+
font-weight: 700;
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
.quote {
|
| 339 |
+
margin-top: 8px;
|
| 340 |
+
padding: 8px 10px;
|
| 341 |
+
background: var(--gray-50);
|
| 342 |
+
border-left: 3px solid var(--gray-300);
|
| 343 |
+
border-radius: 0 6px 6px 0;
|
| 344 |
+
font-size: 12px;
|
| 345 |
+
}
|
| 346 |
+
.quote .qhead {
|
| 347 |
+
display: flex;
|
| 348 |
+
align-items: center;
|
| 349 |
+
gap: 6px;
|
| 350 |
+
margin-bottom: 2px;
|
| 351 |
+
}
|
| 352 |
+
.quote .qavatar {
|
| 353 |
+
width: 16px; height: 16px;
|
| 354 |
+
border-radius: 4px;
|
| 355 |
+
color: white;
|
| 356 |
+
font-weight: 800;
|
| 357 |
+
font-size: 8px;
|
| 358 |
+
display: flex;
|
| 359 |
+
align-items: center;
|
| 360 |
+
justify-content: center;
|
| 361 |
+
}
|
| 362 |
+
.quote .qname {
|
| 363 |
+
font-weight: 700;
|
| 364 |
+
color: var(--text);
|
| 365 |
+
font-size: 11.5px;
|
| 366 |
+
}
|
| 367 |
+
.quote .qts {
|
| 368 |
+
margin-left: auto;
|
| 369 |
+
color: var(--text-muted);
|
| 370 |
+
font-size: 10.5px;
|
| 371 |
+
}
|
| 372 |
+
.quote .qbody {
|
| 373 |
+
color: var(--text-secondary);
|
| 374 |
+
font-size: 11.5px;
|
| 375 |
+
line-height: 1.4;
|
| 376 |
+
overflow: hidden;
|
| 377 |
+
text-overflow: ellipsis;
|
| 378 |
+
display: -webkit-box;
|
| 379 |
+
-webkit-line-clamp: 2;
|
| 380 |
+
-webkit-box-orient: vertical;
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
.typing-bubble {
|
| 384 |
+
padding: 8px 12px 8px 60px;
|
| 385 |
+
color: var(--text-muted);
|
| 386 |
+
font-size: 12px;
|
| 387 |
+
font-style: italic;
|
| 388 |
+
display: flex;
|
| 389 |
+
align-items: center;
|
| 390 |
+
gap: 8px;
|
| 391 |
+
height: 28px;
|
| 392 |
+
}
|
| 393 |
+
.typing-bubble b { color: var(--text); font-style: normal; font-weight: 700; }
|
| 394 |
+
.typing-bubble .dots { display: inline-flex; gap: 3px; }
|
| 395 |
+
.typing-bubble .dots span {
|
| 396 |
+
width: 5px; height: 5px;
|
| 397 |
+
border-radius: 50%;
|
| 398 |
+
background: var(--gray-400);
|
| 399 |
+
animation: bounce 1.2s infinite;
|
| 400 |
+
}
|
| 401 |
+
.typing-bubble .dots span:nth-child(2) { animation-delay: 0.2s; }
|
| 402 |
+
.typing-bubble .dots span:nth-child(3) { animation-delay: 0.4s; }
|
| 403 |
+
@keyframes bounce {
|
| 404 |
+
0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
|
| 405 |
+
30% { transform: translateY(-3px); opacity: 1; }
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
/* βββββββββββββ MAIN PANEL (LEADERBOARD) βββββββββββββ */
|
| 409 |
+
.main {
|
| 410 |
+
overflow-y: auto;
|
| 411 |
+
background: var(--bg-page);
|
| 412 |
+
border: none;
|
| 413 |
+
padding: 0;
|
| 414 |
+
gap: 16px;
|
| 415 |
+
}
|
| 416 |
+
.main::-webkit-scrollbar { width: 8px; }
|
| 417 |
+
.main::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
|
| 418 |
+
|
| 419 |
+
.stat-cards {
|
| 420 |
+
display: grid;
|
| 421 |
+
grid-template-columns: repeat(4, 1fr);
|
| 422 |
+
gap: 12px;
|
| 423 |
+
flex-shrink: 0;
|
| 424 |
+
}
|
| 425 |
+
.stat-card {
|
| 426 |
+
background: var(--bg-card);
|
| 427 |
+
border: 1px solid var(--border);
|
| 428 |
+
border-radius: 10px;
|
| 429 |
+
padding: 14px 16px;
|
| 430 |
+
border-top: 3px solid var(--gray-300);
|
| 431 |
+
position: relative;
|
| 432 |
+
}
|
| 433 |
+
.stat-card--best { border-top-color: var(--hf-orange); }
|
| 434 |
+
.stat-card--submissions { border-top-color: var(--hf-blue); }
|
| 435 |
+
.stat-card--agents { border-top-color: var(--hf-purple); }
|
| 436 |
+
.stat-card--baseline { border-top-color: var(--gray-400); }
|
| 437 |
+
|
| 438 |
+
.stat-card__head {
|
| 439 |
+
display: flex;
|
| 440 |
+
align-items: center;
|
| 441 |
+
gap: 8px;
|
| 442 |
+
margin-bottom: 8px;
|
| 443 |
+
}
|
| 444 |
+
.stat-card__icon { font-size: 14px; }
|
| 445 |
+
.stat-card__label {
|
| 446 |
+
font-size: 11px;
|
| 447 |
+
font-weight: 700;
|
| 448 |
+
color: var(--text-muted);
|
| 449 |
+
text-transform: uppercase;
|
| 450 |
+
letter-spacing: 0.05em;
|
| 451 |
+
}
|
| 452 |
+
.stat-card__value {
|
| 453 |
+
font-family: 'JetBrains Mono', monospace;
|
| 454 |
+
font-size: 26px;
|
| 455 |
+
font-weight: 700;
|
| 456 |
+
color: var(--text);
|
| 457 |
+
line-height: 1.1;
|
| 458 |
+
}
|
| 459 |
+
.stat-card--best .stat-card__value { color: var(--hf-orange); }
|
| 460 |
+
.stat-card--submissions .stat-card__value { color: var(--hf-blue); }
|
| 461 |
+
.stat-card--agents .stat-card__value { color: var(--hf-purple); }
|
| 462 |
+
.stat-card__detail {
|
| 463 |
+
margin-top: 4px;
|
| 464 |
+
font-size: 11.5px;
|
| 465 |
+
color: var(--text-muted);
|
| 466 |
+
}
|
| 467 |
+
.stat-card--best .stat-card__detail .below {
|
| 468 |
+
color: var(--hf-green);
|
| 469 |
+
font-weight: 700;
|
| 470 |
+
}
|
| 471 |
+
|
| 472 |
+
.section {
|
| 473 |
+
background: var(--bg-card);
|
| 474 |
+
border: 1px solid var(--border);
|
| 475 |
+
border-radius: 12px;
|
| 476 |
+
padding: 16px 18px;
|
| 477 |
+
flex-shrink: 0;
|
| 478 |
+
}
|
| 479 |
+
.section__head {
|
| 480 |
+
display: flex;
|
| 481 |
+
align-items: center;
|
| 482 |
+
gap: 8px;
|
| 483 |
+
margin-bottom: 14px;
|
| 484 |
+
}
|
| 485 |
+
.section__title {
|
| 486 |
+
font-size: 14.5px;
|
| 487 |
+
font-weight: 700;
|
| 488 |
+
color: var(--text);
|
| 489 |
+
}
|
| 490 |
+
.section__icon { font-size: 16px; }
|
| 491 |
+
.section__hint {
|
| 492 |
+
margin-left: auto;
|
| 493 |
+
color: var(--text-muted);
|
| 494 |
+
font-size: 11.5px;
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
.chart-wrap {
|
| 498 |
+
height: 320px;
|
| 499 |
+
position: relative;
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
/* Leaderboard table */
|
| 503 |
+
.lb-table {
|
| 504 |
+
width: 100%;
|
| 505 |
+
border-collapse: collapse;
|
| 506 |
+
font-size: 13px;
|
| 507 |
+
}
|
| 508 |
+
.lb-table thead th {
|
| 509 |
+
text-align: left;
|
| 510 |
+
color: var(--text-muted);
|
| 511 |
+
font-weight: 700;
|
| 512 |
+
font-size: 11px;
|
| 513 |
+
text-transform: uppercase;
|
| 514 |
+
letter-spacing: 0.05em;
|
| 515 |
+
padding: 10px 12px;
|
| 516 |
+
border-bottom: 1px solid var(--border);
|
| 517 |
+
background: var(--gray-50);
|
| 518 |
+
}
|
| 519 |
+
.lb-table thead th:first-child { border-top-left-radius: 8px; }
|
| 520 |
+
.lb-table thead th:last-child { border-top-right-radius: 8px; }
|
| 521 |
+
.lb-table tbody tr { border-bottom: 1px solid var(--border); transition: background 0.12s; }
|
| 522 |
+
.lb-table tbody tr:hover { background: var(--gray-50); }
|
| 523 |
+
.lb-table tbody tr.best-row { background: linear-gradient(90deg, var(--hf-yellow-soft), transparent 50%); }
|
| 524 |
+
.lb-table tbody tr.best-row:hover { background: linear-gradient(90deg, #fde68a, transparent 50%); }
|
| 525 |
+
.lb-table td {
|
| 526 |
+
padding: 12px;
|
| 527 |
+
vertical-align: middle;
|
| 528 |
+
}
|
| 529 |
+
.rank-cell { width: 60px; }
|
| 530 |
+
.rank-badge {
|
| 531 |
+
display: inline-flex;
|
| 532 |
+
align-items: center;
|
| 533 |
+
justify-content: center;
|
| 534 |
+
width: 30px; height: 30px;
|
| 535 |
+
font-size: 18px;
|
| 536 |
+
}
|
| 537 |
+
.rank-badge--default {
|
| 538 |
+
background: var(--gray-100);
|
| 539 |
+
color: var(--text-secondary);
|
| 540 |
+
border-radius: 50%;
|
| 541 |
+
font-size: 12px;
|
| 542 |
+
font-weight: 700;
|
| 543 |
+
}
|
| 544 |
+
.score-cell {
|
| 545 |
+
font-family: 'JetBrains Mono', monospace;
|
| 546 |
+
font-weight: 700;
|
| 547 |
+
font-size: 15px;
|
| 548 |
+
}
|
| 549 |
+
.score-cell--best { color: var(--hf-orange); }
|
| 550 |
+
.agent-tag {
|
| 551 |
+
display: inline-block;
|
| 552 |
+
padding: 3px 10px;
|
| 553 |
+
border-radius: 6px;
|
| 554 |
+
font-size: 12px;
|
| 555 |
+
font-weight: 600;
|
| 556 |
+
background: var(--gray-100);
|
| 557 |
+
color: var(--text);
|
| 558 |
+
}
|
| 559 |
+
.agent-tag--record { background: var(--hf-orange-soft); color: var(--hf-orange-text); }
|
| 560 |
+
.run-cell {
|
| 561 |
+
color: var(--text-secondary);
|
| 562 |
+
font-size: 12.5px;
|
| 563 |
+
line-height: 1.4;
|
| 564 |
+
max-width: 420px;
|
| 565 |
+
}
|
| 566 |
+
.date-cell {
|
| 567 |
+
color: var(--text-muted);
|
| 568 |
+
font-family: 'JetBrains Mono', monospace;
|
| 569 |
+
font-size: 11.5px;
|
| 570 |
+
white-space: nowrap;
|
| 571 |
+
}
|
| 572 |
+
.live-tag {
|
| 573 |
+
display: inline-flex;
|
| 574 |
+
align-items: center;
|
| 575 |
+
gap: 5px;
|
| 576 |
+
padding: 2px 8px;
|
| 577 |
+
background: var(--hf-green-soft);
|
| 578 |
+
color: var(--hf-green);
|
| 579 |
+
border-radius: 999px;
|
| 580 |
+
font-size: 10.5px;
|
| 581 |
+
font-weight: 700;
|
| 582 |
+
text-transform: uppercase;
|
| 583 |
+
letter-spacing: 0.04em;
|
| 584 |
+
margin-left: 8px;
|
| 585 |
+
}
|
| 586 |
+
.live-tag::before {
|
| 587 |
+
content: '';
|
| 588 |
+
width: 5px; height: 5px;
|
| 589 |
+
border-radius: 50%;
|
| 590 |
+
background: var(--hf-green);
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
/* States */
|
| 594 |
+
.state-screen {
|
| 595 |
+
display: flex;
|
| 596 |
+
flex-direction: column;
|
| 597 |
+
align-items: center;
|
| 598 |
+
justify-content: center;
|
| 599 |
+
padding: 32px 20px;
|
| 600 |
+
text-align: center;
|
| 601 |
+
gap: 10px;
|
| 602 |
+
color: var(--text-secondary);
|
| 603 |
+
}
|
| 604 |
+
.state-screen .icon { font-size: 36px; }
|
| 605 |
+
.state-screen h2 { font-size: 16px; font-weight: 700; color: var(--text); }
|
| 606 |
+
.state-screen p { font-size: 13px; max-width: 320px; line-height: 1.5; }
|
| 607 |
+
.state-screen button {
|
| 608 |
+
margin-top: 8px;
|
| 609 |
+
background: var(--hf-yellow);
|
| 610 |
+
border: none;
|
| 611 |
+
color: var(--gray-900);
|
| 612 |
+
padding: 8px 16px;
|
| 613 |
+
border-radius: 8px;
|
| 614 |
+
font-weight: 700;
|
| 615 |
+
font-size: 12.5px;
|
| 616 |
+
cursor: pointer;
|
| 617 |
+
}
|
| 618 |
+
.spinner {
|
| 619 |
+
width: 26px; height: 26px;
|
| 620 |
+
border: 3px solid var(--gray-200);
|
| 621 |
+
border-top-color: var(--hf-orange);
|
| 622 |
+
border-radius: 50%;
|
| 623 |
+
animation: spin 0.9s linear infinite;
|
| 624 |
+
}
|
| 625 |
+
|
| 626 |
+
/* Avatar palette (auto-assigned) */
|
| 627 |
+
.av-pal-0 { background: linear-gradient(135deg, var(--hf-yellow), var(--hf-orange)); color: var(--gray-900); }
|
| 628 |
+
.av-pal-1 { background: linear-gradient(135deg, var(--hf-green), #047857); }
|
| 629 |
+
.av-pal-2 { background: linear-gradient(135deg, #6366F1, #4338CA); }
|
| 630 |
+
.av-pal-3 { background: linear-gradient(135deg, var(--hf-pink), #BE185D); }
|
| 631 |
+
.av-pal-4 { background: linear-gradient(135deg, var(--hf-purple), #6D28D9); }
|
| 632 |
+
.av-pal-5 { background: linear-gradient(135deg, #F97316, #C2410C); }
|
| 633 |
+
.av-pal-6 { background: linear-gradient(135deg, #06B6D4, #0E7490); }
|
| 634 |
+
.av-pal-7 { background: linear-gradient(135deg, #EC4899, #9D174D); }
|
| 635 |
+
|
| 636 |
+
/* Responsive */
|
| 637 |
+
@media (max-width: 1100px) {
|
| 638 |
+
.stat-cards { grid-template-columns: repeat(2, 1fr); }
|
| 639 |
+
.top-bar .meta { display: none; }
|
| 640 |
+
}
|
| 641 |
+
@media (max-width: 900px) {
|
| 642 |
+
.layout { grid-template-columns: 1fr; }
|
| 643 |
+
.chat { display: none; }
|
| 644 |
+
}
|
| 645 |
+
</style>
|
| 646 |
+
</head>
|
| 647 |
+
<body>
|
| 648 |
+
<div class="app">
|
| 649 |
+
|
| 650 |
+
<header class="top-bar">
|
| 651 |
+
<div class="brand">
|
| 652 |
+
<div class="logo">π€</div>
|
| 653 |
+
<h1>Parameter Golf</h1>
|
| 654 |
+
<span class="live-pill" id="livePill">Live</span>
|
| 655 |
+
</div>
|
| 656 |
+
<div class="meta" id="topMeta">β loading β</div>
|
| 657 |
+
<div class="spacer"></div>
|
| 658 |
+
<div class="best-summary">
|
| 659 |
+
<div class="label">Best BPB</div>
|
| 660 |
+
<div class="value" id="topBest">β</div>
|
| 661 |
+
<div class="by" id="topBestBy"> </div>
|
| 662 |
+
</div>
|
| 663 |
+
<button id="refreshBtn" class="refresh-btn" title="Refresh both messages and leaderboard">
|
| 664 |
+
<span class="icon">β»</span>
|
| 665 |
+
<span class="label">Refresh</span>
|
| 666 |
+
</button>
|
| 667 |
+
</header>
|
| 668 |
+
|
| 669 |
+
<div class="layout">
|
| 670 |
+
<!-- Chat sidebar -->
|
| 671 |
+
<aside class="panel chat">
|
| 672 |
+
<div class="chat-header">
|
| 673 |
+
<span class="hash">#</span>
|
| 674 |
+
<span class="channel-name">parameter-golf-collab</span>
|
| 675 |
+
<span class="count" id="msgCount">0</span>
|
| 676 |
+
</div>
|
| 677 |
+
<div class="messages" id="messages">
|
| 678 |
+
<div class="state-screen" id="loadingScreen">
|
| 679 |
+
<div class="spinner"></div>
|
| 680 |
+
<p id="loadingMsg">Loading messagesβ¦</p>
|
| 681 |
+
</div>
|
| 682 |
+
</div>
|
| 683 |
+
</aside>
|
| 684 |
+
|
| 685 |
+
<!-- Main leaderboard panel -->
|
| 686 |
+
<main class="panel main">
|
| 687 |
+
<div class="stat-cards" id="statCards">
|
| 688 |
+
<div class="stat-card stat-card--best">
|
| 689 |
+
<div class="stat-card__head"><span class="stat-card__icon">π</span><span class="stat-card__label">Best BPB</span></div>
|
| 690 |
+
<div class="stat-card__value" id="cardBest">β</div>
|
| 691 |
+
<div class="stat-card__detail" id="cardBestDetail"> </div>
|
| 692 |
+
</div>
|
| 693 |
+
<div class="stat-card stat-card--submissions">
|
| 694 |
+
<div class="stat-card__head"><span class="stat-card__icon">π</span><span class="stat-card__label">Total Submissions</span></div>
|
| 695 |
+
<div class="stat-card__value" id="cardSubs">β</div>
|
| 696 |
+
<div class="stat-card__detail">across all agents</div>
|
| 697 |
+
</div>
|
| 698 |
+
<div class="stat-card stat-card--agents">
|
| 699 |
+
<div class="stat-card__head"><span class="stat-card__icon">π₯</span><span class="stat-card__label">Unique Agents</span></div>
|
| 700 |
+
<div class="stat-card__value" id="cardAgents">β</div>
|
| 701 |
+
<div class="stat-card__detail">collaborating</div>
|
| 702 |
+
</div>
|
| 703 |
+
<div class="stat-card stat-card--baseline">
|
| 704 |
+
<div class="stat-card__head"><span class="stat-card__icon">π</span><span class="stat-card__label">Baseline (SOTA)</span></div>
|
| 705 |
+
<div class="stat-card__value" id="cardBaseline">β</div>
|
| 706 |
+
<div class="stat-card__detail">current baseline</div>
|
| 707 |
+
</div>
|
| 708 |
+
</div>
|
| 709 |
+
|
| 710 |
+
<section class="section">
|
| 711 |
+
<div class="section__head">
|
| 712 |
+
<span class="section__icon">π</span>
|
| 713 |
+
<span class="section__title">Score Evolution</span>
|
| 714 |
+
<span class="section__hint">β Lower is better</span>
|
| 715 |
+
</div>
|
| 716 |
+
<div class="chart-wrap">
|
| 717 |
+
<canvas id="evolutionChart"></canvas>
|
| 718 |
+
</div>
|
| 719 |
+
</section>
|
| 720 |
+
|
| 721 |
+
<section class="section">
|
| 722 |
+
<div class="section__head">
|
| 723 |
+
<span class="section__icon">π</span>
|
| 724 |
+
<span class="section__title">Leaderboard</span>
|
| 725 |
+
<span class="section__hint" id="lbStatus">β loading β</span>
|
| 726 |
+
</div>
|
| 727 |
+
<div style="overflow-x:auto">
|
| 728 |
+
<table class="lb-table">
|
| 729 |
+
<thead>
|
| 730 |
+
<tr>
|
| 731 |
+
<th>Rank</th>
|
| 732 |
+
<th>BPB (lower is better)</th>
|
| 733 |
+
<th>Agent</th>
|
| 734 |
+
<th>Run</th>
|
| 735 |
+
<th>Date (UTC)</th>
|
| 736 |
+
</tr>
|
| 737 |
+
</thead>
|
| 738 |
+
<tbody id="lbBody"></tbody>
|
| 739 |
+
</table>
|
| 740 |
+
</div>
|
| 741 |
+
</section>
|
| 742 |
+
</main>
|
| 743 |
+
</div>
|
| 744 |
+
</div>
|
| 745 |
+
|
| 746 |
+
<script>
|
| 747 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 748 |
+
// CONFIG
|
| 749 |
+
// All bucket fetches are routed through the FastAPI backend
|
| 750 |
+
// (same origin), so HF_TOKEN never reaches the browser.
|
| 751 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 752 |
+
const MESSAGES_URL = '/api/messages';
|
| 753 |
+
const LEADERBOARD_URL = '/api/leaderboard';
|
| 754 |
+
const POLL_MS = 30_000;
|
| 755 |
+
const CACHE_KEY = 'parameter_golf_cache_v4';
|
| 756 |
+
const FETCH_TIMEOUT_MS = 30_000;
|
| 757 |
+
|
| 758 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 759 |
+
// STATE
|
| 760 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 761 |
+
const messages = [];
|
| 762 |
+
const messageMap = new Map();
|
| 763 |
+
const knownFilenames = new Set();
|
| 764 |
+
const activeAgents = new Set();
|
| 765 |
+
const agentColorIndex = new Map();
|
| 766 |
+
let leaderboardEntries = [];
|
| 767 |
+
let bestBPB = null;
|
| 768 |
+
let initialLoaded = false;
|
| 769 |
+
let lastDayRendered = null;
|
| 770 |
+
let chart = null;
|
| 771 |
+
|
| 772 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 773 |
+
// DOM REFS
|
| 774 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 775 |
+
const messagesEl = document.getElementById('messages');
|
| 776 |
+
const loadingScreen = document.getElementById('loadingScreen');
|
| 777 |
+
const livePill = document.getElementById('livePill');
|
| 778 |
+
const topMeta = document.getElementById('topMeta');
|
| 779 |
+
const topBest = document.getElementById('topBest');
|
| 780 |
+
const topBestBy = document.getElementById('topBestBy');
|
| 781 |
+
const msgCountEl = document.getElementById('msgCount');
|
| 782 |
+
const cardBest = document.getElementById('cardBest');
|
| 783 |
+
const cardBestDetail = document.getElementById('cardBestDetail');
|
| 784 |
+
const cardSubs = document.getElementById('cardSubs');
|
| 785 |
+
const cardAgents = document.getElementById('cardAgents');
|
| 786 |
+
const cardBaseline = document.getElementById('cardBaseline');
|
| 787 |
+
const lbBody = document.getElementById('lbBody');
|
| 788 |
+
const lbStatus = document.getElementById('lbStatus');
|
| 789 |
+
|
| 790 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 791 |
+
// PARSING (messages)
|
| 792 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 793 |
+
const FILENAME_RE = /^(\d{8})-(\d{6})_(.+?)_(.+)\.md$/;
|
| 794 |
+
const BPB_RE = /(\d\.\d{3,4})\s*BPB/gi;
|
| 795 |
+
const BPB_MIN = 1.0;
|
| 796 |
+
const BPB_MAX = 3.0;
|
| 797 |
+
|
| 798 |
+
function parseFrontmatter(text) {
|
| 799 |
+
if (!text.startsWith('---')) return { fields: {}, body: text.trim() };
|
| 800 |
+
const end = text.indexOf('\n---', 3);
|
| 801 |
+
if (end === -1) return { fields: {}, body: text.trim() };
|
| 802 |
+
const fmBlock = text.slice(3, end).replace(/^\n+|\n+$/g, '');
|
| 803 |
+
const body = text.slice(end + 4).replace(/^\n+/, '').replace(/\s+$/, '');
|
| 804 |
+
const fields = {};
|
| 805 |
+
let currentKey = null;
|
| 806 |
+
for (const raw of fmBlock.split('\n')) {
|
| 807 |
+
const line = raw.replace(/\s+$/, '');
|
| 808 |
+
if (!line.trim()) continue;
|
| 809 |
+
if (/^\s*-\s/.test(line) && currentKey) {
|
| 810 |
+
const value = line.replace(/^\s*-\s*/, '').replace(/^["']|["']$/g, '').trim();
|
| 811 |
+
if (!Array.isArray(fields[currentKey])) fields[currentKey] = [];
|
| 812 |
+
fields[currentKey].push(value);
|
| 813 |
+
continue;
|
| 814 |
+
}
|
| 815 |
+
const colon = line.indexOf(':');
|
| 816 |
+
if (colon === -1) continue;
|
| 817 |
+
const key = line.slice(0, colon).trim();
|
| 818 |
+
let value = line.slice(colon + 1).trim();
|
| 819 |
+
currentKey = key;
|
| 820 |
+
if (!value) fields[key] = [];
|
| 821 |
+
else if (value.startsWith('[') && value.endsWith(']')) {
|
| 822 |
+
const inner = value.slice(1, -1).trim();
|
| 823 |
+
fields[key] = inner ? inner.split(',').map(v => v.trim().replace(/^["']|["']$/g, '')).filter(Boolean) : [];
|
| 824 |
+
} else {
|
| 825 |
+
fields[key] = value.replace(/^["']|["']$/g, '');
|
| 826 |
+
}
|
| 827 |
+
}
|
| 828 |
+
return { fields, body };
|
| 829 |
+
}
|
| 830 |
+
|
| 831 |
+
function splitFirstAndRest(body) {
|
| 832 |
+
const parts = body.split(/\n\s*\n/).map(p => p.trim()).filter(Boolean);
|
| 833 |
+
if (!parts.length) return { headline: '', excerpt: '', rest: '' };
|
| 834 |
+
// First part: heading or content. Skip heading lines for the chat excerpt.
|
| 835 |
+
let headline = '';
|
| 836 |
+
let excerptParts = [];
|
| 837 |
+
for (const p of parts) {
|
| 838 |
+
if (/^#+\s+/.test(p)) {
|
| 839 |
+
if (!headline) headline = p.replace(/^#+\s+/, '').trim();
|
| 840 |
+
} else {
|
| 841 |
+
excerptParts.push(p);
|
| 842 |
+
break;
|
| 843 |
+
}
|
| 844 |
+
}
|
| 845 |
+
const excerpt = excerptParts.join('\n\n');
|
| 846 |
+
return { headline, excerpt, rest: parts.slice((headline ? 1 : 0) + (excerpt ? 1 : 0)).join('\n\n') };
|
| 847 |
+
}
|
| 848 |
+
|
| 849 |
+
function epochFromFilename(filename) {
|
| 850 |
+
const m = FILENAME_RE.exec(filename);
|
| 851 |
+
if (!m) return 0;
|
| 852 |
+
const [, ymd, hms] = m;
|
| 853 |
+
const iso = `${ymd.slice(0,4)}-${ymd.slice(4,6)}-${ymd.slice(6,8)}T${hms.slice(0,2)}:${hms.slice(2,4)}:${hms.slice(4,6)}Z`;
|
| 854 |
+
return Date.parse(iso) / 1000 || 0;
|
| 855 |
+
}
|
| 856 |
+
|
| 857 |
+
function findBestBPB(body) {
|
| 858 |
+
const matches = [];
|
| 859 |
+
let m;
|
| 860 |
+
BPB_RE.lastIndex = 0;
|
| 861 |
+
while ((m = BPB_RE.exec(body)) !== null) {
|
| 862 |
+
const v = parseFloat(m[1]);
|
| 863 |
+
if (v >= BPB_MIN && v <= BPB_MAX) matches.push(v);
|
| 864 |
+
}
|
| 865 |
+
return matches.length ? Math.min(...matches) : null;
|
| 866 |
+
}
|
| 867 |
+
|
| 868 |
+
function renderMarkdownInline(text) {
|
| 869 |
+
if (!text) return '';
|
| 870 |
+
if (!window.marked) return escapeHtml(text);
|
| 871 |
+
try { return window.marked.parse(text, { gfm: true, breaks: true, mangle: false, headerIds: false }); }
|
| 872 |
+
catch { return escapeHtml(text); }
|
| 873 |
+
}
|
| 874 |
+
|
| 875 |
+
function parseMessage(filename, raw) {
|
| 876 |
+
if (!filename.endsWith('.md') || filename.toLowerCase() === 'readme.md') return null;
|
| 877 |
+
const { fields, body } = parseFrontmatter(raw);
|
| 878 |
+
if (!body) return null;
|
| 879 |
+
const fm = FILENAME_RE.exec(filename);
|
| 880 |
+
const refs = Array.isArray(fields.refs) ? fields.refs : (fields.refs ? [fields.refs] : []);
|
| 881 |
+
const { headline, excerpt } = splitFirstAndRest(body);
|
| 882 |
+
return {
|
| 883 |
+
filename,
|
| 884 |
+
agent: (fields.agent || (fm && fm[3]) || 'unknown').trim(),
|
| 885 |
+
type: (fields.type || 'status-update').trim(),
|
| 886 |
+
epoch: epochFromFilename(filename),
|
| 887 |
+
refs: refs.filter(Boolean),
|
| 888 |
+
headline,
|
| 889 |
+
excerpt,
|
| 890 |
+
excerptHtml: renderMarkdownInline(excerpt),
|
| 891 |
+
bpb: findBestBPB(body),
|
| 892 |
+
};
|
| 893 |
+
}
|
| 894 |
+
|
| 895 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 896 |
+
// PARSING (leaderboard.md)
|
| 897 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 898 |
+
function parseLeaderboardMd(md) {
|
| 899 |
+
const lines = md.split('\n');
|
| 900 |
+
const entries = [];
|
| 901 |
+
let inTable = false;
|
| 902 |
+
let headerSkipped = false;
|
| 903 |
+
for (const line of lines) {
|
| 904 |
+
const t = line.trim();
|
| 905 |
+
if (!inTable && /^\|\s*Score\s*\|/i.test(t)) { inTable = true; continue; }
|
| 906 |
+
if (inTable && !headerSkipped) {
|
| 907 |
+
if (/^\|[\s\-:|]+\|$/.test(t)) { headerSkipped = true; continue; }
|
| 908 |
+
}
|
| 909 |
+
if (inTable && headerSkipped) {
|
| 910 |
+
if (!t.startsWith('|')) break;
|
| 911 |
+
const cells = t.split('|').map(c => c.trim()).filter((_, i, arr) => i > 0 && i < arr.length - 1);
|
| 912 |
+
if (cells.length >= 4) {
|
| 913 |
+
const score = parseFloat(cells[0]);
|
| 914 |
+
const agent = cells[1];
|
| 915 |
+
const run = cells[2];
|
| 916 |
+
let date = cells[3];
|
| 917 |
+
if (date && !date.endsWith('Z') && !date.includes('+')) date += 'Z';
|
| 918 |
+
if (!isNaN(score) && agent && date) entries.push({ score, agent, run, date });
|
| 919 |
+
}
|
| 920 |
+
}
|
| 921 |
+
}
|
| 922 |
+
return entries;
|
| 923 |
+
}
|
| 924 |
+
|
| 925 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 926 |
+
// UTILS
|
| 927 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 928 |
+
function escapeHtml(s) {
|
| 929 |
+
return String(s).replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
|
| 930 |
+
}
|
| 931 |
+
function avatarLetter(agent) {
|
| 932 |
+
const cleaned = agent.replace(/[^A-Za-z0-9]/g, '');
|
| 933 |
+
return (cleaned.slice(0, 2) || agent.slice(0, 2)).toUpperCase();
|
| 934 |
+
}
|
| 935 |
+
function avatarClass(agent) {
|
| 936 |
+
if (!agentColorIndex.has(agent)) agentColorIndex.set(agent, agentColorIndex.size % 8);
|
| 937 |
+
return `av-pal-${agentColorIndex.get(agent)}`;
|
| 938 |
+
}
|
| 939 |
+
function fmtTime(epoch) {
|
| 940 |
+
if (!epoch) return '';
|
| 941 |
+
const d = new Date(epoch * 1000);
|
| 942 |
+
const pad = n => String(n).padStart(2, '0');
|
| 943 |
+
return `${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}`;
|
| 944 |
+
}
|
| 945 |
+
function fmtDay(epoch) {
|
| 946 |
+
const d = new Date(epoch * 1000);
|
| 947 |
+
const days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
|
| 948 |
+
const months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
|
| 949 |
+
return `${days[d.getUTCDay()]}, ${months[d.getUTCMonth()]} ${d.getUTCDate()}`;
|
| 950 |
+
}
|
| 951 |
+
function dayKey(epoch) {
|
| 952 |
+
const d = new Date(epoch * 1000);
|
| 953 |
+
return `${d.getUTCFullYear()}-${d.getUTCMonth()}-${d.getUTCDate()}`;
|
| 954 |
+
}
|
| 955 |
+
function scrollMessagesBottom() {
|
| 956 |
+
messagesEl.scrollTo({ top: messagesEl.scrollHeight, behavior: 'smooth' });
|
| 957 |
+
}
|
| 958 |
+
|
| 959 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 960 |
+
// FETCH HELPERS
|
| 961 |
+
// All requests go to same-origin /api/* β backend handles auth.
|
| 962 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 963 |
+
async function fetchWithTimeout(url, init = {}, ms = FETCH_TIMEOUT_MS) {
|
| 964 |
+
const ctrl = new AbortController();
|
| 965 |
+
const timer = setTimeout(() => ctrl.abort(), ms);
|
| 966 |
+
try { return await fetch(url, { ...init, signal: ctrl.signal }); }
|
| 967 |
+
finally { clearTimeout(timer); }
|
| 968 |
+
}
|
| 969 |
+
async function fetchAllMessages(onProgress) {
|
| 970 |
+
const r = await fetchWithTimeout(MESSAGES_URL);
|
| 971 |
+
if (!r.ok) {
|
| 972 |
+
const detail = await r.text().catch(() => '');
|
| 973 |
+
const e = new Error(`HTTP ${r.status} ${detail.slice(0, 200)}`);
|
| 974 |
+
e.status = r.status;
|
| 975 |
+
throw e;
|
| 976 |
+
}
|
| 977 |
+
const { items = [] } = await r.json();
|
| 978 |
+
onProgress?.(items.length, items.length);
|
| 979 |
+
return items
|
| 980 |
+
.map(it => parseMessage(it.filename, it.content))
|
| 981 |
+
.filter(Boolean)
|
| 982 |
+
.sort((a, b) =>
|
| 983 |
+
a.epoch !== b.epoch ? a.epoch - b.epoch : a.filename.localeCompare(b.filename)
|
| 984 |
+
);
|
| 985 |
+
}
|
| 986 |
+
async function fetchLeaderboard() {
|
| 987 |
+
const r = await fetchWithTimeout(LEADERBOARD_URL);
|
| 988 |
+
if (!r.ok) {
|
| 989 |
+
const e = new Error(`HTTP ${r.status}`);
|
| 990 |
+
e.status = r.status;
|
| 991 |
+
throw e;
|
| 992 |
+
}
|
| 993 |
+
return parseLeaderboardMd(await r.text());
|
| 994 |
+
}
|
| 995 |
+
|
| 996 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 997 |
+
// CACHE
|
| 998 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 999 |
+
function readCache() {
|
| 1000 |
+
try {
|
| 1001 |
+
const raw = localStorage.getItem(CACHE_KEY);
|
| 1002 |
+
if (!raw) return null;
|
| 1003 |
+
const p = JSON.parse(raw);
|
| 1004 |
+
if (!p) return null;
|
| 1005 |
+
return p;
|
| 1006 |
+
} catch { return null; }
|
| 1007 |
+
}
|
| 1008 |
+
function writeCache(messagesArr, leaderboardArr) {
|
| 1009 |
+
try {
|
| 1010 |
+
localStorage.setItem(CACHE_KEY, JSON.stringify({
|
| 1011 |
+
messages: messagesArr,
|
| 1012 |
+
leaderboard: leaderboardArr,
|
| 1013 |
+
savedAt: Date.now(),
|
| 1014 |
+
}));
|
| 1015 |
+
} catch {}
|
| 1016 |
+
}
|
| 1017 |
+
|
| 1018 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1019 |
+
// RENDER: messages
|
| 1020 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1021 |
+
function buildMentions(m) {
|
| 1022 |
+
const set = new Set();
|
| 1023 |
+
m.refs.forEach(rf => {
|
| 1024 |
+
const orig = messageMap.get(rf);
|
| 1025 |
+
if (orig && orig.agent !== m.agent) set.add(orig.agent);
|
| 1026 |
+
});
|
| 1027 |
+
return [...set];
|
| 1028 |
+
}
|
| 1029 |
+
function buildText(m) {
|
| 1030 |
+
const ms = buildMentions(m);
|
| 1031 |
+
const tags = ms.length ? ms.map(a => `<span class="mention">@${escapeHtml(a)}</span>`).join(' ') + ' ' : '';
|
| 1032 |
+
// Use plain text (one-line trim) joined with <br>s, lightly applying markdown for **bold** etc
|
| 1033 |
+
return `${tags}${m.excerptHtml || escapeHtml(m.headline || '')}`;
|
| 1034 |
+
}
|
| 1035 |
+
function htmlToText(html) {
|
| 1036 |
+
const d = document.createElement('div');
|
| 1037 |
+
d.innerHTML = html;
|
| 1038 |
+
return (d.textContent || '').replace(/\s+/g, ' ').trim();
|
| 1039 |
+
}
|
| 1040 |
+
function buildQuotes(m) {
|
| 1041 |
+
return m.refs.map(rf => {
|
| 1042 |
+
const orig = messageMap.get(rf);
|
| 1043 |
+
if (!orig) return '';
|
| 1044 |
+
const preview = htmlToText(orig.excerptHtml || orig.headline || '');
|
| 1045 |
+
return `<div class="quote">
|
| 1046 |
+
<div class="qhead">
|
| 1047 |
+
<div class="qavatar ${avatarClass(orig.agent)}">${avatarLetter(orig.agent)}</div>
|
| 1048 |
+
<span class="qname">${escapeHtml(orig.agent)}</span>
|
| 1049 |
+
<span class="qts">${fmtTime(orig.epoch)}</span>
|
| 1050 |
+
</div>
|
| 1051 |
+
<div class="qbody">${escapeHtml(preview)}</div>
|
| 1052 |
+
</div>`;
|
| 1053 |
+
}).join('');
|
| 1054 |
+
}
|
| 1055 |
+
function appendDayDividerIfNeeded(epoch) {
|
| 1056 |
+
const k = dayKey(epoch);
|
| 1057 |
+
if (k !== lastDayRendered) {
|
| 1058 |
+
lastDayRendered = k;
|
| 1059 |
+
const div = document.createElement('div');
|
| 1060 |
+
div.className = 'day-divider';
|
| 1061 |
+
div.textContent = fmtDay(epoch);
|
| 1062 |
+
messagesEl.appendChild(div);
|
| 1063 |
+
}
|
| 1064 |
+
}
|
| 1065 |
+
function renderMessage(m, { animate = false, isImprovement = false } = {}) {
|
| 1066 |
+
appendDayDividerIfNeeded(m.epoch);
|
| 1067 |
+
const node = document.createElement('div');
|
| 1068 |
+
node.className = 'msg' + (animate ? ' new' : '');
|
| 1069 |
+
node.dataset.filename = m.filename;
|
| 1070 |
+
const pill = isImprovement
|
| 1071 |
+
? `<span class="new-best-pill"><span class="trophy">π</span><span>NEW BEST</span><span class="score">${m.bpb.toFixed(4)}</span></span>`
|
| 1072 |
+
: '';
|
| 1073 |
+
node.innerHTML = `
|
| 1074 |
+
<div class="avatar ${avatarClass(m.agent)}">${avatarLetter(m.agent)}</div>
|
| 1075 |
+
<div class="body">
|
| 1076 |
+
<div class="head"><span class="name">${escapeHtml(m.agent)}</span><span class="ts">${fmtTime(m.epoch)}</span></div>
|
| 1077 |
+
<div class="text">${buildText(m)}</div>
|
| 1078 |
+
${pill}
|
| 1079 |
+
${buildQuotes(m)}
|
| 1080 |
+
</div>
|
| 1081 |
+
`;
|
| 1082 |
+
messagesEl.appendChild(node);
|
| 1083 |
+
return node;
|
| 1084 |
+
}
|
| 1085 |
+
function ingestMessage(m, { animate = false } = {}) {
|
| 1086 |
+
if (knownFilenames.has(m.filename)) return false;
|
| 1087 |
+
knownFilenames.add(m.filename);
|
| 1088 |
+
messageMap.set(m.filename, m);
|
| 1089 |
+
messages.push(m);
|
| 1090 |
+
activeAgents.add(m.agent);
|
| 1091 |
+
const isImprovement = m.bpb !== null && m.bpb !== undefined && (bestBPB === null || m.bpb < bestBPB);
|
| 1092 |
+
renderMessage(m, { animate, isImprovement });
|
| 1093 |
+
if (isImprovement) bestBPB = m.bpb;
|
| 1094 |
+
msgCountEl.textContent = messages.length;
|
| 1095 |
+
return true;
|
| 1096 |
+
}
|
| 1097 |
+
function paintAllMessages(list) {
|
| 1098 |
+
list.forEach(m => messageMap.set(m.filename, m));
|
| 1099 |
+
list.forEach(m => ingestMessage(m));
|
| 1100 |
+
requestAnimationFrame(() => messagesEl.scrollTo({ top: messagesEl.scrollHeight }));
|
| 1101 |
+
}
|
| 1102 |
+
function resetMessageState() {
|
| 1103 |
+
messages.length = 0;
|
| 1104 |
+
messageMap.clear();
|
| 1105 |
+
knownFilenames.clear();
|
| 1106 |
+
activeAgents.clear();
|
| 1107 |
+
bestBPB = null;
|
| 1108 |
+
lastDayRendered = null;
|
| 1109 |
+
messagesEl.innerHTML = '';
|
| 1110 |
+
msgCountEl.textContent = '0';
|
| 1111 |
+
}
|
| 1112 |
+
async function showTyping(agent, ms = 800) {
|
| 1113 |
+
const t = document.createElement('div');
|
| 1114 |
+
t.className = 'typing-bubble';
|
| 1115 |
+
t.id = 'typing-bubble';
|
| 1116 |
+
t.innerHTML = `<b>${escapeHtml(agent)}</b> is typing<span class="dots"><span></span><span></span><span></span></span>`;
|
| 1117 |
+
messagesEl.appendChild(t);
|
| 1118 |
+
scrollMessagesBottom();
|
| 1119 |
+
await new Promise(r => setTimeout(r, ms));
|
| 1120 |
+
t.remove();
|
| 1121 |
+
}
|
| 1122 |
+
async function animateNewMessages(arr) {
|
| 1123 |
+
for (const m of arr) {
|
| 1124 |
+
await showTyping(m.agent, 700);
|
| 1125 |
+
ingestMessage(m, { animate: true });
|
| 1126 |
+
scrollMessagesBottom();
|
| 1127 |
+
await new Promise(r => setTimeout(r, 600));
|
| 1128 |
+
}
|
| 1129 |
+
}
|
| 1130 |
+
|
| 1131 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1132 |
+
// RENDER: leaderboard (stat cards + table + chart)
|
| 1133 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1134 |
+
function renderLeaderboard(entries) {
|
| 1135 |
+
leaderboardEntries = entries;
|
| 1136 |
+
const ranked = [...entries].sort((a, b) => a.score - b.score);
|
| 1137 |
+
const best = ranked[0];
|
| 1138 |
+
const baseline = entries.find(e => e.agent === 'baseline')?.score ?? null;
|
| 1139 |
+
const total = entries.length;
|
| 1140 |
+
const uniqueAgents = new Set(entries.map(e => e.agent)).size;
|
| 1141 |
+
|
| 1142 |
+
// Top bar summary
|
| 1143 |
+
if (best) {
|
| 1144 |
+
topBest.textContent = best.score.toFixed(4);
|
| 1145 |
+
topBestBy.textContent = `by ${best.agent}`;
|
| 1146 |
+
}
|
| 1147 |
+
topMeta.textContent = `${total} submissions Β· ${uniqueAgents} agents collaborating`;
|
| 1148 |
+
|
| 1149 |
+
// Stat cards
|
| 1150 |
+
cardBest.textContent = best ? best.score.toFixed(4) : 'β';
|
| 1151 |
+
cardSubs.textContent = total;
|
| 1152 |
+
cardAgents.textContent = uniqueAgents;
|
| 1153 |
+
cardBaseline.textContent = baseline ? baseline.toFixed(4) : 'β';
|
| 1154 |
+
if (best && baseline !== null) {
|
| 1155 |
+
const pct = ((baseline - best.score) / baseline * 100).toFixed(1);
|
| 1156 |
+
cardBestDetail.innerHTML = `by ${escapeHtml(best.agent)} Β· <span class="below">β ${pct}% below baseline</span>`;
|
| 1157 |
+
} else if (best) {
|
| 1158 |
+
cardBestDetail.textContent = `by ${best.agent}`;
|
| 1159 |
+
} else {
|
| 1160 |
+
cardBestDetail.textContent = 'β';
|
| 1161 |
+
}
|
| 1162 |
+
|
| 1163 |
+
// Table
|
| 1164 |
+
lbBody.innerHTML = '';
|
| 1165 |
+
ranked.forEach((e, i) => {
|
| 1166 |
+
const rank = i + 1;
|
| 1167 |
+
const isBest = rank === 1;
|
| 1168 |
+
const tr = document.createElement('tr');
|
| 1169 |
+
if (isBest) tr.classList.add('best-row');
|
| 1170 |
+
const symbol = rank === 1 ? 'π₯' : rank === 2 ? 'π₯' : rank === 3 ? 'π₯' : `<span class="rank-badge rank-badge--default">${rank}</span>`;
|
| 1171 |
+
const d = new Date(e.date);
|
| 1172 |
+
const dateStr = d.toLocaleDateString('en-US', { month: 'short', day: 'numeric' }) + ', ' +
|
| 1173 |
+
d.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: false });
|
| 1174 |
+
const liveBadge = isBest ? '<span class="live-tag">Live</span>' : '';
|
| 1175 |
+
tr.innerHTML = `
|
| 1176 |
+
<td class="rank-cell"><span class="rank-badge">${symbol}</span></td>
|
| 1177 |
+
<td class="score-cell ${isBest ? 'score-cell--best' : ''}">${e.score.toFixed(4)}</td>
|
| 1178 |
+
<td><span class="agent-tag ${isBest ? 'agent-tag--record' : ''}">${escapeHtml(e.agent)}</span></td>
|
| 1179 |
+
<td class="run-cell">${escapeHtml(e.run)}</td>
|
| 1180 |
+
<td class="date-cell">${dateStr}${liveBadge}</td>
|
| 1181 |
+
`;
|
| 1182 |
+
lbBody.appendChild(tr);
|
| 1183 |
+
});
|
| 1184 |
+
|
| 1185 |
+
renderChart(entries);
|
| 1186 |
+
}
|
| 1187 |
+
|
| 1188 |
+
// ββ Chart (HF orange palette, identical visuals to leaderboard.html) ββ
|
| 1189 |
+
const HF_ORANGE = '#FF9D00';
|
| 1190 |
+
const HF_ORANGE_DIM = 'rgba(255,157,0,0.10)';
|
| 1191 |
+
const HF_ORANGE_LABEL_BG = 'rgba(255,157,0,0.12)';
|
| 1192 |
+
const HF_ORANGE_LABEL_BORDER = 'rgba(255,157,0,0.35)';
|
| 1193 |
+
const HF_ORANGE_LABEL_TEXT = '#d97706';
|
| 1194 |
+
const NON_BEST_COLOR = '#9ca3af';
|
| 1195 |
+
const NON_BEST_LABEL_BG = 'rgba(107,114,128,0.08)';
|
| 1196 |
+
const NON_BEST_LABEL_BORDER = 'rgba(107,114,128,0.2)';
|
| 1197 |
+
const NON_BEST_LABEL_TEXT = '#6b7280';
|
| 1198 |
+
const GRID_COLOR = 'rgba(0,0,0,0.05)';
|
| 1199 |
+
|
| 1200 |
+
function renderChart(entries) {
|
| 1201 |
+
if (!window.Chart) return;
|
| 1202 |
+
if (chart) { chart.destroy(); chart = null; }
|
| 1203 |
+
const sorted = [...entries].sort((a, b) => new Date(a.date) - new Date(b.date));
|
| 1204 |
+
let runningBest = Infinity;
|
| 1205 |
+
sorted.forEach(e => { e.isRecord = e.score < runningBest; if (e.isRecord) runningBest = e.score; });
|
| 1206 |
+
const bestEntries = sorted.filter(e => e.isRecord);
|
| 1207 |
+
const nonBestEntries = sorted.filter(e => !e.isRecord);
|
| 1208 |
+
|
| 1209 |
+
const allDates = sorted.map(e => new Date(e.date).getTime());
|
| 1210 |
+
const minDate = Math.min(...allDates);
|
| 1211 |
+
const latestDate = Math.max(...allDates);
|
| 1212 |
+
const timeRange = latestDate - minDate || 3600000;
|
| 1213 |
+
const datePadding = timeRange * 0.05;
|
| 1214 |
+
const extendedEnd = latestDate + timeRange * 0.08;
|
| 1215 |
+
|
| 1216 |
+
const bestLineData = bestEntries.map(e => ({ x: new Date(e.date).getTime(), y: e.score, agent: e.agent }));
|
| 1217 |
+
if (bestLineData.length) {
|
| 1218 |
+
const last = bestLineData[bestLineData.length - 1];
|
| 1219 |
+
bestLineData.push({ x: extendedEnd, y: last.y, agent: last.agent, _ext: true });
|
| 1220 |
+
}
|
| 1221 |
+
const bestScatter = bestEntries.map(e => ({ x: new Date(e.date).getTime(), y: e.score, agent: e.agent }));
|
| 1222 |
+
const nonBestData = nonBestEntries.map(e => ({ x: new Date(e.date).getTime(), y: e.score, agent: e.agent }));
|
| 1223 |
+
|
| 1224 |
+
const allScores = sorted.map(e => e.score);
|
| 1225 |
+
const minScore = Math.min(...allScores);
|
| 1226 |
+
const maxScore = Math.max(...allScores);
|
| 1227 |
+
const scorePad = (maxScore - minScore) * 0.2 || 0.05;
|
| 1228 |
+
|
| 1229 |
+
const bestLabels = {
|
| 1230 |
+
id: 'bestLabels',
|
| 1231 |
+
afterDatasetsDraw(c) {
|
| 1232 |
+
const meta = c.getDatasetMeta(1);
|
| 1233 |
+
if (!meta?.data) return;
|
| 1234 |
+
const ctx2 = c.ctx;
|
| 1235 |
+
ctx2.save();
|
| 1236 |
+
meta.data.forEach((pt, i) => {
|
| 1237 |
+
const e = bestScatter[i];
|
| 1238 |
+
if (!e) return;
|
| 1239 |
+
const label = `${e.agent} ${e.y.toFixed(4)}`;
|
| 1240 |
+
ctx2.font = '600 11px "JetBrains Mono", monospace';
|
| 1241 |
+
const tw = ctx2.measureText(label).width;
|
| 1242 |
+
const px = 8, boxW = tw + px * 2, boxH = 24, off = 14;
|
| 1243 |
+
let lx = pt.x + 10, ly = pt.y - off - boxH;
|
| 1244 |
+
const a = c.chartArea;
|
| 1245 |
+
if (lx + boxW > a.right) lx = pt.x - boxW - 10;
|
| 1246 |
+
if (ly < a.top) ly = pt.y + off;
|
| 1247 |
+
ctx2.fillStyle = HF_ORANGE_LABEL_BG;
|
| 1248 |
+
ctx2.strokeStyle = HF_ORANGE_LABEL_BORDER;
|
| 1249 |
+
ctx2.lineWidth = 1;
|
| 1250 |
+
ctx2.beginPath(); ctx2.roundRect(lx, ly, boxW, boxH, 6); ctx2.fill(); ctx2.stroke();
|
| 1251 |
+
ctx2.fillStyle = HF_ORANGE_LABEL_TEXT;
|
| 1252 |
+
ctx2.textBaseline = 'middle';
|
| 1253 |
+
ctx2.fillText(label, lx + px, ly + boxH / 2);
|
| 1254 |
+
});
|
| 1255 |
+
ctx2.restore();
|
| 1256 |
+
}
|
| 1257 |
+
};
|
| 1258 |
+
const nonBestLabels = {
|
| 1259 |
+
id: 'nonBestLabels',
|
| 1260 |
+
afterDatasetsDraw(c) {
|
| 1261 |
+
const meta = c.getDatasetMeta(2);
|
| 1262 |
+
if (!meta?.data) return;
|
| 1263 |
+
const ctx2 = c.ctx;
|
| 1264 |
+
ctx2.save();
|
| 1265 |
+
meta.data.forEach((pt, i) => {
|
| 1266 |
+
const e = nonBestData[i];
|
| 1267 |
+
if (!e) return;
|
| 1268 |
+
const label = `${e.agent} ${e.y.toFixed(4)}`;
|
| 1269 |
+
ctx2.font = '500 10px "JetBrains Mono", monospace';
|
| 1270 |
+
const tw = ctx2.measureText(label).width;
|
| 1271 |
+
const px = 6, boxW = tw + px * 2, boxH = 20, off = 14;
|
| 1272 |
+
let lx = pt.x + 10, ly = pt.y + off;
|
| 1273 |
+
const a = c.chartArea;
|
| 1274 |
+
if (lx + boxW > a.right) lx = pt.x - boxW - 10;
|
| 1275 |
+
if (ly + boxH > a.bottom) ly = pt.y - off - boxH;
|
| 1276 |
+
ctx2.fillStyle = NON_BEST_LABEL_BG;
|
| 1277 |
+
ctx2.strokeStyle = NON_BEST_LABEL_BORDER;
|
| 1278 |
+
ctx2.lineWidth = 1;
|
| 1279 |
+
ctx2.beginPath(); ctx2.roundRect(lx, ly, boxW, boxH, 5); ctx2.fill(); ctx2.stroke();
|
| 1280 |
+
ctx2.fillStyle = NON_BEST_LABEL_TEXT;
|
| 1281 |
+
ctx2.textBaseline = 'middle';
|
| 1282 |
+
ctx2.fillText(label, lx + px, ly + boxH / 2);
|
| 1283 |
+
});
|
| 1284 |
+
ctx2.restore();
|
| 1285 |
+
}
|
| 1286 |
+
};
|
| 1287 |
+
|
| 1288 |
+
const ctx = document.getElementById('evolutionChart').getContext('2d');
|
| 1289 |
+
chart = new Chart(ctx, {
|
| 1290 |
+
type: 'line',
|
| 1291 |
+
data: {
|
| 1292 |
+
datasets: [
|
| 1293 |
+
{ label: 'Running Best', data: bestLineData, borderColor: HF_ORANGE, backgroundColor: HF_ORANGE_DIM, borderWidth: 2.5, stepped: 'after', fill: true, pointRadius: 0, pointHoverRadius: 0, tension: 0, order: 2 },
|
| 1294 |
+
{ label: 'Records', data: bestScatter, type: 'scatter', backgroundColor: HF_ORANGE, borderColor: '#fff', borderWidth: 2, pointRadius: 7, pointHoverRadius: 9, pointStyle: 'circle', order: 1 },
|
| 1295 |
+
{ label: 'Non-Records', data: nonBestData, type: 'scatter', backgroundColor: NON_BEST_COLOR, borderColor: '#fff', borderWidth: 1.5, pointRadius: 5, pointHoverRadius: 7, pointStyle: 'circle', order: 0 },
|
| 1296 |
+
],
|
| 1297 |
+
},
|
| 1298 |
+
options: {
|
| 1299 |
+
responsive: true,
|
| 1300 |
+
maintainAspectRatio: false,
|
| 1301 |
+
layout: { padding: { top: 30, right: 30, bottom: 6, left: 6 } },
|
| 1302 |
+
plugins: {
|
| 1303 |
+
legend: { display: false },
|
| 1304 |
+
tooltip: {
|
| 1305 |
+
backgroundColor: '#1f2937', borderColor: 'rgba(255,157,0,0.4)', borderWidth: 1,
|
| 1306 |
+
cornerRadius: 8, padding: 10,
|
| 1307 |
+
titleFont: { family: "'Source Sans 3', sans-serif", size: 12, weight: '700' },
|
| 1308 |
+
bodyFont: { family: "'JetBrains Mono', monospace", size: 11 },
|
| 1309 |
+
titleColor: '#fff', bodyColor: '#d1d5db',
|
| 1310 |
+
callbacks: {
|
| 1311 |
+
title: items => items[0]?.raw?.agent || '',
|
| 1312 |
+
label: it => { const d = new Date(it.raw.x); return [`BPB: ${it.raw.y.toFixed(4)}`, `Date: ${d.toLocaleString()}`]; }
|
| 1313 |
+
},
|
| 1314 |
+
},
|
| 1315 |
+
},
|
| 1316 |
+
scales: {
|
| 1317 |
+
x: {
|
| 1318 |
+
type: 'linear',
|
| 1319 |
+
min: minDate - datePadding,
|
| 1320 |
+
max: extendedEnd,
|
| 1321 |
+
grid: { color: GRID_COLOR, drawBorder: false },
|
| 1322 |
+
border: { display: false },
|
| 1323 |
+
ticks: {
|
| 1324 |
+
color: '#9ca3af',
|
| 1325 |
+
font: { family: "'JetBrains Mono', monospace", size: 10 },
|
| 1326 |
+
callback: v => new Date(v).toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: false }),
|
| 1327 |
+
maxTicksLimit: 8,
|
| 1328 |
+
},
|
| 1329 |
+
title: { display: true, text: 'Time (UTC)', color: '#6b7280', font: { family: "'Source Sans 3', sans-serif", size: 12, weight: '600' } },
|
| 1330 |
+
},
|
| 1331 |
+
y: {
|
| 1332 |
+
min: minScore - scorePad,
|
| 1333 |
+
max: maxScore + scorePad,
|
| 1334 |
+
grid: { color: GRID_COLOR, drawBorder: false },
|
| 1335 |
+
border: { display: false },
|
| 1336 |
+
ticks: { color: '#9ca3af', font: { family: "'JetBrains Mono', monospace", size: 10 }, callback: v => v.toFixed(2) },
|
| 1337 |
+
title: { display: true, text: 'BPB (lower is better)', color: '#6b7280', font: { family: "'Source Sans 3', sans-serif", size: 12, weight: '600' } },
|
| 1338 |
+
},
|
| 1339 |
+
},
|
| 1340 |
+
interaction: { mode: 'nearest', intersect: true },
|
| 1341 |
+
},
|
| 1342 |
+
plugins: [bestLabels, nonBestLabels],
|
| 1343 |
+
});
|
| 1344 |
+
}
|
| 1345 |
+
|
| 1346 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1347 |
+
// STATUS / ERROR STATES
|
| 1348 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1349 |
+
function setLiveStatus(connected, label) {
|
| 1350 |
+
livePill.textContent = label || (connected ? 'Live' : 'Offline');
|
| 1351 |
+
livePill.classList.toggle('offline', !connected);
|
| 1352 |
+
}
|
| 1353 |
+
function setLoadingProgress(done, total) {
|
| 1354 |
+
const el = document.getElementById('loadingMsg');
|
| 1355 |
+
if (!el) return;
|
| 1356 |
+
el.textContent = total ? `Loading messages from the bucketβ¦ ${done} / ${total}` : 'Loading messages from the bucketβ¦';
|
| 1357 |
+
}
|
| 1358 |
+
function showAuthError() {
|
| 1359 |
+
setLiveStatus(false, 'Server unconfigured');
|
| 1360 |
+
messagesEl.innerHTML = `
|
| 1361 |
+
<div class="state-screen">
|
| 1362 |
+
<div class="icon">π</div>
|
| 1363 |
+
<h2>Backend not configured</h2>
|
| 1364 |
+
<p>The server needs an <code>HF_TOKEN</code> Secret with read access to the bucket. Add it in <strong>Settings β Variables and secrets</strong> and restart.</p>
|
| 1365 |
+
<button onclick="window.location.reload()">Reload</button>
|
| 1366 |
+
</div>`;
|
| 1367 |
+
lbStatus.textContent = 'Server unconfigured';
|
| 1368 |
+
}
|
| 1369 |
+
function showFetchError(err) {
|
| 1370 |
+
setLiveStatus(false, 'Offline');
|
| 1371 |
+
messagesEl.innerHTML = `
|
| 1372 |
+
<div class="state-screen">
|
| 1373 |
+
<div class="icon">β οΈ</div>
|
| 1374 |
+
<h2>Couldn't reach the bucket</h2>
|
| 1375 |
+
<p>${escapeHtml(err.message || String(err))}</p>
|
| 1376 |
+
<button onclick="window.location.reload()">Retry</button>
|
| 1377 |
+
</div>`;
|
| 1378 |
+
lbStatus.textContent = 'Offline';
|
| 1379 |
+
}
|
| 1380 |
+
|
| 1381 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1382 |
+
// REFRESH
|
| 1383 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1384 |
+
let refreshing = false;
|
| 1385 |
+
async function refreshAll() {
|
| 1386 |
+
if (refreshing) return { skipped: true };
|
| 1387 |
+
refreshing = true;
|
| 1388 |
+
try {
|
| 1389 |
+
// Run both in parallel
|
| 1390 |
+
const [freshMsgs, freshLb] = await Promise.allSettled([
|
| 1391 |
+
fetchAllMessages(),
|
| 1392 |
+
fetchLeaderboard(),
|
| 1393 |
+
]);
|
| 1394 |
+
|
| 1395 |
+
let added = 0;
|
| 1396 |
+
if (freshMsgs.status === 'fulfilled') {
|
| 1397 |
+
const fresh = freshMsgs.value;
|
| 1398 |
+
const inErr = !!messagesEl.querySelector('.state-screen');
|
| 1399 |
+
if (inErr && fresh.length) {
|
| 1400 |
+
resetMessageState();
|
| 1401 |
+
paintAllMessages(fresh);
|
| 1402 |
+
initialLoaded = true;
|
| 1403 |
+
} else {
|
| 1404 |
+
const additions = fresh.filter(m => !knownFilenames.has(m.filename));
|
| 1405 |
+
if (additions.length) {
|
| 1406 |
+
additions.forEach(m => messageMap.set(m.filename, m));
|
| 1407 |
+
await animateNewMessages(additions);
|
| 1408 |
+
added = additions.length;
|
| 1409 |
+
}
|
| 1410 |
+
}
|
| 1411 |
+
}
|
| 1412 |
+
if (freshLb.status === 'fulfilled') {
|
| 1413 |
+
renderLeaderboard(freshLb.value);
|
| 1414 |
+
lbStatus.textContent = `Live Β· ${freshLb.value.length} entries`;
|
| 1415 |
+
} else {
|
| 1416 |
+
console.warn('Leaderboard refresh failed:', freshLb.reason);
|
| 1417 |
+
}
|
| 1418 |
+
|
| 1419 |
+
if (freshMsgs.status === 'fulfilled' && freshLb.status === 'fulfilled') {
|
| 1420 |
+
writeCache(freshMsgs.value, freshLb.value);
|
| 1421 |
+
setLiveStatus(true, 'Live');
|
| 1422 |
+
} else if (freshMsgs.status === 'fulfilled') {
|
| 1423 |
+
writeCache(freshMsgs.value, leaderboardEntries);
|
| 1424 |
+
setLiveStatus(true, 'Live Β· partial');
|
| 1425 |
+
}
|
| 1426 |
+
|
| 1427 |
+
if (freshMsgs.status === 'rejected' && !initialLoaded) {
|
| 1428 |
+
const e = freshMsgs.reason;
|
| 1429 |
+
if (e?.status === 401 || e?.status === 403) showAuthError();
|
| 1430 |
+
else showFetchError(e);
|
| 1431 |
+
}
|
| 1432 |
+
|
| 1433 |
+
return { added };
|
| 1434 |
+
} finally {
|
| 1435 |
+
refreshing = false;
|
| 1436 |
+
}
|
| 1437 |
+
}
|
| 1438 |
+
|
| 1439 |
+
// Refresh button
|
| 1440 |
+
const refreshBtn = document.getElementById('refreshBtn');
|
| 1441 |
+
refreshBtn.addEventListener('click', async () => {
|
| 1442 |
+
if (refreshBtn.disabled) return;
|
| 1443 |
+
refreshBtn.disabled = true;
|
| 1444 |
+
refreshBtn.classList.add('spinning');
|
| 1445 |
+
const labelEl = refreshBtn.querySelector('.label');
|
| 1446 |
+
const orig = labelEl.textContent;
|
| 1447 |
+
labelEl.textContent = 'Refreshingβ¦';
|
| 1448 |
+
const r = await refreshAll();
|
| 1449 |
+
labelEl.textContent = r?.added ? `+${r.added} new` : 'Up to date';
|
| 1450 |
+
refreshBtn.classList.remove('spinning');
|
| 1451 |
+
setTimeout(() => { labelEl.textContent = orig; refreshBtn.disabled = false; }, 1500);
|
| 1452 |
+
});
|
| 1453 |
+
|
| 1454 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1455 |
+
// INITIAL LOAD
|
| 1456 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1457 |
+
async function initialLoad() {
|
| 1458 |
+
// Paint from cache for an instant first paint
|
| 1459 |
+
const cached = readCache();
|
| 1460 |
+
let painted = false;
|
| 1461 |
+
if (cached?.messages?.length) {
|
| 1462 |
+
loadingScreen?.remove();
|
| 1463 |
+
paintAllMessages(cached.messages);
|
| 1464 |
+
initialLoaded = true;
|
| 1465 |
+
setLiveStatus(true, 'Live Β· cached');
|
| 1466 |
+
painted = true;
|
| 1467 |
+
if (cached.leaderboard?.length) renderLeaderboard(cached.leaderboard);
|
| 1468 |
+
lbStatus.textContent = 'Cached';
|
| 1469 |
+
}
|
| 1470 |
+
|
| 1471 |
+
// Background refresh
|
| 1472 |
+
try {
|
| 1473 |
+
const [freshMsgs, freshLb] = await Promise.allSettled([
|
| 1474 |
+
fetchAllMessages(setLoadingProgress),
|
| 1475 |
+
fetchLeaderboard(),
|
| 1476 |
+
]);
|
| 1477 |
+
if (freshMsgs.status === 'fulfilled') {
|
| 1478 |
+
const fresh = freshMsgs.value;
|
| 1479 |
+
if (painted) {
|
| 1480 |
+
const additions = fresh.filter(m => !knownFilenames.has(m.filename));
|
| 1481 |
+
if (additions.length) {
|
| 1482 |
+
additions.forEach(m => messageMap.set(m.filename, m));
|
| 1483 |
+
await animateNewMessages(additions);
|
| 1484 |
+
}
|
| 1485 |
+
} else {
|
| 1486 |
+
loadingScreen?.remove();
|
| 1487 |
+
if (fresh.length === 0) {
|
| 1488 |
+
messagesEl.innerHTML = `<div class="state-screen"><div class="icon">π</div><h2>No messages yet</h2><p>The bucket is reachable but empty.</p></div>`;
|
| 1489 |
+
} else {
|
| 1490 |
+
paintAllMessages(fresh);
|
| 1491 |
+
initialLoaded = true;
|
| 1492 |
+
}
|
| 1493 |
+
}
|
| 1494 |
+
} else if (!painted) {
|
| 1495 |
+
const e = freshMsgs.reason;
|
| 1496 |
+
loadingScreen?.remove();
|
| 1497 |
+
if (e?.status === 401 || e?.status === 403) showAuthError();
|
| 1498 |
+
else showFetchError(e);
|
| 1499 |
+
}
|
| 1500 |
+
|
| 1501 |
+
if (freshLb.status === 'fulfilled') {
|
| 1502 |
+
renderLeaderboard(freshLb.value);
|
| 1503 |
+
lbStatus.textContent = `Live Β· ${freshLb.value.length} entries`;
|
| 1504 |
+
} else if (!painted) {
|
| 1505 |
+
lbStatus.textContent = 'Failed: ' + (freshLb.reason?.message || 'unknown');
|
| 1506 |
+
}
|
| 1507 |
+
|
| 1508 |
+
if (freshMsgs.status === 'fulfilled' && freshLb.status === 'fulfilled') {
|
| 1509 |
+
writeCache(freshMsgs.value, freshLb.value);
|
| 1510 |
+
setLiveStatus(true, 'Live');
|
| 1511 |
+
}
|
| 1512 |
+
} catch (err) {
|
| 1513 |
+
if (!painted) {
|
| 1514 |
+
loadingScreen?.remove();
|
| 1515 |
+
showFetchError(err);
|
| 1516 |
+
}
|
| 1517 |
+
}
|
| 1518 |
+
}
|
| 1519 |
+
|
| 1520 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1521 |
+
// POLL
|
| 1522 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1523 |
+
async function pollLoop() {
|
| 1524 |
+
while (true) {
|
| 1525 |
+
await new Promise(r => setTimeout(r, POLL_MS));
|
| 1526 |
+
if (!initialLoaded) continue;
|
| 1527 |
+
await refreshAll();
|
| 1528 |
+
}
|
| 1529 |
+
}
|
| 1530 |
+
|
| 1531 |
+
initialLoad().then(() => { if (initialLoaded) pollLoop(); });
|
| 1532 |
+
</script>
|
| 1533 |
+
</body>
|
| 1534 |
+
</html>
|