diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9ab2423d0058b12a6351871bdcf545120ccb4876..976780f2b05595fa56e22514ff56a0dc245c2df6 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,7 @@ { // Runs the whole product in a GitHub Codespace (a cloud machine with 8 GB of memory), so full browser runs work // without a laptop or a paid server. The application starts by itself; open the forwarded port 8800. - "name": "Patch Testing Co-worker (demo)", + "name": "Trio Co-Worker (demo)", "build": { "dockerfile": "../Dockerfile", "context": ".." }, "hostRequirements": { "cpus": 2, "memory": "8gb" }, // root inside this throwaway machine: avoids file-ownership differences between the image and the Codespace @@ -18,7 +18,7 @@ }, "forwardPorts": [8800], "portsAttributes": { - "8800": { "label": "Patch Testing Co-worker", "onAutoForward": "openBrowser" } + "8800": { "label": "Trio Co-Worker", "onAutoForward": "openBrowser" } }, "postStartCommand": "sh .devcontainer/start.sh" } diff --git a/.devcontainer/start.sh b/.devcontainer/start.sh index 9e414baf8bfa757b49351e4a61cfa9cfb718d6e8..300cb14220b3b612df6b22ef1adb657ec362b746 100644 --- a/.devcontainer/start.sh +++ b/.devcontainer/start.sh @@ -27,7 +27,7 @@ else fi echo "" -echo " Patch Testing Co-worker is running." +echo " Trio Co-Worker is running." echo " Open the PORTS tab, then the globe icon next to port 8800." echo " Sign in with user: admin password: $(cat /data/demo-password.txt)" echo "" diff --git a/Dockerfile b/Dockerfile index 3e608568b83990ea80c90767527ec521983675c1..4b1dd9237a2388b40da0966ecdbabe44a1f61cd6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -# Patch Testing Co-worker: one application image (web app + API + workflow worker + test executor + practice pod). +# Trio Co-Worker: one application image (web app + API + workflow worker + test executor + practice pod). # Build from the project root: docker build -t patch-coworker:1.0.0 . # Run with deploy/docker-compose.yml (adds Temporal and an HTTPS proxy). All customer data lives in the /data volume. diff --git a/README.md b/README.md index fd24be49401a91728f03aefdb000bebc4a6a7cc4..f66447d5cecbe7cd00b0414895ae2aedb7026c56 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ --- -title: Patch Testing Co-worker +title: Trio Co-Worker emoji: "đŸ§Ș" colorFrom: indigo colorTo: gray @@ -8,7 +8,9 @@ app_port: 8800 pinned: false --- -# Patch Testing Co-worker +

Trio Co-Worker

+ +# Trio Co-Worker A team of AI agents that checks whether a quarterly Oracle Fusion patch is safe: it researches what the patch changes, chooses test scenarios, runs them in a real browser, analyses failures and produces a Ready / Not ready diff --git a/config/coworker.yaml b/config/coworker.yaml index 3391e64f5e9f82e05b1ff396cbdefd683044f2a2..aa21b79960e2dfe7fec0170d75f166f86e2c6d2a 100644 --- a/config/coworker.yaml +++ b/config/coworker.yaml @@ -1,4 +1,4 @@ -# Fusion Patch Testing co-worker: NON-SECRET configuration (env vars and .env override every key; env wins). +# Trio Co-Worker: NON-SECRET configuration (env vars and .env override every key; env wins). # Secrets never go here: they live in the vault (var/secrets/vault.json or FPT_SECRET_* env). # The only pod in this project is the LOCAL MOCK app (mock-app/, 127.0.0.1:3100). It is not Oracle Fusion. diff --git a/coworker/README.md b/coworker/README.md index e4f0fc735964df292a1d36c1f9a338b341cd38f4..ad8a35cce900338e464f18767bb4e46989cb2757 100644 --- a/coworker/README.md +++ b/coworker/README.md @@ -1,4 +1,4 @@ -# Fusion Patch Testing co-worker (pilot) +# Trio Co-Worker (pilot) > **Mock app, not Oracle Fusion.** The only "pod" is the local mock (`mock-app/`, http://127.0.0.1:3100). No Oracle Fusion > pod, credentials or client data exist in this project. Every report, the web app and the desktop app say so. @@ -24,7 +24,7 @@ fpt.cmd down & rem stop what `up` started ( | `fpt.cmd up` / `down` | Temporal + worker (when `orchestrator: temporal`) + mock (if down) + backend (`/` = app, `/api` = API, `/api/docs` = OpenAPI UI). Builds `web/dist` if missing | | `fpt.cmd web-dev` | Vite dev server on http://127.0.0.1:5173 proxying `/api` to :8800 (start the API with `fpt.cmd api`) | | `fpt.cmd desktop` | Electron app in local mode (spawns the backend on a free port) | -| `fpt.cmd package` | builds `web/dist`, then the NSIS installer `desktop\dist\FPT Co-worker Setup 1.0.0.exe` (unsigned) | +| `fpt.cmd package` | builds `web/dist`, then the NSIS installer `desktop\dist\Trio Co-Worker Setup 1.0.0.exe` (unsigned) | | `fpt.cmd create-user --username U --role viewer\|consultant\|qa_approver\|admin [--password-env VAR \| --password-stdin]` | local user | | `fpt.cmd test` | coworker pytest + coworker selftest + architecture selftest (27) + triage tests (71) | | `fpt.cmd selftest [--live]` | offline end-to-end checks (35); `--live` adds 3 real P2P cases in Chromium against the mock | diff --git a/coworker/__main__.py b/coworker/__main__.py index 493a27bff4904699d71bc0f31c11f6bc2253a770..8a82fc52f27123bfc5e0eae545076f85381f5240 100644 --- a/coworker/__main__.py +++ b/coworker/__main__.py @@ -205,7 +205,7 @@ def cmd_up(a) -> int: if loopback_ok(url + "/api/ready", timeout=2): break time.sleep(0.5) - print(f"\nFusion Patch Testing co-worker is up: {url} (API docs {url}/api/docs)", flush=True) + print(f"\nTrio Co-Worker is up: {url} (API docs {url}/api/docs)", flush=True) if cfg.orchestrator == "temporal": print(f"Temporal Web UI: {cfg.temporal_ui_url} (worker log var/logs/worker.out.log)", flush=True) print("Target: mock app on " + cfg.pod_base_url + " -- MOCK APP, NOT ORACLE FUSION. Ctrl+C or `fpt.cmd down` to stop.", flush=True) @@ -346,16 +346,16 @@ def cmd_state(a) -> int: return 0 if a.action == "restore": if (cfg.home / "fpt.sqlite").exists(): + (cfg.home / statesync.FAILED_MARKER).unlink(missing_ok=True) # a stale marker from an earlier start print(f"{cfg.home} already has data: nothing restored") return 0 # the egress gate needs an audit log; while FPT_HOME is still empty it writes to a throwaway one with tempfile.TemporaryDirectory() as tmp: scratch = build_services(cfg.model_copy(update={"fpt_home": Path(tmp)})) client = sb.Supabase(cfg, scratch.egress, None) - try: - done = statesync.restore(cfg, client) - except sb.SupabaseError as e: - print(f"state restore failed: {e}") + done, err = statesync.restore_at_boot(cfg, client) + if err: + print(f"state restore failed (saving to the bucket is paused until the next start): {err}") return 0 if a.soft else 1 print("state restored from Supabase Storage" if done else "no saved state yet: starting empty") return 0 diff --git a/coworker/api/app.py b/coworker/api/app.py index 2eb5aed66122793ff9a69e6457ffb7c6c94f2bbc..f7ec870730afeef1f533bd8e2748c7cf0c3ca6ae 100644 --- a/coworker/api/app.py +++ b/coworker/api/app.py @@ -15,7 +15,7 @@ from ..graph.services import Services, build_services from ..platform.scheduler import Scheduler from . import errors from .middleware import RequestContext, setup_logging -from .routes import admin, auth, chat, consultant, gates, live, llm, pods, review, runs, screens +from .routes import admin, assistant, auth, chat, consultant, gates, live, llm, pods, review, runs, screens from .runner import RunManager log = logging.getLogger("fpt.api") @@ -73,7 +73,7 @@ def create_app(svc: Services | None = None, cfg: Settings | None = None, *, back if syncer: syncer.stop() - app = FastAPI(title="Fusion Patch Testing Co-worker API", version=VERSION, lifespan=lifespan, + app = FastAPI(title="Trio Co-Worker API", version=VERSION, lifespan=lifespan, description="Pilot backend. Runs ONLY against the local mock app, not Oracle Fusion.", docs_url="/api/docs", redoc_url=None, openapi_url="/api/openapi.json") app.state.svc, app.state.runs, app.state.scheduler, app.state.inline_worker = svc, run_mgr, sched, not background @@ -85,7 +85,7 @@ def create_app(svc: Services | None = None, cfg: Settings | None = None, *, back app.add_middleware(RequestContext) api = APIRouter(prefix="/api") - for r in (auth.router, runs.router, gates.router, review.router, admin.router, pods.router, screens.router, consultant.router, live.router, chat.router, llm.router): + for r in (auth.router, runs.router, gates.router, review.router, admin.router, pods.router, screens.router, consultant.router, live.router, chat.router, assistant.router, llm.router): api.include_router(r) app.include_router(api) diff --git a/coworker/api/routes/admin.py b/coworker/api/routes/admin.py index bc99a4f7b9febf7ab22e0a5f8015e48ff57ed41c..1e21e6dacd5354dc74b7a9d07e95c9f3ab037ae7 100644 --- a/coworker/api/routes/admin.py +++ b/coworker/api/routes/admin.py @@ -43,6 +43,9 @@ def ready(request: Request): syncer = getattr(request.app.state, "syncer", None) body["saved_state"] = {"on": syncer is not None, "last_saved_at": (svc.extra.get("state_last") or {}).get("saved_at"), "ok": syncer.last_error is None if syncer else None} + if syncer is not None: + from ...platform import statesync + body["saved_state"]["paused"] = statesync.restore_failed(svc.cfg.home) # the boot restore failed: not saving, to protect the saved copy if not ok: import json return Response(json.dumps(body), status_code=503, media_type="application/json") @@ -113,6 +116,12 @@ def schedule_create(body: ScheduleIn, request: Request, user: Principal = Depend raise ApiError(422, "VALIDATION", "interval schedules need every_minutes") if body.kind == "daily" and not body.at: raise ApiError(422, "VALIDATION", "daily schedules need at (HH:MM, UTC)") + if body.kind in ("monthly", "quarterly") and not (body.at and body.day): + raise ApiError(422, "VALIDATION", f"{body.kind} schedules need day (1-28) and at (HH:MM, UTC)") + if body.kind == "quarterly" and not body.month: + raise ApiError(422, "VALIDATION", "quarterly schedules need month (the first month of the cycle, 1-12)") + if body.pod_id is not None and not request.app.state.svc.db.one("SELECT id FROM pods WHERE id=?", (body.pod_id,)): + raise ApiError(422, "VALIDATION", "that test environment does not exist") s = request.app.state.scheduler.create(body.model_dump(), user.username) request.app.state.svc.audit.append("schedule.created", actor=user.username, payload=s) return s diff --git a/coworker/api/routes/assistant.py b/coworker/api/routes/assistant.py new file mode 100644 index 0000000000000000000000000000000000000000..d1f500176043ebe475336e7aa8833a564f549157 --- /dev/null +++ b/coworker/api/routes/assistant.py @@ -0,0 +1,50 @@ +"""/api/assistant: "Ask a question" answered by the Hermes assistant (platform/hermes.py), a separate service. + +Off by default (FPT_HERMES_ENABLED): then /ask answers 409 HERMES_OFF and the web app keeps using the built-in chat +(/api/chat). Same permission as the built-in chat ("read"); rate limited per user. Mock app, not Oracle Fusion.""" +from __future__ import annotations + +from fastapi import APIRouter, Depends, Request +from pydantic import BaseModel, ConfigDict, Field + +from ...platform import hermes +from ..auth import Principal, require +from ..errors import ApiError + +router = APIRouter(prefix="/assistant", tags=["assistant"]) + + +class AskIn(BaseModel): + model_config = ConfigDict(extra="forbid") + question: str = Field(min_length=1, max_length=hermes.MAX_QUESTION) + conversation_id: str | None = Field(default=None, max_length=80) + + +class AskOut(BaseModel): + answer: str + conversation_id: str + model: str + + +class AssistantStatus(BaseModel): + enabled: bool + configured: bool + reachable: bool | None = None + + +@router.post("/ask", response_model=AskOut) +def ask(body: AskIn, request: Request, user: Principal = Depends(require("read"))): + """Ask Hermes one question. Pass the returned conversation_id to continue the same conversation. + Errors: 409 HERMES_OFF, 503 HERMES_NOT_CONFIGURED, 502 HERMES_UNREACHABLE / HERMES_KEY_REJECTED / HERMES_ERROR, + 504 HERMES_TIMEOUT, 429 RATE_LIMITED, 404 NOT_FOUND (unknown or someone else's conversation).""" + try: + return hermes.ask(request.app.state.svc, user, body.question, body.conversation_id) + except hermes.HermesError as e: + headers = {"Retry-After": str(e.retry_after)} if e.retry_after else None + raise ApiError(e.status, e.code, e.detail, headers=headers) from e + + +@router.get("/status", response_model=AssistantStatus) +def status(request: Request, user: Principal = Depends(require("read"))): + """Whether the Hermes assistant is on, configured (URL and key present) and reachable (checked at most once a minute).""" + return hermes.status(request.app.state.svc) diff --git a/coworker/api/schemas.py b/coworker/api/schemas.py index 1c37a7ba70a41cd3bc7315f67f45dba6d289e10c..5aa4908de2a784a055923f5e8c3542fb72fd7eb2 100644 --- a/coworker/api/schemas.py +++ b/coworker/api/schemas.py @@ -144,6 +144,7 @@ class PodRow(BaseModel): base_url: str environment: str modules: list[str] + from_server_settings: bool = False # defined by FPT_FUSION_BASE_URL: re-created at every start, cannot be deleted in the app notes: str | None = None enabled: bool is_default: bool @@ -261,9 +262,13 @@ class KillIn(Strict): class ScheduleIn(Strict): - kind: Literal["interval", "daily"] + kind: Literal["interval", "daily", "monthly", "quarterly"] every_minutes: int | None = Field(default=None, ge=1, le=7 * 24 * 60) at: str | None = Field(default=None, pattern=r"^\d{2}:\d{2}$") + day: int | None = Field(default=None, ge=1, le=28) # monthly / quarterly: day of the month (UTC) + month: int | None = Field(default=None, ge=1, le=12) # quarterly: the first month of the cycle (runs again every third month) + pod_id: int | None = None # the test environment to run on (default: the server's default pod) + patch_id: str | None = Field(default=None, max_length=40) # the patch name to record, e.g. 26C or 2026-10 modules: list[str] = Field(default_factory=list) include_p2: bool = False playwright_mode: Literal["live", "stub"] = "live" diff --git a/coworker/config.py b/coworker/config.py index 8ec640a66311cb2a742fac5fb4e58ccc46f533ce..9d58bb16544f4866cccc83ec1049fef6effd0844 100644 --- a/coworker/config.py +++ b/coworker/config.py @@ -37,7 +37,7 @@ class Settings(BaseSettings): web_dist: Path = Field(default=ROOT / "web" / "dist", validation_alias=_alias("fpt_web_dist", "web_dist")) oidc_issuer: str = "" # shown in the menu and on the sign-in page (a reseller or customer can set its own) - product_name: str = Field("Patch Testing Co-worker", validation_alias=_alias("fpt_product_name", "product_name")) + product_name: str = Field("Trio Co-Worker", validation_alias=_alias("fpt_product_name", "product_name")) org_name: str = Field("", validation_alias=_alias("fpt_org_name", "org_name")) # ---- Supabase (optional): identity provider for sign-in / registration, and storage for the encrypted state archive. @@ -126,6 +126,9 @@ class Settings(BaseSettings): ollama_model: str = "llava-phi3:latest" llm_frontier: Literal["off", "stub", "frontier"] = "off" frontier_base_url: str = "" + # With no model settings saved in the app, an https FRONTIER_BASE_URL plus a key in the secrets (FPT_SECRET_FRONTIER_API_KEY) + # switches the external model on at start-up, so a restart or a lost snapshot cannot silently turn the AI off. + frontier_auto: bool = Field(True, validation_alias=_alias("fpt_frontier_auto", "frontier_auto")) frontier_model: str = "mistral-large-2512" frontier_timeout_s: float = Field(120.0, validation_alias=_alias("fpt_frontier_timeout_s", "frontier_timeout_s")) frontier_max_tokens: int = Field(4096, validation_alias=_alias("fpt_frontier_max_tokens", "frontier_max_tokens")) @@ -165,12 +168,27 @@ class Settings(BaseSettings): chat_rate_per_minute: int = 20 chat_action_ttl_s: int = 600 + # Hermes assistant ("Ask a question" answered by the Hermes Agent Space, OpenAI-compatible /v1). Off by default: the + # built-in chat stays in use. The API key is a secret (vault HERMES_API_KEY / env FPT_SECRET_HERMES_API_KEY), never here. + hermes_url: str = Field("", validation_alias=_alias("fpt_hermes_url", "hermes_url")) + hermes_enabled: bool = Field(False, validation_alias=_alias("fpt_hermes_enabled", "hermes_enabled")) + hermes_timeout_s: float = Field(120.0, validation_alias=_alias("fpt_hermes_timeout_s", "hermes_timeout_s")) + hermes_rate_per_minute: int = Field(6, validation_alias=_alias("fpt_hermes_rate_per_minute", "hermes_rate_per_minute")) + + # An Oracle Fusion TEST pod that exists from the environment: created at start-up when the saved data has none, so a + # restart or a lost snapshot never removes it. Its test user comes from the secrets FPT_SECRET_FUSION_USERNAME and + # FPT_SECRET_FUSION_PASSWORD (never from a setting). Unset = pods are managed in the app only. + fusion_base_url: str = Field("", validation_alias=_alias("fpt_fusion_base_url", "fusion_base_url")) + fusion_name: str = Field("Oracle Fusion test pod", validation_alias=_alias("fpt_fusion_name", "fusion_name")) + fusion_environment: str = Field("test", validation_alias=_alias("fpt_fusion_environment", "fusion_environment")) + fusion_modules: list[str] = Field(default_factory=lambda: ["AP"], validation_alias=_alias("fpt_fusion_modules", "fusion_modules")) + patch_watch_enabled: bool = True patch_watch_interval_s: int = 300 patch_watch_autostart: bool = False scheduler_tick_s: int = 30 - @field_validator("research_allowed_domains", "cors_origins", "local_llm_hosts", "live_view_block_modules", mode="before") + @field_validator("research_allowed_domains", "cors_origins", "local_llm_hosts", "live_view_block_modules", "fusion_modules", mode="before") @classmethod def _csv(cls, v): if isinstance(v, str): diff --git a/coworker/graph/nodes/report.py b/coworker/graph/nodes/report.py index d4af59a8013f962701febce74197cb9e6dbc9aad..68b455236dbe10aef0da189ee40dfcbed60698c8 100644 --- a/coworker/graph/nodes/report.py +++ b/coworker/graph/nodes/report.py @@ -13,6 +13,7 @@ from ...adapters.pdf import html_to_pdf from ...config import MOCK_BANNER from ...llm.base import LLMRequest, Sensitivity from ...llm.schemas import ExecSummary +from ...platform import brand from .triage import run_triage STUB_BANNER = "STUB RUN: synthetic results from p2p_graph.py stubs. No browser, no mock-app, no Fusion. Not evidence of anything." @@ -77,11 +78,13 @@ def reporter(state, config, svc) -> dict: bundle = out / "bundle.html" bundle.write_text( "Go/no-go bundle " + _html.escape(m) + "" + + brand.header_html() + f"
{_html.escape(MOCK_BANNER.upper())}
" f"

{_html.escape(m)}: {_html.escape(s['decision'])} (decision source: {_html.escape(report_rule.DECISION_SOURCE)})

" f"

Executive summary

{_html.escape(summary_text)}

Summary route: {resp.route.value}/{_html.escape(resp.model)}


" - + (inner.group(1) if inner else body) + "", encoding="utf-8") + + (inner.group(1) if inner else body) + brand.footer_html(MOCK_BANNER + ".") + "", encoding="utf-8") pdf = html_to_pdf(bundle, out / "go-no-go.pdf") + h.write_text(h.read_text(encoding="utf-8").replace("", "" + brand.header_html(), 1).replace("", brand.footer_html(MOCK_BANNER + ".") + ""), encoding="utf-8") summ = {"run_id": run_id, "module": m, "patch_id": state.get("patch_id"), "source": tri.get("source"), "run_mode": tri.get("run_mode"), "target": MOCK_BANNER, "decision": s["decision"], "decision_source": report_rule.DECISION_SOURCE, diff --git a/coworker/graph/services.py b/coworker/graph/services.py index f490f572d8141c0ba96ad3ae984d15ec6e550468..3b781e9d82feb92a740637cbdd2bb0b0909a406c 100644 --- a/coworker/graph/services.py +++ b/coworker/graph/services.py @@ -119,7 +119,10 @@ def build_services(cfg: Settings | None = None, transport=None, frontier_transpo autonomy, users) # AI model settings saved in the app (Settings > AI models) override the environment, here and in every process from ..platform import llm_settings - if frontier_transport is None and llm_settings.saved(svc): - llm_settings.apply(svc) + if frontier_transport is None: + if llm_settings.saved(svc): + llm_settings.apply(svc) + else: + llm_settings.apply_environment(svc) router.before_call = lambda: llm_settings.sync(svc) return svc diff --git a/coworker/platform/assets/wordmark-horizontal-light.svg b/coworker/platform/assets/wordmark-horizontal-light.svg new file mode 100644 index 0000000000000000000000000000000000000000..433c1baf32f2ba0368b65bda4228a6fac8356b06 --- /dev/null +++ b/coworker/platform/assets/wordmark-horizontal-light.svg @@ -0,0 +1 @@ +Trio Co-Worker diff --git a/coworker/platform/brand.py b/coworker/platform/brand.py new file mode 100644 index 0000000000000000000000000000000000000000..c203ff44fb3445017ad4c40acc5de0e5ea0abb71 --- /dev/null +++ b/coworker/platform/brand.py @@ -0,0 +1,34 @@ +"""The product name and logo for documents (report HTML/PDF, Excel). The web app reads the name from /api/ready (product_name).""" +from __future__ import annotations + +import base64 +import html as _html +from functools import lru_cache +from pathlib import Path + +from ..config import VERSION + +NAME = "Trio Co-Worker" +LEGAL = "Trio Co-Worker is independent software. Oracle and Fusion are trademarks of Oracle Corporation." +_WORDMARK = Path(__file__).with_name("assets") / "wordmark-horizontal-light.svg" + + +@lru_cache(maxsize=1) +def wordmark_data_uri() -> str: + """The horizontal wordmark as a data URI, so a report stays one self-contained file. Empty when the asset is missing.""" + try: + return "data:image/svg+xml;base64," + base64.b64encode(_WORDMARK.read_bytes()).decode("ascii") + except OSError: + return "" + + +def header_html() -> str: + uri = wordmark_data_uri() + logo = f"{NAME}" if uri else f"{NAME}" + return f"
{logo}
" + + +def footer_html(note: str = "") -> str: + extra = f" {_html.escape(note)}" if note else "" + return (f"

" + f"Generated by {NAME} v{_html.escape(VERSION)}.{extra} {_html.escape(LEGAL)}

") diff --git a/coworker/platform/egress.py b/coworker/platform/egress.py index f1c25c4179daaa0fb0b6e1c84c104419e11cc535..c056ad897aab3a70299ee72b77a38c1b2b743ab5 100644 --- a/coworker/platform/egress.py +++ b/coworker/platform/egress.py @@ -5,6 +5,7 @@ from __future__ import annotations import ipaddress import json +import re from dataclasses import dataclass, field from typing import Any, Literal from urllib.parse import urlparse @@ -22,6 +23,14 @@ class NotConfigured(RuntimeError): pass +class ServiceTimeout(RuntimeError): + """An external service did not answer in time (raised instead of httpx's exception).""" + + +class ServiceUnreachable(RuntimeError): + """An external service could not be reached: DNS, connection or TLS failure.""" + + @dataclass class FetchedDoc: url: str @@ -157,6 +166,44 @@ class EgressGate: self._log_resp(kind, url.split("?", 1)[0], r, None) return r + # ------------------------------------------------------------ Hermes assistant (OpenAI-compatible /v1 API) + def hermes_request(self, method: Literal["GET", "POST"], path: str, *, key: str, json_body: dict | None = None, + session_id: str | None = None, log_body: Any = None, timeout: float = 120.0) -> httpx.Response: + """One call to the configured Hermes Agent (Settings.hermes_url). https only, that host only, /v1/ paths only, + no redirects. The bearer key goes in a header and is never logged; `log_body` is what the audit records (the + caller passes a digest of the question, never its text). A body that contains a vault secret is refused. + Network failures surface as ServiceTimeout / ServiceUnreachable (callers never import httpx).""" + self.kill.check("egress.hermes") + base = re.sub(r"/v1/?$", "", (self.cfg.hermes_url or "").strip().rstrip("/")) + url = base + "/" + path.lstrip("/") + b, u = urlparse(base), urlparse(url) + if b.scheme != "https" or u.scheme != "https": + self._deny("hermes", "https is required for the Hermes assistant", url, None) + if not b.hostname or (u.scheme, u.hostname, u.port) != (b.scheme, b.hostname, b.port): + self._deny("hermes", f"host {u.hostname} is not the configured Hermes host {b.hostname}", url, None) + if method not in ("GET", "POST") or not u.path.startswith((b.path or "") + "/v1/") or ".." in u.path: + self._deny("hermes", f"{method} {u.path} is outside the Hermes /v1 API", url, None) + if json_body is not None and self.vault is not None: + self.redactor.add_secrets(self.vault.secret_values()) + if any(l["kind"] == "secret" for l in self.redactor.find_leaks(json_body)): + self._deny("hermes", "refused: the message contains a stored secret", url, None) + clean = url.split("?", 1)[0] + self._log_req("hermes", method, clean, log_body, None, {"session": session_id}) + headers = {"Authorization": f"Bearer {key}", "Accept": "application/json"} + if session_id: + headers["X-Hermes-Session-Id"] = session_id + try: + with self._client(timeout=timeout) as c: + r = c.request(method, url, json=json_body, headers=headers) + except httpx.TimeoutException as e: + self.audit.append("egress.hermes.error", actor="system", summary=f"timeout {clean}", payload={"error": type(e).__name__}) + raise ServiceTimeout(f"no answer from Hermes within {timeout:.0f} s") from None + except httpx.HTTPError as e: + self.audit.append("egress.hermes.error", actor="system", summary=f"unreachable {clean}", payload={"error": type(e).__name__}) + raise ServiceUnreachable(f"Hermes could not be reached ({type(e).__name__})") from None + self._log_resp("hermes", clean, r, None) + return r + # ------------------------------------------------------------ public web (research) def web_fetch(self, url: str, *, run_id: str | None = None, max_bytes: int = 2_000_000) -> FetchedDoc: self.kill.check("egress.web") diff --git a/coworker/platform/hermes.py b/coworker/platform/hermes.py new file mode 100644 index 0000000000000000000000000000000000000000..f7bc8d2c1445b8b2b7d43c45c4e7a6016647ce69 --- /dev/null +++ b/coworker/platform/hermes.py @@ -0,0 +1,169 @@ +"""Hermes assistant: "Ask a question" answered by the Hermes Agent (Nous Research) on its own Space. + +Hermes reads the app through its own limited service account (deploy/hermes); this module only forwards the person's +question to Hermes' OpenAI-compatible API (POST {hermes_url}/v1/chat/completions) and returns the answer. + +- Off unless Settings.hermes_enabled (FPT_HERMES_ENABLED). Then the built-in chat stays in use and ask() answers + 409 HERMES_OFF. +- The bearer key is a secret: vault HERMES_API_KEY (env FPT_SECRET_HERMES_API_KEY), never a setting. +- A conversation continues across turns through Hermes' X-Hermes-Session-Id header (history is kept by Hermes). The + id is ours: "fpt-u-", so a person can only continue their own conversations. +- Every call goes through the egress gate (https, the Hermes host only, audited without the key and without the + question text: only its length and sha256).""" +from __future__ import annotations + +import hashlib +import re +import secrets +import threading +import time + +from .egress import EgressDenied, ServiceTimeout, ServiceUnreachable +from .killswitch import KillSwitchEngaged + +MAX_QUESTION = 2000 +MODEL = "hermes-agent" +STATUS_TTL_S = 60.0 +SESSION_RE = re.compile(r"^fpt-u(\d+)-[0-9a-f]{16}$") + +_rate_lock = threading.Lock() +_rate: dict[int, list[float]] = {} +_status_lock = threading.Lock() +_status_cache: dict[str, tuple[float, bool]] = {} + + +class HermesError(Exception): + def __init__(self, status: int, code: str, detail: str, retry_after: int | None = None): + super().__init__(detail) + self.status, self.code, self.detail, self.retry_after = status, code, detail, retry_after + + +def api_key(svc) -> str | None: + return (svc.vault.get("HERMES_API_KEY") if svc.vault else None) or None + + +def configured(svc) -> bool: + return bool((svc.cfg.hermes_url or "").strip()) and bool(api_key(svc)) + + +def reset_caches() -> None: + """Tests: forget rate-limit hits and the cached reachability.""" + with _rate_lock: + _rate.clear() + with _status_lock: + _status_cache.clear() + + +def check_rate(svc, user) -> None: + """Sliding one-minute window per user (Settings.hermes_rate_per_minute).""" + limit, now = max(1, int(svc.cfg.hermes_rate_per_minute)), time.time() + with _rate_lock: + hits = [t for t in _rate.get(user.id, []) if now - t < 60] + if len(hits) >= limit: + _rate[user.id] = hits + raise HermesError(429, "RATE_LIMITED", f"Too many questions: at most {limit} per minute. Please wait a moment.", + retry_after=int(60 - (now - hits[0])) + 1) + hits.append(now) + _rate[user.id] = hits + + +def _ready(svc) -> str: + """The key, or a clear HermesError when Hermes is off or not configured.""" + if not svc.cfg.hermes_enabled: + raise HermesError(409, "HERMES_OFF", "The Hermes assistant is turned off here; use the built-in chat.") + if not (svc.cfg.hermes_url or "").strip(): + raise HermesError(503, "HERMES_NOT_CONFIGURED", "The Hermes assistant is not configured: FPT_HERMES_URL is not set.") + key = api_key(svc) + if not key: + raise HermesError(503, "HERMES_NOT_CONFIGURED", + "The Hermes assistant is not configured: the secret HERMES_API_KEY (FPT_SECRET_HERMES_API_KEY) is not set.") + return key + + +def _call(svc, method: str, path: str, *, key: str, body: dict | None = None, session_id: str | None = None, + log_body=None, timeout: float): + try: + return svc.egress.hermes_request(method, path, key=key, json_body=body, session_id=session_id, log_body=log_body, + timeout=timeout) + except ServiceTimeout as e: + raise HermesError(504, "HERMES_TIMEOUT", f"Hermes did not answer in time ({timeout:.0f} s). Please try again.") from e + except ServiceUnreachable as e: + raise HermesError(502, "HERMES_UNREACHABLE", f"{e}. The Hermes Space may be starting or asleep; try again shortly.") from e + except KillSwitchEngaged as e: + raise HermesError(503, "KILL_SWITCH", "The kill switch is engaged: no outside calls are made.") from e + except EgressDenied as e: + raise HermesError(503, "HERMES_REFUSED", str(e)) from e + + +def _hermes_message(r) -> str: + try: + err = r.json().get("error") or {} + msg = err.get("message") if isinstance(err, dict) else str(err) + except (ValueError, AttributeError): + msg = "" + return (msg or r.text or "")[:200] + + +def ask(svc, user, question: str, conversation_id: str | None = None) -> dict: + """Ask Hermes one question. Returns {answer, conversation_id, model}; raises HermesError with a clear code.""" + key = _ready(svc) + q = (question or "").strip() + if not q or len(q) > MAX_QUESTION: + raise HermesError(422, "BAD_TEXT", f"A question needs 1 to {MAX_QUESTION} characters.") + if conversation_id: + m = SESSION_RE.match(conversation_id) + if not m or int(m.group(1)) != user.id: # someone else's conversation looks exactly like a missing one + raise HermesError(404, "NOT_FOUND", "conversation not found") + cid = conversation_id + else: + cid = f"fpt-u{user.id}-{secrets.token_hex(8)}" + check_rate(svc, user) + digest = {"question_sha256": hashlib.sha256(q.encode("utf-8")).hexdigest(), "question_chars": len(q), + "conversation": cid, "user": user.username} + body = {"model": MODEL, "messages": [{"role": "user", "content": q}], "stream": False} + r = _call(svc, "POST", "/v1/chat/completions", key=key, body=body, session_id=cid, log_body=digest, + timeout=float(svc.cfg.hermes_timeout_s or 120)) + if r.status_code in (401, 403): + _remember(svc, False) + raise HermesError(502, "HERMES_KEY_REJECTED", + "Hermes refused the API key: HERMES_API_KEY here must equal API_SERVER_KEY on the Hermes Space.") + if r.status_code == 429: + raise HermesError(503, "HERMES_BUSY", "Hermes is busy right now. Please try again in a minute.") + if r.status_code != 200: + raise HermesError(502, "HERMES_ERROR", f"Hermes answered {r.status_code}: {_hermes_message(r)}".rstrip(": ")) + try: + data = r.json() + answer = (data["choices"][0]["message"].get("content") or "").strip() + except (ValueError, KeyError, IndexError, TypeError, AttributeError) as e: + raise HermesError(502, "HERMES_ERROR", "Hermes sent an answer this app could not read.") from e + if not answer: + raise HermesError(502, "HERMES_EMPTY", "Hermes returned an empty answer. Please rephrase or try again.") + _remember(svc, True) + svc.audit.append("assistant.asked", actor=user.username, summary="hermes", + payload={**digest, "answer_chars": len(answer), "model": data.get("model")}) + return {"answer": answer, "conversation_id": cid, "model": data.get("model") or MODEL} + + +def _remember(svc, ok: bool) -> None: + with _status_lock: + _status_cache[(svc.cfg.hermes_url or "").strip()] = (time.time(), ok) + + +def status(svc) -> dict: + """{enabled, configured, reachable}. reachable is None unless enabled and configured; then it is whether GET + /v1/models answered 200 with our key, cached for STATUS_TTL_S (a real question also refreshes it).""" + enabled, conf = bool(svc.cfg.hermes_enabled), configured(svc) + if not (enabled and conf): + return {"enabled": enabled, "configured": conf, "reachable": None} + url = (svc.cfg.hermes_url or "").strip() + with _status_lock: + hit = _status_cache.get(url) + if hit and time.time() - hit[0] < STATUS_TTL_S: + return {"enabled": True, "configured": True, "reachable": hit[1]} + try: + r = _call(svc, "GET", "/v1/models", key=api_key(svc) or "", log_body={"probe": "status"}, timeout=10.0) + ok = r.status_code == 200 + except HermesError: + ok = False + _remember(svc, ok) + return {"enabled": True, "configured": True, "reachable": ok} diff --git a/coworker/platform/llm_settings.py b/coworker/platform/llm_settings.py index c3fb7c90ebbaad3c24a8dd351f8d47b441379cd0..5cb9b13b407b670ce1fe1ba2f124f70f17251a1a 100644 --- a/coworker/platform/llm_settings.py +++ b/coworker/platform/llm_settings.py @@ -78,6 +78,19 @@ def apply(svc, values: dict | None = None) -> None: svc.extra["llm_settings_version"] = svc.db.kv_get(KV_VERSION) or 0 +def apply_environment(svc) -> bool: + """Nothing saved in the app and the environment names an external model with its key: use it. Returns True when it did. + Anything saved in the app (even "off") wins, so an administrator's choice is never overridden.""" + cfg = svc.cfg + if saved(svc) or not cfg.frontier_auto or cfg.llm_frontier != "off": + return False + base = (cfg.frontier_base_url or "").strip() + if not base.lower().startswith("https://") or not (cfg.frontier_model or "").strip() or not svc.vault.get(VAULT_KEY): + return False + apply(svc, {"llm_frontier": "frontier", "frontier_base_url": base.rstrip("/")}) + return True + + def sync(svc) -> None: """Cheap check before a model call: re-apply if another process saved new settings.""" if (svc.db.kv_get(KV_VERSION) or 0) != svc.extra.get("llm_settings_version", 0): diff --git a/coworker/platform/migrations/008_schedule_cadence.sql b/coworker/platform/migrations/008_schedule_cadence.sql new file mode 100644 index 0000000000000000000000000000000000000000..1800137093eab0498a9bfd2e6c24391577e18d3e --- /dev/null +++ b/coworker/platform/migrations/008_schedule_cadence.sql @@ -0,0 +1,5 @@ +-- 008: monthly and quarterly schedules, and a schedule can name the pod and patch it tests +ALTER TABLE schedules ADD COLUMN day INTEGER; +ALTER TABLE schedules ADD COLUMN month INTEGER; +ALTER TABLE schedules ADD COLUMN pod_id INTEGER; +ALTER TABLE schedules ADD COLUMN patch_id TEXT; diff --git a/coworker/platform/patchcycle.py b/coworker/platform/patchcycle.py new file mode 100644 index 0000000000000000000000000000000000000000..77c7984bab0609d44e28cf3b383ac3dd9d6e82b5 --- /dev/null +++ b/coworker/platform/patchcycle.py @@ -0,0 +1,26 @@ +"""Patch cycles: Oracle Fusion ships a quarterly update (named by year and quarter letter: 25D, 26A, 26B, 26C) and monthly +updates between them. The patch name on a test run is free text; this module only reads it, so the app can say which +cadence a patch belongs to and sort patches by how recently they were tested. web/src/runName.ts has the same rules.""" +from __future__ import annotations + +import re + +QUARTERLY = re.compile(r"^(\d{2})\s*-?\s*([A-D])$", re.I) # 26C +MONTHLY = re.compile(r"^(?:(20\d{2})[-/.](0[1-9]|1[0-2])|(\d{2})([A-D])[-_ ]?(?:M|MONTHLY)[-_ ]?(\d{1,2}))$", re.I) # 2026-10, 26C-M2 + + +def classify(patch_id: str | None) -> dict: + """{"patch_id", "cadence": quarterly|monthly|other|none, "label"}""" + p = (patch_id or "").strip() + if not p: + return {"patch_id": "", "cadence": "none", "label": "No patch name"} + m = QUARTERLY.match(p) + if m: + q = m.group(2).upper() + return {"patch_id": p, "cadence": "quarterly", "label": f"{m.group(1)}{q} quarterly update"} + m = MONTHLY.match(p) + if m: + if m.group(1): + return {"patch_id": p, "cadence": "monthly", "label": f"{m.group(1)}-{m.group(2)} monthly update"} + return {"patch_id": p, "cadence": "monthly", "label": f"{m.group(3)}{m.group(4).upper()} monthly update {m.group(5)}"} + return {"patch_id": p, "cadence": "other", "label": p} diff --git a/coworker/platform/pods.py b/coworker/platform/pods.py index eea5406fcce8ec0aa7d0c07c80451edab60c35d3..487ce34d7fe4c960df311c4dd4dd558370516d35 100644 --- a/coworker/platform/pods.py +++ b/coworker/platform/pods.py @@ -8,11 +8,13 @@ credential was set (module, by whom, when), never its value.""" from __future__ import annotations import json +import logging import re from urllib.parse import urlparse from .rundb import now_iso +log = logging.getLogger("fpt.pods") ENVIRONMENTS = ("test", "uat", "dev", "sit") _PROD_HOST = re.compile(r"(^|[.-])prod(uction)?([.-]|\d|$)", re.I) @@ -50,6 +52,7 @@ class PodRegistry: def __init__(self, db, vault, cfg, egress, audit): self.db, self.vault, self.cfg, self.egress, self.audit = db, vault, cfg, egress, audit self.ensure_default() + self.ensure_from_env() # ------------------------------------------------------------ records def ensure_default(self) -> None: @@ -60,11 +63,49 @@ class PodRegistry: "notes": "The local mock app every pilot run targets. Not Oracle Fusion.", "created_by": "system", "created_at": now_iso(), "updated_at": now_iso()}) + def env_auth(self) -> tuple[str, str] | None: + """The test user of the pod defined by the environment (secrets FUSION_USERNAME / FUSION_PASSWORD), if both are set.""" + u, p = self.vault.get("FUSION_USERNAME"), self.vault.get("FUSION_PASSWORD") + return (u, p) if u and p else None + + def is_env_pod(self, r: dict) -> bool: + url = (self.cfg.fusion_base_url or "").strip() + return bool(url) and r["kind"] == "fusion" and norm_url(r["base_url"]) == norm_url(url) + + def ensure_from_env(self) -> None: + """FPT_FUSION_BASE_URL: make sure that Fusion test pod is registered (matched by address, so a pod the person already + registered or restored is kept as it is) and that it has a test user when the secrets hold one. Idempotent.""" + url = (self.cfg.fusion_base_url or "").strip() + if not url: + return + try: + base = validate("fusion", url, self.cfg.fusion_environment) + except PodError as e: + log.warning("FPT_FUSION_BASE_URL ignored: %s", e) + return + row = self.db.one("SELECT id FROM pods WHERE kind='fusion' AND base_url=?", (base,)) + if row: + pid = row["id"] + else: + name = self.cfg.fusion_name.strip() or "Oracle Fusion test pod" + if self.db.one("SELECT id FROM pods WHERE name=?", (name,)): + name = f"{name} ({urlparse(base).hostname})" + pid = self.db.insert("pods", {"name": name, "kind": "fusion", "base_url": base, "environment": self.cfg.fusion_environment, + "modules": [m.upper() for m in self.cfg.fusion_modules], "enabled": 1, "is_default": 0, + "notes": "Created from the server settings (FPT_FUSION_BASE_URL), so it survives a restart.", + "created_by": "system", "created_at": now_iso(), "updated_at": now_iso()}) + self.audit.append("pod.created", actor="system", summary=f"{name} (fusion, {self.cfg.fusion_environment}) {base} from the server settings", + payload={"pod_id": pid, "kind": "fusion", "base_url": base, "environment": self.cfg.fusion_environment}) + if self.env_auth() and not self.db.one("SELECT 1 AS x FROM pod_credentials WHERE pod_id=?", (pid,)): + # the user and password stay in the secrets; this row only records that the pod has a test user + self.db.x("INSERT OR REPLACE INTO pod_credentials (pod_id, module, set_by, set_at) VALUES (?,?,?,?)", (pid, "ALL", "system", now_iso())) + self.audit.append("pod.credential_set", actor="system", summary=f"pod {pid} ALL (from the server secrets)", payload={"pod_id": pid, "module": "ALL"}) + def _row(self, r: dict) -> dict: creds = self.db.q("SELECT module, set_by, set_at FROM pod_credentials WHERE pod_id=? ORDER BY module", (r["id"],)) mods = r["modules"] if isinstance(r["modules"], list) else json.loads(r["modules"] or "[]") runnable, why = self.runnable(r) - return {**r, "modules": mods, "enabled": bool(r["enabled"]), "is_default": bool(r["is_default"]), + return {**r, "modules": mods, "from_server_settings": self.is_env_pod(r), "enabled": bool(r["enabled"]), "is_default": bool(r["is_default"]), "last_check_ok": None if r["last_check_ok"] is None else bool(r["last_check_ok"]), "credentials": creds, "runnable": runnable, "not_runnable_reason": why} @@ -108,6 +149,8 @@ class PodRegistry: changes = {k: v for k, v in data.items() if v is not None} if cur["is_default"] and any(k in changes and changes[k] != cur[k] for k in ("kind", "base_url", "environment")): raise PodError("DEFAULT_LOCKED", "the default mock pod's kind, URL and environment come from the server configuration") + if cur["from_server_settings"] and any(k in changes and changes[k] != cur[k] for k in ("kind", "base_url", "environment")): + raise PodError("FROM_SETTINGS", "this pod's kind, address and environment come from the server settings (FPT_FUSION_BASE_URL)") merged = {**cur, **changes} base = validate(merged["kind"], merged["base_url"], merged["environment"]) self.db.update("pods", "id", pod_id, name=merged["name"], kind=merged["kind"], base_url=base, environment=merged["environment"], @@ -120,6 +163,9 @@ class PodRegistry: cur = self.get(pod_id) if cur["is_default"]: raise PodError("DEFAULT_LOCKED", "the default mock pod cannot be deleted") + if cur["from_server_settings"]: + raise PodError("FROM_SETTINGS", "this pod comes from the server settings (FPT_FUSION_BASE_URL) and would be created again at the next start. " + "Disable it instead, or remove that setting to remove the pod.", 409) self.db.x("DELETE FROM pod_credentials WHERE pod_id=?", (pod_id,)) self.db.x("DELETE FROM pods WHERE id=?", (pod_id,)) self.audit.append("pod.deleted", actor=actor, summary=cur["name"], payload={"pod_id": pod_id}) @@ -134,7 +180,11 @@ class PodRegistry: return self.get(pod_id) def fusion_auth(self, pod_id: int) -> tuple[str, str] | None: - """The test user of a Fusion pod, from the vault: the Payables credential if set, else the first one.""" + """The test user of a Fusion pod: the server secrets for the pod defined in the environment, else from the vault + (the Payables credential if set, else the first one).""" + pod = self.db.one("SELECT * FROM pods WHERE id=?", (pod_id,)) + if pod and self.is_env_pod(pod) and self.env_auth(): + return self.env_auth() rows = self.db.q("SELECT module FROM pod_credentials WHERE pod_id=? ORDER BY CASE WHEN module IN ('AP','PAYABLES','ALL') THEN 0 ELSE 1 END, module", (pod_id,)) for r in rows: raw = self.vault.get(f"pods.{pod_id}.{r['module'].lower()}") diff --git a/coworker/platform/readiness.py b/coworker/platform/readiness.py index 4e8dddae0aa6f34bbc70e94b3fdd5724f37c4317..826c08b851b25aac95a2d57f4cb1c5c9ebcbf791 100644 --- a/coworker/platform/readiness.py +++ b/coworker/platform/readiness.py @@ -406,8 +406,10 @@ def readiness(svc, runs_mgr, pod_id: int | None, patch_id: str | None, modules: st = runs_mgr.state(r["run_id"]) if r else None gate = runs_mgr.gate_payload(r["run_id"]) if r and r.get("pending_gate") else None out.append(module_readiness(m, r, st, gate)) - patches = sorted({r.get("patch_id") for r in latest_runs(svc, pod_id, None) if r.get("patch_id")}, reverse=True) - return {"pod_id": pod_id, "patch_id": patch_id, "patches": patches, "modules": out, + # newest test run first: "the latest patch" is the one tested most recently, whatever its name (26C, 2026-10, ...) + patches = list(dict.fromkeys(r["patch_id"] for r in latest_runs(svc, pod_id, None) if r.get("patch_id"))) + from .patchcycle import classify + return {"pod_id": pod_id, "patch_id": patch_id, "patches": patches, "patch_cycles": [classify(p) for p in patches], "modules": out, "legend": {"failing": "Failing", "gap": "No coverage (gap)", "not_tested": "Affected, not yet tested", "passed": "Affected and passed", "not_affected": "Not affected by the patch"}, "target": "Mock app, not Oracle Fusion"} diff --git a/coworker/platform/scheduler.py b/coworker/platform/scheduler.py index 339f9bd184fb716021075ac460ec241a6a5bf03c..67b57c8fdaabcdafe51517a20b8cad2b8324bdd3 100644 --- a/coworker/platform/scheduler.py +++ b/coworker/platform/scheduler.py @@ -18,10 +18,45 @@ def _parse(ts: str | None) -> datetime | None: return datetime.fromisoformat(ts) +def run_inputs(s: dict) -> dict: + """What a due schedule hands to the run manager (shared by the in-process scheduler and the Temporal activity).""" + out = {"modules": s["modules"], "include_p2": bool(s["include_p2"]), "playwright_mode": s["playwright_mode"]} + if s.get("pod_id"): + out["pod_id"] = s["pod_id"] + if s.get("patch_id"): + out["patch_id"] = s["patch_id"] + return out + + +def months_of(s: dict) -> list[int]: + """Calendar months a monthly (every month) or quarterly (every third month, from `month`) schedule runs in.""" + if s["kind"] == "monthly": + return list(range(1, 13)) + first = int(s.get("month") or 1) + return sorted({(first - 1 + 3 * i) % 12 + 1 for i in range(4)}) + + +def cron_of(s: dict) -> str: + hh, mm = (str(s.get("at") or "02:00").split(":") + ["0"])[:2] + if s["kind"] in ("monthly", "quarterly"): + months = "*" if s["kind"] == "monthly" else ",".join(str(m) for m in months_of(s)) + return f"{int(mm)} {int(hh)} {int(s.get('day') or 1)} {months} *" + return f"{int(mm)} {int(hh)} * * *" + + def next_run(s: dict, after: datetime) -> datetime: if s["kind"] == "interval": return after + timedelta(minutes=max(1, int(s.get("every_minutes") or 60))) hh, mm = (str(s.get("at") or "02:00").split(":") + ["0"])[:2] + if s["kind"] in ("monthly", "quarterly"): # day 1-28 of the chosen months, at the given UTC time + day, months = min(28, max(1, int(s.get("day") or 1))), months_of(s) + y, m = after.year, after.month + for _ in range(25): + cand = after.replace(year=y, month=m, day=day, hour=int(hh), minute=int(mm), second=0, microsecond=0) + if m in months and cand > after: + return cand + y, m = (y + 1, 1) if m == 12 else (y, m + 1) + raise ValueError("no next run found") cand = after.replace(hour=int(hh), minute=int(mm), second=0, microsecond=0) return cand if cand > after else cand + timedelta(days=1) @@ -79,8 +114,7 @@ class Scheduler: self.svc.db.update("schedules", "id", s["id"], next_run_at=next_run(s, now).isoformat(timespec="seconds")) continue if due <= now: - rid = self.runs.start({"modules": s["modules"], "include_p2": bool(s["include_p2"]), - "playwright_mode": s["playwright_mode"]}, actor=f"schedule:{s['id']}", trigger="schedule") + rid = self.runs.start(run_inputs(s), actor=f"schedule:{s['id']}", trigger="schedule") out["started"].append(rid) self.svc.db.update("schedules", "id", s["id"], next_run_at=next_run(s, now).isoformat(timespec="seconds")) pw = self.patch_watch() @@ -115,7 +149,8 @@ class Scheduler: def create(self, rec: dict, actor: str) -> dict: row = {"kind": rec["kind"], "every_minutes": rec.get("every_minutes"), "at": rec.get("at"), "modules": rec.get("modules") or [], "include_p2": int(bool(rec.get("include_p2"))), "playwright_mode": rec.get("playwright_mode") or "live", - "enabled": int(rec.get("enabled", True)), "created_by": actor, "created_at": now_iso()} + "enabled": int(rec.get("enabled", True)), "created_by": actor, "created_at": now_iso(), + "day": rec.get("day"), "month": rec.get("month"), "pod_id": rec.get("pod_id"), "patch_id": (rec.get("patch_id") or None)} row["next_run_at"] = next_run(row, datetime.now(timezone.utc)).isoformat(timespec="seconds") sid = self.svc.db.insert("schedules", row) return self.get(sid) # type: ignore[return-value] diff --git a/coworker/platform/statesync.py b/coworker/platform/statesync.py index e971de31e99e1a918b3a91dd043d66c63750ee0a..e9cd269b5ea080cfd1ff398f1b45b409674cac01 100644 --- a/coworker/platform/statesync.py +++ b/coworker/platform/statesync.py @@ -28,6 +28,8 @@ from .rundb import now_iso log = logging.getLogger("fpt.statesync") OBJECT, META = "state/latest.bin", "state/meta.json" +PREVIOUS = "state/previous.bin" # the archive that was in the bucket when this process made its first save +FAILED_MARKER = ".state-restore-failed" # written at boot when the saved state could not be read; blocks saving DATABASES = ("fpt.sqlite", "checkpoints.sqlite") FOLDERS = ("secrets", "runs", "evidence", "tickets") MAX_BYTES = 45 * 1024 * 1024 # Supabase's free plan rejects objects above 50 MB @@ -89,9 +91,19 @@ def build_archive(home: Path, include_evidence: bool = True) -> bytes: return buf.getvalue() +def restore_failed(home: Path | str) -> bool: + return (Path(home) / FAILED_MARKER).exists() + + def push(svc, reason: str = "changed") -> dict: client = sb.of(svc) home = svc.cfg.home + if restore_failed(home): + # Starting empty because the saved state could not be read must never replace that saved state with nothing. + raise sb.SupabaseError("STATE_RESTORE_FAILED", "saving is paused: the saved state could not be read when this instance started. " + "Restart the instance to try again.", 503) + if "state_signature" not in svc.extra: + _keep_previous(client) data = build_archive(home) note = "" if len(data) > MAX_BYTES: @@ -107,6 +119,40 @@ def push(svc, reason: str = "changed") -> dict: return meta +def _keep_previous(client: sb.Supabase) -> None: + """First save of this process: keep a copy of what the bucket holds now, so one bad save can always be undone by hand + (copy state/previous.bin back over state/latest.bin). Best effort: a failure here never stops the save.""" + try: + old = client.download(OBJECT) + if old: + client.ensure_bucket() + client.upload(PREVIOUS, old) + except Exception as e: # noqa: BLE001 + log.warning("could not keep the previous state archive: %s", e) + + +def restore_at_boot(cfg, client: sb.Supabase, attempts: int = 4, wait_s: float = 3.0, sleep=None) -> tuple[bool, str | None]: + """The start-up restore: retries a few times (the network may not be up yet) and, when the saved state still cannot be + read, writes FAILED_MARKER so this instance (which then starts empty) does not overwrite the saved state. + Returns (restored, error). 'No saved state yet' is not an error.""" + import time + sleep = sleep or time.sleep + home = Path(cfg.home) + (home / FAILED_MARKER).unlink(missing_ok=True) # a marker from an earlier start on a persistent disk is stale + err = "" + for i in range(max(1, attempts)): + try: + return restore(cfg, client), None + except Exception as e: # noqa: BLE001 - network, storage and key problems all end the same way + err = f"{type(e).__name__}: {str(e)[:200]}" + log.warning("state restore attempt %d failed: %s", i + 1, err) + if i + 1 < attempts: + sleep(wait_s * (i + 1)) + home.mkdir(parents=True, exist_ok=True) + (home / FAILED_MARKER).write_text(err, encoding="utf-8") + return False, err + + def restore(svc_or_cfg, client: sb.Supabase | None = None, force: bool = False) -> bool: """Download and unpack the archive when this instance has no data yet. Returns True when data was restored.""" cfg = getattr(svc_or_cfg, "cfg", svc_or_cfg) diff --git a/coworker/platform/test_script.py b/coworker/platform/test_script.py index e00a11a9d2cfdaa42370ddbaae12cf52b37004f2..973daa44da074f2eadf0f80ebb20a16e2e3ffaf7 100644 --- a/coworker/platform/test_script.py +++ b/coworker/platform/test_script.py @@ -54,6 +54,7 @@ def build(run: dict, scenarios: list[dict], failures: list[dict], *, area_names: # business order: by area, then the process flow (Requisition before Purchase order...), then scenario id scenarios = sorted(scenarios, key=lambda x: (x.get("module") or "", order.get(x.get("step") or "", 999), x.get("step") or "~", x["id"])) wb = Workbook() + wb.properties.creator = "Trio Co-Worker" # ---- Read me ws = wb.active @@ -62,7 +63,7 @@ def build(run: dict, scenarios: list[dict], failures: list[dict], *, area_names: ws.column_dimensions["B"].width = 96 areas = sorted({s.get("module") or "" for s in scenarios}) rows = [ - ("Test script", "Patch testing co-worker"), + ("Test script", "Trio Co-Worker"), ("Test run", run.get("run_id")), ("Test environment", (run.get("inputs") or {}).get("pod_name") if isinstance(run.get("inputs"), dict) else None), ("Patch", run.get("patch_id") or "the release the pod reports"), diff --git a/coworker/tests/test_brand.py b/coworker/tests/test_brand.py new file mode 100644 index 0000000000000000000000000000000000000000..c59c57bf78ab0b50c9aa52ba5451cee59313fd5f --- /dev/null +++ b/coworker/tests/test_brand.py @@ -0,0 +1,33 @@ +"""The product is "Trio Co-Worker": default name, API docs title, and the report header and footer.""" +from __future__ import annotations + +import unittest + +from coworker.config import Settings, VERSION +from coworker.platform import brand + + +class TestBrand(unittest.TestCase): + def test_default_product_name(self): + self.assertEqual(Settings().product_name, "Trio Co-Worker") + + def test_report_header_has_the_wordmark_as_a_data_uri(self): + h = brand.header_html() + self.assertIn("data:image/svg+xml;base64,", h) # one self-contained file: no external logo request + self.assertIn("alt='Trio Co-Worker'", h) + + def test_report_footer_names_the_product_version_and_the_legal_line(self): + f = brand.footer_html("Mock app, not Oracle Fusion.") + self.assertIn(f"Generated by Trio Co-Worker v{VERSION}", f) + self.assertIn("Mock app, not Oracle Fusion.", f) + self.assertIn("Oracle and Fusion are trademarks of Oracle Corporation", f) + + def test_the_api_docs_carry_the_name(self): + import json + from coworker.config import ROOT + spec = json.loads((ROOT / "web" / "src" / "api" / "openapi.json").read_text(encoding="utf-8")) + self.assertEqual(spec["info"]["title"], "Trio Co-Worker API") + + +if __name__ == "__main__": + unittest.main() diff --git a/coworker/tests/test_cadence.py b/coworker/tests/test_cadence.py new file mode 100644 index 0000000000000000000000000000000000000000..ea4639af9fa2e4e9c054f83faf9de7e6b1d95fa8 --- /dev/null +++ b/coworker/tests/test_cadence.py @@ -0,0 +1,80 @@ +"""Monthly and quarterly patch cycles: patch names are read as cycles, schedules can repeat monthly or quarterly on a chosen +pod and patch, and the newest tested patch is the 'latest' one whatever its name.""" +from __future__ import annotations + +import unittest +from datetime import datetime, timezone + +from coworker.platform import scheduler as S +from coworker.platform.patchcycle import classify +from coworker.tests.fakes import bearer, make_app + + +def utc(y, m, d, hh=0, mm=0): + return datetime(y, m, d, hh, mm, tzinfo=timezone.utc) + + +class TestPatchCycle(unittest.TestCase): + def test_names_are_read_as_quarterly_or_monthly(self): + self.assertEqual(classify("26C")["cadence"], "quarterly") + self.assertEqual(classify("26c")["label"], "26C quarterly update") + self.assertEqual(classify("2026-10")["cadence"], "monthly") + self.assertEqual(classify("26C-M2")["label"], "26C monthly update 2") + self.assertEqual(classify("hotfix 7")["cadence"], "other") + self.assertEqual(classify(None)["cadence"], "none") + self.assertEqual(classify("2026-13")["cadence"], "other") + + +class TestSchedules(unittest.TestCase): + def test_monthly_next_run_and_cron(self): + s = {"kind": "monthly", "day": 5, "at": "02:30"} + self.assertEqual(S.next_run(s, utc(2026, 10, 24)), utc(2026, 11, 5, 2, 30)) + self.assertEqual(S.next_run(s, utc(2026, 10, 3)), utc(2026, 10, 5, 2, 30)) + self.assertEqual(S.next_run(s, utc(2026, 12, 20)), utc(2027, 1, 5, 2, 30)) + self.assertEqual(S.cron_of(s), "30 2 5 * *") + + def test_quarterly_runs_every_third_month_from_the_first(self): + s = {"kind": "quarterly", "day": 10, "at": "03:00", "month": 2} + self.assertEqual(S.months_of(s), [2, 5, 8, 11]) + self.assertEqual(S.next_run(s, utc(2026, 10, 24)), utc(2026, 11, 10, 3)) + self.assertEqual(S.next_run(s, utc(2026, 11, 11)), utc(2027, 2, 10, 3)) + self.assertEqual(S.cron_of(s), "0 3 10 2,5,8,11 *") + self.assertEqual(S.months_of({"kind": "quarterly", "month": 12}), [3, 6, 9, 12]) + + def test_api_validates_and_a_due_schedule_starts_a_run_on_its_pod_and_patch(self): + app, c, svc, _ = make_app() + h = bearer(c, "admin") + for body in ({"kind": "monthly", "playwright_mode": "stub"}, {"kind": "quarterly", "day": 3, "at": "02:00", "playwright_mode": "stub"}, + {"kind": "monthly", "day": 3, "at": "02:00", "pod_id": 999, "playwright_mode": "stub"}): + self.assertEqual(c.post("/api/schedules", json=body, headers=h).status_code, 422, body) + pod = [p for p in c.get("/api/pods", headers=h).json() if p["is_default"]][0] + r = c.post("/api/schedules", json={"kind": "quarterly", "day": 3, "at": "02:00", "month": 2, "modules": ["P2P"], "playwright_mode": "stub", + "pod_id": pod["id"], "patch_id": "26C"}, headers=h) + self.assertEqual(r.status_code, 201, r.text) + s = r.json() + self.assertEqual((s["kind"], s["day"], s["month"], s["pod_id"], s["patch_id"]), ("quarterly", 3, 2, pod["id"], "26C")) + self.assertGreater(S._parse(s["next_run_at"]), datetime.now(timezone.utc)) + svc.db.update("schedules", "id", s["id"], next_run_at="2000-01-01T00:00:00+00:00") + out = app.state.scheduler.tick(datetime.now(timezone.utc)) + self.assertEqual(len(out["started"]), 1) + run = c.get(f"/api/runs/{out['started'][0]}", headers=h).json() + self.assertEqual((run["patch_id"], run["pod_id"], run["trigger"]), ("26C", pod["id"], "schedule")) + app.state.runs.cancel(out["started"][0], "test") + + def test_readiness_lists_the_most_recently_tested_patch_first_with_its_cycle(self): + app, c, svc, _ = make_app() + h = bearer(c, "consultant") + ids = [] + for patch in ("26C", "2026-10", "26B"): + r = c.post("/api/runs", json={"modules": ["P2P"], "playwright_mode": "stub", "patch_id": patch}, headers=h) + self.assertEqual(r.status_code, 202, r.text) + ids.append(r.json()["run_id"]) + for rid in ids: + app.state.runs.cancel(rid, "test") + d = c.get("/api/readiness", headers=h).json() + self.assertEqual(d["patches"], ["26B", "2026-10", "26C"]) + self.assertEqual([x["cadence"] for x in d["patch_cycles"]], ["quarterly", "monthly", "quarterly"]) + + +if __name__ == "__main__": + unittest.main() diff --git a/coworker/tests/test_consultant.py b/coworker/tests/test_consultant.py index de3a4ff4ab54982ad6a27906e1d168cc9ee7d940..c7138c5ee387a4cc2627bfb4289fc5eb6dbcc921 100644 --- a/coworker/tests/test_consultant.py +++ b/coworker/tests/test_consultant.py @@ -109,6 +109,8 @@ class TestConsultantApi(unittest.TestCase): self.assertEqual(wb.sheetnames, ["Read me", "Test script", "Scenarios"]) readme = " ".join(str(c.value) for row in wb["Read me"].iter_rows() for c in row if c.value) self.assertIn("not Oracle Fusion", readme) + self.assertIn("Trio Co-Worker", readme) # the product name, not the earlier one + self.assertEqual(wb.properties.creator, "Trio Co-Worker") ts = wb["Test script"] head = [c.value for c in ts[1]] self.assertEqual(head[:4] + head[8:11] + head[14:], ["Scenario ID", "Business area", "Process step", "Scenario", "Step", "Action", diff --git a/coworker/tests/test_hermes.py b/coworker/tests/test_hermes.py new file mode 100644 index 0000000000000000000000000000000000000000..26d59e4c264f572a7d410cffae53ee611af0e13c --- /dev/null +++ b/coworker/tests/test_hermes.py @@ -0,0 +1,227 @@ +"""Hermes assistant (/api/assistant) against a simulated Hermes API server (no network). + +Off -> 409 HERMES_OFF; on without a key -> a clear error; on with Hermes -> an answer and a continuing conversation; +the key and the question text never reach the audit log; the egress gate keeps to the configured host (https only); +timeouts, unreachable hosts and a wrong key give clear errors.""" +from __future__ import annotations + +import json +import os +import unittest + +import httpx + +from coworker.graph.services import build_services +from coworker.platform import hermes +from coworker.platform.egress import EgressDenied +from coworker.tests.fakes import PASSWORD, ROLES, FakePod, bearer, temp_settings + +URL = "https://hermes.example.hf.space" +KEY = "hermes-test-KEY-0123456789abcdef-do-not-leak" +QUESTION = "Which payables scenarios failed in the last run?" + + +class FakeHermes: + """Just enough of Hermes' OpenAI-compatible API server: bearer key, /v1/models, /v1/chat/completions with + X-Hermes-Session-Id continuity.""" + + def __init__(self, key: str = KEY, mode: str = "ok"): + self.key, self.mode, self.seen, self.sessions = key, mode, [], {} + + def handler(self, req: httpx.Request) -> httpx.Response: + self.seen.append(req) + if self.mode == "timeout": + raise httpx.ReadTimeout("timed out", request=req) + if self.mode == "down": + raise httpx.ConnectError("connection refused", request=req) + if req.headers.get("authorization") != f"Bearer {self.key}": + return httpx.Response(401, json={"error": {"message": "Invalid API key", "type": "invalid_request_error"}}) + if req.url.path == "/v1/models": + return httpx.Response(200, json={"object": "list", "data": [{"id": "hermes-agent", "object": "model"}]}) + if req.url.path == "/v1/chat/completions" and req.method == "POST": + body = json.loads(req.content) + sid = req.headers.get("x-hermes-session-id", "derived") + turns = self.sessions.setdefault(sid, []) + turns.append(body["messages"][-1]["content"]) + answer = f"Answer {len(turns)} for session {sid}" + return httpx.Response(200, headers={"X-Hermes-Session-Id": sid}, json={ + "id": "chatcmpl-1", "object": "chat.completion", "model": "hermes-agent", + "choices": [{"index": 0, "message": {"role": "assistant", "content": answer}, "finish_reason": "stop"}]}) + return httpx.Response(404, json={"error": {"message": "not found"}}) + + +def make(fake: FakeHermes | None, *, key: str | None = KEY, **over): + from fastapi.testclient import TestClient + + from coworker.api.app import create_app + pod = FakePod() + + def route(req: httpx.Request) -> httpx.Response: + if fake is not None and req.url.host == "hermes.example.hf.space": + return fake.handler(req) + return pod.handler(req) + if key: + os.environ["FPT_SECRET_HERMES_API_KEY"] = key + else: + os.environ.pop("FPT_SECRET_HERMES_API_KEY", None) + cfg = temp_settings(**{"hermes_url": URL, "hermes_enabled": True, **over}) + svc = build_services(cfg, transport=httpx.MockTransport(route)) + for r in ROLES: + svc.users.create(r, PASSWORD, r, created_by="test") + app = create_app(svc, background=False) + return TestClient(app), svc + + +class TestHermesAssistant(unittest.TestCase): + def setUp(self): + hermes.reset_caches() + + def tearDown(self): + os.environ.pop("FPT_SECRET_HERMES_API_KEY", None) + hermes.reset_caches() + + def test_off_answers_409_and_makes_no_call(self): + fake = FakeHermes() + c, _ = make(fake, hermes_enabled=False) + h = bearer(c, "viewer") + r = c.post("/api/assistant/ask", json={"question": QUESTION}, headers=h) + self.assertEqual(r.status_code, 409, r.text) + self.assertEqual(r.json()["code"], "HERMES_OFF") + self.assertEqual(c.get("/api/assistant/status", headers=h).json(), {"enabled": False, "configured": True, "reachable": None}) + self.assertEqual(fake.seen, []) + + def test_on_without_key_is_a_clear_error(self): + fake = FakeHermes() + c, _ = make(fake, key=None) + h = bearer(c, "viewer") + r = c.post("/api/assistant/ask", json={"question": QUESTION}, headers=h) + self.assertEqual(r.status_code, 503) + self.assertEqual(r.json()["code"], "HERMES_NOT_CONFIGURED") + self.assertIn("HERMES_API_KEY", r.json()["detail"]) + self.assertEqual(c.get("/api/assistant/status", headers=h).json(), {"enabled": True, "configured": False, "reachable": None}) + self.assertEqual(fake.seen, []) + + def test_on_without_url_is_a_clear_error(self): + c, _ = make(FakeHermes(), hermes_url="") + r = c.post("/api/assistant/ask", json={"question": QUESTION}, headers=bearer(c, "viewer")) + self.assertEqual((r.status_code, r.json()["code"]), (503, "HERMES_NOT_CONFIGURED")) + self.assertIn("FPT_HERMES_URL", r.json()["detail"]) + + def test_answer_and_conversation_continues(self): + fake = FakeHermes() + c, _ = make(fake) + h = bearer(c, "viewer") + r = c.post("/api/assistant/ask", json={"question": QUESTION}, headers=h) + self.assertEqual(r.status_code, 200, r.text) + d = r.json() + self.assertEqual(d["model"], "hermes-agent") + cid = d["conversation_id"] + self.assertRegex(cid, r"^fpt-u\d+-[0-9a-f]{16}$") + self.assertEqual(d["answer"], f"Answer 1 for session {cid}") + req = fake.seen[-1] + self.assertEqual(req.url.path, "/v1/chat/completions") + self.assertEqual(req.headers["x-hermes-session-id"], cid) + sent = json.loads(req.content) + self.assertEqual(sent["messages"], [{"role": "user", "content": QUESTION}]) + self.assertFalse(sent["stream"]) + r2 = c.post("/api/assistant/ask", json={"question": "And why?", "conversation_id": cid}, headers=h) + self.assertEqual(r2.json()["answer"], f"Answer 2 for session {cid}") + self.assertEqual(c.get("/api/assistant/status", headers=h).json(), {"enabled": True, "configured": True, "reachable": True}) + + def test_someone_elses_conversation_is_not_found(self): + fake = FakeHermes() + c, _ = make(fake) + cid = c.post("/api/assistant/ask", json={"question": QUESTION}, headers=bearer(c, "viewer")).json()["conversation_id"] + n = len(fake.seen) + for other in (cid, "fpt-u1-zzzz", "../../etc"): + r = c.post("/api/assistant/ask", json={"question": QUESTION, "conversation_id": other}, headers=bearer(c, "consultant")) + self.assertEqual(r.status_code, 404, other) + self.assertEqual(len(fake.seen), n) + + def test_key_and_question_never_in_audit(self): + fake = FakeHermes() + c, svc = make(fake) + self.assertEqual(c.post("/api/assistant/ask", json={"question": QUESTION}, headers=bearer(c, "viewer")).status_code, 200) + c.post("/api/assistant/ask", json={"question": QUESTION}, headers={**bearer(c, "viewer")}) + rows = svc.db.q("SELECT kind, summary, payload FROM audit_log") + blob = json.dumps(rows) + self.assertNotIn(KEY, blob) + self.assertNotIn(QUESTION, blob) + self.assertNotIn("Answer 1", blob) + kinds = {r["kind"] for r in rows} + self.assertTrue({"egress.hermes.request", "egress.hermes.response", "assistant.asked"} <= kinds, kinds) + + def test_host_lock_and_https_only(self): + _, svc = make(FakeHermes()) + with self.assertRaises(EgressDenied): + svc.egress.hermes_request("GET", "https://evil.example.com/v1/models", key=KEY) + with self.assertRaises(EgressDenied): + svc.egress.hermes_request("GET", "/api/config", key=KEY) # only the /v1 API + svc.cfg.hermes_url = "http://hermes.example.hf.space" + with self.assertRaises(EgressDenied): + svc.egress.hermes_request("GET", "/v1/models", key=KEY) + svc.cfg.hermes_url = URL + "/v1" # a trailing /v1 is tolerated + self.assertEqual(svc.egress.hermes_request("GET", "/v1/models", key=KEY).status_code, 200) + + def test_http_url_gives_a_clear_error(self): + fake = FakeHermes() + c, _ = make(fake, hermes_url="http://hermes.example.hf.space") + r = c.post("/api/assistant/ask", json={"question": QUESTION}, headers=bearer(c, "viewer")) + self.assertEqual((r.status_code, r.json()["code"]), (503, "HERMES_REFUSED")) + self.assertIn("https", r.json()["detail"]) + self.assertEqual(fake.seen, []) + + def test_secret_in_question_is_refused(self): + fake = FakeHermes() + c, _ = make(fake) + r = c.post("/api/assistant/ask", json={"question": f"is {KEY} right?"}, headers=bearer(c, "viewer")) + self.assertEqual((r.status_code, r.json()["code"]), (503, "HERMES_REFUSED")) + self.assertEqual(fake.seen, []) + + def test_timeout_unreachable_and_wrong_key(self): + c, _ = make(FakeHermes(mode="timeout")) + r = c.post("/api/assistant/ask", json={"question": QUESTION}, headers=bearer(c, "viewer")) + self.assertEqual((r.status_code, r.json()["code"]), (504, "HERMES_TIMEOUT")) + hermes.reset_caches() + c, _ = make(FakeHermes(mode="down")) + h = bearer(c, "viewer") + r = c.post("/api/assistant/ask", json={"question": QUESTION}, headers=h) + self.assertEqual((r.status_code, r.json()["code"]), (502, "HERMES_UNREACHABLE")) + self.assertFalse(c.get("/api/assistant/status", headers=h).json()["reachable"]) + hermes.reset_caches() + c, _ = make(FakeHermes(key="another-key-entirely-0123456789")) + h = bearer(c, "viewer") + r = c.post("/api/assistant/ask", json={"question": QUESTION}, headers=h) + self.assertEqual((r.status_code, r.json()["code"]), (502, "HERMES_KEY_REJECTED")) + self.assertFalse(c.get("/api/assistant/status", headers=h).json()["reachable"]) + + def test_status_is_cached(self): + fake = FakeHermes() + c, _ = make(fake) + h = bearer(c, "viewer") + for _ in range(3): + self.assertTrue(c.get("/api/assistant/status", headers=h).json()["reachable"]) + self.assertEqual(sum(1 for q in fake.seen if q.url.path == "/v1/models"), 1) + + def test_rate_limited_per_user(self): + fake = FakeHermes() + c, _ = make(fake, hermes_rate_per_minute=2) + h = bearer(c, "viewer") + codes = [c.post("/api/assistant/ask", json={"question": QUESTION}, headers=h).status_code for _ in range(3)] + self.assertEqual(codes, [200, 200, 429]) + r = c.post("/api/assistant/ask", json={"question": QUESTION}, headers=h) + self.assertIn("Retry-After", r.headers) + self.assertEqual(c.post("/api/assistant/ask", json={"question": QUESTION}, headers=bearer(c, "consultant")).status_code, 200) + + def test_needs_sign_in(self): + c, _ = make(FakeHermes()) + self.assertEqual(c.post("/api/assistant/ask", json={"question": QUESTION}).status_code, 401) + self.assertEqual(c.get("/api/assistant/status").status_code, 401) + + def test_key_not_in_public_config(self): + c, _ = make(FakeHermes()) + self.assertNotIn(KEY, c.get("/api/config", headers=bearer(c, "admin")).text) + + +if __name__ == "__main__": + unittest.main() diff --git a/coworker/tests/test_llm_settings.py b/coworker/tests/test_llm_settings.py index 3003d9861a548d6989c0f8fb0e90bfb8f276148d..9d29bad6fe63ac1afe8d19cba8c5f1f094f80b95 100644 --- a/coworker/tests/test_llm_settings.py +++ b/coworker/tests/test_llm_settings.py @@ -88,5 +88,48 @@ class TestLLMSettings(unittest.TestCase): self.assertEqual(self.c.get("/api/llm/settings", headers=self.h["admin"]).json()["active"]["external"], "off") +class TestExternalModelFromEnvironment(unittest.TestCase): + """A restart (or a lost snapshot) must not turn the external model off when the environment names it and holds its key.""" + BASE = "https://integrate.api.nvidia.com/v1" + + def setUp(self): + import os + self._old = os.environ.get("FPT_SECRET_FRONTIER_API_KEY") + + def tearDown(self): + import os + os.environ.pop("FPT_SECRET_FRONTIER_API_KEY", None) if self._old is None else os.environ.__setitem__("FPT_SECRET_FRONTIER_API_KEY", self._old) + + def build(self, key: bool = True, **over): + import os + + from coworker.graph.services import build_services + from coworker.tests.fakes import FakePod, temp_settings + cfg = temp_settings(**over) + if key: + os.environ["FPT_SECRET_FRONTIER_API_KEY"] = "nvapi-test-key-not-real" # after temp_settings, which clears it + return build_services(cfg, transport=FakePod().transport()) + + def test_base_url_model_and_key_switch_it_on_when_nothing_is_saved(self): + svc = self.build(frontier_base_url=self.BASE, frontier_model="nvidia/llama-3.3-nemotron") + self.assertEqual(svc.cfg.llm_frontier, "frontier") + self.assertIsNotNone(svc.router.frontier) + self.assertTrue(svc.cfg.public_dict()["frontier_configured"]) + + def test_not_without_a_key_or_an_https_address_or_when_opted_out(self): + self.assertEqual(self.build(key=False, frontier_base_url=self.BASE).cfg.llm_frontier, "off") + self.assertEqual(self.build(frontier_base_url="http://api.example.com/v1").cfg.llm_frontier, "off") + self.assertEqual(self.build(frontier_base_url=self.BASE, frontier_auto=False).cfg.llm_frontier, "off") + self.assertEqual(self.build().cfg.llm_frontier, "off") + + def test_what_an_administrator_saved_wins_even_when_it_says_off(self): + svc = self.build(frontier_base_url=self.BASE) + svc.db.kv_set(L.KV, {"llm_frontier": "off", "frontier_base_url": self.BASE, "frontier_model": "m"}) + from coworker.graph.services import build_services + svc2 = build_services(svc.cfg.model_copy(update={"llm_frontier": "off"}), transport=None) + self.assertEqual(svc2.cfg.llm_frontier, "off") + self.assertIsNone(svc2.router.frontier) + + if __name__ == "__main__": unittest.main() diff --git a/coworker/tests/test_pods.py b/coworker/tests/test_pods.py index c24812a6a43d36fb0b34b3a9d454cab4e4d9445d..50724b7dce3c940d40a4bd61315b3790fe845463 100644 --- a/coworker/tests/test_pods.py +++ b/coworker/tests/test_pods.py @@ -89,3 +89,72 @@ class TestPods(unittest.TestCase): self.assertEqual(run["pod_name"], "Local mock pod") self.assertIsNotNone(run["pod_id"]) self.app.state.runs.cancel(rid, "test") + + +class TestPodFromServerSettings(unittest.TestCase): + """FPT_FUSION_BASE_URL + the secrets FPT_SECRET_FUSION_USERNAME / _PASSWORD: the Fusion pod exists after every start, + even when the saved data is empty, and its test user never has to be typed in again.""" + URL = "https://acme-test.fa.ocs.oraclecloud.com" + + def setUp(self): + import os + self._saved = {k: os.environ.get(k) for k in ("FPT_SECRET_FUSION_USERNAME", "FPT_SECRET_FUSION_PASSWORD")} + os.environ["FPT_SECRET_FUSION_USERNAME"], os.environ["FPT_SECRET_FUSION_PASSWORD"] = "svc.tester", "Env-Only-Pw-123!" + + def tearDown(self): + import os + for k, v in self._saved.items(): + os.environ.pop(k, None) if v is None else os.environ.__setitem__(k, v) + + def test_pod_is_created_from_settings_with_its_test_user_and_runs_can_use_it(self): + _, c, svc, _ = make_app(fusion_base_url=self.URL + "/", fusion_name="Acme Fusion test") + h = bearer(c, "viewer") + pods = c.get("/api/pods", headers=h).json() + fusion = [p for p in pods if p["kind"] == "fusion"] + self.assertEqual(len(fusion), 1) + p = fusion[0] + self.assertEqual((p["name"], p["base_url"], p["environment"], p["modules"]), ("Acme Fusion test", self.URL, "test", ["AP"])) + self.assertTrue(p["from_server_settings"]) + self.assertTrue(p["runnable"], p["not_runnable_reason"]) + self.assertEqual([x["module"] for x in p["credentials"]], ["ALL"]) + from coworker.platform.pods import PodRegistry + env = PodRegistry(svc.db, svc.vault, svc.cfg, svc.egress, svc.audit).executor_env(p["id"]) + self.assertEqual((env["FUSION_USERNAME"], env["FUSION_PASSWORD"]), ("svc.tester", "Env-Only-Pw-123!")) + # the password is in no API answer and no vault file + self.assertNotIn("Env-Only-Pw-123!", json.dumps(pods)) + vault_file = svc.cfg.home / "secrets" / "vault.json" + self.assertNotIn("Env-Only-Pw-123!", vault_file.read_text(encoding="utf-8")) + + def test_idempotent_and_an_empty_database_gets_the_pod_back(self): + _, c, svc, _ = make_app(fusion_base_url=self.URL) + from coworker.platform.pods import PodRegistry + for _ in range(3): + PodRegistry(svc.db, svc.vault, svc.cfg, svc.egress, svc.audit) + self.assertEqual(len([p for p in c.get("/api/pods", headers=bearer(c, "viewer")).json() if p["kind"] == "fusion"]), 1) + # a pod the person registered earlier (same address) is kept as it is, not duplicated or renamed + svc.db.x("DELETE FROM pod_credentials") + svc.db.x("UPDATE pods SET name='My own name' WHERE kind='fusion'") + reg = PodRegistry(svc.db, svc.vault, svc.cfg, svc.egress, svc.audit) + fusion = [p for p in reg.list() if p["kind"] == "fusion"] + self.assertEqual([p["name"] for p in fusion], ["My own name"]) + self.assertTrue(fusion[0]["runnable"]) + + def test_without_the_secrets_the_pod_exists_but_asks_for_a_test_user(self): + import os + os.environ.pop("FPT_SECRET_FUSION_PASSWORD") + _, c, _, _ = make_app(fusion_base_url=self.URL) + p = [p for p in c.get("/api/pods", headers=bearer(c, "viewer")).json() if p["kind"] == "fusion"][0] + self.assertFalse(p["runnable"]) + self.assertIn("Set the test user", p["not_runnable_reason"]) + + def test_it_cannot_be_deleted_or_moved_but_can_be_disabled_and_production_is_refused(self): + _, c, _, _ = make_app(fusion_base_url=self.URL) + h = bearer(c, "admin") + p = [p for p in c.get("/api/pods", headers=h).json() if p["kind"] == "fusion"][0] + r = c.delete(f"/api/pods/{p['id']}", headers=h) + self.assertEqual((r.status_code, r.json()["code"]), (409, "FROM_SETTINGS")) + r = c.patch(f"/api/pods/{p['id']}", json={"base_url": "https://other-test.fa.ocs.oraclecloud.com"}, headers=h) + self.assertEqual(r.json()["code"], "FROM_SETTINGS") + self.assertEqual(c.patch(f"/api/pods/{p['id']}", json={"enabled": False}, headers=h).status_code, 200) + _, c2, _, _ = make_app(fusion_base_url="https://acme-prod.fa.ocs.oraclecloud.com") + self.assertEqual([p for p in c2.get("/api/pods", headers=bearer(c2, "viewer")).json() if p["kind"] == "fusion"], []) diff --git a/coworker/tests/test_supabase.py b/coworker/tests/test_supabase.py index b8a756ba2534e6d58c10f0a566a2481f55a72311..cb092a1d77d8fb240f9cf980b8ff90d4a736d1cc 100644 --- a/coworker/tests/test_supabase.py +++ b/coworker/tests/test_supabase.py @@ -260,6 +260,47 @@ class TestStateSync(unittest.TestCase): statesync.restore(cfg2, sb.Supabase(cfg2, svc.egress, None)) self.assertFalse((fresh / "fpt.sqlite").exists()) + def test_a_failed_restore_never_overwrites_the_saved_state(self): + fake = FakeSupabase(confirm=False) + _, c, svc = make(fake) + c.post("/api/auth/register", json={"email": "keep@example.com", "password": SECRET_PW}) + statesync.push(svc, "test") + good = fake.objects[f"{svc.cfg.supabase_bucket}/{statesync.OBJECT}"] + # a new instance whose start-up restore cannot read the bucket (storage answers 500) + fresh = Path(tempfile.mkdtemp(prefix="fpt-restore-")) + cfg2 = svc.cfg.model_copy(update={"fpt_home": fresh}) + real = fake.handler + fake.handler = lambda req: httpx.Response(500, json={"message": "down"}) if req.url.path.startswith("/storage/") else real(req) + done, err = statesync.restore_at_boot(cfg2, sb.Supabase(cfg2, svc.egress, None), attempts=3, sleep=lambda s: None) + self.assertFalse(done) + self.assertIn("download failed", err) + self.assertTrue(statesync.restore_failed(fresh)) + fake.handler = real + # the instance starts empty; its saver must refuse to replace the good archive with that empty state + svc2 = build_services(cfg2, transport=svc.egress._transport if hasattr(svc.egress, "_transport") else None) + s = statesync.Syncer(svc2, 60) + self.assertFalse(s.tick()) + self.assertIn("saving is paused", s.last_error or "") + self.assertEqual(fake.objects[f"{svc.cfg.supabase_bucket}/{statesync.OBJECT}"], good) + # the next start (marker removed by the boot restore) restores normally + fresh2 = Path(tempfile.mkdtemp(prefix="fpt-restore-")) + cfg3 = svc.cfg.model_copy(update={"fpt_home": fresh2}) + (fresh2).mkdir(exist_ok=True) + (fresh2 / statesync.FAILED_MARKER).write_text("old", encoding="utf-8") + done, err = statesync.restore_at_boot(cfg3, sb.Supabase(cfg3, svc.egress, None), sleep=lambda s: None) + self.assertEqual((done, err), (True, None)) + self.assertFalse(statesync.restore_failed(fresh2)) + + def test_first_save_keeps_a_copy_of_what_the_bucket_held(self): + fake = FakeSupabase(confirm=False) + _, _, svc = make(fake) + statesync.push(svc, "one") + first = fake.objects[f"{svc.cfg.supabase_bucket}/{statesync.OBJECT}"] + _, _, svc2 = make(fake) # a second process, same bucket: its first save keeps the first archive + svc2.users.create("newperson", PASSWORD, "viewer", created_by="test") + statesync.push(svc2, "two") + self.assertEqual(fake.objects[f"{svc.cfg.supabase_bucket}/{statesync.PREVIOUS}"], first) + def test_storage_only_talks_to_the_project_host(self): fake = FakeSupabase() _, _, svc = make(fake) diff --git a/coworker/workflows/activities.py b/coworker/workflows/activities.py index 96e38bd5303981c9b101e052e5c9770941d1e8a7..3063e90e2c16f49afa54924ff8a2c2007ca220e4 100644 --- a/coworker/workflows/activities.py +++ b/coworker/workflows/activities.py @@ -365,8 +365,8 @@ def create_scheduled_run(schedule_id: int) -> str | None: sch = s.db.one("SELECT * FROM schedules WHERE id=? AND enabled=1", (schedule_id,)) if not sch or s.kill.engaged(): return None - return _RunCreator(s).start({"modules": sch["modules"], "include_p2": bool(sch["include_p2"]), - "playwright_mode": sch["playwright_mode"]}, actor=f"schedule:{schedule_id}", trigger="schedule") + from ..platform.scheduler import run_inputs + return _RunCreator(s).start(run_inputs(sch), actor=f"schedule:{schedule_id}", trigger="schedule") @activity.defn(name="purge") diff --git a/coworker/workflows/client.py b/coworker/workflows/client.py index b1d880b88267a5d3d5e3506826e1b199844b7825..84353bd47c4ee41d05a1a2c87478313109383e4e 100644 --- a/coworker/workflows/client.py +++ b/coworker/workflows/client.py @@ -207,8 +207,8 @@ class TemporalScheduler(Scheduler): if s["kind"] == "interval": spec = ScheduleSpec(intervals=[ScheduleIntervalSpec(every=timedelta(minutes=int(s["every_minutes"] or 60)))]) else: - hh, mm = (str(s.get("at") or "02:00").split(":") + ["0"])[:2] - spec = ScheduleSpec(cron_expressions=[f"{int(mm)} {int(hh)} * * *"]) + from ..platform.scheduler import cron_of + spec = ScheduleSpec(cron_expressions=[cron_of(s)]) await self._upsert(sid, "ScheduledRunWorkflow", {**base, "schedule_id": s["id"]}, spec) def sync(self) -> None: diff --git a/deploy/.env.example b/deploy/.env.example index 19314a0b378d77081e36e10929639cb3cd43aa3a..4761e0bfac08bc32eb9a78868aa80fa954abd97c 100644 --- a/deploy/.env.example +++ b/deploy/.env.example @@ -13,7 +13,7 @@ FPT_BOOTSTRAP_ADMIN_PASSWORD=change-me-to-a-long-passphrase FPT_IMAGE=patch-coworker:1.0.0 # --- product name shown in the menu and on the sign-in page -FPT_PRODUCT_NAME=Patch Testing Co-worker +FPT_PRODUCT_NAME=Trio Co-Worker FPT_ORG_NAME= # --- AI models can also be set in the app (Settings > AI models). Values saved there win over these. diff --git a/deploy/DEPLOY.md b/deploy/DEPLOY.md index c05d9afe321b9e9c3e9deaa0cf0e96139474c0d3..eaa716687166a34b375848b1bcc84f7ac8b3e79b 100644 --- a/deploy/DEPLOY.md +++ b/deploy/DEPLOY.md @@ -1,4 +1,4 @@ -# Deploying the Patch Testing Co-worker in a customer's cloud +# Deploying Trio Co-Worker in a customer's cloud One deployment serves one customer. Everything the product stores stays on the customer's own server, in Docker volumes: nothing is kept outside their environment. @@ -100,3 +100,19 @@ These are the limits of the product today, not of the packaging. Say them plainl - **Windows desktop app**: the installer is not code-signed. - **Updates and licensing**: there is no licence check, update channel or usage metering. - **No independent security test** (penetration test) has been done. + +## Settings that make the demo survive a restart (Hugging Face Space or any host without a disk) + +The app keeps its data in an encrypted snapshot in Supabase Storage and restores it at start. These settings rebuild the +essentials from the environment, so a lost or unreadable snapshot never leaves the product without its pod or its AI model. + +| Setting | Kind | Effect | +|---|---|---| +| `FPT_FUSION_BASE_URL` (`https://.fa.ocs.oraclecloud.com`), `FPT_FUSION_NAME`, `FPT_FUSION_ENVIRONMENT`, `FPT_FUSION_MODULES` | variable | The Oracle Fusion test pod exists after every start. Production addresses are refused. | +| `FPT_SECRET_FUSION_USERNAME`, `FPT_SECRET_FUSION_PASSWORD` | secret | The pod's test user. Never written to the vault file or shown. | +| `FRONTIER_BASE_URL` (https), `FRONTIER_MODEL`, `FPT_SECRET_FRONTIER_API_KEY` | variable, variable, secret | The external model is switched on at start when no AI settings are saved in the app. `FPT_FRONTIER_AUTO=0` turns this off. | +| `SUPABASE_BUCKET`, `SUPABASE_URL`, `SUPABASE_SERVICE_KEY`, `FPT_STATE_KEY` | variable and secrets | One bucket per deployment; never share a bucket between two instances (the last writer wins). | + +If the start-up restore fails, the instance starts empty and **stops saving** (`/api/ready` shows `saved_state.paused`, and the app shows a notice) so the good +snapshot is not overwritten; restart to retry. The first save of every start keeps the archive it found as `state/previous.bin` +in the bucket; copy it over `state/latest.bin` to undo a bad save. diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index 394daf7179eb92b37bc63e77b290046da8a0d2b4..560aeb7aba2733b9b5e05d3e15be6a6ab0fb1df4 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -1,4 +1,4 @@ -# Patch Testing Co-worker: single-tenant deployment for one customer environment. +# Trio Co-Worker: single-tenant deployment for one customer environment. # cp .env.example .env (edit it) then: docker compose up -d # Three containers: the application, Temporal (durable workflows) and Caddy (HTTPS). All customer data stays in the # named volumes on this host: nothing is stored outside the customer's environment. diff --git a/desktop/package.json b/desktop/package.json index 261d0641e78421718a0da911cda58c88e9d35de9..f6d2ad4239e79d4cdb1cb1b0bbfb5a180c5aee1c 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -1,8 +1,8 @@ { "name": "fpt-desktop", - "productName": "FPT Co-worker", + "productName": "Trio Co-Worker", "version": "1.0.0", - "description": "Windows desktop shell for the Fusion Patch Testing co-worker (loads the same web app). Mock app, not Oracle Fusion.", + "description": "Windows desktop shell for Trio Co-Worker (loads the same web app). Mock app, not Oracle Fusion.", "main": "src/main.js", "author": "FPT pilot team", "license": "UNLICENSED", @@ -19,11 +19,11 @@ }, "build": { "appId": "local.fpt.coworker", - "productName": "FPT Co-worker", + "productName": "Trio Co-Worker", "directories": { "output": "dist", "buildResources": "build" }, "files": ["src/**/*", "build/icon.png", "build/icon.ico", "package.json"], "win": { "target": [{ "target": "nsis", "arch": ["x64"] }], "icon": "build/icon.ico", "signAndEditExecutable": false }, - "nsis": { "oneClick": false, "perMachine": false, "allowToChangeInstallationDirectory": true, "createDesktopShortcut": true, "shortcutName": "FPT Co-worker", "installerIcon": "build/icon.ico", "uninstallerIcon": "build/icon.ico" }, + "nsis": { "oneClick": false, "perMachine": false, "allowToChangeInstallationDirectory": true, "createDesktopShortcut": true, "shortcutName": "Trio Co-Worker", "installerIcon": "build/icon.ico", "uninstallerIcon": "build/icon.ico" }, "forceCodeSigning": false } } diff --git a/desktop/src/loading.html b/desktop/src/loading.html index 85a05d50bed5f4afd1343cb0c8b58e94d586655a..4917918e4ae750f039f2fe896dc6337221f4c0e3 100644 --- a/desktop/src/loading.html +++ b/desktop/src/loading.html @@ -1,6 +1,6 @@ -Starting FPT Co-worker +Starting Trio Co-Worker

Starting the co-worker...

Starting the local backend and waiting for it to be ready (or contacting the server).

diff --git a/desktop/src/main.js b/desktop/src/main.js index 0f44ba0347a9109232fffe3f3dfa5cdab5620ea7..86dd2815dda6092b8e8a17979e6051e5f2dc9bcd 100644 --- a/desktop/src/main.js +++ b/desktop/src/main.js @@ -1,5 +1,5 @@ 'use strict'; -// FPT Co-worker desktop shell (Electron). Loads the SAME built web app the backend serves; no second UI codebase. +// Trio Co-Worker desktop shell (Electron). Loads the SAME built web app the backend serves; no second UI codebase. // local mode : spawns the project's venv Python -> FastAPI on a free 127.0.0.1 port, waits for /api/ready, kills it on quit // remote mode: loads a shared backend URL entered in Settings // Security: contextIsolation on, nodeIntegration off, sandboxed renderer, minimal preload bridge, CSP, external links in @@ -151,7 +151,7 @@ function secureWebContents(wc) { const WEB_PREFS = { preload: path.join(__dirname, 'preload.js'), contextIsolation: true, nodeIntegration: false, sandbox: true, webSecurity: true, spellcheck: false }; function createMainWindow() { - win = new BrowserWindow({ width: 1360, height: 900, minWidth: 380, title: 'FPT Co-worker (mock app, not Oracle Fusion)', show: false, + win = new BrowserWindow({ width: 1360, height: 900, minWidth: 380, title: 'Trio Co-Worker (mock app, not Oracle Fusion)', show: false, icon: path.join(__dirname, '..', 'build', 'icon.png'), webPreferences: WEB_PREFS }); secureWebContents(win.webContents); win.once('ready-to-show', () => win.show()); @@ -161,7 +161,7 @@ function createMainWindow() { function openSettings(message) { if (settingsWin) { settingsWin.focus(); return; } - settingsWin = new BrowserWindow({ width: 560, height: 560, title: 'FPT Co-worker settings', parent: win || undefined, webPreferences: WEB_PREFS }); + settingsWin = new BrowserWindow({ width: 560, height: 560, title: 'Trio Co-Worker settings', parent: win || undefined, webPreferences: WEB_PREFS }); secureWebContents(settingsWin.webContents); settingsWin.loadFile(path.join(__dirname, 'settings.html'), { query: message ? { message } : {} }); settingsWin.on('closed', () => { settingsWin = null; }); @@ -186,7 +186,7 @@ async function connect() { await win.loadURL(`${base}/`); buildTray(); } catch (e) { - dialog.showErrorBox('FPT Co-worker', String(e && e.message ? e.message : e)); + dialog.showErrorBox('Trio Co-Worker', String(e && e.message ? e.message : e)); openSettings(String(e && e.message ? e.message : e)); } } @@ -194,7 +194,7 @@ async function connect() { function buildTray() { if (!tray) { tray = new Tray(nativeImage.createFromPath(path.join(__dirname, 'tray.png'))); - tray.setToolTip('FPT Co-worker (mock app, not Oracle Fusion)'); + tray.setToolTip('Trio Co-Worker (mock app, not Oracle Fusion)'); tray.on('click', () => { if (win) { win.show(); win.focus(); } }); } const cfg = loadConfig(); diff --git a/desktop/src/settings.html b/desktop/src/settings.html index 36861957f8894100202c2afdd64192a3790ac578..34dac9a7f4b6984dc94d633b6845cf0978f8a1d9 100644 --- a/desktop/src/settings.html +++ b/desktop/src/settings.html @@ -3,7 +3,7 @@ - FPT Co-worker settings + Trio Co-Worker settings diff --git a/docker-compose.temporal.yml b/docker-compose.temporal.yml index 561afbd991fb350e5a671548793887f5369cfd3c..683fbec1169d8f58b8c15cbbacb4c9d96ef59c70 100644 --- a/docker-compose.temporal.yml +++ b/docker-compose.temporal.yml @@ -1,4 +1,4 @@ -# Temporal dev server for the FPT co-worker (pilot). Single container: Temporal server (SQLite persisted in a named +# Temporal dev server for Trio Co-Worker (pilot). Single container: Temporal server (SQLite persisted in a named # volume) + bundled Web UI. Ports bound to loopback only. Started by `fpt.cmd temporal` / `fpt.cmd up`. name: fpt-temporal services: diff --git a/docs/design/UI-APPLE.md b/docs/design/UI-APPLE.md new file mode 100644 index 0000000000000000000000000000000000000000..37736fca8f9bcdb363a22f53db116ef256edbad3 --- /dev/null +++ b/docs/design/UI-APPLE.md @@ -0,0 +1,486 @@ +> Note (24 Oct 2026): this is the design the app was built to on branch `trio-apple-ui`. The product is now named "Trio Co-Worker"; older documents in this folder keep the earlier name. Where the build differs from this text: Ask is a sidebar item that opens the Ask dock (the `Ctrl K` palette also opens it); there is no separate Ask page. See the build notes in the commit history. + +# UI-APPLE: Trio Co-Worker, Apple-style desktop web UI + +Status: design proposal for the lead's approval. Desktop web only (1280 px and wider; no phone or tablet work). +Supersedes the visual layer of `UI-MINIMAL.md` and the Fluent pass. Keeps every rule of `UI-REDESIGN.md` sections 9 (58 features) and 10 (test hooks). + +- Clickable mockup: `mockup/index.html` (one file, no network requests, Inter embedded as base64, system font stack first). Open it, use the sidebar, + `Ctrl K`, the sign-in links, the "Approve all" button, and the small "Mockup controls" pill at the bottom (run stage and live-browser state). + `?theme=dark|light` forces a theme; otherwise it follows the system. Hash routes: `#signin`, `#signin/register`, `#home`, `#start`, `#runs`, + `#run/approve|testing|decide|result[/starting|live|reconnecting|masked|unavailable]`, `#report`, `#scenarios`, `#defects`, `#envs`, `#pod`, + `#reports`, `#ask`, `#settings/ai|users|auto|sched|stop`, `#palette`, `#kit`. +- Screenshots (1440x900, light and dark, Chromium): `shots/*.png`. +- Brand: `brand/BRAND.md` and the SVG/PNG assets. Build plan: `BUILD-PLAN.md`. + +## 0. The decisions in one page + +1. **Apple's layout grammar, not a skin.** Translucent sidebar, translucent toolbar that content scrolls under, inset grouped lists on a quiet grey page, + capsule controls, sheets for short tasks, a right inspector for details. Honest to the HIG: sidebars up to two levels (we use one), no critical actions at + the bottom, segmented controls for view switching in an inspector, a single prominent action per toolbar. +2. **One accent, system blue** `#0071e3` (white text 4.70:1). Green, orange and red are status only. Orange also means "waiting for you" and "practice pod", + so the two things a consultant must never miss share one warm colour. +3. **Type:** system stack first (`-apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display"`), then **Inter Variable** (self-hosted, OFL) so Windows and Linux + look intentional. Never bundle SF. 14 px body, 28 px large title, tracking tightens as size grows. +4. **Materials with a fallback.** `backdrop-filter` only on three surfaces (sidebar, toolbar, floating layers). Solid colours under `prefers-reduced-transparency`, + `forced-colors`, and when `backdrop-filter` is unsupported. Nothing nests blur on blur. +5. **Four-stage run, one live browser.** The Run workspace is a vertical stage list (Prepare, Approve, Testing/Decision, Result) beside a 456 px inspector + (Live, Steps, Screens, Report, Excel). The live browser has seven explicit states, each with its own words and controls. +6. **Honesty is a design element.** The environment switcher at the top of the sidebar always says "Mock app, not Oracle Fusion" (orange, shield) or + "Oracle Fusion pod" (blue, cloud). Every report line, sheet and run header repeats it. Hermes attribution appears only on answers Hermes gave. +7. **Calm motion.** 120/200/320 ms, three curves, one small overshoot (segmented thumb, switch). No motion on frequent actions beyond a 0.975 press scale. +8. **Brand:** product is now "Trio Co-Worker" with an original mark (three nodes, one closed line). See `brand/BRAND.md`. + +--- + +## 1. Research and what we adopt + +### 1.1 Apple Human Interface Guidelines (read from developer.apple.com, via the site's JSON documentation endpoint) + +The HIG pages are client-rendered, so a normal fetch returns only the title. Each page below was read through `developer.apple.com/tutorials/data/design/human-interface-guidelines/.json`. +Quotes are paraphrased; numbers are exact. + +| Page | What it says (relevant part) | What we do | +|---|---|---| +| [Sidebars](https://developer.apple.com/design/human-interface-guidelines/sidebars) | Sidebars float above content in the Liquid Glass layer; show at most two hierarchy levels; use succinct group labels; don't hide the sidebar by default but offer a show/hide control; "avoid putting critical information or actions at the bottom of the sidebar" because windows get moved; icons use the accent colour and should have a purpose | 264 px translucent sidebar, one level with two small group labels, a visible hide button in the toolbar, **only the user row at the bottom** (the environment switcher, the honesty cue, is at the top), accent-coloured icons, selected row = neutral fill (not a second colour) | +| [Toolbars](https://developer.apple.com/design/human-interface-guidelines/toolbars) | Three zones: leading (sidebar toggle, title), centre, trailing (search, More, one prominent action); no bezels on items; aim for at most three groups; keep titles short; no custom tinted backgrounds that fight the system effect; don't make a toolbar item the only way to reach a command; "avoid segmented controls in toolbars" appears in the search summary but the Segmented controls page prefers them for toolbar/inspector view switching | 56 px translucent toolbar: sidebar toggle, back link, title + one-line subtitle, then actions, then the search field. One primary action per page, kept in the page head (Home, Test runs) so the toolbar stays calm. Every toolbar command is also in the palette (`Ctrl K`) | +| [Materials](https://developer.apple.com/design/human-interface-guidelines/materials) | Liquid Glass is for the **controls/navigation layer**, not content; "use Liquid Glass sparingly"; content-layer elements use standard materials; choose materials by meaning not colour; thicker = more legible; vibrant foreground colours on materials; avoid quaternary labels on thin materials | Glass only for sidebar, toolbar, menus, palette, toasts, composer. Cards and lists are **opaque** (content layer). Label colours on materials are `label` / `label-2` only. No clear glass over rich media | +| [Color](https://developer.apple.com/design/human-interface-guidelines/color) | Don't rely on colour alone; don't hard-code system colours; use dynamic colours for their purpose; supply light, dark and increased-contrast variants; for primary actions put colour on the **background**, not on text/symbol; don't add colour to several controls at once; system blue sample RGB 0,136,255 (light) / 0,145,255 (dark) | Status is always dot + word. Primary action = blue **fill** with white text, one per screen. We use `#0071e3`, a deliberately deeper blue than system `#0088ff`, because `#0088ff` with white text is only 3.65:1. An `Increase contrast` variant is specified in 6.9 | +| [Typography](https://developer.apple.com/design/human-interface-guidelines/typography) | macOS built-in styles: Large Title 26/32, Title 1 22/26, Title 2 17/22, Title 3 15/20, Headline 13/16 bold, Body 13/16, Callout 12/15, Subheadline 11/14, Footnote 10/13; default size 13, minimum 10; avoid ultralight/thin/light; system font uses dynamic optical sizes (Text and Display merged) | Our scale (section 4) follows the same ladder shifted up for web and Windows density: 28/34, 22/28, 17/22, 15/20, 14/20, 13/18, 12/16, 11.5/14. Weights 400/500/550/600/650 only. Inter has an `opsz` axis, so `font-optical-sizing: auto` mimics SF's text/display switch | +| [Segmented controls](https://developer.apple.com/design/human-interface-guidelines/segmented-controls) | For closely related choices; about 5-7 segments in a wide interface; equal widths; don't mix text and images; nouns or noun phrases; **on macOS prefer a tab view in the main window and use a segmented control for view switching in a toolbar or inspector** | Segmented control for the inspector tabs (Live/Steps/Screens/Report/Excel), run filters, Approve/Skip, environment type. Page-level sections use the sidebar, not tabs. 5 or fewer segments everywhere | +| [Sheets](https://developer.apple.com/design/human-interface-guidelines/sheets) | Use sparingly; one at a time; pair Done with Cancel; macOS sheets are modal cards with rounded corners floating on the parent; reasonable default size, resizable only if useful; use a panel for repeated input | Sheets for: Start a test run (3 steps), Register a Fusion pod, sign-in details. Cancel always present. Never two sheets at once. The palette and the Ask dock are not sheets | +| [Motion](https://developer.apple.com/design/human-interface-guidelines/motion) | Purposeful motion; feedback brief and precise; "generally avoid adding motion to frequent UI interactions"; let people cancel motion; make motion optional | Motion table in 5.5. Frequent actions (row hover, button press, nav) get 120 ms colour/scale only. Larger motion (sheet, page enter, toast) is 200-320 ms and never blocks input | +| [Lists and tables](https://developer.apple.com/design/human-interface-guidelines/lists-and-tables) | Prefer lists for text; keep item text succinct; middle ellipsis when clipped; descriptive column headings, noun phrases, title-style capitalisation; macOS: click header to sort, resizable columns, striping only for wide multi-column tables | Inset grouped lists for browse-and-act, tables for compare. Sortable headers on Test runs, Defects, Scenarios. No striping (hairlines only); middle ellipsis for run refs and URLs | +| [Layout](https://developer.apple.com/design/human-interface-guidelines/layout) | Order by importance; align to aid scanning; group with space or separators; progressive disclosure; "avoid placing controls or critical information at the bottom of a window" on macOS; separate controls from content | Waiting-for-you first on Home; "Approve all" is **inside** the stage card, not pinned at the window bottom; the Ask composer is the one exception (a conversational input is expected at the bottom) | +| [Accessibility](https://developer.apple.com/design/human-interface-guidelines/accessibility) | WCAG AA: 4.5:1 up to 17 pt, 3:1 for 18 pt and up or bold; macOS control hit target default 28x28, minimum 20x20; macOS text 13 default / 10 minimum; Reduce Motion: tighten springs, replace x/y transitions with fades, avoid animating blurs; support full keyboard access | Section 7. Our targets: 32 default, 28 minimum, 40 for stage actions. All text 4.5:1 or better (checked, section 3.4); focus ring 3:1 | +| [SF Symbols](https://developer.apple.com/design/human-interface-guidelines/sf-symbols) | Nine weights match the system font weights; three scales relative to cap height; **prohibits using symbols, or images confusingly similar, in app icons, logos or trademarked use** | We cannot use SF Symbols on the web (Apple restricts them to Apple platforms; this is from Apple's licence terms as I know them and was not re-verified in this session). We draw/choose an open icon set whose stroke matches Inter at 14 px (1.7 px at 18 px), and the logo is original | + +Not verified in this session: Apple's SF Pro font licence text (my understanding: SF is licensed for design mockups and Apple-platform apps, not for web +embedding, which is why we use the system stack and Inter); the Liquid Glass (macOS 26) pages beyond Materials, Sidebars and Toolbars; Apple's own +HIG numbers for corner radii (the Layout page says concentricity is covered on the Liquid Glass page, which I did not read). + +### 1.2 Open-source references (licences checked on GitHub, 24 Oct 2026) + +| Reference | Licence | Use | Verdict | +|---|---|---|---| +| [Mantine](https://github.com/mantinedev/mantine) 7 (in the app) | MIT | theming through `createTheme`, CSS variables, `styles`/`classNames` | **Keep.** All restyling goes through theme tokens + one CSS layer | +| [Tabler Icons](https://github.com/tabler/tabler-icons) (in the app, `@tabler/icons-react`) | MIT | 6,000+ outline icons, stroke adjustable | **Keep** as the icon set. Set `stroke={1.7}` at 18 px; the mockup's icons are hand-drawn in the same style (24 grid, round caps) to avoid a build step | +| [Lucide](https://github.com/lucide-icons/lucide) | ISC (checked in `LICENSE`) | closest to SF Symbols' proportions | Fallback if Tabler lacks a glyph. Not needed now | +| [Inter](https://github.com/rsms/inter) / `@fontsource-variable/inter` (in the app) | OFL-1.1 | UI fallback font; `opsz` + `wght` axes | **Keep**; the mockup embeds the Latin `opsz` subset (73 KB) | +| [Geist](https://github.com/vercel/geist-font) | OFL-1.1 | alternative sans | Not adopted: Inter is closer to SF's proportions and already shipped | +| [shadcn/ui](https://github.com/shadcn-ui/ui) | MIT | pattern library built on Radix + CSS variables; its "tokens as CSS variables, components own their styles" approach | **Pattern only.** We do not add Tailwind or Radix: Mantine already provides the primitives. We copy the idea of semantic tokens (`--background`, `--muted`, `--ring`) | +| [Radix Primitives](https://github.com/radix-ui/primitives) | MIT | accessible behaviour reference for menus, dialogs, tabs, switch, radio group | **Reference for ARIA behaviour** when checking Mantine components (roving tabindex, `aria-checked`, focus return) | +| [Sonner](https://github.com/emilkowalski/sonner) | MIT | toast stacking and motion | Reference for the toast spec (2 visible, bottom centre). Implementation stays Mantine Notifications | +| [cmdk](https://github.com/pacocoursey/cmdk) | no licence file reported by the GitHub API in this session (the repo is widely reported as MIT; treat as unverified) | command palette | **Pattern only**; build on Mantine `Modal` + `Combobox` logic, no dependency | +| [Linear](https://github.com/linear/linear) (SDK only, UI is closed) / Raycast / Things / Craft / Arc | UI not open | patterns: `g`-then-letter navigation, single-key shortcuts, command palette as front door, sidebar with few items, quiet colour | **Patterns adopted:** palette, `N` new, `[` toggles sidebar, `g h/r/s/d/e` go-to | +| [awesome-liquid-glass](https://github.com/carolhsiaoo/awesome-liquid-glass) (list), `liquid-glass-effect-macos`, `shuding/liquid-glass` | n/a (list) | SVG-filter "refraction" glass | **Rejected.** SVG `backdrop-filter` refraction works only in Chromium, fails in Safari/Firefox, and costs GPU. We use plain `backdrop-filter: blur() saturate()` | +| An open-source Apple-style CSS component kit | none found | | The search found only SwiftUI/Liquid Glass effect demos, no maintained macOS-style component CSS. So we write ours (about 400 lines of CSS in the mockup) | + +### 1.3 Agent-run and test-run UIs (what to borrow) + +| Product | Observed pattern | Borrow | +|---|---|---| +| OpenAI Operator ([launch post](https://openai.com/index/introducing-operator/), [TechCrunch](https://techcrunch.com/2025/01/23/openai-launches-operator-an-ai-Agent-that-performs-tasks-autonomously)) | A small window shows the agent's dedicated browser with explanations of each action; the user can take over at any time; the agent hands control back for login, payment, CAPTCHA; takeover is not screenshotted. (Wikipedia says Operator was retired in Aug 2025 and the later ChatGPT agent was removed in Aug 2026; single source, unconfirmed, so treat the product as history, not a dependency.) | Plain-language "Now: ..." line under the frame; **sign-in is hidden** ("Sign-in screen hidden. Passwords are never shown here.", already in `LiveView`); a person decides at the hand-off points. We deliberately do **not** offer takeover: the live view is view-only (existing rule) | +| [Browserbase live view](https://docs.browserbase.com/features/session-live-view) | Embed a read-only iframe from a per-session debug URL; one URL per tab; fetch the URL server-side when the user asks to watch; separate replay (HLS) for recordings | Confirms our model: live = view-only stream, recording = separate "Watch the recording". If a tab opens, show a tab switcher inside the frame chrome (future) | +| [Playwright trace viewer](https://playwright.dev/docs/trace-viewer) | Actions list with locator and duration; film strip of screenshots; before/action/after snapshots; console and network filtered by selected action; source line highlighted; Errors tab | Steps tab = actions list with duration and state; Screens tab = film strip of evidence per scenario; failure card shows expected vs actual and "See the failed screen". The engineering view (Technical report, admin) can link to the real trace | + +--- + +## 2. Principles + +1. **Every screen answers three questions in order:** what is this, what is its state, what do I do next. One primary action per screen. +2. **Content is opaque, controls are glass.** Lists and cards are solid; chrome (sidebar, toolbar, menus, palette, toasts) is translucent. +3. **A person decides.** Waiting-for-you is the loudest thing in the app: orange count in the sidebar, orange stage marker with a ring and a 1.5 px orange card outline. +4. **Say where it ran.** Practice versus Oracle Fusion on every page, every report line, every notification. +5. **Calm by default:** neutral grey surfaces, one blue, status as a dot plus a word, no coloured tiles except the status tint on the "waiting" icon tile. +6. **Plain language.** Sentence case, no jargon in headings, no arrows on buttons, names for actions that say what happens ("Approve all 79 and start testing"). +7. **Keyboard-first and pointer-friendly:** everything reachable by Tab, palette for navigation, arrows in segmented controls and radio lists. + +--- + +## 3. Tokens + +All tokens are CSS custom properties on `:root`, redefined under `@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { ... } }` and +`:root[data-theme="dark"]`. Mantine's `data-mantine-color-scheme` is mapped onto the same variables (BUILD-PLAN section 2). Values below are exactly those in the mockup. + +### 3.1 Colour + +| Token | Light | Dark | Use | +|---|---|---|---| +| `--bg` | `#f5f5f7` | `#1c1c1e` | page / window | +| `--bg-base` | `#ececf0` | `#141416` | layer behind the sidebar material | +| `--bg-elev` | `#ffffff` | `#2a2a2d` | grouped lists, cards, sheets, inspector | +| `--bg-elev-2` | `#fbfbfd` | `#313134` | table header, review bar | +| `--mat-sidebar` | `rgba(240,240,244,.72)` | `rgba(46,46,50,.64)` | sidebar (with blur 28 px, saturate 180%) | +| `--mat-bar` | `rgba(245,245,247,.74)` | `rgba(28,28,30,.74)` | toolbar (blur 24 px) | +| `--mat-pop` | `rgba(255,255,255,.78)` | `rgba(48,48,52,.8)` | menus, palette, toasts, composer (blur 30-40 px) | +| `--mat-*-solid` | `#ececf0` / `#f5f5f7` / `#ffffff` | `#232326` / `#1c1c1e` / `#2c2c2e` | fallbacks (reduced transparency, `forced-colors`, no `backdrop-filter`) | +| `--fill` / `-2` / `-3` | `rgba(60,60,67,.08/.12/.18)` | `rgba(235,235,245,.10/.16/.24)` | secondary buttons, track of segmented control, hover, skeleton | +| `--sep` | `rgba(60,60,67,.13)` | `rgba(235,235,245,.13)` | hairlines between rows (0.5 px) | +| `--sep-strong` | `rgba(60,60,67,.22)` | `rgba(235,235,245,.26)` | input borders, unselected radio ring | +| `--label` | `#1d1d1f` | `#f5f5f7` | primary text | +| `--label-2` | `#636366` | `#a1a1a6` | secondary text, captions, table headers | +| `--label-3` | `#8e8e93` | `#6e6e73` | disabled and decoration only, never required text | +| `--ph` (placeholder) | `#70707a` | `#98989f` | input placeholder (4.5:1 or better) | +| `--accent` | `#0071e3` | `#0071e3` | primary fill, switch-free selection, focus | +| `--accent-hover` / `-press` | `#0077ed` / `#0062c4` | `#1a84f0` / `#0062c4` | | +| `--accent-text` | `#0066cc` | `#64a8ff` | links, plain buttons, "Watch live" | +| `--accent-soft` / `-soft-2` | `rgba(0,113,227,.10/.16)` | `rgba(10,132,255,.16/.26)` | selected table row, selected choice, info banner, "Oracle Fusion" chip | +| `--green` (text) / `--green-dot` / `--green-soft` | `#1d7a35` / `#34c759` / `rgba(52,199,89,.16)` | `#30d158` / `#30d158` / `rgba(48,209,88,.18)` | Ready, passed | +| `--orange` (text) / `--orange-dot` / `--orange-soft` | `#a85a00` / `#f59300` / `rgba(255,159,10,.17)` | `#ff9f0a` / `#ff9f0a` / `rgba(255,159,10,.18)` | Waiting for you, practice pod | +| `--red` (text) / `--red-dot` / `--red-soft` | `#d70015` / `#ff3b30` / `rgba(255,59,48,.12)` | `#ff7a72` / `#ff453a` / `rgba(255,69,58,.2)` | Not ready, failed, emergency stop | +| `--focus` | `#0071e3` | `#64a8ff` | focus ring | +| `--scrim` | `rgba(0,0,0,.28)` | `rgba(0,0,0,.5)` | behind sheets and palette | + +Dark-mode elevation: page `#1c1c1e` < cards and inspector `#2a2a2d` < table header `#313134` < thumb of segmented control `#5e5e63`. Higher means lighter; the sidebar +material sits slightly lighter than the page and darker than cards. There is no pure black. + +### 3.2 Why not the exact Apple system colours + +System blue `#0088ff` fills fail white text (3.65:1) and `#0a84ff` (dark) 3.65:1. We use `#0071e3` (apple.com's own button blue, 4.70:1). Green, orange and red text use the +darker "accessible" variants for text on light (`#1d7a35`, `#a85a00`, `#d70015`) and the system dots (`#34c759`, `#f59300`, `#ff3b30`) for the 8 px status dot, +where 3:1 is enough. + +### 3.3 Increase contrast (`prefers-contrast: more`) + +`--sep` becomes `--sep-strong`; `--label-2` becomes `#48484a` (light) / `#c7c7cc` (dark); `--fill` +50% alpha; focus ring 3 px; borders 1 px on cards. Materials fall back to solid. + +### 3.4 Contrast checks (computed with `tools/contrast.py`, WCAG relative luminance) + +| Pair | Ratio | | Pair | Ratio | +|---|---|---|---|---| +| light label on page | 15.5 | | dark label on `#1c1c1e` | 15.6 | +| light label-2 `#636366` on white / page / sidebar (~`#e9e9ee`) | 6.0 / 5.5 / 4.95 | | dark label-2 on `#2a2a2d` / `#1c1c1e` | 5.6 / 6.6 | +| placeholder `#70707a` on white | 4.9 | | dark placeholder on `#2a2a2d` | 5.0 | +| white on accent `#0071e3` | 4.70 | | dark accent-text `#64a8ff` on `#2a2a2d` / `#1c1c1e` | 5.85 / 6.96 | +| accent-text `#0066cc` on white / page | 5.57 / 5.11 | | green `#30d158` on `#2a2a2d` | 7.1 | +| green `#1d7a35` on white | 5.4 | | orange `#ff9f0a` on `#2a2a2d` | 7.0 | +| orange `#a85a00` on white / on its soft tint | 5.1 / 4.5 | | red `#ff7a72` on `#2a2a2d` / on its tint | 5.5 / 4.7 | +| red `#d70015` on white / on its tint | 5.4 / 4.7 | | focus ring `#64a8ff` on `#1c1c1e` | 7.0 | +| focus ring `#0071e3` on page `#f5f5f7` | 4.3 | | dark `label-3` `#6e6e73` | decoration only | + +Translucent materials were checked against the worst plausible backdrop (the page colour plus the radial wash). Not measured on a real display in other themes. + +### 3.5 CSS variable block (copy into `apple.css`) + +```css +:root { + --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter Variable", system-ui, "Segoe UI", sans-serif; + --mono: ui-monospace, "SF Mono", SFMono-Regular, "Cascadia Mono", Menlo, Consolas, monospace; + --bg:#f5f5f7; --bg-base:#ececf0; --bg-elev:#fff; --bg-elev-2:#fbfbfd; + --mat-sidebar:rgba(240,240,244,.72); --mat-bar:rgba(245,245,247,.74); --mat-pop:rgba(255,255,255,.78); + --fill:rgba(60,60,67,.08); --fill-2:rgba(60,60,67,.12); --fill-3:rgba(60,60,67,.18); + --sep:rgba(60,60,67,.13); --sep-strong:rgba(60,60,67,.22); + --label:#1d1d1f; --label-2:#636366; --label-3:#8e8e93; --ph:#70707a; + --accent:#0071e3; --accent-hover:#0077ed; --accent-press:#0062c4; --accent-text:#0066cc; --on-accent:#fff; + --accent-soft:rgba(0,113,227,.10); --accent-soft-2:rgba(0,113,227,.16); + --green:#1d7a35; --green-dot:#34c759; --green-soft:rgba(52,199,89,.16); + --orange:#a85a00; --orange-dot:#f59300; --orange-soft:rgba(255,159,10,.17); + --red:#d70015; --red-dot:#ff3b30; --red-soft:rgba(255,59,48,.12); + --r-xs:6px; --r-sm:8px; --r-md:10px; --r-lg:14px; --r-xl:18px; --r-2xl:22px; --r-pill:999px; + --sh-card:0 0 0 .5px rgba(0,0,0,.06),0 1px 2px rgba(0,0,0,.04),0 2px 8px rgba(0,0,0,.03); + --sh-pop:0 0 0 .5px rgba(0,0,0,.1),0 2px 6px rgba(0,0,0,.08),0 16px 48px rgba(0,0,0,.18); + --ease:cubic-bezier(.22,1,.36,1); --ease-sheet:cubic-bezier(.32,.72,0,1); --ease-spring:cubic-bezier(.34,1.4,.64,1); + --d1:120ms; --d2:200ms; --d3:320ms; --focus:#0071e3; +} +``` +Dark values: see `tools/build_mockup.py` (`DARK`) for the full list; they are the right-hand column of 3.1. + +--- + +## 4. Type scale + +| Style | Size / line | Weight | Tracking | Use | +|---|---|---|---|---| +| Large title | 28 / 34 | 650 | -0.024em | page title (`h1`) | +| Title | 22 / 28 | 650 | -0.020em | settings pane title | +| Headline | 17 / 22 | 600 | -0.016em | card and sheet titles, section heads | +| Subhead | 15 / 20 | 600 | -0.012em | toolbar title, stage titles (16), row titles (14.5/550) | +| Body | 14 / 20 | 400 | -0.006em | default | +| Callout | 13 / 18 | 400-500 | -0.004em | row subtitles, captions under controls, buttons (13.5) | +| Caption | 12 / 16 | 400 | 0 | hints, footers, table headers, honesty lines | +| Micro | 11.5 / 14 | 600 | 0 | sidebar group labels, badges (never uppercase except LIVE badge) | +| Stat number | 34 / 40 | 700 | -0.030em | Home stats, verdict word | + +Tabular numerals (`font-variant-numeric: tabular-nums`) on counts, times, tables. Monospace only for run refs, URLs and code. Minimum text size 11.5 px (HIG minimum 10 pt on macOS). +Body is 14 px, not Apple's 13 pt, because web text at 100% zoom on Windows renders lighter and smaller than on macOS; the HIG says default size guidance is for system fonts, and Inter at 14 matches SF at 13 optically. + +## 5. Space, shape, depth, motion + +### 5.1 Spacing (8-pt grid) +4 / 8 / 12 / 16 / 24 / 32 / 40 / 48 / 56. Page gutter 40; section gap 32; card padding 20; list row 12x16 with 56 min height; toolbar 56; sidebar 264 (min 232, collapsible to 0); +inspector 456 (400 under 1180 px); content max width 960 (wide pages 1120); readable lede 62 ch. + +### 5.2 Radii (continuous-corner feel) +6 (kbd, minor), 8 (menu items), 10 (fields, nav items, icon tiles, tap rows), 14 (banners, inner boxes), 18 (cards, grouped lists), 22 (sheets, palette), 999 (buttons, chips, segmented, search). +Rule of concentricity: inner radius = outer radius minus the padding between them, never less than 6. Browsers do not offer true squircles; the 18/22 radii plus a 0.5 px ring approximate it. The app icon uses a real superellipse path (n = 5). + +### 5.3 Elevation +- Content layer: **no shadows on lists**; cards get a 0.5 px ring plus 1-2 px soft shadow (`--sh-card`). +- Floating layer (menus, palette, sheets, toasts): `--sh-pop` (ring + 2/6 + 16/48). +- Stage card waiting for you: 1.5 px orange outline + 24 px orange glow at 12%. +- Hero card (Home): the only gradient surface (accent to indigo mix) and a coloured shadow. One per app. + +### 5.4 Materials +Sidebar: blur 28, saturate 180%, alpha .72; toolbar: blur 24; popovers 30-40. A radial wash behind the sidebar (blue top-left, violet bottom-left, 7-10% alpha) gives the material something to show. +Fallbacks per 3.1. Do not use `backdrop-filter` on scrolling lists or tables (performance), and never stack blurred layers except toast over page. + +### 5.5 Motion + +| Token | Value | Use | +|---|---|---| +| `--d1` 120 ms, `--ease` | hover, press (scale .975), colour | buttons, rows, nav | +| `--d2` 200 ms, `--ease` | fades, switch colour, menu in (scale .96 to 1, translateY -4) | menus, overlays fade-in, banners | +| `--d3` 320 ms, `--ease-sheet` | sheets (translateY 22 + scale .975 to 1), palette (-10), sidebar slide, page enter (translateY 6) | | +| `--ease-spring` 320 ms | segmented thumb, switch knob (one 4% overshoot) | | +| shimmer 1.4 s linear, pulse 1.8 s, LIVE blink 1.4 s | skeleton, "Testing" dot, LIVE badge | only while the state lasts | + +**Reduced motion** (`prefers-reduced-motion: reduce`): all durations 1 ms, no transforms on enter, no shimmer or pulse (static dots), springs become fades. Page enter and sheet become instant opacity. +Never animate `backdrop-filter` or blur radii. + +## 6. Components + +| Component | Spec | +|---|---| +| **Sidebar** | 264 px, `--mat-sidebar`, inner hairline right edge. Brand row (30 px `favicon.svg`, name 14.5/650, org name 11.5 caption). **Environment switcher** (radius-10 fill, tile 26 px: orange shield "Local mock pod / Mock app, not Oracle Fusion" or blue cloud "Acme UAT 26C / Oracle Fusion pod"; chevrons; opens a menu). Nav: Home, Test runs (orange count capsule), Ask; group "Library": Scenarios, Defects, Reports; group "Setup": Test environments, Settings (admin). Row 32 px, radius 10, icon 18 px accent, selected = `--fill-2` + 600 weight. Kill indicator (red, only when engaged) above the user row. Bottom: user row (avatar 28, name, role) opens account menu (appearance, Settings, Sign out). Hide with the toolbar button or `[`. | +| **Toolbar** | 56 px, `--mat-bar`, 0.5 px bottom hairline. Left: sidebar toggle (icon button 32), back link (accent, only on detail pages), title 15/650 + one-line caption. Right: page actions, then search field (pill, 300 px, "Search or ask" + `Ctrl K` / `⌘K` hint by platform). Content scrolls under it. | +| **Buttons** | pill. Regular 32 (13.5/500), small 28, large 40 (14.5). Primary = accent fill, white 600; secondary = `--fill`; plain = accent-text on transparent (hover `--accent-soft`); destructive = `--red-soft` with red text, and solid red only for irreversible, confirmed actions (Engage kill switch). Disabled .42 opacity. Press = scale .975. Loading = spinner replaces icon, label stays. **One primary per screen.** | +| **Icon buttons** | 32 (28 small), circular hover fill, `aria-label` required, tooltip after 600 ms. | +| **Segmented control** | pill track `--fill`, 2 px inset, thumb `--bg-elev` (dark `#5e5e63`) with `--sh-seg`, 28 px segments, 13/500, sliding thumb 320 ms spring. 2 to 5 segments (counts allowed: orange for waiting). Roving tabindex, arrows move and select. | +| **Inset grouped list** | `--bg-elev`, radius 18, `--sh-card`. Rows min 56, padding 12x16, leading tile 36 (radius 10; neutral, or orange/green/red/blue soft with a glyph), title 14.5/550, subtitle 13 `--label-2`, trailing status or button, chevron for navigation. Hairline between rows inset 66 px when a leading tile exists. Hover `--fill`; whole row is the hit target. A group has an optional 13/600 `--label-2` header above and a 12 caption footer below. | +| **Table** | in a grouped card. Header 12 `--label-2`, 52 px rows, hairlines, sortable headers (aria-sort), selected row `--accent-soft`, row actions (ellipsis) appear on hover and focus-within, numbers tabular. No zebra. | +| **Text field** | 38 px, radius 10, 1 px `--sep-strong` inset border; hover darker; focus = 1.5 px accent + 4 px `--accent-soft-2` halo; error = red border + message below (12 px red). Label above (13/500), hint below (12 caption). Stacked fields in one group for sign-in (Apple-ID style), outline on the group when any field has focus. | +| **Switch** | 44x26, knob 22 with shadow, on = system green `#34c759` (green here means "on", the single exception to "green = status"; it is the platform's switch colour). | +| **Radio list / choice cards** | radio rows in a bordered group (decision), choice cards with 2 px accent border and `--accent-soft` when selected (sheet steps). `role="radio"`/`checkbox` with `aria-checked`. | +| **Chips and status** | status = 8 px dot + word (13/550, never colour alone). Chips: 22 px pill, 12/550, for environment (Practice orange with shield, Oracle Fusion blue with cloud), severity, signed-off state. | +| **Banner** | radius 14, soft tint, 18 px glyph, body 13.5. orange = reminder/practice, red = error with "Try again", blue = information. | +| **Sheet** | modal, 600 px (max 100vw-48), radius 22, `--bg-elev`, `--sh-pop`, scrim; header (20/650 title, 1-line sub), body scroll, footer: Cancel left, secondary and primary right. Focus lands on the dialog; Esc and scrim click cancel; focus returns to the opener. One at a time. 3-step progress as three 4 px bars. | +| **Menu / popover** | `--mat-pop`, radius 14, padding 6, items 32 px radius 8; hover/keyboard highlight = accent fill with white text (macOS convention); group labels 11.5/600; hairline dividers; opens from its trigger with a 200 ms scale-in; Esc closes; arrow keys move. | +| **Command palette** | `Ctrl/⌘ K` or the search field. 640 px, radius 22, `--mat-pop`, input 18 px; groups: Waiting for you (when empty), Go to, Test runs, Actions, then "Ask: ..." as the fallback. Selected row = accent fill. Footer: key hints and "Nothing changes until you confirm." Actions that change data (Approve) only navigate to the confirm UI. Implemented so that **Ask** still opens the existing `aside aria-label="Ask the co-worker"` dock (see BUILD-PLAN risks). | +| **Toast** | bottom centre, `--mat-pop`, radius 18, green check disc, one action ("Watch live", "View run"), 4.2 s, max 2 visible, `role="status"`. Used after: approve, decision, sign-off, pod saved, kill switch. Errors are never toasts; they are banners next to the cause. | +| **Empty state** | 56 px grey tile with a glyph, headline 17/600, one sentence (42 ch), one action. Copy always says what to do next. | +| **Skeleton** | rounded bars `--fill` with a 1.4 s shimmer; same row heights as real rows; `aria-busy="true"` on the region; replaced by the real content with a 200 ms fade. Never a bare spinner for more than 300 ms. | +| **Error state** | red banner at the top of the region: what failed, the likely reason, "Try again" (calls `refetch`). Technical detail behind "Show details". | +| **Progress** | 6 px capsule `--accent` on `--fill-2`, with `role="progressbar"`; text under it states done / total and time left. | +| **Live badge** | 22 px pill: LIVE (red, blinking dot), STARTING / PAUSED / ENDED (grey), RECONNECTING (orange). The word is always present (colour is not the signal). | +| **Browser frame** | 30 px chrome (three neutral dots, centred URL pill with a lock), 16:10.2 viewport, radius 14, hairline ring; state overlays use `--bg-elev` at 84% plus a 10 px blur. The frame is always light-chrome content (the test environment's page) even in dark mode. | + +## 7. Accessibility + +- **Contrast:** AA (4.5:1 text, 3:1 UI and large text) everywhere, checked in 3.4. Status never by colour alone. `prefers-contrast: more` variant in 3.3. +- **Focus ring:** 2 px solid `--focus` with 2 px offset on buttons, rows, nav, segmented segments, switches (3:1 against both themes). Text fields: accent border + 4 px halo. Menus/palette: the highlighted item is the focus. Never `outline: none` without a replacement. Mantine's `focusRing: 'auto'` is kept. +- **Targets:** 32 px default (HIG macOS default 28, minimum 20), 28 px small, 40 px stage actions; table rows are fully clickable. +- **Keyboard map** (single keys only when focus is not in a field; shown in the `?` sheet and the Glossary popover footer): + +| Keys | Action | +|---|---| +| `Ctrl/⌘ K` | command palette (search, go to, actions, ask) | +| `/` | focus search (opens palette) | +| `N` | new test run (opens the Start sheet) | +| `[` | hide / show the sidebar | +| `G` then `H` / `R` / `S` / `D` / `E` / `P` | go to Home / Test runs / Scenarios / Defects / Test environments / rePorts | +| `Alt+1` / `Alt+2` / `Alt+3` | focus the stage list / the inspector tabs / the inspector content (run page) | +| `←` `→` | move inside a segmented control; `↑` `↓` inside menus, radio lists, palette | +| `Enter` / `Space` | activate; `Enter` on a table row opens it | +| `Esc` | close menu, palette, sheet; clear search | +| `?` | shortcuts sheet | +| `Ctrl/⌘ Enter` | submit the focused sheet or confirm card (never approves anything without a visible button) | + + Approving, deciding, signing off and the kill switch have **no single-key shortcut** by design. +- **Screen readers:** landmarks `nav "Pages"`, `main`, `aside "Run details"`, `aside "Ask the co-worker"`; sidebar count has a visually hidden ", 2 waiting for you"; stage changes announced through a polite `role="status"` line ("Waiting for your approval: 79 scenarios"); the live view's overlay text is `role="status"`, the live "Now:" line is `aria-live="off"` (existing) so it does not chatter; toasts `role="status"`; tables have captions/`aria-label` and `aria-sort`; icon-only buttons have labels; progress has `aria-valuenow`. +- **Motion:** section 5.5. **Transparency:** `prefers-reduced-transparency`, `forced-colors` (Windows High Contrast: borders replace fills, `CanvasText` for text, `Highlight` for selection and focus), and missing `backdrop-filter` all fall back to solid. +- **Zoom:** layout tested conceptually to 200% (sidebar collapses via `[`; the inspector becomes a section below the stages under 1180 px logical width, already how REDESIGN planned it). Not tested on a real browser at 200%. +- **Language and tone:** reading level plain; no abbreviations without a gloss on first use (P2P is written "Procure-to-Pay" in UI; module codes appear only in test ids). + +## 8. Shell and screens + +### 8.0 Shell +Sidebar + toolbar as in section 6. Route to nav mapping: Home `/`; Test runs `/runs`, `/runs/new`, `/runs/:id`, `/runs/:id/:tab`, `/schedules`; Ask `/assistant`, `/assistant/:id`; Scenarios `/scenarios`; +Defects `/tickets`; Reports `/reports`; Test environments `/pods`; Settings `/admin` (and `/agents`, `/heal`, `/scripts`, `/learner`, `/audit`, `/admin/*`). The page `` is "Page · Trio Co-Worker (practice pod, mock app)" while a practice pod is selected. +Global states: loading = skeleton rows inside the page (the shell never blanks); error = red banner; offline/"test environment down" = amber banner under the toolbar with "The test environment is not answering" (replaces the sidebar warning); emergency stop on = red row in the sidebar and a red banner at the top of Home and the run page. + +### 8.1 Sign in, register, forgot, reset (`/login`, `/register`, `/forgot`, `/reset`) +- **Layout:** one centred 400 px column on a soft three-colour radial wash (blue, violet, green at 10-22% alpha; solid page colour in dark with 10-16% alpha), vertical centre. `app-icon.svg` 116 px, `h1` 28/650, one sentence, stacked fields group (Username, Password; Apple-ID style, 48 px rows), full-width primary 40 px, two text links, the orange honesty line with shield (`data-testid="mock-banner"` kept), version caption. +- **Content:** "Sign in to Trio Co-Worker" / "Your team's patch testing partner. It plans and runs the tests. You decide." Links: "Forgot your password?", "Create account". Honesty: "Practice environment. Mock app, not Oracle Fusion." (hidden on production deployments that have only Fusion pods; the line then reads "Connected to Oracle Fusion test pods.") +- **Register:** "Create your account" / "An administrator approves new accounts before you can sign in." Fields Username, Email, Password ("At least 12 characters"). Success: "Account requested" (`register-sent`). **Forgot:** "Reset your password"; success "Check your email" (`forgot-sent`). **Reset:** "Choose a new password"; success `reset-done` then back to sign in with a toast. +- **States:** submitting = button spinner, fields disabled; wrong password = red inline message under the group ("That username or password is not right. Try again.") and focus returns to Password; locked/disabled account = banner with "Ask an administrator"; network down = banner "Can't reach Trio Co-Worker. Check your connection." Labels "Username", "Password", button "Sign in" unchanged (tests). +- Keyboard: Enter submits; autocomplete attributes set; password reveal not offered. + +### 8.2 Home: Patch readiness (`/`) +- **Head:** `h1` "Patch readiness" (e2e), lede "Oracle update 26C on the practice pod. Pod release checked 21 Oct at 13:12." Right: patch select (pill, `aria-label` "Patch"), environment select if needed (`aria-label` "Test environment"), primary **New test run** (exact name; opens the Start sheet, `?new=1` too). When something waits, the first waiting row's button is the stronger action visually but "New test run" stays the only `filled` button on the page. +- **Summary row (3 cards):** hero "1 of 4 areas ready" with a segmented bar and a plain sentence; "Waiting for you 2"; "Open defects 3, 1 critical". Numbers come from existing endpoints (`useRuns`, readiness, tickets). +- **Waiting for you** (hidden when empty): grouped list, each row names the action ("Approve 79 scenarios for Procure-to-Pay", "Decide 1 failure in Order-to-Cash"), orange icon tile, one supporting line, button ("Review scenarios", "Decide"). Row opens the run at the right stage. +- **Business areas:** one row per area: name, last finished verdict as dot + word (Ready / Not ready / Not tested yet), one sentence, trailing "Start a test run" for untested. `readiness-<MOD>`, `verdict-<MOD>`, `summary-<MOD>` kept. +- **What this patch changes:** one row with a blue info tile; opens the existing accordion/sheet content (button name "What this patch changes"), glossary link in the footer. +- **States:** loading = hero and rows skeleton; empty (no runs yet) = Business areas shows all "Not tested yet" and the hero reads "No areas tested yet" with the primary highlighted; error = banner "Couldn't load readiness. Try again." Practice versus Fusion: lede names the pod. + +### 8.3 Start a test run (guided sheet; `?new=1`, `N`, palette, empty states) +**Four steps, same as today's `StartRunWizard` (Where, What, How, Review)**, in one sheet with a 4-bar progress and Back / Next / Cancel; the last button is **Start run** (the e2e clicks exactly that name). The mockup's sheet passes the repo's e2e locators for this flow (`New test run` in `main`, button `/Local mock pod/` with `aria-pressed`, checkbox `/Procure-to-Pay/` checked by default, radio "Quick simulation (no browser)", button `/Demo options/`, label "Scenarios that fail with a real defect", `Next`, `Start run`), tested with Playwright in light and dark. +1. **Where should I test?** "Step 1 of 4. Pick the test environment." Two kinds of choice (toggle buttons with `aria-pressed`): "**Local mock pod**: Practice environment. Mock app, not Oracle Fusion. Good for learning and rehearsal." (orange tile) and each enabled Fusion pod ("Acme UAT 26C: Oracle Fusion pod. Your test environment. Results count towards sign-off.", blue tile). Preselected from the sidebar switcher; pods that are not runnable show greyed with the server's reason. (The mock pod's name stays "Local mock pod"; "Practice environment" is its kind label.) +2. **What should I test?** Checkbox cards per business area, label "Procure-to-Pay (P2P)" (`area-<MOD>` kept), the area of the selected patch pre-ticked. Next disabled until one is ticked. +3. **How should I run it?** Radio cards "Quick simulation (no browser)" (`mode-quick`) and "Full browser run" (`mode-live`; disabled when browser runs are off, with the reason). On the mock pod a "Demo options" disclosure reveals "Scenarios that fail with a real defect", "Also run High-priority scenarios", and patch name; on Fusion pods "Watch the test live" replaces it. +4. **Ready to start?** A grouped summary (Where with its environment chip, What, How), then the honesty banner (orange on the mock pod, blue on Fusion): "This runs on ... What happens next: the agents scan the pod and the release notes, then pause and ask a consultant to approve the test cases. You will see each step on the run page." +Starting navigates to `/runs/:id` (no extra segment) and shows a toast "Test run started. The agents are preparing the scenarios." Errors (pod not runnable, kill switch on, no permission) show as a banner in the sheet and keep it open. While any sheet or the palette is open, the page behind is `inert` and `aria-hidden` (so role queries and screen readers see only the dialog; this is also what makes the e2e's single `/Local mock pod/` button unambiguous). + +### 8.4 Run workspace (`/runs/:id`, `/runs/:id/:tab`): the heart + +**Toolbar:** back "Test runs", title "Procure-to-Pay", caption "Update 26C · Local mock pod · started 13:12", **All details** menu (`data-testid="all-details"`, items in 8.4.6), **Cancel test run** (destructive, asks to confirm; `run.control`), search. +**Layout:** two columns. Left: scrolling stage column (max 680, centred). Right: inspector 456 px (solid `--bg-elev`, hairline left edge) with the segmented tabs and a scrolling pane. Under 1180 px the inspector narrows to 400; under 1100 it becomes a section after the stages. + +#### 8.4.1 Run header (inside the stage column) +`h1` "Procure-to-Pay test run" (`run-title`), then a meta row: status dot + words (`run-status`: "Waiting for your approval" orange, "Testing, scenario 23 of 79" blue pulsing, "Waiting for your decision" orange, "Finished: Ready/Not ready/On hold" green/red/orange, "Stopped" grey/red), environment chip (`mock-banner`, "Practice environment" orange or "Oracle Fusion pod" blue), run type chip ("Full browser run" / "Quick simulation"), reference chip with copy icon (`run-id`, aria-label "Run reference r-7f3a2c, copy"; admin `temporal-link` appears here). `attention` reminder banner sits above the stages when set. Resume (secondary) shows when paused. + +#### 8.4.2 Stages (numbered, vertical rail) +Marker 32 px: grey number (todo), accent number with a 5 px soft ring (current), orange number with orange ring (current and waits for a person), green check (done); the rail between markers turns green for done stages. Titles 16/600; a one-line summary for every stage; only the current stage has a card (`data-testid="run-guide"` + `data-stage` = prepare | approve | testing | judge | result | stopped on the card). +1. **Prepare** (done): "Chose 79 scenarios. See what each agent did" (opens the Team board `/runs/:id/workflow`). While running: three ticks (scouting, researching, designing) with a skeleton line. +2. **Approve the scenarios** (waiting): orange card. Headline "79 scenarios are ready to test", lede "A scenario is one business check. 75 of them cover something this update changes. 2 are new, written by the AI model, and passed a dry run on the practice pod." Actions: primary large **Approve all 79 and start testing** (`guide-approve-all`), secondary **Let me look at them first** (exact; expands the review inline, `scenario review`), plain **Download as Excel** (`excel-script`). Done summary: "Approved by Sai Anirudh at 13:13." +3. **Testing** (running): card "Running scenario 23 of 79", lede "You are asked only if one fails. Watch it on the right, or keep working. We will tell you when something needs you.", progress bar with "22 passed, 0 failed" and "About 14 minutes left" (`guide-progress`). Quick simulation shows `no-live-note`: "This is a quick simulation, so there is no browser to watch. Choose “Full browser run” next time to see the test live." + **Your decision** (waiting, renamed stage 3): see 8.4.5. +4. **Result:** see 8.4.6. Stopped runs replace stages 3-4 with the Stopped card (reason, "Carry on from where it stopped" for `run.control`). +Stage changes announce via a polite status line; focus moves to the new card's primary button only if focus was in the stage column or on `body`. + +#### 8.4.3 Approvals (inline review and `/runs/:id/scenarios`) +- Inline review (from "Let me look at them first") shows grouped rows: group header (step name, "4 of 7 shown", plain link "Approve all 7 Requisition scenarios"), rows with title, caption ("Critical. Changed by the update." / "High. Written by the AI model, dry run passed at 11:23."), and an **Approve | Skip** segmented control (accessible names unchanged: "Skip Rejected requisition for this patch"), a sticky review bar ("4 of 79 approved" `review-count`, secondary "Approve the remaining 75", primary **Submit review**; `review-bar`, `approve_cases` payload unchanged). Filter tabs All / Changed by the update / Written by the AI model / Critical (segmented, with counts). "Approve all 1 unchanged" and "Unchanged (1)" keep their names. AI drafts show "Dry run passed" or "Not runnable: reason" (`dry-run`, `ai-not-runnable`). +- Full page `/runs/:id/scenarios` uses the same list at full width with the inspector showing the selected scenario's steps. +- After submit: toast "Approved 79 scenarios. Testing has started." with **Watch live**. + +#### 8.4.4 Live browser panel (inspector tab Live; `/runs/:id/live`) +Header: scenario title (15/600) + one line "Procure-to-Pay â€ș Requisition · Signed in as Buyer · scenario 23 of 79", state badge at right. "Now:" line (`live-action`, 13 px, play glyph) when active. Browser frame (`live-frame`), then controls row: **Pause view** (freezes the last frame client-side; the test keeps running), **Fullscreen**, right-aligned freshness caption ("Updated just now", "Last picture 8 s ago"). Honesty line (always): "Test data only. This is the test environment's browser, not your own session." Below: **Results so far** (last three, newest first, failed first with a red X, durations) and **Up next**. `live-view`, `live-title`, `live-frame`, `live-action`, `live-failure-banner`, `live-unavailable` kept. + +| State | Trigger (existing data in `LiveView.tsx`) | Badge | Overlay (title / sentence) | Controls | +|---|---|---|---|---| +| **Starting** | `l.active` and no `frame_ts` yet | STARTING grey | "Starting the browser" / "This takes a few seconds. The first screen appears here." + indeterminate bar | all disabled | +| **Live** | `l.active`, frame arriving | LIVE red blinking | none; an orange ring shows the element being acted on | Pause view, Fullscreen | +| **Sign-in hidden** | `l.masked` | LIVE | lock tile, "Sign-in screen hidden" / "Passwords are never shown here."; Now line "Signing in (the sign-in screen is not shown)" | Fullscreen | +| **Reconnecting** | `l.active && l.stale`, or stream `onError` (retry after 2 s, existing) | RECONNECTING orange | spinner, "Reconnecting to the test browser" / "The test keeps running. We show the last picture we received." Caption "Last picture N s ago" | Fullscreen only. After 30 s: add a plain button "Reload the picture" (new, bumps `conn`) | +| **Paused for your review** | status waiting; `gate` approve or human_review | PAUSED grey | pause tile (orange), "Paused for your review" / "Testing starts after you approve the scenarios." or "Testing continues after you decide the failure." | disabled | +| **Preparing next batch** | not active, running, `everActive` | STARTING | "Preparing the next batch of scenarios" / "The browser opens when the scenarios start." | disabled | +| **Ended** | not active and not running | ENDED grey | check tile, "Testing has finished" / "Open the report for the results." plus **Watch the recording** link when saved | disabled | +| **Unavailable** | `l.available === false` | none | replaces the frame with an empty state (`live-unavailable`): "Live view is not available" + the server's `reason`; for quick simulations the fixed text (`no-live-note` wording); secondary action "New test run" | none | +| **No permission** | `!canWatch` | none | "Watching the test needs the consultant, QA approver or admin role." | none | +| **Failure seen** | `l.failed` or failed results | banner above frame | red banner `live-failure-banner`: "This step failed. Testing continues with the next scenario." + **See the failed screen** (modal) + **Open in failure review** | | + +The frame never shows a spinner without words. View-only is stated, there is no click-through, no "take over". + +#### 8.4.5 Failures and decisions (stage "Your decision"; `/runs/:id/failures`) +Orange card: "1 scenario failed. What should we do?", lede names the scenario and what went wrong in one sentence. **We expected | What happened** pair (red tint on the actual). Evidence strip: 112 px thumbnail of the failed screen, "Screen at the moment it failed", "Step 6 of 9 · 11:48:02", **See the failed screen**. Radio list (`guide-failure-<id>`): "Yes, this is a real defect" (preselected with a "Suggested" chip, caption "We raise a defect with the screen and steps attached. This scenario counts as failed."), "No, the test needs fixing" (self-heal proposes a corrected step), "It is flaky, run it again" (retries up to 3, owner select). Primary **Submit decision** (`guide-submit-decisions`; multiple failures use Back/Next and a final submit). Waiver for P2 priority and a note field live behind "Add a note or waive" (`gate.human_review`). After submit: toast naming the defect raised; stage 3 returns to Testing or moves to Result. + +#### 8.4.6 Result and sign-off; All details menu +- **Result card:** verdict word 34/700 in status colour (Ready green, Not ready red, On hold orange; `decision-badge`, `data-rule`), one sentence why, five numbers (tested, failing, not run, defect raised, steps not covered; `process-summary`), primary **Open the report and sign off**, plain **Download the results (Excel)**, honesty caption "Tested on the practice pod. Mock app, not Oracle Fusion. Sign-off is yours to give." (`guide-result`). +- **Report page** (`/runs/:id/report`): back link "Test run", title "Procure-to-Pay report", lede names the environment; toolbar-row actions Share, Download PDF (`pdf-link`), More downloads menu (Markdown, HTML, run-summary.json, Excel); verdict card with five numbers (`exec-summary`); "Results by business process" table (`criteria`, steps with Matched / Waived with a note); open defects; HTML report iframe titled "<MOD> go/no-go report" (contains NOT ORACLE FUSION on practice); **Sign off** card (`signoff`: "Sign-off is yours to give. It records your name, the time and your comment in the audit log.", comment field, primary **Sign off this report**, plain **Audit details**). After sign-off the card becomes "Signed off by Sai Anirudh, 21 Oct 2026, 13:41" with a green shield tile, and the toolbar shows a "Signed off" chip. +- **All details menu:** Watch the test live · Screens · Scenarios · Failures · Team board · Report and sign-off · By business process · What the patch changes · Activity log · Add a note for the team · Excel test script · group "Engineering views (admin)": Coverage map, Data plan, Scripts, Technical report. Names "Activity log", "Scenarios", "Failures", "Report and sign-off" verbatim (e2e). + +#### 8.4.7 Inspector tabs +- **Live:** 8.4.4. **Steps:** the selected scenario's steps as a numbered grouped list with state (done check, running spinner, next), plain-language text, duration; a caption "Steps are written in plain business language. The code behind them is in All details." **Screens:** film-strip cards per scenario with pass/fail word, step, "Watch the recording"; `proof-card`s, search field, pager, permission fallback text. **Report:** state of the report, primary "Open the report and sign off", PDF / Copy link. **Excel:** two rows: Test script, Results (`excel-script`). `?scenario=<id>` selects the scenario for Steps/Screens. +- Resizable by dragging the left edge (400 to 560); collapsible; remembered per user. + +### 8.5 Test runs (`/runs`) +Head: title, lede, plain link "Scheduled runs", primary **New test run**. Segmented filter: All · Waiting for you (orange count) · Running (count) · Finished · Stopped (+ "Started by me" switch). Table in a grouped card: Test run (name + run type caption), State (dot + word), Where (environment chip), Started; row opens the run; ellipsis menu (Open, Report, Resume, Cancel) on hover/focus; `run-row-<id>` kept; sortable headers. Empty: "No test runs yet. Start one and the co-worker plans the scenarios for you." + primary. Footer "Showing 6 of 6 test runs." with pager when more. `?waiting=1` preselects the filter. + +### 8.6 Scenarios (`/scenarios`) +Master-detail: table (Scenario with "Area â€ș Step" caption, Priority, Origin, Last result) at left, inspector at right with the selected scenario's steps, Excel, "Show in a run". Filters (segmented): All, Changed by the update, Written by the AI model, Critical; search; Export Excel in the head. `aria-label="scenarios library"`. Empty and error states as 6. Edits are an admin/consultant action with audit entry (existing permissions). + +### 8.7 Defects (`/tickets`) +Table (`aria-label="tickets"`): Defect (title + ID), Area, Severity chip, Status dot (Open orange, Fixed green, Waived grey), Raised, Test run link. Segmented: Open (count) · Fixed · Waived · All. Row opens a right inspector (evidence, steps, owner, link to run). Footer: "Defects stay in this list; they are not sent to another system unless an administrator turns that on." Empty: "No open defects. Nice." + +### 8.8 Test environments (`/pods`) +Head with primary **Add a Fusion pod** (opens the sheet "Add an Oracle Fusion test pod": Pod name, Pod URL, Environment type segmented Test/UAT/SIT/Development, Modules chips, notes; banner "Sign-in details come next. Passwords go to the secrets vault and never reach an AI model."; "Production pods are refused" as lede). Cards in a 2-column grid, **clearly labelled by kind**: +- **Local mock pod:** orange chip with shield "Practice environment", name, URL, orange banner "Mock app, not Oracle Fusion. Use it to learn the co-worker and rehearse a run. Results never count as a Fusion sign-off.", connection dot + words, "Ready for test runs", **Test connection**. +- **Oracle Fusion pod:** blue chip with cloud "Oracle Fusion pod", environment type chip (UAT), release and modules, connection dot ("Connected, checked 12:58" / red "Connection failed, checked ...: reason"), "Sign-in details: P2P (set by Sai)...", buttons **Test connection** (`pod-test-result` line under the grid), **Sign-in details** (sheet with module, test username, test password; password never shown again), Enabled switch, default marker. +- A dashed "Register a Fusion pod" row at the end. `pod-<id>`, `data-kind` kept. Capture-screen API (#38) stays API-only; if a UI is added it lives in a card "..." menu. + +### 8.9 Reports (`/reports`) +Grouped list (`aria-label="reports"`): leading tile coloured by verdict, "Procure-to-Pay, update 26C", "19 Oct, practice pod. 78 of 79 passed.", trailing verdict word and "Not signed off" / "Signed off" chip. Row opens `/runs/:id/report`. Filters: verdict, signed off, environment. Empty: "Reports appear here when a test run finishes." + +### 8.10 Ask (`/assistant`, `/assistant/:id`) and the Ask dock +- **Page:** centred 760 px thread; user bubbles accent with white text (radius 20, tail corner 6), assistant answers in white cards with the product avatar (`favicon.svg` 32), answer **cards** inside bubbles (readiness card `chat-card-readiness`, run progress `chat-run-progress`, mock strip `chat-mock-strip`), each answer ends with a caption "Source: your latest test runs and defects." (`chat-source`). Proposed actions are **confirm cards** (`chat-confirm`, "Nothing changes until you confirm.", primary `chat-confirm-button`, Cancel; after: "Done · test run started" `chat-action-done`, or `chat-action-closed`). Composer: glass pill at the bottom, placeholder "Ask about a run, a defect or an area" (`assistant-input`), send button, context chip when scoped (`chat-context`, removable). +- **Hermes notice (honesty rule):** when Hermes answered, that answer's caption reads "Source: ... Answered by the Hermes assistant." and the composer caption reads "The Hermes assistant uses NVIDIA's AI model. Don't paste client data." When Hermes is off or did not answer, neither line appears and answers are the built-in cards. Settings â€ș AI models has "Use the Hermes assistant for Ask" (switch) with the same disclosure. If Hermes is configured but unreachable: banner "The Hermes assistant isn't answering. Using built-in answers." and answers carry no Hermes line. +- **Dock:** `Ctrl K` palette's "Ask: ..." opens the existing `aside aria-label="Ask the co-worker"` (right side, 380 px, same bubbles, `chat-dock`, `chat-toggle`, `chat-new`). States: thinking (three dots), error banner with Try again, empty (suggested questions as plain-pill buttons). + +### 8.11 Settings (admin; `/admin?tab=...` and the engineering routes) +Left list inside the page (selected = accent fill, macOS Settings style) and a 720 px pane: **AI models** (Local model: "Now: running on this machine. Nothing leaves your network." + Test; External model: key state + Save key / Remove; routing table "Which agent uses which model"; Ask assistant switch), **Users** (table with role select, status, create/approve), **Automatic approval** (switches with plain sentences; "Failures are always decided by a person."), **Schedules** (grouped rows with switch, Patch watch with "Check now"; create/delete), **Emergency stop** (red tinted group, "Stop all test runs now", destructive solid **Engage kill switch** then **Release**, `kill-state`; sidebar shows `kill-indicator`), and group "Under the hood": Audit log (filter + **Verify chain**, `audit-verify`), Agent team, Self-heal (approve/reject), Scripts and drafts (promote/discard), Learner. Each pane uses the grouped-list or table patterns above; destructive or irreversible changes confirm in a small sheet with the exact consequence in the first sentence. Non-admins do not see the Settings item. + +### 8.12 Command palette and global search +Specified in section 6. Result groups and microcopy: "Waiting for you" (only when the query is empty), "Go to", "Test runs", "Actions", "Ask". Empty result: "Nothing matches." then the single row `Ask: "<query>"`. Footer: "Up Down to move · Enter to open · Nothing changes until you confirm." + +### 8.13 Sidebar user menu and notifications +Menu: Appearance (cycles Match system / Light / Dark; the aria-labels "Switch to dark theme" / "Switch to light theme" stay), Settings, Sign out (aria-label "Sign out"). `whoami` is the user name. Desktop (Electron) adds "Desktop settings" and notifications through the existing `DesktopNotifier`. + +--- + +## 9. Feature map: all 58 checklist items + +Sidebar items: **Home, Test runs, Ask, Scenarios, Defects, Reports, Test environments, Settings**. "Run" = Run workspace (8.4), "Report" = `/runs/:id/report` (8.4.6), "Inspector" = right panel tab. + +| # | Feature | Place in the Apple UI | +|---|---|---| +| 1 | Report and sign-off view | Report page `/runs/:id/report`; Result card primary; Inspector Report tab; All details menu | +| 2 | Sign-off form | Report page "Sign off" card (`signoff`, button "Sign off this report") | +| 3 | Download PDF | Report page toolbar row (`pdf-link`), Inspector Report tab, More downloads menu | +| 4 | Share (copy link) | Report page "Share"; Inspector Report "Copy link" | +| 5 | MD / HTML / run-summary.json downloads | Report page More downloads menu; Technical report (engineering views) | +| 6 | Criteria explanation (Audit details, C1-C6, exec summary, rule result) | Report page "Audit details" plain button, `criteria` table, `exec-summary`, `rule-result` | +| 7 | HTML report iframe | Report page lower section, iframe title "<MOD> go/no-go report" | +| 8 | Excel test script download | Approve card "Download as Excel" (`excel-script`), Inspector Excel tab, All details | +| 9 | Excel results download | Result card plain button, Inspector Excel tab | +| 10 | Screens / proof | Inspector Screens tab (`/runs/:id/proof` opens it) | +| 11 | Technical report + evidence list | All details > Engineering views > Technical report (`aria-label="evidence"`) | +| 12 | Delete this run's evidence (admin) | Technical report, destructive button with confirm sheet (`delete-evidence`) | +| 13 | Coverage map / Data plan / Scripts (admin) | All details > Engineering views | +| 14 | Live view (stream, pause, jump to live, fullscreen, failed-screen modal, results so far, up next, honesty line) | Inspector Live tab, states table 8.4.4; "Jump to live" appears in the controls when paused | +| 15 | Now testing line + Watch | the "Now:" line (`live-action`), status dot in the run header, Live tab badge | +| 16 | Workflow / agent states | Team board (`/runs/:id/workflow`, `/team` alias) from "See what each agent did"; All details > Team board | +| 17 | Agent team graph + stream mode | All details > Activity log (`stream-mode`) | +| 18 | Activity log + team notes | All details > Activity log; "Add a note for the team" menu item | +| 19 | Scenario review (approve/skip, approve all per step / unchanged / remaining, notes, submit, AI drafts, dry run, technical details) | Approve stage inline review and `/runs/:id/scenarios`, 8.4.3 | +| 20 | Approve all (one click) | Approve card primary (`guide-approve-all`) | +| 21 | Failure decision (three choices, suggestion, owner for flaky, back/next/submit) | "Your decision" stage card, 8.4.5 | +| 22 | Open all failure details (verdict, owner, waiver, note, submit) | `/runs/:id/failures` (All details > Failures), "Submit failure review" | +| 23 | What the patch changes (per run) | All details > What the patch changes (`change-*`) | +| 24 | By business process | All details > By business process (`business-progress`) | +| 25 | Next step banner | blue banner at the top of detail views (`next-step`) | +| 26 | Attention reminder | orange banner above the stages (`attention`) | +| 27 | Resume / Cancel test run | toolbar (Cancel test run), run header (Resume) with `run.control` | +| 28 | Run reference id copy | run header reference chip (`run-id`) | +| 29 | Temporal link (admin) | run header chip (`temporal-link`) | +| 30 | Chat command input (status, approve, cancel, report, screens, new) | Ask dock and Ask page composer; palette covers navigate-type commands | +| 31 | Patch readiness (selects, module cards, what changes, glossary, New test run) | Home, 8.2 | +| 32 | Start run wizard | Start sheet, 8.3 (+ "Use the full form") | +| 33 | Test runs list (filters, row menu, getting started, pager) | Test runs, 8.5 | +| 34 | Defects / tickets | Defects, 8.7 | +| 35 | Scenarios library | Scenarios, 8.6 | +| 36 | Reports page | Reports, 8.9 | +| 37 | Test environments (add pod, sign-in details, test connection, enabled) | Test environments, 8.8 | +| 38 | Screen capture (API only) | unchanged; future home: pod card "..." menu | +| 39 | Settings > AI models | Settings, AI models pane | +| 40 | Settings > Users | Settings, Users pane | +| 41 | Settings > Automatic approval | Settings, Automatic approval pane | +| 42 | Settings > Schedules (scheduler, patch watch) | Settings, Schedules pane; `/schedules`; link on Test runs | +| 43 | Emergency stop / kill switch | Settings, Emergency stop pane; red sidebar indicator (`kill-indicator`, `kill-state`) | +| 44 | Audit log (filter, verify chain) | Settings > Under the hood > Audit log (`audit-verify`) | +| 45 | Learner | Settings > Under the hood > Learner | +| 46 | Self-heal review | Settings > Under the hood > Self-heal | +| 47 | Scripts and drafts | Settings > Under the hood > Scripts and drafts | +| 48 | Agent team | Settings > Under the hood > Agent team | +| 49 | Chat page | Ask (`/assistant`, `/assistant/:id`); intake chips live in the Start sheet (`area-<MOD>`, `mode-quick`, `mode-full`) | +| 50 | Ask-a-question dock (Ctrl K), cards, confirm actions, context chip | Palette "Ask: ..." opens the dock; Ask page uses the same components | +| 51 | Sign in / register / forgot / reset | 8.1 | +| 52 | Dark mode toggle | Account menu "Appearance", aria-labels unchanged; follows the system by default | +| 53 | Sign out | Account menu (aria-label "Sign out") | +| 54 | Desktop notifications and Desktop settings | unchanged (Electron); Desktop settings in the account menu | +| 55 | Practice vs Fusion honesty cues | sidebar switcher (`mock-banner`), run header chip, report lines, pod cards, Start sheet banner, sign-in line, page title | +| 56 | Glossary popover | Home "What this patch changes" footer link and a help button in the run toolbar; keyboard sheet `?` | +| 57 | Health badge "test environment down" | amber banner under the toolbar (and a dot on the environment switcher) | +| 58 | Brand | sidebar brand row, sign-in (`brand` testid), page title, favicon (see `brand/BRAND.md`) | + +## 10. Brand integration +Name "Trio Co-Worker" everywhere (BRAND.md section 6). Mark: `favicon.svg` in the sidebar (30 px), `app-icon.svg` on sign-in (116 px), `wordmark-*` in reports and README. The mockup embeds the real SVGs. + +## 11. What I could not verify (honest list) +- HIG: read through Apple's JSON endpoint, not in a rendered browser; I did not read the "Liquid Glass" page (corner radii/concentricity) or Apple's SF font licence text. Apple font/symbol licence statements marked above are from memory. +- Rendered only in **Chromium on Windows** (Playwright), 1440x900. Not seen in Safari, Firefox, or on macOS with real SF Pro and real vibrancy. `backdrop-filter` support is Baseline in current browsers, from my knowledge, not re-checked in this session. Inter stands in for SF in all screenshots. +- No screen reader (NVDA/JAWS/VoiceOver) pass; keyboard flow was exercised by script only (Tab, Enter, Esc, arrows in palette, Ctrl K). +- Contrast numbers are computed from the token values, with translucent materials approximated against the page colour. `prefers-contrast`, `forced-colors` and `prefers-reduced-transparency` rules are specified, not rendered. +- Layouts under 1280 px, and 200% zoom, were not rendered (the mockup has one breakpoint at 1180 px, untested). +- The live-view states mirror `LiveView.tsx` logic by reading the code; I did not run the backend, so real frame timing, `stale` thresholds and the "Last picture N s ago" caption (needs `frame_ts` age; `stale` exists today, the age may need a backend field) are unconfirmed. +- Telegram/email notifications do not exist in the repo today (no matches), so those brand placements are for when they are built. diff --git a/docs/design/UI-RESEARCH-RECOVERY.md b/docs/design/UI-RESEARCH-RECOVERY.md new file mode 100644 index 0000000000000000000000000000000000000000..8bb477b1babaf2f2e79bf5c5814b9404e60c6595 --- /dev/null +++ b/docs/design/UI-RESEARCH-RECOVERY.md @@ -0,0 +1,52 @@ +# UI research for the run page, live view, approvals and pod clarity + +Written during the recovery of the Hugging Face demo (October 2026). It records what comparable products do, what we +took from them, and what is still a proposal. Only functional changes were made on `ui-fluent-fixes`; the visual +language is decided separately. + +## 1. What comparable products do + +| Product | What it shows | Source | +|---|---|---| +| Playwright trace viewer | One list of actions; for the selected action a before and after snapshot, a timeline you can hover, and its log, source, network, errors and console. The snapshot is a live DOM, not a picture. | https://playwright.dev/docs/trace-viewer-intro | +| Browserbase live view | The browser is an embedded frame with a small bar. It can be read-only (no pointer events) or interactive. It has an explicit "disconnected" state that the host page can react to, and one live view per tab. | https://docs.browserbase.com/features/session-live-view | +| OpenAI Operator | Three modes: the agent hands control back for sign-in and payment and does not capture the screen then (takeover), high-risk sites require the person to watch (watch mode), and the agent asks for approval before a significant final action (confirmation). | https://openai.com/index/introducing-operator/ (page blocked for our fetch; summarised from https://originality.ai/pt/blog/openai-operator and the system card https://cdn.openai.com/pdf/4375e605-f9a6-438d-bcc8-190599c183a6/o3_cua_system_card.pdf) | +| Anthropic computer use | Guidance, not a UI: run in an isolated VM or container, give it no sensitive logins, restrict the network to an allowlist, and ask a person to confirm actions with real-world consequences. Check before each action, not once per batch. Stop at the first failed action. The reference demo has a chat plus a screen of the container side by side. | https://platform.claude.com/docs/en/docs/agents-and-tools/tool-use/computer-use-tool | +| mabl | Step panel with the screenshot taken before the step, a Logs tab (activity, network, DOM), a timeline where a slow or auto-healed step is marked, a chat with the agent about a failure, and an exported PDF. | https://api.help.mabl.com/docs/browser-test-output, https://help.mabl.com/hc/en-us/articles/19083859201556 | +| Opkey, Testim | Public pages are mostly marketing. Opkey sends you to a Debug Info tab and failure screenshots, and heals through impact analysis in batches, not inside the run. Not verified further. | https://customerhub.opkey.com/support/solutions/articles/88000057990-test-execution-best-practices-and-remedies-for-common-errors | + +## 2. Recommendations, and where we stand + +Run page +1. One screen answers "what is happening and what do you need from me". Keep the current step, the one action that is + waiting for the person, and progress ("3 of 5 scenarios") above everything else. Status in words, never colour only. (Done in the current run guide.) +2. Every step is traceable: the list of actions on one side, the picture of that moment on the other, the log under it + (Playwright and mabl). We have the Screens, Steps and Activity tabs; a single combined step timeline is a proposal (P1). +3. State where the test runs, always, in words: "Oracle Fusion pod" or "Practice environment, mock app". Implemented on the + run header, the environment switcher, the pod cards, and now in the start flow (quick simulation never contacts a Fusion pod). + +Live view +4. Every state is explicit (Browserbase): starting, live, paused for your review, hidden sign-in, reconnecting, finished, + unavailable with the reason. The new state is "taking longer than usual" after 60 seconds without a picture, instead of "Starting the browser" forever. +5. View only by default; a person never types into the test browser. Sign-in screens are not streamed (Operator's takeover + rule; we already mask password pages). +6. Show what the agent is doing in plain words next to the picture ("Now: ..."), already present. +7. Proposal (P2): a "browser could not open" state fed by the executor's exit status, so the page can show the real error instead of a timer. + +Approvals +8. Ask before consequential actions only, and say what will happen (Operator, Anthropic). Our two gates (approve scenarios, + judge failures) are the right places; creating tickets stays human-confirmed. Approve-all in one click is kept, with the changed-by-patch scenarios first. +9. Proposal (P2): show the same confirmation inside the chat card and in the run header so a waiting gate is never missed. + +Fusion and practice clarity +10. A real pod and the practice pod must never look alike. Full browser run is the default on a Fusion pod; the page states that + a simulation does not touch the pod. The Test environments page says which pods come from the server settings and survive a restart. + +Monthly and quarterly cycles +11. A patch name is read as quarterly (26C) or monthly (2026-10); the readiness page lists the newest tested patch first and labels + the cadence; schedules can repeat monthly or quarterly on a chosen pod and patch. Proposal (P1): patch watch for Fusion pods + (it only reads the practice pod's release today), and a "this cycle vs last cycle" comparison on the readiness page. + +## 3. Not done on purpose +- No visual change: colours, typography and layout are untouched on this branch. +- No interactive takeover of the test browser: it needs a trusted channel and is out of scope for the pilot. diff --git a/docs/design/brand/BRAND.md b/docs/design/brand/BRAND.md new file mode 100644 index 0000000000000000000000000000000000000000..d20b34a1b6ca5967ef799d41bcb688c7fd8a7de4 --- /dev/null +++ b/docs/design/brand/BRAND.md @@ -0,0 +1,116 @@ +# Trio Co-Worker: brand + +Status: proposal for approval. Replaces "Patch Testing Co-worker" / "FPT Co-worker" as the product name everywhere a person can see it. +All assets in this folder are original, hand-written SVG (generated by `../tools/gen_brand.py`). Nothing is copied from Apple, SF Symbols or any +other brand. Apple's HIG explicitly forbids using SF Symbols, or images confusingly similar to them, in app icons and logos, so the mark was +drawn from plain circles and lines. + +## 1. The name + +- **Spelling: "Trio Co-Worker"**. Capital T, capital C, capital W, hyphen, singular. Never "Trio Coworker", "TrioCoWorker", "Trio co-worker" (except + inside a running sentence, see below), "TRIO", or "Trio CW". +- In a sentence, after first use, "Trio" alone is fine ("Trio asks you before it starts testing"). Do not use "the Trio". +- Descriptor, when a line of explanation is needed: "patch testing for Oracle Fusion". Always lower case, never part of the name. + Do not write "Trio for Oracle", "Oracle Trio" or anything that implies Oracle makes or endorses the product. +- Why "Trio": three parties do the work together, the **consultant** (decides), the **AI agents** (plan, write, triage) and the **test browser** + (does the clicking on a real pod). The mark shows the same three. +- Legal line for About and report footers: "Trio Co-Worker is independent software. Oracle and Fusion are trademarks of Oracle Corporation." + (Oracle's name is used only to say which system is tested.) + +## 2. The mark + +Three round nodes joined by one closed line. + +- The **top node has a ring** (a centre dot). It is the person: the one who decides. It is also the largest. +- The two lower nodes are the **AI agent** and the **test browser**. +- The line closes into a triangle: no part works alone, every hand-off is visible. + +Files (all in this folder): + +| File | Use | +|---|---| +| `app-icon.svg` (512, continuous-corner rounded square, blue gradient, white mark) | app icon, desktop app, sign-in screen, PWA, social card | +| `favicon.svg` (full-bleed variant, heavier strokes for 16 px) | browser tab (`<link rel="icon" type="image/svg+xml">`) and small UI (sidebar 28-32 px, chat avatar) | +| `favicon-16.png`, `favicon-32.png`, `favicon-48.png` | `<link rel="icon" sizes="...">` fallback, Windows shortcuts | +| `apple-touch-icon-180.png` (full bleed, no transparency; iOS applies its own mask) | `<link rel="apple-touch-icon">` | +| `icon-512.png` | PWA manifest, Electron `build.icon` source (convert to .ico/.icns in the desktop build), README social image | +| `logo-mark.svg`, `logo-mark-dark.svg` | bare mark in accent blue (light / dark surfaces) | +| `logo-mark-mono-black.svg`, `logo-mark-mono-white.svg` | one-colour print, Excel header image, fax-like contexts, watermarks | +| `wordmark-horizontal-light.svg` / `-dark.svg` | report headers, email header, README, docs | +| `wordmark-stacked-light.svg` / `-dark.svg` | sign-in, About, splash, slides | + +The wordmark text is **outlined from Inter** (SIL OFL 1.1, free to use in a logo) so it renders the same in PDF, Excel, email and Telegram. +In the web UI itself the name is live text in the UI font stack next to `favicon.svg`, so it follows the user's font and the theme. + +Wordmark rules: "Trio" in the primary label colour, "Co-Worker" in the secondary label colour, one weight (600-ish), no +all-caps, no tracking changes, no outline or shadow. Never set the name in two lines inside the horizontal lockup. + +## 3. Colour + +One accent, like the app: **Apple-style blue**. + +| Role | Light | Dark | +|---|---|---| +| Accent (fills, the mark on light) | `#0071e3` (white text on it 4.70:1) | `#0071e3` for fills; mark and links use `#4da3ff` / `#64a8ff` | +| Accent text on white | `#0066cc` (5.57:1) | `#64a8ff` (5.85:1 on `#2a2a2d`) | +| App icon gradient | `#4aa3ff` to `#0062d6`, top to bottom, plus a 28% white highlight fading out by mid-height | same | +| Name text | `#1d1d1f` (Trio), `#636366` (Co-Worker) | `#f5f5f7`, `#a1a1a6` | + +Rules: +- The blue is the **brand and the primary action**. Green, orange and red are status only (ready, waiting for you / practice pod, not ready). + Never colour the logo green, orange or red, and never use the logo to mean a status. +- On a photo or a busy background use the white mono mark on the app icon, not the coloured mark. +- Never put the coloured wordmark on the accent blue. Use the white mono mark and white text. + +## 4. Clear space and size + +- **Clear space** around the mark or lockup = the diameter of one lower node (x). Nothing (text, edge, other logo) inside that. + Around the app icon: 1/4 of its width. +- **Minimum sizes**: app icon 16 px (use `favicon.svg`/`favicon-16.png`, never a scaled-down `app-icon.svg`); bare mark 14 px; horizontal wordmark 96 px wide; + stacked 72 px wide. Below that, show the mark only. +- Do not rotate, stretch, recolour a single node, add a drop shadow to the bare mark, put the mark in a circle, or animate the nodes + except for the optional 1.2 s "loading" pulse (nodes scale 1 to 1.08 one after another, disabled under reduced motion). + +## 5. Tagline + +One line, plain English. Recommended first, used on the sign-in screen and README: + +1. **"It tests. You decide."** (short, true to the approval model; use as the sign-in subtitle with a second sentence) +2. "Your Oracle patch testing partner." +3. "Quarterly patch testing, done with you." +4. "Test every patch. Sign off with confidence." +5. "You, the agents and a real browser, working as one." + +Sign-in microcopy (used in the mockup): "Your team's patch testing partner. It plans and runs the tests. You decide." + +Avoid: "AI-powered", "next-gen", "revolutionary", anything promising that the product replaces a human sign-off. Sign-off stays a person's. + +## 6. Every place the name and logo must appear + +The product name comes from one source of truth: `product_name` in `coworker/config.py` (env `FPT_PRODUCT_NAME`), served by `/api/ready` and read by the web +app (`useBrand`). Fallback strings in code must be changed too, so the name never flashes the old value. + +| # | Place | What | Logo form | +|---|---|---|---| +| 1 | Sign-in, register, forgot, reset (`web/src/pages/AuthShell.tsx`) | heading "Sign in to Trio Co-Worker", tagline, `data-testid="brand"` kept | `app-icon.svg` 116 px above the heading | +| 2 | Sidebar brand row (`AppSidebar.tsx`) | "Trio Co-Worker" + org name | `favicon.svg` 30 px | +| 3 | Browser tab | `<title>`: "Trio Co-Worker" (+ page, + "practice pod, mock app" while a practice pod is selected) | `favicon.svg`, `favicon-32.png`, `apple-touch-icon` in `web/public/` and `web/index.html` | +| 4 | `web/index.html` meta description | "Trio Co-Worker. Patch testing for Oracle Fusion. Mock app, not Oracle Fusion." | | +| 5 | Report HTML bundle (`coworker/graph/nodes/report.py`, title and `<h1>` area) | header: wordmark; footer: "Generated by Trio Co-Worker v{version}. Tested on {pod}. {practice-pod line}" | `wordmark-horizontal-light.svg` inlined as data URI (reports must be self-contained) | +| 6 | Report PDF (`coworker/adapters/pdf.py`) | page header wordmark, footer text with page numbers and run reference | same, vector | +| 7 | Excel exports (`coworker/platform/test_script.py` and the results workbook) | "Read me" sheet: logo image top-left + "Trio Co-Worker"; replace the "Patch testing co-worker" cell; document property Creator = "Trio Co-Worker" | `logo-mark.svg` rendered to PNG at 2x for the sheet | +| 8 | Emails and notifications (none exist in the repo today; add when built) | subject prefix "[Trio Co-Worker]", header wordmark, footer line, plain-text fallback with the name | `wordmark-horizontal-light.svg` (PNG for mail clients that block SVG) | +| 9 | Desktop notifications (`web/src/desktop.ts`, Electron `DesktopNotifier`) and Electron `productName`/window title | title "Trio Co-Worker", body names the run | `icon-512.png` to .ico/.icns | +| 10 | Telegram / Hermes messages (Hermes integration) | first line "Trio Co-Worker:" then the sentence; bot name and photo = `icon-512.png`; the Hermes honesty line stays ("Answered by the Hermes assistant using NVIDIA's AI model") | `icon-512.png` as bot photo | +| 11 | Ask page and dock | assistant avatar, "Ask Trio" is not used: the box says "Ask about a run, a defect or an area" | `favicon.svg` 32 px | +| 12 | README (title and badge), `README.md` HF Spaces front matter `title:`, `coworker/README.md`, `deploy/DEPLOY.md` | "Trio Co-Worker" | horizontal wordmark at the top of README | +| 13 | API docs (`coworker/api/app.py`, FastAPI `title=`; Swagger/ReDoc pages) | "Trio Co-Worker API"; set `swagger_ui_parameters`/custom favicon via `/favicon.svg` | `favicon.svg` | +| 14 | CLI banner (`coworker/__main__.py`), launcher (`fpt.cmd` header comment), start script messages (`.devcontainer/start.sh`) | "Trio Co-Worker is up: URL" | text | +| 15 | Audit log and exported evidence (`generated_by` fields where a product name is recorded) | "Trio Co-Worker vX.Y" | text | +| 16 | Docs and design files (`docs/design/*.md` headings, mockup) | name only in new docs; do not rewrite history in old design docs | | +| 17 | Mock app / practice pod chrome | stays "Practice App": it is not our product and must not look like it | none | + +## 7. Voice + +Sentence case. Plain words ("test run", "scenario", "Waiting for you", "Approve"). No jargon in headings. One sentence of explanation, then the action. +Honesty first: always say practice pod versus Oracle Fusion, and always say who decides. diff --git a/docs/design/brand/app-icon.svg b/docs/design/brand/app-icon.svg new file mode 100644 index 0000000000000000000000000000000000000000..5a189b80bd5e7ceaeb758c7fa57e5f1a91d54eb8 --- /dev/null +++ b/docs/design/brand/app-icon.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512" role="img" aria-label="Trio Co-Worker"><title>Trio Co-Worker diff --git a/docs/design/brand/favicon.svg b/docs/design/brand/favicon.svg new file mode 100644 index 0000000000000000000000000000000000000000..cfa6ea3a4f5ac893ce8f3de6111c86628c4cfe93 --- /dev/null +++ b/docs/design/brand/favicon.svg @@ -0,0 +1 @@ +Trio Co-Worker diff --git a/docs/design/brand/logo-mark-dark.svg b/docs/design/brand/logo-mark-dark.svg new file mode 100644 index 0000000000000000000000000000000000000000..d565304f2b6dc6423d65a97077c998ae93444a11 --- /dev/null +++ b/docs/design/brand/logo-mark-dark.svg @@ -0,0 +1 @@ +Trio Co-Worker diff --git a/docs/design/brand/logo-mark-mono-black.svg b/docs/design/brand/logo-mark-mono-black.svg new file mode 100644 index 0000000000000000000000000000000000000000..38ba7db6c7ef72023b844ce73808d1d039fe8413 --- /dev/null +++ b/docs/design/brand/logo-mark-mono-black.svg @@ -0,0 +1 @@ +Trio Co-Worker diff --git a/docs/design/brand/logo-mark-mono-white.svg b/docs/design/brand/logo-mark-mono-white.svg new file mode 100644 index 0000000000000000000000000000000000000000..eb976549cef8ee91d065331c96b96575eb2d5ceb --- /dev/null +++ b/docs/design/brand/logo-mark-mono-white.svg @@ -0,0 +1 @@ +Trio Co-Worker diff --git a/docs/design/brand/logo-mark.svg b/docs/design/brand/logo-mark.svg new file mode 100644 index 0000000000000000000000000000000000000000..834d6b5634ee215723ce85127c2399298a084842 --- /dev/null +++ b/docs/design/brand/logo-mark.svg @@ -0,0 +1 @@ +Trio Co-Worker diff --git a/docs/design/brand/wordmark-horizontal-dark.svg b/docs/design/brand/wordmark-horizontal-dark.svg new file mode 100644 index 0000000000000000000000000000000000000000..aff82537a94718c9b89959e2597436deb2735e44 --- /dev/null +++ b/docs/design/brand/wordmark-horizontal-dark.svg @@ -0,0 +1 @@ +Trio Co-Worker diff --git a/docs/design/brand/wordmark-horizontal-light.svg b/docs/design/brand/wordmark-horizontal-light.svg new file mode 100644 index 0000000000000000000000000000000000000000..433c1baf32f2ba0368b65bda4228a6fac8356b06 --- /dev/null +++ b/docs/design/brand/wordmark-horizontal-light.svg @@ -0,0 +1 @@ +Trio Co-Worker diff --git a/docs/design/brand/wordmark-stacked-dark.svg b/docs/design/brand/wordmark-stacked-dark.svg new file mode 100644 index 0000000000000000000000000000000000000000..47d5b7cad90e166762ec49a33d39dd4dda2898ab --- /dev/null +++ b/docs/design/brand/wordmark-stacked-dark.svg @@ -0,0 +1 @@ +Trio Co-Worker diff --git a/docs/design/brand/wordmark-stacked-light.svg b/docs/design/brand/wordmark-stacked-light.svg new file mode 100644 index 0000000000000000000000000000000000000000..d8e1297231d7f346f1c2ee9892a8901307904950 --- /dev/null +++ b/docs/design/brand/wordmark-stacked-light.svg @@ -0,0 +1 @@ +Trio Co-Worker diff --git a/fpt.cmd b/fpt.cmd index e1a51336770e4dc429df6924b8d034b3a9605e8e..3b72f212c3974504108fc08f88ca5a351f8003b7 100644 --- a/fpt.cmd +++ b/fpt.cmd @@ -1,5 +1,5 @@ @echo off -rem Fusion Patch Testing co-worker launcher (Windows). Mock app only, never Oracle Fusion. +rem Trio Co-Worker launcher (Windows). Mock app only, never Oracle Fusion. rem fpt setup | up | down | api | mock | web-dev | desktop | package | create-user | test | selftest | kill | unkill | run | resume setlocal cd /d %~dp0 diff --git a/qa/test-strategy.md b/qa/test-strategy.md index 2f914363605b483dd52816e985f5a3df17366118..45ce4a909531cb1f3b2358a82898fb1040ff4537 100644 --- a/qa/test-strategy.md +++ b/qa/test-strategy.md @@ -11,7 +11,7 @@ Earlier: v0.5 made the strategy module-generic with P1–P4 score bands; v0.4 sy ## 1. Purpose and scope -Purpose: show that each **module pack** of the Fusion Patch Testing co-worker can design, automate, run, triage and report +Purpose: show that each **module pack** of Trio Co-Worker can design, automate, run, triage and report regression tests for its module, and that its reported counts can be trusted. ### 1a. Module packs diff --git a/render.yaml b/render.yaml index b875d565bd58ca910bd56df208418f166b3df854..ef744e6da6a6ce9a0c420aae4e8e2bbf3b25448e 100644 --- a/render.yaml +++ b/render.yaml @@ -1,4 +1,4 @@ -# Render blueprint for a DEMO of the Patch Testing Co-worker. +# Render blueprint for a DEMO of Trio Co-Worker. # In Render: New > Blueprint > pick this repository. Render builds the Dockerfile and starts one web service. # # Demo limits (by design, to fit a small instance): @@ -29,7 +29,7 @@ services: - key: PATCH_WATCH_ENABLED value: "0" - key: FPT_PRODUCT_NAME - value: Patch Testing Co-worker + value: Trio Co-Worker - key: FPT_ORG_NAME value: Demo - key: FPT_BOOTSTRAP_ADMIN_USER diff --git a/web/e2e/coworker.e2e.ts b/web/e2e/coworker.e2e.ts index 0b16eeaa51494b70af7edbec94edf2e2e2ec3a24..62aa2c9721712667b39214e8727b2496ce222bca 100644 --- a/web/e2e/coworker.e2e.ts +++ b/web/e2e/coworker.e2e.ts @@ -43,7 +43,7 @@ test('consultant flow: readiness, start a test run, scenario review, failure rev await expect(page.getByTestId('pod-test-result')).toContainText('Reachable'); // start a quick simulation with one synthetic business-value defect: where -> what -> how -> review - await page.getByRole('link', { name: 'Patch readiness' }).first().click(); + await page.getByRole('link', { name: 'Home' }).first().click(); await page.getByRole('main').getByRole('button', { name: 'New test run', exact: true }).click(); await expect(page.getByRole('button', { name: /Local mock pod/ })).toHaveAttribute('aria-pressed', 'true'); await page.getByRole('button', { name: 'Next' }).click(); @@ -186,8 +186,10 @@ test('chat: ask about readiness, propose a quick simulation, confirm, and the te await expect(page.getByRole('heading', { name: 'Patch readiness' })).toBeVisible(); const total = () => page.evaluate(async () => (await (await fetch('/api/runs?limit=1')).json()).total as number); - // Ctrl+K opens the dock (a complementary landmark that pushes the page, not a modal) and focuses the input + // Ctrl+K opens the command palette; its Ask row opens the dock (a complementary landmark that pushes the page, not a modal) and focuses the input await page.keyboard.press('Control+k'); + await expect(page.getByTestId('palette')).toBeVisible(); + await page.getByRole('option', { name: /Ask the co-worker a question/ }).click(); const dock = page.getByRole('complementary', { name: 'Ask the co-worker' }); await expect(dock).toBeVisible(); await expect(dock.getByTestId('chat-mock-strip')).toContainText('not Oracle Fusion'); @@ -236,3 +238,27 @@ test('chat: ask about readiness, propose a quick simulation, confirm, and the te await fetch(`/api/runs/${id}/cancel`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': decodeURIComponent(csrf) }, body: JSON.stringify({ reason: 'e2e: chat checked' }) }); }, runId); }); + +test('brand and keyboard: the product name, the command palette (Ctrl K) and the dark appearance', async ({ page }) => { + await page.goto('/login'); + await expect(page).toHaveTitle(/Trio Co-Worker/); + await expect(page.getByRole('heading', { name: 'Sign in to Trio Co-Worker' })).toBeVisible(); + await page.getByLabel('Username').fill(E2E_USER); + await page.getByLabel('Password').fill(E2E_PASSWORD); + await page.getByRole('button', { name: 'Sign in' }).click(); + await expect(page.getByRole('heading', { name: 'Patch readiness' })).toBeVisible(); + await expect(page.getByTestId('brand')).toContainText('Trio Co-Worker'); + // Ctrl K: type, Enter, and the first match opens + await page.keyboard.press('Control+k'); + await expect(page.getByTestId('palette')).toBeVisible(); + await page.keyboard.type('scen'); + await page.keyboard.press('Enter'); + await expect(page).toHaveURL(/\/scenarios$/); + // appearance: the account menu keeps the "Switch to dark theme" name + await page.getByLabel(/^Account:/).click(); + await page.getByRole('menuitem', { name: 'Switch to dark theme' }).click(); + await expect(page.locator('html')).toHaveAttribute('data-mantine-color-scheme', 'dark'); + await page.getByLabel(/^Account:/).click(); + await page.getByRole('menuitem', { name: 'Switch to light theme' }).click(); + await expect(page.locator('html')).toHaveAttribute('data-mantine-color-scheme', 'light'); +}); diff --git a/web/index.html b/web/index.html index b18799151762bc2b319baf16bc90ed3c5297ea10..17ed53e9d0c1ba045a30eb78781a98e7dec0f166 100644 --- a/web/index.html +++ b/web/index.html @@ -3,9 +3,13 @@ + + + - - FPT Co-worker (mock app, not Oracle Fusion) + + + Trio Co-Worker
diff --git a/web/package-lock.json b/web/package-lock.json index 6d923dd54cf601a9bacc9ac7a20e41c32f93b579..2e41db7a5149b5397ed8e004b3899ab31a372dee 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -8,6 +8,7 @@ "name": "fpt-web", "version": "1.0.0", "dependencies": { + "@fontsource-variable/inter": "^5.3.0", "@mantine/core": "^7.17.8", "@mantine/hooks": "^7.17.8", "@mantine/notifications": "^7.17.8", @@ -1126,6 +1127,15 @@ "integrity": "sha512-HpCo8tmWzLVad5s2d19EhAz5zqrrQ6s69qd6moPMQvkOuSwDT1YgRfWSVuc4ennqrgv3OHppiOGMQ7oC13yIww==", "license": "MIT" }, + "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/@humanfs/core": { "version": "0.19.2", "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.2.tgz", diff --git a/web/package.json b/web/package.json index e93e0b083dc1182feffc8ae9c3166de83c644abe..2bb64c9532e99cf47994dad78142cf32d7690f0d 100644 --- a/web/package.json +++ b/web/package.json @@ -2,7 +2,7 @@ "name": "fpt-web", "private": true, "version": "1.0.0", - "description": "Fusion Patch Testing co-worker web app (React + Mantine). Talks only to the REST API. Mock app, not Oracle Fusion.", + "description": "Trio Co-Worker web app (React + Mantine). Talks only to the REST API. Mock app, not Oracle Fusion.", "type": "module", "scripts": { "dev": "vite", @@ -15,6 +15,7 @@ "e2e": "playwright test -c e2e/playwright.config.ts" }, "dependencies": { + "@fontsource-variable/inter": "^5.3.0", "@mantine/core": "^7.17.8", "@mantine/hooks": "^7.17.8", "@mantine/notifications": "^7.17.8", diff --git a/web/public/app-icon.svg b/web/public/app-icon.svg new file mode 100644 index 0000000000000000000000000000000000000000..5a189b80bd5e7ceaeb758c7fa57e5f1a91d54eb8 --- /dev/null +++ b/web/public/app-icon.svg @@ -0,0 +1 @@ +Trio Co-Worker diff --git a/web/public/apple-touch-icon-180.png b/web/public/apple-touch-icon-180.png new file mode 100644 index 0000000000000000000000000000000000000000..87ab9de4381730b5798b0868809700dff831e94f Binary files /dev/null and b/web/public/apple-touch-icon-180.png differ diff --git a/web/public/favicon-16.png b/web/public/favicon-16.png new file mode 100644 index 0000000000000000000000000000000000000000..7cf86785177973ea46029c84cac7544cd119f0b6 Binary files /dev/null and b/web/public/favicon-16.png differ diff --git a/web/public/favicon-32.png b/web/public/favicon-32.png new file mode 100644 index 0000000000000000000000000000000000000000..73bcc22971c03847a664dc33e8c6d78a4832f61b Binary files /dev/null and b/web/public/favicon-32.png differ diff --git a/web/public/favicon-48.png b/web/public/favicon-48.png new file mode 100644 index 0000000000000000000000000000000000000000..c3f709c5176d3a323c3953de901a5eab665d7a60 Binary files /dev/null and b/web/public/favicon-48.png differ diff --git a/web/public/favicon.svg b/web/public/favicon.svg index 994da0a9f8179db928aabffaaed02a227637d573..cfa6ea3a4f5ac893ce8f3de6111c86628c4cfe93 100644 --- a/web/public/favicon.svg +++ b/web/public/favicon.svg @@ -1 +1 @@ - +Trio Co-Worker diff --git a/web/public/icon-512.png b/web/public/icon-512.png new file mode 100644 index 0000000000000000000000000000000000000000..878873d69d87a3e8fe1266a3d780ac71f2fb12f5 Binary files /dev/null and b/web/public/icon-512.png differ diff --git a/web/public/logo-mark-dark.svg b/web/public/logo-mark-dark.svg new file mode 100644 index 0000000000000000000000000000000000000000..d565304f2b6dc6423d65a97077c998ae93444a11 --- /dev/null +++ b/web/public/logo-mark-dark.svg @@ -0,0 +1 @@ +Trio Co-Worker diff --git a/web/public/logo-mark.svg b/web/public/logo-mark.svg new file mode 100644 index 0000000000000000000000000000000000000000..834d6b5634ee215723ce85127c2399298a084842 --- /dev/null +++ b/web/public/logo-mark.svg @@ -0,0 +1 @@ +Trio Co-Worker diff --git a/web/src/App.tsx b/web/src/App.tsx index 3b79287f4de12ba2e2cb8ee6fe2f86bb367ec8f5..8183b8e8fabe7f9d36034c28e826e79c82068452 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -1,6 +1,6 @@ import { Center, Loader } from '@mantine/core'; import { lazy, Suspense, type ReactNode } from 'react'; -import { Navigate, Route, Routes, useLocation } from 'react-router-dom'; +import { Navigate, Route, Routes, useLocation, useSearchParams } from 'react-router-dom'; import { AssistantPage } from './pages/AssistantPage'; import { AuthProvider, useAuth } from './auth/AuthContext'; import { Layout } from './components/Layout'; @@ -33,6 +33,13 @@ function RequireAuth({ children }: { children: ReactNode }) { return <>{children}; } +/** The old "new test run" page is now the Start sheet over the home page. */ +function NewRunRedirect() { + const [p] = useSearchParams(); + const area = p.get('area'); + return ; +} + export function AppRoutes() { return ( @@ -43,7 +50,7 @@ export function AppRoutes() { }> } /> } /> - } /> + } /> } /> } /> } /> diff --git a/web/src/api/hooks.ts b/web/src/api/hooks.ts index e5d7694892a6c3c7c00d05bf6863ce35d69ee156..cbc9bbb80bcfd3db74bd8001bd4d93968bef9315 100644 --- a/web/src/api/hooks.ts +++ b/web/src/api/hooks.ts @@ -1,5 +1,5 @@ import { useMutation, useQuery, useQueryClient, type UseQueryOptions } from '@tanstack/react-query'; -import { api, getJson, unwrap, type Schemas } from './client'; +import { api, ApiError, getJson, unwrap, type Schemas } from './client'; import type { AuditRow, AutonomyRow, CasesView, DataView, Draft, Evidence, Failure, LiveStatus, GatePayload, GraphSpec, HealProposal, HistoryRow, KillState, LibraryScenario, Metrics, ReadinessView, Scenario, Paged, PatchWatch, Pattern, PodProfile, ReportView, ResearchView, ResultsView, Schedule, ScriptRef, Ticket, @@ -197,7 +197,71 @@ export function useSignOff(id: string) { }); } +/** Whether the app's data is being saved to backup storage (public /api/ready); refreshed once a minute. */ +export type SavedState = { on: boolean; ok: boolean | null; paused?: boolean; last_saved_at?: string | null }; +export const useSavedState = () => + useQuery({ queryKey: ['saved-state'], refetchInterval: 60_000, retry: false, + queryFn: async () => (await getJson<{ saved_state?: SavedState }>('/api/ready')).saved_state ?? null }); + // ------------------------------------------------------------------ product identity (public: also used on the sign-in page) export const useBrand = () => useQuery({ queryKey: ['brand'], staleTime: Infinity, retry: false, queryFn: () => getJson<{ product_name?: string; org_name?: string; version?: string; browser_runs?: boolean }>('/api/ready') }); + +// ------------------------------------------------------------------ Hermes assistant ("Ask", when an admin switched it on) +export type AssistantStatus = Schemas['AssistantStatus']; +export type AskOut = Schemas['AskOut']; +/** Whether Ask goes to the Hermes assistant: on, configured (and reachable when known). Checked once a minute. */ +export const useAssistantStatus = () => + useQuery({ queryKey: ['assistant-status'], queryFn: () => unwrap(api.GET('/api/assistant/status')), staleTime: 60_000, refetchInterval: 60_000, retry: false }); + +/** An ApiError that also carries the Retry-After seconds of a 429. */ +export class AskError extends ApiError { + retryAfter: number | null; + constructor(e: ApiError, retryAfter: number | null) { + super(e.status, e.code, e.message, e.body, e.requestId); + this.retryAfter = retryAfter; + } +} + +/** One question to Hermes; pass the returned conversation_id with the next one to keep the conversation. */ +export function useAssistantAsk() { + const qc = useQueryClient(); + return useMutation({ + mutationFn: async (body: Schemas['AskIn']) => { + const res = await api.POST('/api/assistant/ask', { body }); + try { + return await unwrap(Promise.resolve(res)); + } catch (e) { + const after = Number(res.response.headers.get('Retry-After')); + throw e instanceof ApiError ? new AskError(e, Number.isFinite(after) && after > 0 ? after : null) : e; + } + }, + onError: (e) => { if (e instanceof ApiError && [409, 503].includes(e.status)) qc.invalidateQueries({ queryKey: ['assistant-status'] }); }, + }); +} + +/** Plain words for a failed Ask: what happened and what to do. Never the raw error. */ +export function askErrorWords(e: unknown): string { + const err = e as { status?: number; code?: string; retryAfter?: number | null }; + switch (err.code) { + case 'HERMES_OFF': return 'The Hermes assistant has just been switched off. Ask again and the built-in assistant answers.'; + case 'HERMES_NOT_CONFIGURED': return 'The Hermes assistant is not set up yet. Ask an administrator, or ask again later.'; + case 'HERMES_BUSY': return 'The Hermes assistant is busy with other questions. Try again in a minute.'; + case 'HERMES_TIMEOUT': return 'The Hermes assistant took too long to answer. Try a shorter question, or try again.'; + case 'HERMES_UNREACHABLE': return 'The Hermes assistant cannot be reached right now. Try again later.'; + case 'HERMES_KEY_REJECTED': return 'The Hermes assistant refused the connection. Ask an administrator to check its key.'; + case 'RATE_LIMITED': return `You have asked many questions in a short time. Try again${err.retryAfter ? ` in ${err.retryAfter} seconds` : ' in a minute'}.`; + case 'HERMES_ERROR': return 'The Hermes assistant ran into a problem. Try again in a minute.'; + case 'HERMES_EMPTY': return 'The Hermes assistant sent an empty answer. Rephrase the question, or try again.'; + case 'HERMES_REFUSED': return 'The Hermes assistant did not accept this question. Rephrase it, or ask again later.'; + case 'KILL_SWITCH': return 'The emergency stop is on, so no question is sent outside this app.'; + case 'BAD_TEXT': return 'A question needs between 1 and 2,000 characters.'; + case 'NOT_FOUND': return 'This conversation is no longer available. Ask again to start a new one.'; + default: + if (err.status === 429) return `You have asked many questions in a short time. Try again${err.retryAfter ? ` in ${err.retryAfter} seconds` : ' in a minute'}.`; + if (err.status === 504) return 'The Hermes assistant took too long to answer. Try again.'; + if (err.status === 503) return 'The Hermes assistant is busy or not available. Try again in a minute.'; + return 'The Hermes assistant could not answer. Try again.'; + } +} diff --git a/web/src/api/openapi.json b/web/src/api/openapi.json index f85dc7081b0dbb58516eb34a532a8594c7cdf1fa..710cf6863551274b0670244b37db973d83c5a586 100644 --- a/web/src/api/openapi.json +++ b/web/src/api/openapi.json @@ -29,6 +29,86 @@ "title": "ApproveCasesIn", "type": "object" }, + "AskIn": { + "additionalProperties": false, + "properties": { + "conversation_id": { + "anyOf": [ + { + "maxLength": 80, + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Conversation Id" + }, + "question": { + "maxLength": 2000, + "minLength": 1, + "title": "Question", + "type": "string" + } + }, + "required": [ + "question" + ], + "title": "AskIn", + "type": "object" + }, + "AskOut": { + "properties": { + "answer": { + "title": "Answer", + "type": "string" + }, + "conversation_id": { + "title": "Conversation Id", + "type": "string" + }, + "model": { + "title": "Model", + "type": "string" + } + }, + "required": [ + "answer", + "conversation_id", + "model" + ], + "title": "AskOut", + "type": "object" + }, + "AssistantStatus": { + "properties": { + "configured": { + "title": "Configured", + "type": "boolean" + }, + "enabled": { + "title": "Enabled", + "type": "boolean" + }, + "reachable": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Reachable" + } + }, + "required": [ + "enabled", + "configured" + ], + "title": "AssistantStatus", + "type": "object" + }, "AutonomyIn": { "additionalProperties": false, "properties": { @@ -756,6 +836,11 @@ "title": "Environment", "type": "string" }, + "from_server_settings": { + "default": false, + "title": "From Server Settings", + "type": "boolean" + }, "id": { "title": "Id", "type": "integer" @@ -1606,6 +1691,19 @@ ], "title": "At" }, + "day": { + "anyOf": [ + { + "maximum": 28.0, + "minimum": 1.0, + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Day" + }, "enabled": { "default": true, "title": "Enabled", @@ -1632,7 +1730,9 @@ "kind": { "enum": [ "interval", - "daily" + "daily", + "monthly", + "quarterly" ], "title": "Kind", "type": "string" @@ -1644,6 +1744,31 @@ "title": "Modules", "type": "array" }, + "month": { + "anyOf": [ + { + "maximum": 12.0, + "minimum": 1.0, + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Month" + }, + "patch_id": { + "anyOf": [ + { + "maxLength": 40, + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Patch Id" + }, "playwright_mode": { "default": "live", "enum": [ @@ -1652,6 +1777,17 @@ ], "title": "Playwright Mode", "type": "string" + }, + "pod_id": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Pod Id" } }, "required": [ @@ -2257,11 +2393,75 @@ }, "info": { "description": "Pilot backend. Runs ONLY against the local mock app, not Oracle Fusion.", - "title": "Fusion Patch Testing Co-worker API", + "title": "Trio Co-Worker API", "version": "1.0.0-pilot" }, "openapi": "3.1.0", "paths": { + "/api/assistant/ask": { + "post": { + "description": "Ask Hermes one question. Pass the returned conversation_id to continue the same conversation.\nErrors: 409 HERMES_OFF, 503 HERMES_NOT_CONFIGURED, 502 HERMES_UNREACHABLE / HERMES_KEY_REJECTED / HERMES_ERROR,\n504 HERMES_TIMEOUT, 429 RATE_LIMITED, 404 NOT_FOUND (unknown or someone else's conversation).", + "operationId": "ask_api_assistant_ask_post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AskIn" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AskOut" + } + } + }, + "description": "Successful Response" + }, + "422": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + }, + "description": "Validation Error" + } + }, + "summary": "Ask", + "tags": [ + "assistant" + ] + } + }, + "/api/assistant/status": { + "get": { + "description": "Whether the Hermes assistant is on, configured (URL and key present) and reachable (checked at most once a minute).", + "operationId": "status_api_assistant_status_get", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AssistantStatus" + } + } + }, + "description": "Successful Response" + } + }, + "summary": "Status", + "tags": [ + "assistant" + ] + } + }, "/api/audit": { "get": { "operationId": "audit_api_audit_get", diff --git a/web/src/api/schema.d.ts b/web/src/api/schema.d.ts index 5e926a9d1b6ad65bd14c996c6397cee37b25a579..bf9809c155306899ae24fae79774a3555aafa4cf 100644 --- a/web/src/api/schema.d.ts +++ b/web/src/api/schema.d.ts @@ -4,6 +4,48 @@ */ export interface paths { + "/api/assistant/ask": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** + * Ask + * @description Ask Hermes one question. Pass the returned conversation_id to continue the same conversation. + * Errors: 409 HERMES_OFF, 503 HERMES_NOT_CONFIGURED, 502 HERMES_UNREACHABLE / HERMES_KEY_REJECTED / HERMES_ERROR, + * 504 HERMES_TIMEOUT, 429 RATE_LIMITED, 404 NOT_FOUND (unknown or someone else's conversation). + */ + post: operations["ask_api_assistant_ask_post"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/api/assistant/status": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** + * Status + * @description Whether the Hermes assistant is on, configured (URL and key present) and reachable (checked at most once a minute). + */ + get: operations["status_api_assistant_status_get"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; "/api/audit": { parameters: { query?: never; @@ -1568,6 +1610,31 @@ export interface components { /** Rejected */ rejected?: string[]; }; + /** AskIn */ + AskIn: { + /** Conversation Id */ + conversation_id?: string | null; + /** Question */ + question: string; + }; + /** AskOut */ + AskOut: { + /** Answer */ + answer: string; + /** Conversation Id */ + conversation_id: string; + /** Model */ + model: string; + }; + /** AssistantStatus */ + AssistantStatus: { + /** Configured */ + configured: boolean; + /** Enabled */ + enabled: boolean; + /** Reachable */ + reachable?: boolean | null; + }; /** AutonomyIn */ AutonomyIn: { /** @@ -1799,6 +1866,11 @@ export interface components { enabled: boolean; /** Environment */ environment: string; + /** + * From Server Settings + * @default false + */ + from_server_settings: boolean; /** Id */ id: number; /** Is Default */ @@ -2070,6 +2142,8 @@ export interface components { ScheduleIn: { /** At */ at?: string | null; + /** Day */ + day?: number | null; /** * Enabled * @default true @@ -2086,15 +2160,21 @@ export interface components { * Kind * @enum {string} */ - kind: "interval" | "daily"; + kind: "interval" | "daily" | "monthly" | "quarterly"; /** Modules */ modules?: string[]; + /** Month */ + month?: number | null; + /** Patch Id */ + patch_id?: string | null; /** * Playwright Mode * @default live * @enum {string} */ playwright_mode: "live" | "stub"; + /** Pod Id */ + pod_id?: number | null; }; /** ScreenCaptureIn */ ScreenCaptureIn: { @@ -2300,6 +2380,59 @@ export interface components { } export type $defs = Record; export interface operations { + ask_api_assistant_ask_post: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["AskIn"]; + }; + }; + responses: { + /** @description Successful Response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["AskOut"]; + }; + }; + /** @description Validation Error */ + 422: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["HTTPValidationError"]; + }; + }; + }; + }; + status_api_assistant_status_get: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Successful Response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["AssistantStatus"]; + }; + }; + }; + }; audit_api_audit_get: { parameters: { query?: { diff --git a/web/src/api/types.ts b/web/src/api/types.ts index 8647927ccba5dde910875a9c6f0c8f834b1bc5f6..b2ccd2a12b91d69ede26822ff4263d8451e5ebca 100644 --- a/web/src/api/types.ts +++ b/web/src/api/types.ts @@ -45,7 +45,7 @@ export interface Ticket { ticket_id: string; run_id: string; case_id: string; si export interface AuditRow { seq: number; ts: string; actor: string; kind: string; run_id: string | null; node: string | null; summary: string; payload: unknown; hash: string; prev_hash: string } export interface Metrics { n_labeled: number; agreement: number | null; real_defect_recall: number | null; override_rate: number | null; false_fail_rate: number | null; n_approval_decisions: number; case_approval_rate: number | null; n_proposals: number } export interface AutonomyRow { level: 'L0' | 'L1' | 'L2'; metrics: Metrics; can_promote: { L1: boolean; L2: boolean }; thresholds: { min_labels: number; min_agreement: number; min_recall: number } } -export interface Schedule { id: number; kind: 'interval' | 'daily'; every_minutes: number | null; at: string | null; modules: string[]; include_p2: boolean; playwright_mode: string; enabled: boolean; next_run_at: string | null; created_by: string } +export interface Schedule { id: number; kind: 'interval' | 'daily' | 'monthly' | 'quarterly'; every_minutes: number | null; at: string | null; day?: number | null; month?: number | null; pod_id?: number | null; patch_id?: string | null; modules: string[]; include_p2: boolean; playwright_mode: string; enabled: boolean; next_run_at: string | null; created_by: string } export interface PatchWatch { enabled: boolean; interval_s: number; autostart: boolean; modules: string[]; last_seen_release: string | null; last_checked_at: string | null; last_error?: string | null } export interface KillState { engaged: boolean; reason: string | null; actor: string | null; since: string | null } export interface HistoryRow { id: number; run_id: string; module: string; patch_id: string; decision: string; counts: Record; ts: string } diff --git a/web/src/apple-components.css b/web/src/apple-components.css new file mode 100644 index 0000000000000000000000000000000000000000..3fc0bb383a4b740cd2a7e67996df2bf98ba9b914 --- /dev/null +++ b/web/src/apple-components.css @@ -0,0 +1,156 @@ +/* Trio Co-Worker, shared components of the Apple-style layer (UI-APPLE.md section 6). Loaded after apple.css. */ + +/* ------------------------------------------------------------------ page head and text roles */ +.trio-head { display: flex; align-items: flex-start; gap: 12px; } +.trio-head-text { flex: 1 1 auto; min-width: 0; } +.trio-head h1 { font-size: 28px; line-height: 34px; font-weight: 650; letter-spacing: -0.024em; margin: 0; } +.trio-head-actions { display: flex; align-items: center; gap: 8px; flex: none; flex-wrap: wrap; justify-content: flex-end; margin-top: 1px; } +.trio-head-actions .mantine-Input-input { border-radius: var(--r-pill); background: var(--fill); box-shadow: none; min-height: 32px; height: 32px; font-weight: 500; font-size: 13.5px !important; padding-inline: 14px; } +.trio-head-actions .mantine-Input-input:hover { background: var(--fill-2); box-shadow: none; } +.trio-head-actions .mantine-Select-section { color: var(--label-2); } +.trio-lede { color: var(--label-2); font-size: 15px; line-height: 21px; max-width: 62ch; margin-top: 4px; } +.trio-lede .fpt-release-line, .trio-lede .fpt-pagedesc { font-size: 15px; color: var(--label-2); } +.trio-foot { color: var(--label-2); font-size: 12px; line-height: 16px; margin: 8px 6px 0; } +.fpt-embedded .trio-head { display: none; } +.fpt-embedded .trio-head .fpt-embedded-only { display: flex; } +.fpt-dimtext, .fpt-pagedesc, .fpt-dim { color: var(--label-2); } +.fpt-pagedesc a { color: var(--accent-text); } + +/* ------------------------------------------------------------------ groups, rows, tiles, chips, banners */ +.trio-group, .fpt-card { background: var(--bg-elev); border-radius: var(--r-xl); box-shadow: var(--sh-card); border: 0; } +.trio-group { overflow: hidden; } +.trio-row { position: relative; display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 12px 16px; color: var(--label); text-decoration: none; transition: background var(--d1); } +.trio-row + .trio-row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 0.5px; background: var(--sep); } +.trio-row-k { width: 140px; flex: none; color: var(--label-2); font-size: 13px; } +.trio-row-v { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 500; } +a.trio-row:hover, .trio-row[data-tap]:hover { background: var(--fill); text-decoration: none; } +.trio-tile { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--fill); color: var(--label-2); flex: none; } +.trio-tile[data-tone='orange'] { background: var(--orange-soft); color: var(--orange); } +.trio-tile[data-tone='green'] { background: var(--green-soft); color: var(--green); } +.trio-tile[data-tone='red'] { background: var(--red-soft); color: var(--red); } +.trio-tile[data-tone='blue'] { background: var(--accent-soft-2); color: var(--accent-text); } +.trio-chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: var(--r-pill); font-size: 12px; font-weight: 550; background: var(--fill); color: var(--label-2); white-space: nowrap; } +.trio-chip[data-tone='orange'] { background: var(--orange-soft); color: var(--orange); } +.trio-chip[data-tone='green'] { background: var(--green-soft); color: var(--green); } +.trio-chip[data-tone='red'] { background: var(--red-soft); color: var(--red); } +.trio-chip[data-tone='blue'] { background: var(--accent-soft-2); color: var(--accent-text); } +.trio-dotword { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 550; white-space: nowrap; color: var(--label-2); } +.trio-dotword::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--label-3); flex: none; } +.trio-dotword[data-tone='green'] { color: var(--green); } .trio-dotword[data-tone='green']::before { background: var(--green-dot); } +.trio-dotword[data-tone='orange'] { color: var(--orange); } .trio-dotword[data-tone='orange']::before { background: var(--orange-dot); } +.trio-dotword[data-tone='red'] { color: var(--red); } .trio-dotword[data-tone='red']::before { background: var(--red-dot); } +.trio-dotword[data-tone='blue'] { color: var(--accent-text); } .trio-dotword[data-tone='blue']::before { background: var(--accent); } +.trio-dotword[data-pulse]::before { animation: trio-pulse 1.8s var(--ease) infinite; } +.trio-banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-lg); background: var(--fill); font-size: 13.5px; line-height: 19px; color: var(--label); } +.trio-banner[data-tone='orange'] { background: var(--orange-soft); } +.trio-banner[data-tone='red'] { background: var(--red-soft); } +.trio-banner[data-tone='blue'] { background: var(--accent-soft); } +.trio-banner[data-tone='green'] { background: var(--green-soft); } +.trio-banner b { font-weight: 600; } +.trio-globalbanners { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 0; } +.trio-check { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; } + +/* ------------------------------------------------------------------ the start sheet, choices */ +.trio-steps { display: flex; gap: 6px; } +.trio-steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--fill-2); transition: background var(--d2); } +.trio-steps i[data-on] { background: var(--accent); } +.trio-choice { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 14px 16px; border: 0; border-radius: var(--r-lg); background: var(--bg-elev); box-shadow: inset 0 0 0 1px var(--sep-strong); cursor: default; transition: box-shadow var(--d1), background var(--d1); color: var(--label); } +.trio-choice:hover:not(:disabled):not([data-disabled]) { background: var(--fill); } +.trio-choice[data-checked] { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); } +.trio-choice:disabled, .trio-choice[data-disabled] { opacity: 0.6; } +.trio-choice-body { flex: 1; min-width: 0; display: flex; flex-direction: column; } +.trio-choice-body b { font-weight: 600; } +.trio-choice-body > span { color: var(--label-2); font-size: 13px; line-height: 18px; } +.trio-choice-body > .trio-choice-why { color: var(--orange); } +.trio-choice-check { padding: 12px 14px; } +.trio-choice-check .mantine-Checkbox-root, .trio-choice-check .mantine-Radio-root { width: 100%; } +.trio-sheet-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; } +.trio-sheet-sp { flex: 1; } +.trio-sheet-form .mantine-Accordion-item { box-shadow: inset 0 0 0 1px var(--sep-strong); background: transparent; } + +/* ------------------------------------------------------------------ command palette and keyboard sheet */ +.trio-palette { background: var(--mat-pop) !important; -webkit-backdrop-filter: saturate(180%) blur(40px); backdrop-filter: saturate(180%) blur(40px); border-radius: var(--r-2xl) !important; box-shadow: var(--sh-pop) !important; overflow: hidden; } +.trio-palette-body { padding: 0 !important; } +.trio-pin { display: flex; align-items: center; gap: 12px; padding: 0 20px; height: 58px; border-bottom: 0.5px solid var(--sep); color: var(--label-2); } +.trio-pin input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 18px; letter-spacing: -0.014em; color: var(--label); height: 100%; font-family: inherit; } +.trio-pin input::placeholder { color: var(--ph); } +.trio-pl { max-height: 380px; overflow-y: auto; padding: 8px; } +.trio-pl h6 { margin: 10px 12px 4px; font-size: 11.5px; line-height: 14px; font-weight: 600; color: var(--label-2); } +.trio-pe { padding: 18px 12px; color: var(--label-2); } +.trio-pit { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: var(--r-md); font-size: 14px; cursor: default; color: var(--label); } +.trio-pit svg { color: var(--label-2); flex: none; } +.trio-pit-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.trio-pit-k { margin-left: auto; color: var(--label-2); font-size: 12px; } +.trio-pit[aria-selected='true'] { background: var(--accent); color: #fff; } +.trio-pit[aria-selected='true'] svg, .trio-pit[aria-selected='true'] .trio-pit-k { color: rgba(255, 255, 255, 0.9); } +.trio-pf { display: flex; gap: 16px; padding: 10px 20px; border-top: 0.5px solid var(--sep); font-size: 12px; color: var(--label-2); } +.trio-pf-sp { flex: 1; } +.trio-keys { margin: 0; display: grid; gap: 2px; } +.trio-keys > div { display: flex; align-items: center; gap: 16px; min-height: 36px; padding: 4px 0; border-bottom: 0.5px solid var(--sep); } +.trio-keys dt { width: 120px; flex: none; display: flex; gap: 4px; } +.trio-keys dd { margin: 0; color: var(--label); font-size: 13.5px; } +.fpt-kbd { font: 500 11.5px var(--font); padding: 1px 6px; border-radius: 5px; background: var(--fill); color: var(--label-2); letter-spacing: 0; border: 0; line-height: 16px; } + +/* ------------------------------------------------------------------ older shared pieces, restyled */ +.fpt-pill, .fpt-pill[data-tone] { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: var(--r-pill); font-size: 12px; line-height: 22px; font-weight: 550; white-space: nowrap; background: var(--fill); box-shadow: none; color: var(--label-2); } +.fpt-pill[data-tone='blue'] { background: var(--accent-soft-2); color: var(--accent-text); } +.fpt-pill[data-tone='amber'], .fpt-pill[data-tone='green'], .fpt-pill[data-tone='red'] { background: transparent; padding: 0; height: auto; font-size: 13px; line-height: 18px; } +.fpt-pill[data-tone='amber']:has(svg), .fpt-pill[data-tone='green']:has(svg), .fpt-pill[data-tone='red']:has(svg) { padding: 0 9px; height: 22px; font-size: 12px; line-height: 22px; } +.fpt-pill[data-tone='amber']:has(svg) { background: var(--orange-soft); } +.fpt-pill[data-tone='green']:has(svg) { background: var(--green-soft); } +.fpt-pill[data-tone='red']:has(svg) { background: var(--red-soft); } +.fpt-pill[data-tone='amber'] { color: var(--orange); } +.fpt-pill[data-tone='green'] { color: var(--green); } +.fpt-pill[data-tone='red'] { color: var(--red); } +.fpt-pill[data-tone='green']:not(:has(svg))::before, .fpt-pill[data-tone='red']:not(:has(svg))::before, .fpt-pill[data-tone='amber']:not(:has(svg))::before { width: 8px; height: 8px; flex-basis: 8px; } +.fpt-pill[data-tone='green']:not(:has(svg))::before { background: var(--green-dot); } +.fpt-pill[data-tone='red']:not(:has(svg))::before { background: var(--red-dot); } +.fpt-pill[data-tone='amber']:not(:has(svg))::before { background: var(--orange-dot); } +.fpt-pill[data-outline='true'] { background: transparent; box-shadow: inset 0 0 0 1px var(--sep-strong); } +.fpt-pill[data-state], .fpt-pill[data-state='gap'], .fpt-pill[data-state='not_affected'] { background: var(--fill); box-shadow: none; } +.fpt-pill[data-state='failing'] { background: var(--red-soft); color: var(--red); } +.fpt-envbadge, .fpt-envbadge[data-tone] { height: 22px; padding: 0 9px !important; font-size: 12px; font-weight: 550; } +.fpt-envbadge[data-tone='amber'] { background: var(--orange-soft) !important; color: var(--orange); } +.fpt-envbadge[data-tone='blue'] { background: var(--accent-soft-2) !important; color: var(--accent-text); } +.fpt-idpill { background: var(--fill); color: var(--label-2); font-family: var(--mono); font-size: 11.5px; padding: 0 9px; border: 0; height: 22px; border-radius: var(--r-pill); } +.fpt-mock { background: var(--orange-soft); color: var(--orange); padding: 5px 12px; border-radius: var(--r-pill); font-size: 12.5px; font-weight: 500; } +.fpt-dchip { display: inline-flex; align-items: center; gap: 7px; height: auto; padding: 0; border: 0; border-radius: 0; background: transparent; font-size: 13px; font-weight: 550; line-height: 18px; color: var(--label-2); } +.fpt-dchip[data-tone='green'] { color: var(--green); } .fpt-dchip[data-tone='red'] { color: var(--red); } .fpt-dchip[data-tone='amber'] { color: var(--orange); } +.fpt-dchip-dot { width: 8px; height: 8px; } +.fpt-dchip[data-tone='green'] .fpt-dchip-dot { background: var(--green-dot); } .fpt-dchip[data-tone='red'] .fpt-dchip-dot { background: var(--red-dot); } .fpt-dchip[data-tone='amber'] .fpt-dchip-dot { background: var(--orange-dot); } +.fpt-dchip[data-size='lg'], .fpt-dchip[data-size='xl'] { font-size: 15px; padding: 0; } +.fpt-statechip, .fpt-statechip[data-state] { display: inline-flex; align-items: center; gap: 7px; padding: 0; border: 0; background: transparent; font-size: 13px; font-weight: 550; color: var(--label-2); } +.fpt-statechip[data-state='waiting'], .fpt-statechip[data-state='paused'] { color: var(--orange); } +.fpt-statechip[data-state='running'], .fpt-statechip[data-state='queued'] { color: var(--accent-text); } +.fpt-statechip[data-state='failed'] { color: var(--red); } +.fpt-sdot { width: 8px; height: 8px; flex: 0 0 8px; box-shadow: none; } +.fpt-sdot[data-state='waiting'] { box-shadow: none; background: var(--orange-dot); } +.fpt-sdot[data-state='queued'], .fpt-sdot[data-state='running'] { background: var(--accent); } +.fpt-sdot[data-state='done-ready'], .fpt-sdot[data-state='done'] { background: var(--green-dot); } +.fpt-sdot[data-state='done-notready'], .fpt-sdot[data-state='failed'] { background: var(--red-dot); } +.fpt-sdot[data-state='done-held'], .fpt-sdot[data-state='paused'] { background: var(--orange-dot); } +.fpt-sdot[data-pulse='true'] { animation: trio-pulse 1.8s var(--ease) infinite; } +.fpt-verdictword, .fpt-dotword { font-weight: 550; font-size: 13px; } +.fpt-dotword::before { width: 8px; height: 8px; background: var(--label-3); } +.fpt-dotword[data-tone='green'] { color: var(--green); } .fpt-dotword[data-tone='green']::before { background: var(--green-dot); } +.fpt-dotword[data-tone='amber'] { color: var(--orange); } .fpt-dotword[data-tone='amber']::before { background: var(--orange-dot); } +.fpt-dotword[data-tone='red'] { color: var(--red); } .fpt-dotword[data-tone='red']::before { background: var(--red-dot); } +.fpt-verdictword[data-tone='green'] { color: var(--green); } .fpt-verdictword[data-tone='red'] { color: var(--red); } .fpt-verdictword[data-tone='amber'] { color: var(--orange); } +.fpt-empty { padding: 56px 24px; color: var(--label-2); } +.fpt-empty-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; margin: 0 auto 14px; background: var(--fill); color: var(--label-2); opacity: 1; } +.fpt-empty-title { color: var(--label); font-size: 17px; line-height: 22px; font-weight: 600; letter-spacing: -0.016em; } +.fpt-empty-body { max-width: 42ch; font-size: 14px; } +.fpt-textlink, .fpt-linkbtn { color: var(--accent-text); text-decoration: none; font-weight: 500; } +.fpt-textlink:hover, .fpt-linkbtn:hover { text-decoration: underline; text-underline-offset: 2px; } +.fpt-spin { color: var(--label-2); } +.fpt-nextstep { border: 0; border-radius: var(--r-lg); background: var(--accent-soft); padding: 12px 16px; } +.fpt-nextstep[data-tone='amber'] { background: var(--orange-soft); } +.fpt-nextstep[data-tone='red'] { background: var(--red-soft); } +.fpt-nextstep[data-tone='green'] { background: var(--green-soft); } +.fpt-nextstep[data-compact='true'] { background: transparent; padding: 0; } +.fpt-statustext { font-weight: 550; } +.fpt-prio { font-weight: 550; color: var(--label); } +.fpt-aitext, .fpt-dryok { color: var(--label-2); } +.fpt-ruleresult { color: var(--label-2); } +.fpt-kv dt { color: var(--label-2); } +.fpt-kv dd { font-weight: 550; } diff --git a/web/src/apple-pages.css b/web/src/apple-pages.css new file mode 100644 index 0000000000000000000000000000000000000000..0c08d4ae0836d6e80d89f42a128bb1f9878215b2 --- /dev/null +++ b/web/src/apple-pages.css @@ -0,0 +1,106 @@ +/* Trio Co-Worker, lists and settings screens: test runs, scenarios, defects, reports, test environments, settings, approvals. Loaded last. */ + +/* ------------------------------------------------------------------ segmented filter (FilterChips) */ +.fpt-filterchips { display: inline-flex; gap: 0; flex-wrap: nowrap; padding: 2px; border-radius: var(--r-pill); background: var(--fill); width: fit-content; max-width: 100%; -webkit-mask-image: none; mask-image: none; } +.fpt-filterchip { display: inline-flex; align-items: center; gap: 6px; height: 28px; min-height: 28px; padding: 0 14px; border-radius: var(--r-pill); border: 0; background: transparent; color: var(--label-2); font-size: 13px; font-weight: 500; cursor: default; box-shadow: none; transition: color var(--d2), background var(--d2) var(--ease); } +.fpt-filterchip:hover:not(:disabled) { background: transparent; color: var(--label); border: 0; } +.fpt-filterchip[data-active='true'] { background: var(--seg-thumb); color: var(--label); box-shadow: var(--sh-seg); border: 0; font-weight: 550; } +.fpt-filterchip:disabled { opacity: 0.5; } +.fpt-filterchip-count, .fpt-filterchip[data-active='true'] .fpt-filterchip-count { font-size: 11.5px; font-weight: 600; background: transparent; color: var(--label-2); padding: 0; line-height: 16px; } +.fpt-filterchip[data-active='true'] .fpt-filterchip-count { color: var(--label-2); } + +/* ------------------------------------------------------------------ tables as grouped lists */ +.trio-group .mantine-Table-table { width: 100%; } +.trio-group .mantine-Table-th { padding: 10px 16px; white-space: nowrap; text-align: left; } +.trio-group .mantine-Table-td { padding: 8px 16px; vertical-align: middle; } +.trio-runtable .mantine-Table-tr { height: 56px; } +.trio-runrow { cursor: default; } +.trio-runrow:hover { background: var(--fill); } +.trio-t2 { display: block; font-size: 12.5px; line-height: 16px; color: var(--label-2); margin-top: 1px; } +.fpt-runrow-title { color: var(--label); font-weight: 550; letter-spacing: -0.008em; text-decoration: none; font-size: 14px; } +.fpt-runrow-title:hover { text-decoration: underline; text-underline-offset: 2px; } +.trio-more { text-align: right; white-space: nowrap; width: 1%; } +.trio-more .mantine-ActionIcon-root { opacity: 0; transition: opacity var(--d1); } +.trio-runrow:hover .trio-more .mantine-ActionIcon-root, .trio-runrow:focus-within .trio-more .mantine-ActionIcon-root, .trio-more .mantine-ActionIcon-root[aria-expanded='true'] { opacity: 1; } +.mantine-Table-td.nw { white-space: nowrap; } +.trio-empty { text-align: center; padding: 48px 24px; color: var(--label-2); } +.fpt-table { width: 100%; } +.fpt-libro:hover { background: var(--fill); } +.fpt-libro[data-selected] { background: var(--accent-soft); } +.fpt-libtitle { font-size: 14px; font-weight: 550; letter-spacing: -0.008em; color: var(--label); } +.fpt-libro[data-selected] .fpt-libtitle { color: var(--label); font-weight: 600; } +.fpt-libpanel { background: var(--bg-elev); border-radius: var(--r-xl); box-shadow: var(--sh-card); padding: 16px; } +.fpt-libfilters .mantine-Select-input, .fpt-libfilterbar .mantine-Select-input { background: var(--bg-elev); } +.fpt-reportrow { padding: 12px 16px; } + +/* ------------------------------------------------------------------ test environments */ +.fpt-podcard { padding: 20px; display: flex; flex-direction: column; } +.fpt-podcard-cue { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; } +.fpt-podcard-note { color: var(--label-2); font-size: 12.5px; } +.fpt-podcard-name { font-size: 17px; line-height: 22px; font-weight: 600; letter-spacing: -0.016em; margin: 0; } +.fpt-podcard-default { font-size: 13px; font-weight: 400; color: var(--label-2); } +.fpt-podcard[data-kind='mock'] .fpt-podcard-cue { color: var(--orange); } +.fpt-podtest[data-ok='true'] svg { color: var(--green-dot); } +.fpt-podtest[data-ok='false'] { color: var(--red); } +.trio-addrow { all: unset; box-sizing: border-box; display: flex; align-items: center; justify-content: center; gap: 16px; width: 100%; min-height: 88px; padding: 16px; border-radius: var(--r-xl); box-shadow: inset 0 0 0 1.5px var(--sep-strong); color: var(--label-2); cursor: default; text-align: left; transition: background var(--d1); } +.trio-addrow:hover { background: var(--fill); } +.trio-addrow:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; } +.trio-addrow-plus { width: 44px; height: 44px; border-radius: 50%; background: var(--fill); display: grid; place-items: center; color: var(--accent-text); flex: none; } +.trio-addrow b { display: block; color: var(--label); font-weight: 600; } +.trio-addrow span span { display: block; font-size: 13px; max-width: 52ch; } +.fpt-podhelp summary { color: var(--accent-text); font-size: 13.5px; } +.fpt-podhelp { margin: -4px 4px 0; } + +/* ------------------------------------------------------------------ settings: a list on the left, a pane on the right (macOS Settings) */ +.fpt-settings-tabs[data-orientation='vertical'] > .mantine-Tabs-list { width: 220px; flex: 0 0 220px; gap: 1px; padding: 0; background: transparent; border-radius: 0; position: sticky; top: 84px; } +.fpt-settings-tabs[data-orientation='vertical'] > .mantine-Tabs-panel { padding-left: 32px; max-width: 800px; } +.fpt-settings-tabs .mantine-Tabs-tab { border-radius: var(--r-md); height: 34px; min-height: 34px; padding: 0 12px; justify-content: flex-start; color: var(--label); font-size: 13.5px; font-weight: 500; background: transparent; box-shadow: none; } +.fpt-settings-tabs .mantine-Tabs-tab:hover:not([data-active]) { background: var(--fill); } +.fpt-settings-tabs .mantine-Tabs-tab[data-active], .mantine-Tabs-list[data-orientation='vertical'] .mantine-Tabs-tab[data-active] { background: var(--accent); color: #fff; font-weight: 550; box-shadow: none; } +.fpt-settings-tabs .mantine-Tabs-tab[data-active] svg { color: #fff; } + +/* ------------------------------------------------------------------ approvals (scenario review) and failure review */ +.fpt-approval { border-left: 0; padding: 12px 14px; background: transparent; } +.fpt-sticky-bar { background: var(--mat-pop); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px); border: 0; border-radius: var(--r-lg); box-shadow: var(--sh-pop); padding: 10px 14px; } +.fpt-srow { border-top: 0.5px solid var(--sep); } +.fpt-dry[data-result='passed'] svg, .fpt-dryok svg { color: var(--green-dot); } +.fpt-judge-screen:empty { display: none; } +.fpt-agent, .fpt-coord, .fpt-board-phase { border: 0; box-shadow: var(--sh-card); border-radius: var(--r-lg); background: var(--bg-elev); } +.fpt-board-phase { background: var(--fill); box-shadow: none; } +.fpt-agent[data-state='waiting'], .fpt-agent[data-state='silent'], .fpt-agent[data-state='paused'] { box-shadow: 0 0 0 1.5px var(--orange-dot); border-left: 0; } +.fpt-agent[data-state='error'] { box-shadow: 0 0 0 1.5px var(--red-dot); border-left: 0; border-top: 0; } +.fpt-agent-btn[aria-pressed='true'] { box-shadow: inset 0 0 0 2px var(--accent); } +.fpt-agent-avatar, .fpt-agent-avatar[data-tone] { background: var(--fill); color: var(--label-2); box-shadow: none; } +.fpt-coord, .fpt-coord[data-tone] { border: 0; border-left: 0; } +.fpt-coord[data-tone='amber'] { box-shadow: 0 0 0 1.5px var(--orange-dot); } +.fpt-coord[data-tone='red'] { box-shadow: 0 0 0 1.5px var(--red-dot); } + +/* ------------------------------------------------------------------ chat dock and Ask bubbles */ +.fpt-chat { width: 400px; flex: 0 0 400px; border: 0; box-shadow: -0.5px 0 0 var(--sep); background: var(--bg-elev); } +.fpt-chat-panel { background: var(--bg-elev); color: var(--label); } +.fpt-chat-head { padding: 14px 16px 8px; border: 0; background: transparent; } +.fpt-chat-mock { margin: 0 16px; padding: 6px 10px; border-radius: var(--r-md); background: var(--orange-soft); color: var(--orange); font-size: 12px; } +.fpt-chat-log { padding: 14px 16px; gap: 12px; } +.fpt-chat-msg { max-width: 100%; } +.fpt-chat-msg[data-role='user'] { background: var(--accent); color: #fff; border-radius: 20px 20px 6px 20px; padding: 9px 14px; } +.fpt-chat-msg[data-role='assistant'] { background: var(--fill); border-radius: 20px 20px 20px 6px; padding: 10px 14px; } +.fpt-chat-card { background: var(--bg-elev); box-shadow: var(--sh-card); border-radius: var(--r-lg); } +.fpt-chat-confirm { background: var(--bg-elev); border: 0; box-shadow: var(--sh-card); border-radius: var(--r-lg); } +.fpt-chat-foot { border: 0; padding: 8px 14px 14px; background: transparent; } +.fpt-chat-input { background: var(--mat-pop); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px); border-radius: 26px; box-shadow: var(--sh-pop); padding: 6px 6px 6px 14px; align-items: center; } +.fpt-chat-input .mantine-Input-input { background: transparent; box-shadow: none !important; padding-inline: 0; min-height: 34px; } +.fpt-chat-input:focus-within { box-shadow: var(--sh-pop), 0 0 0 2px var(--accent); } +.fpt-chat-input .mantine-Button-root { border-radius: 50%; width: 34px; height: 34px; padding: 0; } +.fpt-ask-hermes { margin: 0; font-size: 12px; line-height: 16px; color: var(--label-2); } +.fpt-chat-chip .fpt-pill { max-width: 100%; } +.fpt-chat-suggest button { color: var(--accent-text); } +.fpt-chat-dl dt { color: var(--label-2); } + +/* ------------------------------------------------------------------ cards inside cards, danger zone */ +.fpt-card .fpt-card, .fpt-stage .fpt-card { background: var(--fill); box-shadow: none; } +.fpt-danger { background: var(--red-soft); box-shadow: none; padding: 20px; border: 0; } +.fpt-danger[data-engaged] { box-shadow: 0 0 0 1.5px var(--red-dot); } +.fpt-danger .mantine-Input-input { background: var(--bg-elev); } +.fpt-plainsection { border-bottom: 0.5px solid var(--sep); } +.fpt-chat-msg { flex: 0 0 auto; } +.fpt-chat-log { min-height: 0; } diff --git a/web/src/apple-run.css b/web/src/apple-run.css new file mode 100644 index 0000000000000000000000000000000000000000..8d8d0f487c91d6625f3745e8e56b187d7318d673 --- /dev/null +++ b/web/src/apple-run.css @@ -0,0 +1,167 @@ +/* Trio Co-Worker, the run workspace: stage rail, stage cards, approvals, decisions, result, the details panel and the live browser. */ + +/* ------------------------------------------------------------------ workspace frame */ +.fpt-main:has(> .fpt-ws) { padding: 0; overflow: hidden; box-shadow: none; } +.fpt-ws { display: flex; height: 100%; min-height: 0; position: relative; background: var(--bg); } +.fpt-ws-center { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; min-height: 0; background: var(--bg); box-shadow: -0.5px 0 0 var(--sep); } +.fpt-ws .fpt-topbar { position: relative; margin: 0; padding: 6px 20px 6px 16px; max-height: none; align-items: center; flex: 0 0 auto; } +.fpt-ws .fpt-topbar-left { min-width: 0; } +.fpt-ws .fpt-topbar-row1 { display: flex; align-items: center; gap: 10px; } +.fpt-ws .fpt-title { line-height: 19px; } +.fpt-ws .fpt-topbar-sub { flex-wrap: nowrap; } +.fpt-ws-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; background: var(--bg); scroll-behavior: auto; overscroll-behavior: contain; } +.fpt-ws-scroll:focus-visible { outline-offset: -2px; } +.fpt-ws-detail { padding: 20px 28px 40px; max-width: 960px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; } +.fpt-detail-head { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; min-height: 48px; padding: 8px 28px; background: var(--mat-bar); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px); border: 0; box-shadow: 0 0.5px 0 var(--sep); } +.fpt-detail-switch { margin-left: auto; } +.fpt-detail-switch .mantine-Tabs-list { flex-wrap: nowrap; overflow-x: auto; } +.trio-nowtesting { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--r-lg); background: var(--bg-elev); box-shadow: var(--sh-card); } + +/* ------------------------------------------------------------------ the stage column */ +.trio-stages { max-width: 680px; margin: 0 auto; padding: 32px 36px 120px; } +.trio-rhead { margin-bottom: 24px; } +.trio-rhead h1 { font-size: 28px; line-height: 34px; font-weight: 650; letter-spacing: -0.024em; margin: 0; } +.trio-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; } +.trio-meta .fpt-idpill { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; } +.trio-meta .fpt-idpill:hover { background: var(--fill-2); } +.trio-stagelist { list-style: none; margin: 0; padding: 0; } +.trio-stage { position: relative; display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 0 16px; padding-bottom: 8px; } +.trio-rail { position: relative; display: flex; flex-direction: column; align-items: center; } +.trio-rail::after { content: ""; position: absolute; top: 34px; bottom: -8px; width: 2px; border-radius: 1px; background: var(--fill-2); } +.trio-stage:last-child .trio-rail::after { display: none; } +.trio-stage[data-mark='done'] .trio-rail::after { background: var(--green-dot); opacity: 0.55; } +.trio-marker { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 650; font-size: 14px; background: var(--fill-2); color: var(--label-2); position: relative; z-index: 1; font-variant-numeric: tabular-nums; } +.trio-stage[data-mark='done'] .trio-marker { background: var(--green-dot); color: #fff; } +.trio-stage[data-mark='stop'] .trio-marker { background: var(--red-dot); color: #fff; } +.trio-stage[data-mark='cur'] .trio-marker { background: var(--accent); color: #fff; box-shadow: 0 0 0 5px var(--accent-soft-2); } +.trio-stage[data-mark='cur'][data-wait] .trio-marker { background: var(--orange-dot); color: #1d1d1f; box-shadow: 0 0 0 5px var(--orange-soft); } +.trio-sbody { padding-bottom: 20px; min-width: 0; } +.trio-st { padding-top: 5px; display: flex; align-items: baseline; gap: 10px; } +.trio-st h3 { font-size: 16px; line-height: 22px; font-weight: 600; letter-spacing: -0.014em; margin: 0; } +.trio-stage[data-mark='todo'] .trio-st h3 { color: var(--label-2); font-weight: 550; } +.trio-tag { font-size: 12.5px; font-weight: 550; } +.trio-tag[data-tone='orange'] { color: var(--orange); } +.trio-tag[data-tone='blue'] { color: var(--accent-text); } +.trio-sum { color: var(--label-2); font-size: 13.5px; line-height: 19px; margin: 2px 0 0; } +.trio-sum a { color: var(--accent-text); } +.trio-teamline { margin-top: 6px; } +.trio-teamline .fpt-team-line { font-size: 13px; color: var(--label-2); gap: 6px; } +.trio-teamline .fpt-team-sum { font-size: 13px; color: var(--label-2); } +.trio-teamline .fpt-team-more { margin-top: 2px; } +.trio-aifoot { margin: 18px 0 0 48px; font-size: 12px; color: var(--label-2); } +.trio-after { display: flex; gap: 16px; margin-top: 6px; } +/* the current stage's card */ +.fpt-stage { margin-top: 12px; padding: 20px; border: 0; border-radius: var(--r-xl); background: var(--bg-elev); box-shadow: var(--sh-card); animation: trio-pagein var(--d3) var(--ease) both; } +.fpt-stage[data-stage='approve'], .fpt-stage[data-stage='judge'] { border-left: 0; box-shadow: 0 0 0 1.5px var(--orange-dot), 0 6px 24px rgba(245, 147, 0, 0.12); } +.fpt-stage[data-stage='stopped'] { border-left: 0; box-shadow: 0 0 0 1.5px var(--red-dot); } +.trio-card-h { font-size: 17px; line-height: 22px; font-weight: 600; letter-spacing: -0.016em; margin: 0; } +.fpt-stage .trio-lede { font-size: 14px; line-height: 20px; margin-top: 0; max-width: 54ch; } +.trio-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 6px; } +.trio-progress-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; } +.trio-dim { color: var(--label-2); font-size: 12.5px; } +.fpt-stage .fpt-card { box-shadow: inset 0 0 0 0.5px var(--sep-strong); background: transparent; border-radius: var(--r-lg); } +.trio-judge { display: grid; gap: 16px; } +.trio-diff { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; } +.trio-diff > div { padding: 10px 12px; border-radius: var(--r-md); background: var(--fill); font-size: 13px; line-height: 18px; } +.trio-diff small { display: block; font-size: 11.5px; font-weight: 600; color: var(--label-2); margin-bottom: 2px; } +.trio-diff > div[data-bad] { background: var(--red-soft); } +.trio-diff > div[data-bad] small { color: var(--red); } +.trio-radiolist { margin-top: 6px; border-radius: var(--r-lg); box-shadow: inset 0 0 0 0.5px var(--sep-strong); overflow: hidden; } +.trio-radio { display: flex; gap: 12px; align-items: flex-start; width: 100%; padding: 12px 14px; text-align: left; cursor: default; } +.trio-radio + .trio-radio { box-shadow: inset 0 0.5px 0 var(--sep); } +.trio-radio:hover { background: var(--fill); } +.trio-rd { width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--sep-strong); flex: none; margin-top: 1px; display: grid; place-items: center; transition: all var(--d2) var(--ease); } +.trio-radio[data-active='true'] .trio-rd { background: var(--accent); box-shadow: none; } +.trio-radio[data-active='true'] .trio-rd::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff; } +.trio-radio-t { display: flex; flex-direction: column; min-width: 0; } +.trio-radio-t b { font-weight: 550; display: flex; align-items: center; gap: 8px; } +.trio-radio-t > span { color: var(--label-2); font-size: 13px; line-height: 18px; } +.fpt-failshot-img { border-radius: var(--r-md); border: 0; box-shadow: 0 0 0 1.5px var(--red-dot); } +.fpt-judge-noscreen { color: var(--label-2); } +.fpt-result { padding: 0; } +.fpt-verdict { font-size: 34px; line-height: 40px; font-weight: 700; letter-spacing: -0.03em; } +.fpt-result[data-tone='green'] .fpt-verdict { color: var(--green); } +.fpt-result[data-tone='red'] .fpt-verdict { color: var(--red); } +.fpt-result[data-tone='amber'] .fpt-verdict { color: var(--orange); } +.fpt-result-facts { padding: 10px 14px; border-radius: var(--r-lg); background: var(--fill); font-size: 13.5px; } +.fpt-result-facts [data-fail='true'] { color: var(--red); font-weight: 600; } +.fpt-team-icon { color: var(--label-2); } +.fpt-team-icon[data-kind='waiting'] { color: var(--orange); } + +/* ------------------------------------------------------------------ the details panel (inspector) */ +.fpt-panel { background: var(--bg-elev); border: 0; box-shadow: -0.5px 0 0 var(--sep); } +.fpt-panel[data-state='strip'] { background: var(--bg); } +.fpt-panel-handle:hover, .fpt-panel-handle:focus-visible { background: var(--accent); opacity: 0.35; } +.fpt-panel-head { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 12px 12px 0 16px; border: 0; } +.fpt-panel-tablist { flex: 1 1 auto; min-width: 0; display: flex; width: auto !important; max-width: none !important; -webkit-mask-image: none; mask-image: none; padding-inline: 2px !important; overflow: visible; } +.fpt-panel-tablist .mantine-Tabs-tab { flex: 1 1 0; justify-content: center; padding: 0 8px; height: 28px; font-size: 13px; } +.fpt-panel-tablabel { display: inline-flex; align-items: center; gap: 6px; } +.fpt-panel-count { background: transparent; color: var(--label-2); font-weight: 600; padding: 0; } +.fpt-panel-content { padding: 14px 16px 24px; } +.fpt-panel-stripbtn { border-radius: 50%; } +.fpt-panel-livedot { width: 7px; height: 7px; flex-basis: 7px; background: var(--red-dot) !important; animation: trio-blink 1.4s ease-in-out infinite; } + +/* ------------------------------------------------------------------ the live browser */ +.trio-live { display: flex; flex-direction: column; gap: 12px; min-width: 0; } +.trio-live-top { display: flex; align-items: flex-start; gap: 10px; } +.trio-live-t { flex: 1; min-width: 0; } +.trio-live-t b { display: block; font-size: 15px; line-height: 20px; font-weight: 600; letter-spacing: -0.012em; } +.trio-live-t span { display: block; font-size: 12.5px; line-height: 17px; color: var(--label-2); } +.trio-livebadge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px 0 8px; border-radius: var(--r-pill); font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; flex: none; background: var(--fill); color: var(--label-2); } +.trio-livebadge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--label-3); } +.trio-livebadge[data-tone='red'] { background: var(--red-soft); color: var(--red); } +.trio-livebadge[data-tone='red']::before { background: var(--red-dot); animation: trio-blink 1.4s ease-in-out infinite; } +.trio-livebadge[data-tone='orange'] { background: var(--orange-soft); color: var(--orange); } +.trio-livebadge[data-tone='orange']::before { background: var(--orange-dot); } +.trio-nowline { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: var(--r-md); background: var(--fill); font-size: 13px; line-height: 18px; } +.trio-nowline svg { flex: none; color: var(--label-2); } +.trio-nowline b { font-weight: 600; } +.trio-browser { position: relative; border-radius: var(--r-lg); overflow: hidden; background: #fff; box-shadow: 0 0 0 0.5px var(--sep-strong), 0 6px 20px rgba(0, 0, 0, 0.1); } +.trio-bchrome { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px; background: linear-gradient(var(--chrome-a), var(--chrome-b)); box-shadow: inset 0 -0.5px 0 rgba(0, 0, 0, 0.12); } +.trio-bdots { display: flex; gap: 5px; } +.trio-bdots i { width: 9px; height: 9px; border-radius: 50%; background: #d0d0d5; box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.15); } +.trio-burl { flex: 1; min-width: 0; height: 18px; border-radius: 9px; background: var(--chrome-url-bg); color: var(--chrome-url-fg); font-size: 10.5px; display: flex; align-items: center; justify-content: center; gap: 4px; letter-spacing: 0; box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.1); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 8px; } +.trio-viewport, .fpt-live-frame { position: relative; width: 100%; aspect-ratio: 16 / 10.2; background: #fff; border: 0; border-radius: 0; overflow: hidden; display: grid; place-items: center; color: #1d1d1f; } +.fpt-live-frame img { width: 100%; height: 100%; object-fit: contain; display: block; } +.fpt-live-frame[data-dim='true'] img { opacity: 0.5; filter: saturate(0.6) blur(1.2px); } +.fpt-live-frame:fullscreen { border-radius: 0; border: 0; aspect-ratio: auto; background: #000; } +.fpt-live-overlay { position: absolute; inset: 0; transform: none; max-width: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px; text-align: center; border: 0; border-radius: 0; + background: color-mix(in srgb, var(--bg-elev) 84%, transparent); -webkit-backdrop-filter: blur(10px) saturate(140%); backdrop-filter: blur(10px) saturate(140%); animation: trio-fadein var(--d3) var(--ease) both; color: var(--label); } +.fpt-live-overlay[data-kind='paused'] { border: 0; } +.fpt-live-overlay b { font-size: 15px; line-height: 20px; font-weight: 600; letter-spacing: -0.012em; } +.trio-ov-s { font-size: 13px; line-height: 18px; color: var(--label-2); max-width: 32ch; } +.trio-ov-ic { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--fill-2); color: var(--label-2); } +.trio-ov-ic[data-tone='orange'] { background: var(--orange-soft); color: var(--orange); } +.trio-skelline { width: 140px; height: 6px; border-radius: 3px; overflow: hidden; background: var(--fill-2); position: relative; } +.trio-skelline::after { content: ""; position: absolute; inset: 0; width: 40%; border-radius: 3px; background: var(--accent); animation: trio-slide 1.3s var(--ease-sheet) infinite; } +.trio-live-ctrls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } +.trio-live-sp { flex: 1; } +.trio-live-cap { font-size: 12.5px; color: var(--label-2); } +.trio-honest { display: flex; gap: 6px; margin: 0; font-size: 12px; line-height: 16px; color: var(--label-2); } +.trio-honest svg { flex: none; margin-top: 1px; } +.trio-live-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 32px 20px; border-radius: var(--r-lg); background: var(--fill); color: var(--label-2); } +.trio-live-empty b { color: var(--label); font-size: 15px; font-weight: 600; } +.trio-live-empty > span:not(.trio-live-ic) { max-width: 36ch; font-size: 13.5px; line-height: 19px; } +.trio-live-ic { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--fill-2); color: var(--label-2); } +.trio-live[data-variant='inline'] .trio-browser { max-width: 100%; } +.trio-banner-acts { display: flex; gap: 6px; flex-wrap: wrap; } +.trio-live-results h4 { display: flex; font-size: 12.5px; line-height: 16px; font-weight: 600; color: var(--label-2); margin: 14px 0 6px; } +.trio-live-results h4 span:last-child:not(:first-child) { margin-left: auto; font-weight: 500; } +.trio-group-flat { box-shadow: inset 0 0 0 0.5px var(--sep-strong); background: transparent; border-radius: var(--r-lg); } +.trio-row-sm { min-height: 40px; padding: 8px 12px; gap: 10px; font-size: 13px; } +.trio-row-sm .trio-row-body b { font-size: 13px; line-height: 17px; font-weight: 500; } +.trio-ico { width: 18px; height: 18px; flex: none; display: grid; place-items: center; } +.trio-ico[data-tone='green'] { color: var(--green-dot); } +.trio-ico[data-tone='red'] { color: var(--red-dot); } +.trio-upnext { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--label-2); } +.fpt-failed-frame { border: 0; box-shadow: 0 0 0 1.5px var(--red-dot); border-radius: var(--r-md); background: var(--bg-elev); } + +@media (max-width: 1180px) { .trio-stages { padding-inline: 24px; } } +/* in the run workspace the toolbar shares its row with the details panel: the search field is an icon */ +.fpt-ws .fpt-search { width: 32px; padding: 0; justify-content: center; } +.fpt-ws .fpt-search > svg { position: static; } +.fpt-ws .fpt-search span, .fpt-ws .fpt-search kbd { display: none; } +.fpt-ws .fpt-topbar-title-min { min-width: 120px; } +.fpt-ws .fpt-topbar-left { flex: 1 1 120px; } +.fpt-ws .fpt-topbar-actions { flex-shrink: 0; } +.fpt-panel-head { align-items: center; padding: 0 12px 0 16px; } diff --git a/web/src/apple-screens.css b/web/src/apple-screens.css new file mode 100644 index 0000000000000000000000000000000000000000..48746bbe0e2cccfc9a35bb8bf13c18fa6b4a3ed9 --- /dev/null +++ b/web/src/apple-screens.css @@ -0,0 +1,76 @@ +/* Trio Co-Worker, per-screen rules of the Apple-style layer. Loaded last. One section per screen. */ + +/* ------------------------------------------------------------------ sign-in, create account, forgot, reset */ +.trio-auth { position: fixed; inset: 0; display: grid; place-items: center; overflow-y: auto; padding: 24px 0; + background: radial-gradient(60% 60% at 18% 12%, rgba(0, 113, 227, 0.22), transparent 70%), radial-gradient(55% 55% at 88% 90%, rgba(175, 82, 222, 0.16), transparent 70%), + radial-gradient(40% 40% at 80% 10%, rgba(52, 199, 89, 0.10), transparent 70%), var(--bg); } +html:root[data-mantine-color-scheme='dark'] .trio-auth { background: radial-gradient(60% 60% at 18% 12%, rgba(10, 132, 255, 0.2), transparent 70%), radial-gradient(55% 55% at 88% 90%, rgba(191, 90, 242, 0.14), transparent 70%), + radial-gradient(40% 40% at 80% 10%, rgba(48, 209, 88, 0.08), transparent 70%), var(--bg); } +.trio-auth-panel { width: 400px; max-width: calc(100vw - 32px); padding: 8px 0 24px; animation: trio-pagein var(--d3) var(--ease) both; } +.trio-auth-brand { display: flex; justify-content: center; margin: -10px auto -2px; } +.trio-auth-brand img { filter: drop-shadow(0 8px 18px rgba(0, 70, 160, 0.28)); } +.trio-auth-panel h1 { text-align: center; font-size: 28px; line-height: 34px; font-weight: 650; letter-spacing: -0.024em; margin: 0; } +.trio-auth-sub { text-align: center; color: var(--label-2); margin: 6px auto 26px; max-width: 34ch; font-size: 15px; line-height: 21px; } +.trio-auth-panel h1 + form { margin-top: 26px; } +.trio-stack-fields { background: var(--bg-elev); border-radius: var(--r-lg); box-shadow: var(--sh-card); overflow: hidden; } +.trio-stack-fields:focus-within { outline: 2px solid var(--accent); outline-offset: 0; } +.trio-stack-fields .mantine-InputWrapper-root { display: flex; align-items: center; height: 48px; padding: 0 16px; gap: 12px; position: relative; } +.trio-stack-fields .mantine-InputWrapper-root + .mantine-InputWrapper-root::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 0.5px; background: var(--sep); } +.trio-stack-fields .mantine-InputWrapper-label { width: 84px; flex: none; margin: 0; font-weight: 500; font-size: 14px; } +.trio-stack-fields .mantine-Input-wrapper { flex: 1; min-width: 0; } +.trio-stack-fields .mantine-Input-input, .trio-stack-fields .mantine-PasswordInput-input { background: transparent; box-shadow: none !important; height: 46px; font-size: 15px !important; padding-inline: 0; } +.trio-stack-fields .mantine-PasswordInput-input { display: flex; align-items: center; } +.trio-stack-fields .mantine-PasswordInput-innerInput { height: 46px; padding-inline: 0; } +.trio-stack-fields .mantine-PasswordInput-visibilityToggle { display: none; } +.trio-auth-panel .mantine-Button-root[style*='--button-height-md'], .trio-auth-panel .mantine-Button-root[data-size='md'] { height: 40px; font-size: 14.5px !important; } +.trio-auth-links { display: flex; justify-content: space-between; margin-top: 2px; font-size: 13.5px; padding: 0 4px; } +.trio-auth-links[data-center] { justify-content: center; } +.trio-auth-honest { display: flex; justify-content: center; margin-top: 28px; } +.trio-auth-honest .fpt-mock { background: transparent; color: var(--orange); padding: 0; font-size: 12.5px; font-weight: 500; } +.trio-auth-ver { text-align: center; margin-top: 10px; font-size: 11.5px; color: var(--label-2); min-height: 14px; } +.trio-h2 { font-size: 20px; line-height: 26px; font-weight: 650; letter-spacing: -0.02em; margin: 0; } +.trio-stack-fields .mantine-InputWrapper-required { display: none; } +.fpt-topbar-menu { background: transparent; color: var(--label-2); } +.fpt-topbar-menu:hover { background: var(--fill); color: var(--label); } + +/* ------------------------------------------------------------------ home (patch readiness) */ +.trio-sect-h { display: flex; align-items: baseline; gap: 8px; font-size: 13px; line-height: 18px; font-weight: 600; color: var(--label-2); margin: 0 4px 8px; letter-spacing: -0.004em; } +.trio-sect-h span { font-weight: 500; color: var(--label-3); } +.trio-summary { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 16px; } +.trio-stat { padding: 18px 20px; border-radius: var(--r-xl); background: var(--bg-elev); box-shadow: var(--sh-card); } +.trio-stat-k { font-size: 13px; color: var(--label-2); font-weight: 500; } +.trio-stat-v { font-size: 34px; line-height: 40px; font-weight: 700; letter-spacing: -0.03em; margin-top: 6px; font-variant-numeric: tabular-nums; } +.trio-stat-v[data-tone='orange'] { color: var(--orange); } +.trio-stat-s { font-size: 13px; color: var(--label-2); margin-top: 2px; } +.trio-hero { padding: 20px 22px; border-radius: var(--r-xl); position: relative; overflow: hidden; color: #fff; + background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 94%, #fff 6%), color-mix(in srgb, var(--accent) 70%, #5e5ce6)); box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.1), 0 10px 28px rgba(0, 90, 200, 0.28); } +.trio-hero::after { content: ""; position: absolute; right: -40px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, 0.22), transparent 70%); pointer-events: none; } +.trio-hero .trio-stat-k { color: rgba(255, 255, 255, 0.85); } +.trio-hero-v { font-size: 30px; line-height: 36px; font-weight: 700; letter-spacing: -0.03em; margin-top: 6px; } +.trio-hero-s { color: rgba(255, 255, 255, 0.9); font-size: 13px; margin-top: 2px; } +.trio-segbar { display: flex; height: 8px; gap: 2px; margin-top: 16px; } +.trio-segbar i { flex: 1; display: block; height: 100%; border-radius: 3px; background: rgba(255, 255, 255, 0.28); } +.trio-segbar i[data-on] { background: #fff; } +.trio-row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; } +.trio-row-body b { font-weight: 550; font-size: 14.5px; line-height: 20px; letter-spacing: -0.01em; } +.trio-row-body > span { color: var(--label-2); font-size: 13px; line-height: 18px; } +.trio-row-trail { display: flex; align-items: center; gap: 10px; color: var(--label-2); flex: none; } +.trio-chev { color: var(--label-3); } +.trio-btn-look { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: var(--r-pill); background: var(--fill); font-size: 12.5px; font-weight: 500; color: var(--label); } +a.trio-row:hover .trio-btn-look { background: var(--fill-2); } +.trio-skel-stack { display: flex; flex-direction: column; gap: 16px; } +/* business areas: one row of text, the process flow beneath, hairlines between areas */ +.trio-area { position: relative; padding: 16px 18px 14px; } +.trio-area + .trio-area::before { content: ""; position: absolute; top: 0; left: 18px; right: 0; height: 0.5px; background: var(--sep); } +.trio-area-head { display: flex; align-items: center; gap: 14px; } +.trio-area-text { flex: 1; min-width: 0; display: flex; flex-direction: column; } +.trio-area-text b { font-size: 15px; line-height: 20px; font-weight: 600; letter-spacing: -0.012em; } +.trio-area-text span { color: var(--label-2); font-size: 13px; line-height: 18px; } +.trio-area-flow { margin: 12px 0 0 50px; } +.trio-area-acts { margin: 12px 0 0 50px; } +.trio-area[data-waiting] .trio-tile { background: var(--orange-soft); color: var(--orange); } +.fpt-area-newer { margin: 10px 0 0 50px; padding: 10px 12px; border-radius: var(--r-md); background: var(--fill); } +.fpt-area-newer[data-waiting] { background: var(--orange-soft); color: var(--orange); } +.fpt-area-newer[data-waiting] svg { color: var(--orange); } +.fpt-areas { display: block; } +@media (max-width: 1180px) { .trio-summary { grid-template-columns: 1fr 1fr; } .trio-hero { grid-column: 1 / -1; } } diff --git a/web/src/apple.css b/web/src/apple.css new file mode 100644 index 0000000000000000000000000000000000000000..4f56440cc723411acda0a4e4ef810eeae25cf4e3 --- /dev/null +++ b/web/src/apple.css @@ -0,0 +1,327 @@ +/* Trio Co-Worker: the Apple-style layer (UI-APPLE.md). Loaded after styles.css and the Mantine styles. + 1 tokens 2 legacy aliases (the older --fpt-* names now read from these) 3 base 4 Mantine controls 5 materials and shell + 6 shared components 7 screens (appended below, one section per screen). */ + +/* ------------------------------------------------------------------ 1. tokens */ +html:root { + --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter Variable", system-ui, "Segoe UI", sans-serif; + --mono: ui-monospace, "SF Mono", SFMono-Regular, "Cascadia Mono", Menlo, Consolas, monospace; + --bg: #f5f5f7; --bg-base: #ececf0; --bg-elev: #ffffff; --bg-elev-2: #fbfbfd; + --mat-sidebar: rgba(240, 240, 244, 0.72); --mat-bar: rgba(245, 245, 247, 0.74); --mat-pop: rgba(255, 255, 255, 0.78); + --fill: rgba(60, 60, 67, 0.08); --fill-2: rgba(60, 60, 67, 0.12); --fill-3: rgba(60, 60, 67, 0.18); + --sep: rgba(60, 60, 67, 0.13); --sep-strong: rgba(60, 60, 67, 0.22); --ring: rgba(0, 0, 0, 0.06); + --label: #1d1d1f; --label-2: #636366; --label-3: #8e8e93; --ph: #70707a; + --accent: #0071e3; --accent-hover: #0077ed; --accent-press: #0062c4; --on-accent: #ffffff; + --accent-text: #0066cc; --accent-soft: rgba(0, 113, 227, 0.10); --accent-soft-2: rgba(0, 113, 227, 0.16); + --green: #1d7a35; --green-soft: rgba(52, 199, 89, 0.16); --green-dot: #34c759; + --orange: #a85a00; --orange-soft: rgba(255, 159, 10, 0.17); --orange-dot: #f59300; + --red: #d70015; --red-soft: rgba(255, 59, 48, 0.12); --red-dot: #ff3b30; + --r-xs: 6px; --r-sm: 8px; --r-md: 10px; --r-lg: 14px; --r-xl: 18px; --r-2xl: 22px; --r-pill: 999px; + --sh-card: 0 0 0 0.5px var(--ring), 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.03); + --sh-pop: 0 0 0 0.5px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.08), 0 16px 48px rgba(0, 0, 0, 0.18); + --sh-seg: 0 0.5px 1px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.08); + --scrim: rgba(0, 0, 0, 0.28); + --wash-a: rgba(0, 113, 227, 0.10); --wash-b: rgba(175, 82, 222, 0.07); + --ease: cubic-bezier(0.22, 1, 0.36, 1); --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1); --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1); + --d1: 120ms; --d2: 200ms; --d3: 320ms; + --focus: #0071e3; + --mat-sidebar-solid: #ececf0; --mat-bar-solid: #f5f5f7; --mat-pop-solid: #ffffff; + --seg-thumb: #ffffff; --chrome-a: #f3f3f5; --chrome-b: #e9e9ed; --chrome-url-bg: #ffffff; --chrome-url-fg: #636366; +} +html:root[data-mantine-color-scheme='dark'] { + --bg: #1c1c1e; --bg-base: #141416; --bg-elev: #2a2a2d; --bg-elev-2: #313134; + --mat-sidebar: rgba(46, 46, 50, 0.64); --mat-bar: rgba(28, 28, 30, 0.74); --mat-pop: rgba(48, 48, 52, 0.8); + --fill: rgba(235, 235, 245, 0.10); --fill-2: rgba(235, 235, 245, 0.16); --fill-3: rgba(235, 235, 245, 0.24); + --sep: rgba(235, 235, 245, 0.13); --sep-strong: rgba(235, 235, 245, 0.26); --ring: rgba(255, 255, 255, 0.07); + --label: #f5f5f7; --label-2: #a1a1a6; --label-3: #6e6e73; --ph: #98989f; + --accent: #0071e3; --accent-hover: #1a84f0; --accent-press: #0062c4; --accent-text: #64a8ff; --accent-soft: rgba(10, 132, 255, 0.16); --accent-soft-2: rgba(10, 132, 255, 0.26); + --green: #30d158; --green-soft: rgba(48, 209, 88, 0.18); --green-dot: #30d158; + --orange: #ff9f0a; --orange-soft: rgba(255, 159, 10, 0.18); --orange-dot: #ff9f0a; + --red: #ff7a72; --red-soft: rgba(255, 69, 58, 0.2); --red-dot: #ff453a; + --sh-card: 0 0 0 0.5px var(--ring), 0 1px 3px rgba(0, 0, 0, 0.3); + --sh-pop: 0 0 0 0.5px rgba(255, 255, 255, 0.14), 0 2px 6px rgba(0, 0, 0, 0.4), 0 20px 56px rgba(0, 0, 0, 0.6); + --sh-seg: 0 0.5px 1px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.3); + --scrim: rgba(0, 0, 0, 0.5); --wash-a: rgba(10, 132, 255, 0.16); --wash-b: rgba(191, 90, 242, 0.12); + --focus: #64a8ff; + --mat-sidebar-solid: #232326; --mat-bar-solid: #1c1c1e; --mat-pop-solid: #2c2c2e; + --seg-thumb: #5e5e63; --chrome-a: #3a3a3d; --chrome-b: #303033; --chrome-url-bg: #1c1c1e; --chrome-url-fg: #a1a1a6; +} +@media (prefers-reduced-transparency: reduce) { html:root { --mat-sidebar: var(--mat-sidebar-solid); --mat-bar: var(--mat-bar-solid); --mat-pop: var(--mat-pop-solid); } } +@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { html:root { --mat-sidebar: var(--mat-sidebar-solid); --mat-bar: var(--mat-bar-solid); --mat-pop: var(--mat-pop-solid); } } +@media (prefers-contrast: more) { + html:root { --sep: var(--sep-strong); --label-2: #48484a; --mat-sidebar: var(--mat-sidebar-solid); --mat-bar: var(--mat-bar-solid); --mat-pop: var(--mat-pop-solid); } + html:root[data-mantine-color-scheme='dark'] { --label-2: #c7c7cc; } +} + +/* ------------------------------------------------------------------ 2. legacy aliases: the older rules keep rendering, in the new look */ +html:root, html:root[data-mantine-color-scheme='dark'] { + --fpt-font: var(--font); --fpt-font-display: var(--font); --fpt-mono: var(--mono); + --fpt-page: var(--bg); --fpt-sidebar: var(--bg-base); + --fpt-surface: var(--bg-elev); --fpt-surface-2: var(--fill); + --fpt-border: var(--sep); --fpt-line: var(--sep-strong); + --fpt-text: var(--label); --fpt-dim: var(--label-2); --fpt-disabled: var(--label-3); + --fpt-accent: var(--accent-text); --fpt-accent-hover: var(--accent-hover); --fpt-accent-pressed: var(--accent-press); --fpt-accent-text: #ffffff; + --fpt-ink: var(--accent); --fpt-ink-text: #ffffff; + --fpt-selected: var(--fill-2); --fpt-hover: var(--fill); + --fpt-focus: var(--focus); --fpt-focus-inner: var(--bg-elev); + --fpt-status-running: var(--accent); --fpt-status-waiting: var(--orange-dot); --fpt-status-done: var(--green-dot); + --fpt-status-failed: var(--red-dot); --fpt-status-idle: var(--label-3); + --fpt-env-practice-bg: var(--orange-soft); --fpt-env-practice-fg: var(--orange); + --fpt-env-fusion-bg: var(--accent-soft-2); --fpt-env-fusion-fg: var(--accent-text); + --fpt-shadow-1: var(--sh-card); --fpt-shadow-2: var(--sh-pop); --fpt-shadow-3: var(--sh-pop); + --fpt-radius-control: var(--r-md); --fpt-radius-card: var(--r-lg); + --fpt-ease: var(--ease); --fpt-dur-1: var(--d1); --fpt-dur-2: var(--d2); --fpt-dur-3: var(--d3); + --fpt-band: transparent; --fpt-mint-card: transparent; --fpt-lav-card: transparent; + --pill-neutral-bg: var(--fill); --pill-neutral-fg: var(--label-2); + --pill-green-bg: var(--green-soft); --pill-green-fg: var(--green); + --pill-amber-bg: var(--orange-soft); --pill-amber-fg: var(--orange); + --pill-red-bg: var(--red-soft); --pill-red-fg: var(--red); + --pill-blue-bg: var(--accent-soft-2); --pill-blue-fg: var(--accent-text); + --pill-mint-bg: var(--fill); --pill-mint-fg: var(--label-2); --pill-lav-bg: var(--fill); --pill-lav-fg: var(--label-2); + /* Mantine reads these for default (secondary) controls, links, body and dimmed text */ + --mantine-color-default: var(--fill); --mantine-color-default-hover: var(--fill-2); --mantine-color-default-color: var(--label); --mantine-color-default-border: transparent; + --mantine-color-anchor: var(--accent-text); --mantine-color-dimmed: var(--label-2); --mantine-color-text: var(--label); --mantine-color-body: var(--bg-elev); + --mantine-color-error: var(--red); + --mantine-shadow-xs: none; --mantine-shadow-sm: var(--sh-card); --mantine-shadow-md: var(--sh-card); --mantine-shadow-lg: var(--sh-pop); --mantine-shadow-xl: var(--sh-pop); + --mantine-font-family: var(--font); --mantine-font-family-headings: var(--font); + --mantine-font-weight-bold: 650; +} + +/* ------------------------------------------------------------------ 3. base */ +html { font-optical-sizing: auto; } +body { background: var(--bg); color: var(--label); font-family: var(--font); font-size: 14px; line-height: 20px; letter-spacing: -0.006em; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; } +h1, h2, h3, h4, h5, h6, .fpt-title { font-family: var(--font); font-weight: 650; } +a { color: var(--accent-text); } +::selection { background: var(--accent-soft-2); } +code, kbd, pre, samp, .fpt-idpill { font-family: var(--mono); } +.fpt-num { font-variant-numeric: tabular-nums; } +:focus-visible, .mantine-focus-auto:focus-visible, .mantine-focus-always:focus { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); } +@media (prefers-reduced-motion: reduce) { + *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; } +} +.fpt-main::-webkit-scrollbar, .fpt-ws-scroll::-webkit-scrollbar, .fpt-panel-content::-webkit-scrollbar, .fpt-chat-scroll::-webkit-scrollbar { width: 12px; } +.fpt-main::-webkit-scrollbar-thumb, .fpt-ws-scroll::-webkit-scrollbar-thumb, .fpt-panel-content::-webkit-scrollbar-thumb, .fpt-chat-scroll::-webkit-scrollbar-thumb { background: var(--fill-3); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; } +@keyframes trio-pagein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } } +@keyframes trio-pulse { 0% { box-shadow: 0 0 0 0 rgba(0, 113, 227, 0.5); } 70%, 100% { box-shadow: 0 0 0 7px rgba(0, 113, 227, 0); } } +@keyframes trio-blink { 50% { opacity: 0.35; } } +@keyframes trio-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } } +@keyframes trio-slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } } +@keyframes trio-fadein { from { opacity: 0; } to { opacity: 1; } } + +/* ------------------------------------------------------------------ 4. Mantine controls */ +html:root { + --button-height-xs: 32px; --button-height-sm: 32px; --button-height-md: 40px; --button-height-lg: 44px; + --button-height-compact-xs: 24px; --button-height-compact-sm: 28px; --button-height-compact-md: 30px; + --button-padding-x-xs: 14px; --button-padding-x-sm: 14px; --button-padding-x-md: 20px; + --input-height-xs: 34px; --input-height-sm: 38px; --input-height-md: 42px; +} +/* buttons: pills, 32px, a calm press */ +.mantine-Button-root { --button-fz: 13.5px !important; border-radius: var(--r-pill); font-weight: 500; letter-spacing: -0.006em; border-width: 0; + transition: background var(--d1) var(--ease), transform var(--d1) var(--ease), box-shadow var(--d2), opacity var(--d2); } +.mantine-Button-root[style*='compact'] { --button-fz: 12.5px !important; } +.mantine-Button-root[style*='--button-height: var(--button-height-md)'] { --button-fz: 14.5px !important; } +.mantine-Button-root:active:not(:disabled):not([data-disabled]) { transform: scale(0.975); } +.mantine-Button-root[data-variant='default'] { background: var(--fill); color: var(--label); border: 0; --button-hover: var(--fill-2); } +.mantine-Button-root[data-variant='default']:hover:not(:disabled):not([data-disabled]) { background: var(--fill-2); } +.mantine-Button-root[data-variant='default']:active:not(:disabled):not([data-disabled]) { background: var(--fill-3); } +.mantine-Button-root[data-variant='filled'] { font-weight: 600; color: var(--on-accent); } +.mantine-Button-root[data-variant='filled']:not([style*='red']):not([style*='green']):not([style*='orange']):not([style*='yellow']) { background: var(--accent); } +.mantine-Button-root[data-variant='filled']:not([style*='red']):not([style*='green']):not([style*='orange']):not([style*='yellow']):hover:not(:disabled):not([data-disabled]) { background: var(--accent-hover); } +.mantine-Button-root[data-variant='filled']:not([style*='red']):not([style*='green']):not([style*='orange']):not([style*='yellow']):active:not(:disabled):not([data-disabled]) { background: var(--accent-press); } +.mantine-Button-root[data-variant='filled'][style*='red'] { background: #d70015; } +.mantine-Button-root[data-variant='light'][style*='red'] { background: var(--red-soft); color: var(--red); } +.mantine-Button-root[data-variant='light'][style*='red']:hover:not(:disabled) { background: rgba(255, 59, 48, 0.2); } +.mantine-Button-root[data-variant='subtle'], .mantine-Button-root[data-variant='transparent'] { color: var(--accent-text); } +.mantine-Button-root[data-variant='subtle']:hover:not(:disabled), .mantine-Button-root[data-variant='transparent']:hover:not(:disabled) { background: var(--accent-soft); } +.mantine-Button-root[data-variant='subtle'][style*='gray'] { color: var(--label-2); } +.mantine-Button-root[data-variant='subtle'][style*='gray']:hover:not(:disabled) { background: var(--fill); color: var(--label); } +.mantine-Button-root[data-variant='white'] { background: var(--bg-elev); color: var(--label); } +.mantine-Button-root:disabled, .mantine-Button-root[data-disabled] { opacity: 0.42; background: var(--fill); color: var(--label-2); } +.mantine-Button-root[data-variant='filled']:disabled, .mantine-Button-root[data-variant='filled'][data-disabled] { background: var(--accent); color: var(--on-accent); opacity: 0.42; } +.mantine-ActionIcon-root { border-radius: var(--r-pill); } +.mantine-ActionIcon-root[data-variant='subtle'], .mantine-ActionIcon-root[data-variant='transparent'] { color: var(--label-2); --ai-hover: var(--fill); } +.mantine-ActionIcon-root[data-variant='subtle']:hover { color: var(--label); } +.mantine-ActionIcon-root[data-variant='default'] { background: var(--fill); border: 0; color: var(--label); --ai-hover: var(--fill-2); } +.mantine-ActionIcon-root[data-variant='filled'] { background: var(--accent); color: #fff; } +.fpt-iconbtn { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--fill); color: var(--label); transition: background var(--d1) var(--ease); } +.fpt-iconbtn:hover { background: var(--fill-2); } +.fpt-iconbtn[data-active='true'] { background: var(--accent-soft-2); color: var(--accent-text); } + +/* text fields: 38px, inset ring, accent halo on focus */ +.mantine-Input-input, .mantine-Textarea-input, .mantine-Select-input, .mantine-PasswordInput-innerInput { font-size: 14px !important; letter-spacing: -0.006em; color: var(--label); background: var(--bg-elev); + border: 0 !important; border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--sep-strong); transition: box-shadow var(--d2); } +.mantine-PasswordInput-input { border: 0 !important; background: var(--bg-elev); box-shadow: inset 0 0 0 1px var(--sep-strong); border-radius: var(--r-md); } +.mantine-PasswordInput-innerInput { box-shadow: none; background: transparent; } +.mantine-Input-input:hover:not(:disabled), .mantine-PasswordInput-input:hover { box-shadow: inset 0 0 0 1px var(--label-3); } +.mantine-Input-input:focus, .mantine-Input-input:focus-within, .mantine-Input-input[data-expanded], .mantine-PasswordInput-input:focus-within { + box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 4px var(--accent-soft-2) !important; outline: none; border-bottom-color: transparent; } +.mantine-Input-input[data-error], .mantine-PasswordInput-input[data-error] { box-shadow: inset 0 0 0 1.5px var(--red-dot); } +.mantine-Input-input::placeholder { color: var(--ph); opacity: 1; } +.mantine-Input-input:disabled { opacity: 0.6; background: var(--fill); } +.mantine-InputWrapper-label { font-size: 13px; line-height: 16px; font-weight: 500; margin-bottom: 6px; color: var(--label); } +.mantine-InputWrapper-description { font-size: 12px; line-height: 16px; color: var(--label-2); } +.mantine-InputWrapper-error { font-size: 12px; color: var(--red); } +.mantine-Input-section { color: var(--label-2); } +.mantine-Checkbox-input { border-radius: 6px; border: 0; box-shadow: inset 0 0 0 1.5px var(--sep-strong); background: var(--bg-elev); } +.mantine-Checkbox-input:checked { background: var(--accent); box-shadow: none; } +.mantine-Radio-radio { border: 0; box-shadow: inset 0 0 0 1.5px var(--sep-strong); background: var(--bg-elev); } +.mantine-Radio-radio:checked { background: var(--accent); box-shadow: none; } +.mantine-Radio-icon { color: #fff; } +.mantine-Checkbox-label, .mantine-Radio-label, .mantine-Switch-label { font-size: 14px; color: var(--label); } +.mantine-Checkbox-description, .mantine-Radio-description, .mantine-Switch-description { font-size: 12.5px; line-height: 17px; color: var(--label-2); } +/* switch: 44x26, system green when on */ +.mantine-Switch-root { --switch-height: 26px !important; --switch-width: 44px !important; --switch-thumb-size: 22px !important; --switch-color: var(--green-dot) !important; } +.mantine-Switch-track { border: 0; background: var(--fill-3); } +.mantine-Switch-thumb { border: 0; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28), 0 0 0 0.5px rgba(0, 0, 0, 0.04); background: #fff; transition: inset-inline-start var(--d3) var(--ease-spring); } +/* segmented control: a pill track with a thumb */ +.mantine-SegmentedControl-root { padding: 2px; border-radius: var(--r-pill); background: var(--fill); border: 0; overflow: visible; } +.mantine-SegmentedControl-indicator { border-radius: var(--r-pill); background: var(--seg-thumb); box-shadow: var(--sh-seg); border: 0; transition-duration: var(--d3); transition-timing-function: var(--ease-spring); } +.mantine-SegmentedControl-label { font-size: 13px; font-weight: 500; color: var(--label-2); border-radius: var(--r-pill); padding: 4px 14px; } +.mantine-SegmentedControl-label[data-active] { color: var(--label); font-weight: 500; } +.mantine-SegmentedControl-label:hover:not([data-active]) { color: var(--label); } +.mantine-SegmentedControl-control::before { display: none; } +/* tabs: pill tabs on a track (inspector, detail switcher); settings keeps its own vertical list below */ +.mantine-Tabs-list { gap: 2px; } +.mantine-Tabs-list::before { display: none; } +.mantine-Tabs-tab { font-size: 13px; font-weight: 500; color: var(--label-2); border-radius: var(--r-pill); background: transparent; padding: 5px 12px; transition: color var(--d2), background var(--d1); } +.mantine-Tabs-tab:hover:not([data-active]) { background: var(--fill); color: var(--label); } +.mantine-Tabs-tab[data-active], .mantine-Tabs-tab[data-variant='pills'][data-active], .fpt-panel-tablist .mantine-Tabs-tab[data-active] { + color: var(--label); font-weight: 550; background: var(--seg-thumb); box-shadow: var(--sh-seg); border-color: transparent; --tab-border-color: transparent; } +.mantine-Tabs-list:not([data-orientation='vertical']) { background: var(--fill); padding: 2px; border-radius: var(--r-pill); width: fit-content; max-width: 100%; } +/* menus, popovers, combobox: a thick material */ +.mantine-Menu-dropdown, .mantine-Popover-dropdown, .mantine-Combobox-dropdown, .mantine-Select-dropdown { + background: var(--mat-pop); -webkit-backdrop-filter: saturate(180%) blur(30px); backdrop-filter: saturate(180%) blur(30px); + border: 0; border-radius: var(--r-lg); box-shadow: var(--sh-pop); padding: 6px; color: var(--label); } +.mantine-Menu-item { font-size: 13.5px; min-height: 32px; border-radius: var(--r-sm); padding: 0 10px; color: var(--label); } +.mantine-Menu-item:hover, .mantine-Menu-item[data-hovered], .mantine-Menu-item:focus-visible { background: var(--accent); color: #fff; } +.mantine-Menu-item[data-hovered] .mantine-Menu-itemLabel *, .mantine-Menu-item:hover .mantine-Menu-itemLabel * { color: inherit !important; } +.mantine-Menu-item[color='red'], .mantine-Menu-item[data-color='red'] { color: var(--red); } +.mantine-Menu-label { font-size: 11.5px; font-weight: 600; color: var(--label-2); padding: 6px 10px 2px; } +.mantine-Menu-divider { border-color: var(--sep); margin: 5px 8px; } +.mantine-Combobox-option { border-radius: var(--r-sm); font-size: 13.5px; min-height: 32px; display: flex; align-items: center; } +.mantine-Combobox-option:hover, .mantine-Combobox-option[data-combobox-selected] { background: var(--accent); color: #fff; } +.mantine-Combobox-option[data-checked] { font-weight: 600; } +/* sheets and dialogs */ +.mantine-Modal-overlay, .mantine-Drawer-overlay { background: var(--scrim); } +.mantine-Modal-content, .mantine-Drawer-content { background: var(--bg-elev); border-radius: var(--r-2xl); box-shadow: var(--sh-pop); color: var(--label); } +.mantine-Modal-header, .mantine-Drawer-header { background: var(--bg-elev); padding: 22px 24px 4px; } +.mantine-Modal-body { padding: 12px 24px 24px; } +.mantine-Modal-title, .mantine-Drawer-title { font-family: var(--font); font-size: 20px; line-height: 26px; font-weight: 650; letter-spacing: -0.02em; } +.mantine-Modal-close { border-radius: 50%; } +.mantine-Tooltip-tooltip { font-size: 12px; line-height: 16px; border-radius: var(--r-sm); background: var(--mat-pop-solid); color: var(--label); box-shadow: var(--sh-pop); font-weight: 500; } +html:root[data-mantine-color-scheme='dark'] .mantine-Tooltip-tooltip { background: #3a3a3d; } +.mantine-Notification-root { background: var(--mat-pop); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px); border-radius: var(--r-xl); box-shadow: var(--sh-pop); padding: 12px 14px 12px 16px; color: var(--label); } +.mantine-Notification-root::before { display: none; } +.mantine-Notification-title { font-weight: 600; color: var(--label); } +.mantine-Notification-description { color: var(--label-2); } +.mantine-Alert-root { border-radius: var(--r-lg); border: 0; background: var(--fill); color: var(--label); padding: 14px 16px; } +.mantine-Alert-root[data-variant='light'][style*='red'], .mantine-Alert-root[style*='--alert-bg: var(--mantine-color-red'] { background: var(--red-soft); } +.mantine-Alert-root[style*='yellow'], .mantine-Alert-root[style*='orange'] { background: var(--orange-soft); } +.mantine-Alert-root[style*='blue'], .mantine-Alert-root[style*='trio'], .mantine-Alert-root[style*='accent'] { background: var(--accent-soft); } +.mantine-Alert-root[style*='teal'], .mantine-Alert-root[style*='green'] { background: var(--green-soft); } +.mantine-Alert-title { font-weight: 600; } +.mantine-Alert-message { font-size: 13.5px; line-height: 19px; color: var(--label); } +.mantine-Badge-root { text-transform: none; font-weight: 550; letter-spacing: 0; font-size: 12px; } +.mantine-Progress-root { background: var(--fill-2); border-radius: var(--r-pill); height: 6px !important; } +.mantine-Progress-section { background: var(--accent); } +.mantine-Skeleton-root { border-radius: 8px; } +.mantine-Skeleton-root::before { background: transparent; } +.mantine-Skeleton-root::after { background: linear-gradient(90deg, var(--fill) 0%, var(--fill-2) 40%, var(--fill) 80%); background-size: 200% 100%; animation: trio-shimmer 1.4s linear infinite; } +.mantine-Accordion-item { background: var(--bg-elev); border: 0; border-radius: var(--r-xl); box-shadow: var(--sh-card); overflow: hidden; margin-bottom: 8px; } +.mantine-Accordion-item[data-active] { background: var(--bg-elev); } +.mantine-Accordion-control { padding: 12px 16px; min-height: 52px; } +.mantine-Accordion-control:hover { background: var(--fill); } +.mantine-Accordion-label { font-size: 14.5px; font-weight: 550; } +.mantine-Accordion-content { padding: 0 16px 16px; } +.mantine-Pagination-control { border: 0; background: var(--fill); border-radius: var(--r-pill); } +.mantine-Pagination-control[data-active] { background: var(--accent); color: #fff; } +.mantine-Anchor-root { color: var(--accent-text); } +.mantine-Code-root { background: var(--fill); border-radius: var(--r-md); } +/* tables: hairlines, 52px rows, quiet header */ +.mantine-Table-table { --table-border-color: var(--sep); --table-highlight-on-hover-color: var(--fill); --table-striped-color: transparent; font-size: 13.5px; } +.mantine-Table-tr { height: 52px; } +.mantine-Table-th { color: var(--label-2); font-weight: 500; font-size: 12px; background: var(--bg-elev-2); border-bottom: 0.5px solid var(--sep); } +.mantine-Table-td { border-bottom: 0.5px solid var(--sep); } +.mantine-Table-thead { border-bottom: 0; } +.mantine-Table-tr:last-child .mantine-Table-td { border-bottom: 0; } +.fpt-table thead, .fpt-report .mantine-Table-thead { background: var(--bg-elev-2); } +.mantine-Table-tr[data-hover]:hover, .mantine-Table-table[data-highlight-on-hover] tbody tr:hover { background: var(--fill); } +.mantine-ScrollArea-scrollbar { background: transparent; } + +/* ------------------------------------------------------------------ 5. materials and shell */ +.fpt-shell { display: flex; height: 100dvh; overflow: hidden; background: var(--bg); position: relative; } +.fpt-shell::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 264px; z-index: 0; pointer-events: none; + background: radial-gradient(120% 60% at 0% 0%, var(--wash-a), transparent 60%), radial-gradient(90% 50% at 0% 100%, var(--wash-b), transparent 60%), var(--bg-base); } +.fpt-shell[data-sb='closed']::before, .fpt-shell[data-size='tablet']::before, .fpt-shell[data-size='phone']::before { display: none; } +.fpt-sidebar { position: relative; z-index: 5; width: 264px; flex: 0 0 264px; display: flex; min-height: 0; overflow: hidden; border: 0; + background: var(--mat-sidebar); -webkit-backdrop-filter: saturate(180%) blur(28px); backdrop-filter: saturate(180%) blur(28px); box-shadow: inset -0.5px 0 0 var(--sep); + transition: width var(--d3) var(--ease-sheet), flex-basis var(--d3) var(--ease-sheet), opacity var(--d2); } +.fpt-sidebar[data-mode='closed'] { width: 0; flex-basis: 0; opacity: 0; pointer-events: none; } +.fpt-sidebar[data-mode='closed'] > * { visibility: hidden; } +.fpt-main { flex: 1 1 auto; min-width: 0; overflow-y: auto; overflow-x: hidden; padding: 0 40px 96px; position: relative; background: var(--bg); box-shadow: -0.5px 0 0 var(--sep); } +.fpt-main[data-reading='true'] > .mantine-Stack-root > :not(.fpt-topbar) { width: 100%; max-width: 960px; margin-inline: auto; } +.fpt-main[data-wide='true'] > .mantine-Stack-root > :not(.fpt-topbar) { max-width: 1120px; } +.fpt-main > .mantine-Stack-root { animation: trio-pagein var(--d3) var(--ease) both; } + +/* sidebar content */ +.fpt-sb { display: flex; flex-direction: column; width: 100%; min-width: 264px; min-height: 0; height: 100%; padding: 14px 10px 10px; gap: 0; box-sizing: border-box; } +.fpt-sb-brand { display: flex; align-items: center; gap: 10px; min-height: 0; padding: 2px 8px 14px; font-weight: 650; font-size: 14.5px; letter-spacing: -0.014em; line-height: 1.2; } +.fpt-sb-brand img { width: 30px; height: 30px; flex: none; filter: drop-shadow(0 1px 2px rgba(0, 40, 100, 0.25)); } +.fpt-sb-brand-name { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; } +.fpt-sb-brand-name small { font-weight: 400; font-size: 11.5px; color: var(--label-2); letter-spacing: 0; margin-top: -1px; } +.fpt-sb-top { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow-y: auto; } +.fpt-sb-nav { display: flex; flex-direction: column; gap: 1px; width: 100%; } +.fpt-sb-nav h6 { margin: 14px 10px 4px; font-size: 11.5px; line-height: 14px; font-weight: 600; color: var(--label-2); letter-spacing: 0; } +.fpt-nav-item { position: relative; display: flex; align-items: center; gap: 10px; height: 32px; min-height: 32px; padding: 0 10px; border-radius: var(--r-md); font-size: 13.5px; font-weight: 500; color: var(--label); text-decoration: none; width: 100%; text-align: left; border: 0; background: transparent; cursor: default; font-family: inherit; letter-spacing: -0.006em; transition: background var(--d1); } +.fpt-nav-item:hover { background: var(--fill); text-decoration: none; } +.fpt-nav-item:active { background: var(--fill-2); } +.fpt-nav-item svg { color: var(--accent); flex: none; } +.fpt-nav-item[data-active='true'] { background: var(--fill-2); color: var(--label); font-weight: 600; } +.fpt-nav-item[data-active='true']::before { display: none; } +.fpt-nav-item[data-active='true'] svg { color: var(--accent); } +.fpt-nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.fpt-nav-badge { margin-left: auto; min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px; background: var(--orange-dot); color: #1d1d1f; font-size: 11.5px; font-weight: 650; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; } +.fpt-sb-foot { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; width: 100%; padding-top: 8px; } +.fpt-kill { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-md); background: var(--red-soft); color: var(--red); font-size: 12.5px; font-weight: 600; } +.fpt-warnrow { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-md); background: var(--orange-soft); color: var(--orange); font-size: 12.5px; font-weight: 600; } +.fpt-me { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border-radius: var(--r-md); cursor: default; } +.fpt-me:hover { background: var(--fill); } +.fpt-me:focus-visible { outline: 2px solid var(--focus); outline-offset: -1px; } +.fpt-avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(#9a9aa3, #76767f); color: #fff; font-size: 11.5px; font-weight: 650; flex: none; border: 0; } +.fpt-me b { display: block; font-size: 13px; line-height: 16px; font-weight: 600; } +.fpt-me small { display: block; font-size: 11.5px; line-height: 14px; color: var(--label-2); } +.fpt-me-text { min-width: 0; flex: 1; } +.fpt-me-text > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +/* the environment switcher: the honesty cue at the top */ +.fpt-env { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; margin: 0 0 10px; border-radius: var(--r-md); background: var(--fill); cursor: default; transition: background var(--d1); text-align: left; } +.fpt-env:hover { background: var(--fill-2); } +.fpt-env:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; } +.fpt-env-tile { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--orange-soft); color: var(--orange); flex: none; } +.fpt-env[data-kind='fusion'] .fpt-env-tile { background: var(--accent-soft-2); color: var(--accent-text); } +.fpt-env-label { display: flex; flex-direction: column; min-width: 0; flex: 1; font-size: 11.5px; line-height: 14px; } +.fpt-env-label > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.fpt-env-label b { font-weight: 600; font-size: 13px; line-height: 16px; color: var(--label); } +.fpt-env-label .fpt-env-sub { color: var(--orange); } +.fpt-env[data-kind='fusion'] .fpt-env-label .fpt-env-sub { color: var(--label-2); } +.fpt-env .fpt-env-chev { color: var(--label-3); flex: none; } + +/* the toolbar: translucent, content scrolls under it */ +.fpt-topbar { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 6px 40px; margin: 0 -40px 28px; + background: var(--mat-bar); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px); border: 0; box-shadow: 0 0.5px 0 var(--sep); box-sizing: border-box; } +.fpt-topbar-left { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; justify-content: center; } +.fpt-title { font-size: 15px; line-height: 19px; font-weight: 650; letter-spacing: -0.014em; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.fpt-topbar-sub { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; overflow: hidden; font-size: 12px; line-height: 15px; color: var(--label-2); margin-top: 1px; min-width: 0; white-space: nowrap; } +.fpt-topbar-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; justify-content: flex-end; } +.fpt-search { position: relative; display: flex; align-items: center; height: 32px; width: 260px; padding: 0 10px 0 32px; border-radius: var(--r-pill); background: var(--fill); color: var(--label-2); font-size: 13.5px; cursor: text; border: 0; text-align: left; gap: 8px; transition: background var(--d1); flex: none; font-family: inherit; } +.fpt-search:hover { background: var(--fill-2); } +.fpt-search > svg { position: absolute; left: 10px; } +.fpt-search kbd { margin-left: auto; font: 500 11.5px var(--font); color: var(--label-2); padding: 1px 6px; border-radius: 5px; background: var(--fill); letter-spacing: 0; } +.fpt-crumb a { color: var(--accent-text); } +.fpt-back { display: inline-flex; align-items: center; gap: 2px; color: var(--accent-text); font-weight: 500; font-size: 13.5px; text-decoration: none; margin-right: 4px; white-space: nowrap; } +.fpt-back:hover { text-decoration: underline; text-underline-offset: 2px; } +.fpt-savednotice { margin: 0 -40px; } +@media (max-width: 1279px) { .fpt-search { width: 36px; padding: 0; justify-content: center; } .fpt-search > svg { position: static; } .fpt-search span, .fpt-search kbd { display: none; } } +/* the sidebar is the same 264px at laptop widths; hidden means gone (the older laptop rule made it a 64px rail) */ +.fpt-shell[data-size='laptop'] .fpt-sidebar { width: 264px; flex-basis: 264px; } +.fpt-shell[data-size] .fpt-sidebar[data-mode='closed'] { width: 0; flex-basis: 0; } +.fpt-sb-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } diff --git a/web/src/chat/ChatDock.tsx b/web/src/chat/ChatDock.tsx index f34bbbad2ea853d5c152daa576ac8a1380cc4f7b..051691b7b8c3bf4b986136160dc2a64bd9e7aee5 100644 --- a/web/src/chat/ChatDock.tsx +++ b/web/src/chat/ChatDock.tsx @@ -5,7 +5,7 @@ import { useCallback, useEffect, useMemo, useRef, useState, type KeyboardEvent a import { useLocation, useSearchParams } from 'react-router-dom'; import { MODULE_NAMES } from '../agents'; import { errorMessage } from '../api/client'; -import { useRun } from '../api/hooks'; +import { askErrorWords, useAssistantAsk, useAssistantStatus, useRun } from '../api/hooks'; import { useAuth } from '../auth/AuthContext'; import { runTitle } from '../runName'; import { AnswerCard, ConfirmCard, ScreenLinks, Sources } from './ChatCards'; @@ -19,12 +19,13 @@ const store = { set(k: string, v: string | null) { try { if (v === null) window.localStorage.removeItem(k); else window.localStorage.setItem(k, v); } catch { /* private mode */ } }, }; -/** Open/closed state of the dock, remembered per user. Ctrl+K opens it and focuses the input. */ +/** Open/closed state of the dock, remembered per user. The command palette (Ctrl K) opens it through `ask`. */ export function useChatDock() { const { user } = useAuth(); const key = `fpt-chat-open:${user?.username ?? ''}`; const [open, setOpenState] = useState(false); const [focusTick, setFocusTick] = useState(0); + const [pendingAsk, setPendingAsk] = useState(null); const returnTo = useRef(null); useEffect(() => { setOpenState(store.get(key) === '1'); }, [key]); const setOpen = useCallback((v: boolean) => { setOpenState(v); store.set(key, v ? '1' : '0'); }, [key]); @@ -33,15 +34,11 @@ export function useChatDock() { setOpen(true); setFocusTick((t) => t + 1); }, [setOpen]); + /** Open the dock; with a question, it is sent as soon as the dock is open. */ + const ask = useCallback((q?: string) => { if (q) setPendingAsk(q); focusInput(); }, [focusInput]); + const consumeAsk = useCallback(() => setPendingAsk(null), []); const giveFocusBack = useCallback(() => { returnTo.current?.focus?.(); returnTo.current = null; }, []); - useEffect(() => { - const onKey = (e: KeyboardEvent) => { - if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'k') { e.preventDefault(); focusInput(); } - }; - window.addEventListener('keydown', onKey); - return () => window.removeEventListener('keydown', onKey); - }, [focusInput]); - return { open, setOpen, focusTick, focusInput, giveFocusBack }; + return { open, setOpen, focusTick, focusInput, ask, pendingAsk, consumeAsk, giveFocusBack }; } export type ChatDockState = ReturnType; @@ -74,15 +71,26 @@ function Message({ m, onAction }: { m: ChatMessage; onAction: (a: ChatAction) => {m.action && } {r && } {r && } + {m.by === 'hermes' && !m.pending && m.text && Answered by the Hermes assistant{m.model ? ` (${m.model})` : ''}.} ); } +/** A question that asks the co-worker to do something: it always goes to the built-in assistant, whose proposed actions + * keep their confirm cards. Everything else goes to Hermes when an admin switched Hermes on. */ +const ACTION_WORDS = /^(please\s+)?(start|run|launch|re-?run|approve|skip|cancel|stop|add a note|note)\b/i; +/** Shown under the input only while Hermes is the one answering. */ +export const HERMES_NOTICE = "Answered by the Hermes assistant using NVIDIA's AI model. Don't paste client data."; + function ChatPanel({ dock, onClose }: { dock: ChatDockState; onClose: () => void }) { const { user } = useAuth(); const chip = useContextChip(); + const status = useAssistantStatus(); + const askHermes = useAssistantAsk(); + const hermesOn = !!status.data?.enabled && !!status.data?.configured; const convKey = `fpt-chat-conv:${user?.username ?? ''}`; const [convId, setConvId] = useState(null); + const [hermesConv, setHermesConv] = useState(null); const [messages, setMessages] = useState([]); const [text, setText] = useState(''); const [busy, setBusy] = useState(false); @@ -90,6 +98,7 @@ function ChatPanel({ dock, onClose }: { dock: ChatDockState; onClose: () => void const inputRef = useRef(null); const logRef = useRef(null); const seq = useRef(0); + const sendRef = useRef<(q: string) => Promise>(async () => undefined); useEffect(() => { // restore the user's last conversation (text and action state; cards are shown for answers of this session) const id = store.get(convKey); @@ -103,9 +112,28 @@ function ChatPanel({ dock, onClose }: { dock: ChatDockState; onClose: () => void return () => { live = false; }; }, [convKey]); useEffect(() => { if (dock.focusTick) window.setTimeout(() => inputRef.current?.focus(), 30); }, [dock.focusTick]); + useEffect(() => { // a question typed in the command palette + if (!dock.pendingAsk) return; + const q = dock.pendingAsk; + dock.consumeAsk(); + window.setTimeout(() => void sendRef.current(q), 60); + }, [dock.pendingAsk]); // eslint-disable-line react-hooks/exhaustive-deps useEffect(() => { const el = logRef.current; if (el) el.scrollTop = el.scrollHeight; }, [messages]); const patch = (key: string, f: (m: ChatMessage) => ChatMessage) => setMessages((ms) => ms.map((m) => (m.key === key ? f(m) : m))); + /** The built-in assistant: answers from the app's own data, with cards, sources and confirm cards. */ + const askBuiltIn = async (q: string, aKey: string) => { + let id = convId; + if (!id) { id = (await createConversation(chip.runId)).id; setConvId(id); store.set(convKey, id); } + await sendMessage(id, q, chip.context, (ev, data) => { + const d = data as Record; + if (ev === 'intent') patch(aKey, (m) => ({ ...m, tool: String(d.tool) })); + else if (ev === 'delta') patch(aKey, (m) => ({ ...m, text: m.text + String(d.text ?? '') })); + else if (ev === 'result') patch(aKey, (m) => ({ ...m, result: data as ChatResult })); + else if (ev === 'action') patch(aKey, (m) => ({ ...m, action: data as ChatAction })); + else if (ev === 'error') patch(aKey, (m) => ({ ...m, error: String(d.detail ?? 'The answer could not be completed.') })); + }); + }; const send = async (raw: string) => { const q = raw.trim(); if (!q || busy) return; @@ -113,18 +141,23 @@ function ChatPanel({ dock, onClose }: { dock: ChatDockState; onClose: () => void setText(''); setBusy(true); const aKey = `a${++seq.current}-${Date.now()}`; - setMessages((ms) => [...ms, { key: `u${aKey}`, role: 'user', text: q }, { key: aKey, role: 'assistant', text: '', pending: true }]); + const viaHermes = hermesOn && !ACTION_WORDS.test(q); + setMessages((ms) => [...ms, { key: `u${aKey}`, role: 'user', text: q }, { key: aKey, role: 'assistant', text: '', pending: true, by: viaHermes ? 'hermes' : 'builtin' }]); try { - let id = convId; - if (!id) { id = (await createConversation(chip.runId)).id; setConvId(id); store.set(convKey, id); } - await sendMessage(id, q, chip.context, (ev, data) => { - const d = data as Record; - if (ev === 'intent') patch(aKey, (m) => ({ ...m, tool: String(d.tool) })); - else if (ev === 'delta') patch(aKey, (m) => ({ ...m, text: m.text + String(d.text ?? '') })); - else if (ev === 'result') patch(aKey, (m) => ({ ...m, result: data as ChatResult })); - else if (ev === 'action') patch(aKey, (m) => ({ ...m, action: data as ChatAction })); - else if (ev === 'error') patch(aKey, (m) => ({ ...m, error: String(d.detail ?? 'The answer could not be completed.') })); - }); + if (viaHermes) { + try { + const out = await askHermes.mutateAsync({ question: q, conversation_id: hermesConv ?? undefined }); + setHermesConv(out.conversation_id); + patch(aKey, (m) => ({ ...m, text: out.answer, model: out.model })); + } catch (e) { + const code = (e as { code?: string }).code; + if (code === 'NOT_FOUND') setHermesConv(null); + if (code === 'HERMES_OFF') { // switched off meanwhile: the built-in assistant answers this one + patch(aKey, (m) => ({ ...m, by: 'builtin' })); + await askBuiltIn(q, aKey); + } else patch(aKey, (m) => ({ ...m, error: askErrorWords(e) })); + } + } else await askBuiltIn(q, aKey); } catch (e) { const gone = (e as { status?: number }).status === 404; if (gone) { store.set(convKey, null); setConvId(null); } @@ -134,10 +167,12 @@ function ChatPanel({ dock, onClose }: { dock: ChatDockState; onClose: () => void setBusy(false); } }; + sendRef.current = send; const reset = async () => { if (convId) await deleteConversation(convId).catch(() => undefined); store.set(convKey, null); setConvId(null); + setHermesConv(null); setMessages([]); inputRef.current?.focus(); }; @@ -154,7 +189,7 @@ function ChatPanel({ dock, onClose }: { dock: ChatDockState; onClose: () => void Ask the co-worker
- +
Practice environment: answers describe the local mock app, not Oracle Fusion.
@@ -175,8 +210,9 @@ function ChatPanel({ dock, onClose }: { dock: ChatDockState; onClose: () => void {chip.label} {chip.removable && } + {hermesOn &&

{HERMES_NOTICE}

}
-