diff --git a/.dockerignore b/.dockerignore index 55a15c0aa..412c37bed 100644 --- a/.dockerignore +++ b/.dockerignore @@ -39,6 +39,8 @@ tmp/ # Local documentation-site outputs. site/dist/ site/.astro/ +site/src/assets/landing/*.webm +site/src/assets/landing/*.mp4 # Local browser-test outputs. ui/host/playwright-report/ diff --git a/.gitignore b/.gitignore index c4bf56ffc..8123a213e 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,8 @@ ui/host/test-results/ # Documentation site workspace outputs. site/dist/ site/.astro/ +site/src/assets/landing/*.webm +site/src/assets/landing/*.mp4 # Test/temp # Root-scoped: a bare `testdata/` would also ignore Go package fixtures, which diff --git a/docs/testing.md b/docs/testing.md index ae6d509c8..952424ca1 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -167,4 +167,4 @@ canonical guards included in that script. `just site-build` also installs site dependencies; use the installed build directly when dependency installation is outside the verification environment's scope. Neither command publishes the site. -Refresh the landing page’s light and dark product captures with `rtk just landing-captures` (real seeded server and local Chrome); to capture a real workload on an existing instance such as Fanout v2026.10.7-alpha through a local tunnel, set `FANOUT_LANDING_BASE_URL=http://127.0.0.1:17520` and `FANOUT_LANDING_SESSION_COOKIE` to the `name=value` session cookie from first-admin setup before running the same command (no server startup or seed, default live dashboard range, and a complete trace with at least 10 spans across 3 services, preferring success). +Refresh the README's light and dark System overview captures with `just landing-captures` (real seeded server and local Chrome). To capture an existing instance such as the live demo, set `FANOUT_LANDING_BASE_URL` to its URL and `FANOUT_LANDING_SESSION_COOKIE` to a `name=value` session cookie before running the same command; no server starts and no data is seeded. The landing page's chat and dashboard clips are recorded the same way with `FANOUT_LANDING_RECORDINGS=1`; see `site/scripts/landing-recordings.md`. diff --git a/justfile b/justfile index 3e1daf4d9..ca31253c0 100644 --- a/justfile +++ b/justfile @@ -70,7 +70,7 @@ e2e *ARGS: just build cd ui/host && bun run e2e {{ARGS}} -# Refresh the six real product captures used by the landing page. +# Refresh the README's light and dark System overview captures. landing-captures: FANOUT_LANDING_BASE_URL="${FANOUT_LANDING_BASE_URL:-}" FANOUT_LANDING_SESSION_COOKIE="${FANOUT_LANDING_SESSION_COOKIE:-}" FANOUT_LANDING_CAPTURES=1 just e2e e2e/landing-captures.spec.ts diff --git a/site/astro.config.mjs b/site/astro.config.mjs index 764814dce..fe5c3d55e 100644 --- a/site/astro.config.mjs +++ b/site/astro.config.mjs @@ -29,7 +29,7 @@ export default defineConfig({ // The separator between a page's title and the site's: "Install · Fanout". titleDelimiter: "·", description: - "One binary that ingests OpenTelemetry, stores it, and answers questions about it.", + "Send OpenTelemetry to one binary. Investigate with Fanout's built-in agent, or connect yours over MCP.", social: [ { icon: "github", @@ -49,6 +49,7 @@ export default defineConfig({ }, customCss: ["./src/styles/fanout.css"], components: { + SocialIcons: "./src/components/SocialIcons.astro", // Advertises the Markdown alternate for the current page, so an agent // that reads the HTML head never has to parse the HTML body. Head: "./src/components/Head.astro", diff --git a/site/scripts/check-benchmark-numbers.mjs b/site/scripts/check-benchmark-numbers.mjs index e0a4703bb..2fe4a1630 100644 --- a/site/scripts/check-benchmark-numbers.mjs +++ b/site/scripts/check-benchmark-numbers.mjs @@ -20,8 +20,9 @@ for (const relative of files) { equal(relative, "sustained/preview items/s", amount(match[1]), benchmark.sustained.accepted_per_second); rates++; } - // A throughput heading cannot silently disappear from the prose contract. - if (!rates) failures.push(`${relative}: missing authored headline items/s`); + // The landing replay renders its headline directly from the benchmark data. + const dataHeadline = relative === "../src/content/docs/index.mdx" && /^$/m.test(source); + if (!rates && !dataHeadline) failures.push(`${relative}: missing authored headline items/s`); const perSignal = [ ["spans", benchmark.sustained.spans_per_second], ["log records", benchmark.sustained.log_records_per_second], diff --git a/site/scripts/clip-timeline.mjs b/site/scripts/clip-timeline.mjs new file mode 100644 index 000000000..c56a717f9 --- /dev/null +++ b/site/scripts/clip-timeline.mjs @@ -0,0 +1,35 @@ +/** Merge concurrent tool/model waits so no source frame is compressed twice. Frames before from are cut. */ +export function clipSegments(waits, duration, from = 0) { + if (!Number.isFinite(duration) || duration <= 0) throw new Error("Video duration must be positive"); + if (!Number.isFinite(from) || from < 0 || from >= duration) throw new Error("Clip start must be within the raw video"); + if (!Array.isArray(waits)) throw new Error("Timeline waits must be an array"); + const intervals = waits.map(({ start, end }) => { + if (!Number.isFinite(start) || !Number.isFinite(end) || start < 0 || end <= start) { + throw new Error("Wait intervals must have finite seconds with 0 <= start < end"); + } + if (end > duration + 0.25) throw new Error("Wait interval extends past the raw video"); + return { start: Math.max(from, Math.min(start, duration)), end: Math.min(end, duration) }; + }).filter(({ start, end }) => end > start).sort((a, b) => a.start - b.start); + const merged = []; + for (const interval of intervals) { + const previous = merged.at(-1); + if (previous && interval.start <= previous.end) previous.end = Math.max(previous.end, interval.end); + else merged.push({ ...interval }); + } + const segments = []; + let cursor = from; + for (const { start, end } of merged) { + if (start > cursor) segments.push({ start: cursor, end: start, seconds: start - cursor }); + if (end > start) segments.push({ start, end, seconds: Math.min(0.6, end - start) }); + cursor = end; + } + if (cursor < duration) segments.push({ start: cursor, end: duration, seconds: duration - cursor }); + return segments; +} + +export function clipFilter(segments) { + const filters = segments.map(({ start, end, seconds }, index) => + `[0:v]trim=start=${start}:end=${end},setpts=(PTS-STARTPTS)*${seconds / (end - start)}[v${index}]`); + filters.push(`${segments.map((_, index) => `[v${index}]`).join("")}concat=n=${segments.length}:v=1:a=0,scale=1280:800,fps=30,format=yuv420p[out]`); + return filters.join(";\n"); +} diff --git a/site/scripts/encode-clips.mjs b/site/scripts/encode-clips.mjs new file mode 100644 index 000000000..d31d85aa9 --- /dev/null +++ b/site/scripts/encode-clips.mjs @@ -0,0 +1,55 @@ +import { spawnSync } from "node:child_process"; +import { existsSync, mkdtempSync, readFileSync, rmSync } from "node:fs"; +import { mkdir } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { basename, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import { clipFilter, clipSegments } from "./clip-timeline.mjs"; + +const input = resolve(process.argv[2] ?? fileURLToPath(new URL("../../ui/host/test-results/landing-recordings/", import.meta.url))); +const output = resolve(process.argv[3] ?? fileURLToPath(new URL("../src/assets/landing/", import.meta.url))); +const temporary = mkdtempSync(join(tmpdir(), "fanout-clips-")); +function run(command, args, capture = false) { + const result = spawnSync(command, args, { encoding: "utf8", stdio: capture ? ["ignore", "pipe", "inherit"] : "inherit" }); + if (result.error) throw result.error; + if (result.status !== 0) throw new Error(`${command} exited with status ${result.status}`); + return result.stdout; +} + +try { + await mkdir(output, { recursive: true }); + // Encode every recording present, so a single retake needs no other takes. + const names = ["chat", "dashboard"].flatMap(view => ["light", "dark"].map(theme => `${view}-${theme}`)) + .filter(name => existsSync(join(input, `${name}.json`))); + if (!names.length) throw new Error(`No recordings found in ${input}`); + for (const name of names) { + const timeline = JSON.parse(readFileSync(join(input, `${name}.json`), "utf8")); + if (timeline.version !== 1 || timeline.raw_file !== `${name}.webm` || basename(timeline.raw_file) !== timeline.raw_file) { + throw new Error(`Invalid recording timeline for ${name}`); + } + const raw = join(input, timeline.raw_file); + const probe = JSON.parse(run("ffprobe", ["-v", "error", "-show_entries", "format=duration:stream=width,height", "-of", "json", raw], true)); + if (!probe.streams.some(stream => stream.width === 1280 && stream.height === 800)) throw new Error(`${name} must be recorded at 1280 × 800`); + const segments = clipSegments(timeline.waits, Number(probe.format.duration), timeline.start); + const seconds = segments.reduce((sum, segment) => sum + segment.seconds, 0); + // Reserve 5% of a decimal 4 MB target for muxing; two passes share this budget. + const bitrate = String(Math.floor(4_000_000 * 8 * 0.95 / seconds)); + const filter = clipFilter(segments); + for (const format of ["webm", "mp4"]) { + const passlog = join(temporary, `${name}-${format}`); + const codec = format === "webm" + ? ["-c:v", "libvpx-vp9", "-deadline", "good", "-cpu-used", "2", "-row-mt", "1"] + : ["-c:v", "libx264", "-preset", "slow"]; + const args = ["-hide_banner", "-loglevel", "warning", "-y", "-i", raw, + "-filter_complex", filter, "-map", "[out]", "-an", ...codec, "-b:v", bitrate, "-passlogfile", passlog]; + run("ffmpeg", [...args, "-pass", "1", "-f", "null", "-"]); + run("ffmpeg", [...args, "-pass", "2", ...(format === "mp4" ? ["-movflags", "+faststart"] : []), join(output, `${name}.${format}`)]); + } + // Reverse only the final second so the PNG is the last encoded frame. + run("ffmpeg", ["-hide_banner", "-loglevel", "warning", "-y", "-sseof", "-1", "-i", join(output, `${name}.mp4`), + "-vf", "reverse", "-frames:v", "1", "-update", "1", join(output, `${name}.png`)]); + console.log(`${name}: ${seconds.toFixed(1)} s, 1280 × 800, 30 fps, approximately 4 MB per format`); + } +} finally { + rmSync(temporary, { recursive: true, force: true }); +} diff --git a/site/scripts/encode-clips.sh b/site/scripts/encode-clips.sh new file mode 100644 index 000000000..a948f0f6d --- /dev/null +++ b/site/scripts/encode-clips.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -euo pipefail + +node "$(dirname "$0")/encode-clips.mjs" "$@" diff --git a/site/scripts/fixtures/landing-media.json b/site/scripts/fixtures/landing-media.json new file mode 100644 index 000000000..a6bef0b6e --- /dev/null +++ b/site/scripts/fixtures/landing-media.json @@ -0,0 +1,18 @@ +{ + "chat-dark": { + "mp4": "https://assets.fanout.run/landing/chat-dark-0123456789ab.mp4", + "webm": "https://assets.fanout.run/landing/chat-dark-0123456789ab.webm" + }, + "chat-light": { + "mp4": "https://assets.fanout.run/landing/chat-light-0123456789ab.mp4", + "webm": "https://assets.fanout.run/landing/chat-light-0123456789ab.webm" + }, + "dashboard-dark": { + "mp4": "https://assets.fanout.run/landing/dashboard-dark-0123456789ab.mp4", + "webm": "https://assets.fanout.run/landing/dashboard-dark-0123456789ab.webm" + }, + "dashboard-light": { + "mp4": "https://assets.fanout.run/landing/dashboard-light-0123456789ab.mp4", + "webm": "https://assets.fanout.run/landing/dashboard-light-0123456789ab.webm" + } +} diff --git a/site/scripts/landing-media.test.mjs b/site/scripts/landing-media.test.mjs new file mode 100644 index 000000000..92bb78c29 --- /dev/null +++ b/site/scripts/landing-media.test.mjs @@ -0,0 +1,32 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { hasProductVideo } from "../src/components/landing/landing-media.ts"; + +const fixture = JSON.parse(readFileSync(new URL("./fixtures/landing-media.json", import.meta.url), "utf8")); + +test("playback requires both formats in both themes, independently for each view", () => { + for (const view of ["chat", "dashboard"]) { + const sources = ["light", "dark"].flatMap(theme => ["webm", "mp4"].map(format => [`${view}-${theme}`, format])); + for (let mask = 0; mask < 16; mask++) { + const manifest = structuredClone(fixture); + sources.forEach(([name, format], index) => { if (!(mask & (1 << index))) delete manifest[name][format]; }); + assert.equal(hasProductVideo(manifest, view), mask === 15, `${view}: ${mask}`); + assert.equal(hasProductVideo(manifest, view === "chat" ? "dashboard" : "chat"), true); + } + } +}); + +test("missing entries or empty URLs keep the poster fallback", () => { + assert.equal(hasProductVideo({}, "chat"), false); + for (const theme of ["light", "dark"]) { + const manifest = structuredClone(fixture); + delete manifest[`chat-${theme}`]; + assert.equal(hasProductVideo(manifest, "chat"), false); + for (const invalid of ["", null, 42]) { + const manifest = structuredClone(fixture); + manifest[`chat-${theme}`].mp4 = invalid; + assert.equal(hasProductVideo(manifest, "chat"), false); + } + } +}); diff --git a/site/scripts/landing-recordings.md b/site/scripts/landing-recordings.md new file mode 100644 index 000000000..fac181104 --- /dev/null +++ b/site/scripts/landing-recordings.md @@ -0,0 +1,73 @@ +# Landing recordings + +Record the chat and dashboard slots from an OpenTelemetry Demo instance with +chat enabled. + +Expected assets (all at 1280 × 800): + +- `site/src/assets/landing/chat-{light,dark}.{webm,mp4,png}` +- `site/src/assets/landing/dashboard-{light,dark}.{webm,mp4,png}` + +Encoded videos stay local and are ignored by Git and Docker; PNG posters stay +in the repository so Astro can optimize them. Published videos live in the +Cloudflare R2 bucket `fanout-assets`, served at `https://assets.fanout.run/`. + +Each slot stays poster-only until both themes have both video formats in +`site/src/data/landing-media.json`. An absent manifest also shows posters. The +component follows the site theme, pauses off screen and in hidden tabs, and +shows only the poster when reduced motion is enabled. Its `spedUp` prop marks +recordings with shortened waits in the caption. + +Set `FANOUT_LANDING_RECORDINGS=1`, `FANOUT_LANDING_BASE_URL` to the existing +instance URL, and `FANOUT_LANDING_SESSION_COOKIE` to a `name=value` session cookie +in the process environment. Run from `ui/host`: + +```sh +bun run e2e landing-recordings.spec.ts --project=1440-light --project=1440-dark +``` + +Recordings use a 1280 × 800 viewport and raw video at the same size; Playwright +video captures CSS pixels, so a higher device scale only pads the frame. This only uses the external instance. It types the brief's prompts, waits for +the real run to finish, and dwells for three seconds. The dashboard clip also +opens the dashboard from its successful `create_dashboard` result and waits +for the saved panels to render. It creates real chats and dashboards; no data +is mocked or intercepted. + +Raw WebM files and matching JSON timelines go to +`ui/host/test-results/landing-recordings/`, excluded from Git and Docker inputs. +Keep a copy before another Playwright run clears `test-results`. Timelines use +seconds from page creation, with server event timestamps anchored to receipt of +the run's response headers to avoid server clock skew. They list model-thinking +and tool-call intervals from the unmodified AG-UI stream and contain no session +credentials or tool result payloads. Raw recordings can contain instance data. + +From the repository root, with ffmpeg and ffprobe installed: + +```sh +bash site/scripts/encode-clips.sh +# Or use a saved raw output directory: +bash site/scripts/encode-clips.sh /path/to/landing-recordings +``` + +It encodes every recording present in the input directory. An optional second +directory argument writes encoded assets elsewhere for review. + +The encoder merges overlapping waits, compresses each wait longer than 0.6 s +to 0.6 s, preserves typing and the final dwell, and writes VP9 WebM and H.264 +MP4 at 1280 × 800 and 30 fps with a two-pass target of about 4 MB per file. +It extracts each PNG poster from the final encoded frame. Review the clips and +posters, then upload from the repository root with Wrangler logged in to the +account that owns `fanout-assets`: + +```sh +bash site/scripts/upload-clips.sh +# Or upload an encoded directory used for review: +bash site/scripts/upload-clips.sh /path/to/encoded-clips +``` + +The uploader writes content-addressed immutable keys, skips unchanged clips +already listed in the manifest, and preserves URLs for clips absent from the +input directory. It never deletes old objects because published pages may still +reference them. After uploading, commit `site/src/data/landing-media.json` and +the PNG posters. If encoding elsewhere, copy the reviewed PNGs into +`site/src/assets/landing/` first. Never commit WebM or MP4 files. diff --git a/site/scripts/landing-recordings.test.mjs b/site/scripts/landing-recordings.test.mjs new file mode 100644 index 000000000..0c75de8e8 --- /dev/null +++ b/site/scripts/landing-recordings.test.mjs @@ -0,0 +1,82 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { recordingTimeline } from "../../ui/host/e2e/landing-recording-support.ts"; +import { clipSegments, clipFilter } from "./clip-timeline.mjs"; + +const stream = events => events.map(event => `data: ${JSON.stringify(event)}\n\n`).join(""); +const event = (type, at, data = {}) => ({ type, timestamp: 1_000_000 + at * 1000, ...data }); + +test("recording times survive server clock skew and preserve visible reasoning and answer text", () => { + const recorded = recordingTimeline(stream([ + event("RUN_STARTED", 0), event("REASONING_MESSAGE_START", 2), event("REASONING_MESSAGE_CONTENT", 3), + event("REASONING_MESSAGE_END", 4), event("TOOL_CALL_START", 6, { toolCallId: "q", toolCallName: "query_telemetry" }), + event("TOOL_CALL_END", 6.1, { toolCallId: "q" }), // Arguments ended; the tool is still running. + event("TOOL_CALL_RESULT", 9, { toolCallId: "q", content: "{}" }), + event("TEXT_MESSAGE_START", 12), event("TEXT_MESSAGE_CONTENT", 13), event("RUN_FINISHED", 14), + ]), 10); + assert.deepEqual(recorded.waits, [ + { kind: "model_thinking", start: 10, end: 12 }, + { kind: "model_thinking", start: 14, end: 16 }, + { kind: "tool_call", start: 16, end: 19, tool: "query_telemetry" }, + { kind: "model_thinking", start: 19, end: 22 }, + ]); +}); + +test("concurrent tools remain distinct and only a successful create receipt identifies the new dashboard", () => { + const created = { dashboard: { id: "new-dashboard" }, receipt: { version: 1 } }; + for (const result of [created, { ...created, error: "failed" }, { ...created, isError: true }, { dashboard: created.dashboard }]) { + const timeline = recordingTimeline(stream([ + event("RUN_STARTED", 0), + event("TOOL_CALL_START", 1, { toolCallId: "a", toolCallName: "create_dashboard" }), + event("TOOL_CALL_START", 2, { toolCallId: "b", toolCallName: "search_logs" }), + event("TOOL_CALL_RESULT", 3, { toolCallId: "a", content: JSON.stringify(result) }), + event("TOOL_CALL_RESULT", 4, { toolCallId: "b", content: "{}" }), + event("TEXT_MESSAGE_START", 5), event("RUN_FINISHED", 6), + ]).replaceAll("\n", "\r\n"), 0); + assert.equal(timeline.dashboardId, result === created ? "new-dashboard" : undefined); + assert.deepEqual(timeline.waits.filter(wait => wait.kind === "model_thinking"), [ + { kind: "model_thinking", start: 0, end: 1 }, { kind: "model_thinking", start: 4, end: 5 }, + ]); + assert.equal(timeline.waits.filter(wait => wait.kind === "tool_call").length, 2); + } +}); + +test("failed, truncated, untimed or unresolved runs cannot become successful recordings", () => { + const start = event("RUN_STARTED", 0), end = event("RUN_FINISHED", 10); + for (const events of [[], [start], [start, event("RUN_ERROR", 1), end], + [start, { type: "TEXT_MESSAGE_START" }, end], + [start, event("TOOL_CALL_START", 1, { toolCallId: "a", toolCallName: "query_telemetry" }), end], + [start, event("TOOL_CALL_RESULT", 1, { toolCallId: "a" }), end]]) { + assert.throws(() => recordingTimeline(stream(events), 0)); + } +}); + +test("encoding merges overlapping waits, keeps short waits and preserves typing and dwell", () => { + const segments = clipSegments([{ start: 5, end: 12 }, { start: 4, end: 8 }, { start: 15, end: 15.2 }], 20); + assert.deepEqual(segments, [ + { start: 0, end: 4, seconds: 4 }, { start: 4, end: 12, seconds: 0.6 }, + { start: 12, end: 15, seconds: 3 }, { start: 15, end: 15.2, seconds: 15.2 - 15 }, + { start: 15.2, end: 20, seconds: 20 - 15.2 }, + ]); + const filter = clipFilter(segments); + assert.match(filter, /trim=start=4:end=12,setpts=\(PTS-STARTPTS\)\*0.075\[v1\]/); + assert.match(filter, /concat=n=5:v=1:a=0,scale=1280:800,fps=30,format=yuv420p\[out\]/); + assert.deepEqual(clipSegments([], 3), [{ start: 0, end: 3, seconds: 3 }]); +}); + +test("invalid trim times fail before invoking ffmpeg", () => { + for (const waits of [[{ start: -1, end: 2 }], [{ start: 3, end: 2 }], [{ start: 0, end: Infinity }], [{ start: 1, end: 11 }], null]) { + assert.throws(() => clipSegments(waits, 10)); + } + assert.throws(() => clipSegments([], 0)); +}); + +test("encoding cuts frames before the clip start", () => { + const segments = clipSegments([{ start: 1, end: 3 }, { start: 5, end: 8 }], 12, 4); + assert.deepEqual(segments, [ + { start: 4, end: 5, seconds: 1 }, + { start: 5, end: 8, seconds: 0.6 }, + { start: 8, end: 12, seconds: 4 }, + ]); + assert.throws(() => clipSegments([], 12, 12), /Clip start must be within the raw video/); +}); diff --git a/site/scripts/product-video.test.mjs b/site/scripts/product-video.test.mjs new file mode 100644 index 000000000..7f886f8ed --- /dev/null +++ b/site/scripts/product-video.test.mjs @@ -0,0 +1,120 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { hasProductVideo } from "../src/components/landing/landing-media.ts"; +import { mountProductVideo } from "../src/components/landing/product-video.ts"; + +const fixture = JSON.parse(readFileSync(new URL("./fixtures/landing-media.json", import.meta.url), "utf8")); + +function events(value = {}) { + const listeners = new Map(); + return { ...value, listeners, + addEventListener(type, callback) { if (!listeners.has(type)) listeners.set(type, new Set()); listeners.get(type).add(callback); }, + removeEventListener(type, callback) { listeners.get(type)?.delete(callback); }, + dispatch(type) { for (const callback of listeners.get(type) ?? []) callback(); }, + }; +} + +function setup(t, reduced = false, manifest = fixture) { + const players = {}, observers = {}; + const slots = ["light", "dark"].map(theme => ({ dataset: { videoTheme: theme }, + querySelector: () => ({ content: { firstElementChild: { cloneNode: () => { + const player = events({ paused: true, plays: 0, pauses: 0, sources: manifest[`chat-${theme}`], + play() { this.paused = false; this.plays++; return Promise.resolve(); }, + pause() { this.paused = true; this.pauses++; }, + }); + players[theme] = player; + return player; + } } } }), append() {}, + })); + const control = events({ hidden: true, attributes: {}, setAttribute(key, value) { this.attributes[key] = value; } }); + const root = { querySelectorAll: () => slots, querySelector: selector => selector === "template" ? (hasProductVideo(manifest, "chat") ? {} : null) : control }; + const doc = events({ hidden: false, documentElement: { dataset: { theme: "dark" } } }); + const motion = events({ matches: reduced }); + const globals = { document: doc, matchMedia: () => motion, + IntersectionObserver: class { constructor(callback) { this.callback = callback; observers.intersection = this; } observe() {} disconnect() { this.disconnected = true; } }, + MutationObserver: class { constructor(callback) { this.callback = callback; observers.theme = this; } observe() {} disconnect() { this.disconnected = true; } }, + }; + const restore = []; + for (const [key, value] of Object.entries(globals)) { + const original = Object.getOwnPropertyDescriptor(globalThis, key); + Object.defineProperty(globalThis, key, { configurable: true, value }); + restore.push(() => original ? Object.defineProperty(globalThis, key, original) : delete globalThis[key]); + } + const cleanup = mountProductVideo(root); + t.after(() => { cleanup(); restore.reverse().forEach(fn => fn()); }); + return { players, slots, control, motion, doc, observers, cleanup, + visible(value) { observers.intersection.callback([{ isIntersecting: value }]); }, + theme(value) { doc.documentElement.dataset.theme = value; observers.theme.callback(); }, + }; +} + +test("poster-only slots need no playback observers", () => { + assert.doesNotThrow(() => mountProductVideo({ querySelectorAll: () => [], querySelector: () => null })()); +}); + +test("an incomplete manifest leaves posters without observers or players", t => { + const manifest = structuredClone(fixture); + delete manifest["chat-dark"].webm; + const s = setup(t, false, manifest); + assert.deepEqual(s.observers, {}); + assert.deepEqual(s.players, {}); + assert.equal(s.control.hidden, true); +}); + +test("only the visible theme starts, and hidden tabs and offscreen clips pause", t => { + const s = setup(t); + assert.deepEqual(s.players, {}); + s.visible(true); + assert.equal(s.players.dark.muted, true); + assert.equal(s.players.dark.paused, false); + assert.deepEqual(s.players.dark.sources, fixture["chat-dark"]); + assert.equal(s.players.light, undefined); + s.players.dark.dispatch("playing"); + assert.equal(s.slots[1].dataset.playing, ""); + s.theme("light"); + assert.equal(s.players.dark.paused, true); + assert.equal(s.slots[1].dataset.playing, undefined); + assert.equal(s.players.light.paused, false); + assert.deepEqual(s.players.light.sources, fixture["chat-light"]); + s.doc.hidden = true; s.doc.dispatch("visibilitychange"); + assert.equal(s.players.light.paused, true); + s.doc.hidden = false; s.doc.dispatch("visibilitychange"); + assert.equal(s.players.light.paused, false); + s.visible(false); + assert.equal(s.players.light.paused, true); +}); + +test("reduced motion never instantiates autoplay media and switches back to posters", t => { + const s = setup(t, true); + s.visible(true); + assert.deepEqual(s.players, {}); + assert.equal(s.control.hidden, true); + s.motion.matches = false; s.motion.dispatch("change"); + s.players.dark.dispatch("playing"); + assert.equal(s.slots[1].dataset.playing, ""); + s.motion.matches = true; s.motion.dispatch("change"); + assert.equal(s.players.dark.paused, true); + assert.equal(s.slots[1].dataset.playing, undefined); + s.players.dark.dispatch("playing"); + assert.equal(s.slots[1].dataset.playing, undefined); +}); + +test("manual pause survives visibility, theme and motion changes; teardown stops every player", t => { + const s = setup(t); + s.visible(true); s.control.dispatch("click"); + assert.equal(s.players.dark.paused, true); + assert.equal(s.control.attributes["aria-label"], "Play clip"); + s.visible(false); s.visible(true); s.theme("light"); + s.motion.matches = true; s.motion.dispatch("change"); + s.motion.matches = false; s.motion.dispatch("change"); + assert.equal(s.players.light, undefined); + s.control.dispatch("click"); + assert.equal(s.players.light.paused, false); + s.cleanup(); + assert.equal(s.players.light.paused, true); + assert.equal(s.players.dark.paused, true); + for (const observer of Object.values(s.observers)) assert.equal(observer.disconnected, true); + assert.equal(s.doc.listeners.get("visibilitychange").size, 0); + assert.equal(s.motion.listeners.get("change").size, 0); +}); diff --git a/site/scripts/upload-clips.mjs b/site/scripts/upload-clips.mjs new file mode 100644 index 000000000..75beac087 --- /dev/null +++ b/site/scripts/upload-clips.mjs @@ -0,0 +1,55 @@ +import { spawnSync } from "node:child_process"; +import { createHash } from "node:crypto"; +import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, writeFileSync } from "node:fs"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +const defaultInput = fileURLToPath(new URL("../src/assets/landing/", import.meta.url)); +const defaultManifest = fileURLToPath(new URL("../src/data/landing-media.json", import.meta.url)); +const names = ["chat-dark", "chat-light", "dashboard-dark", "dashboard-light"]; +const formats = ["mp4", "webm"]; + +export function clipObject(name, format, contents) { + const hash = createHash("sha256").update(contents).digest("hex").slice(0, 12); + const key = `landing/${name}-${hash}.${format}`; + return { key, url: `https://assets.fanout.run/${key}` }; +} + +function put(args) { + const result = spawnSync("wrangler", args, { stdio: "inherit" }); + if (result.error) throw result.error; + if (result.status !== 0) throw new Error(`wrangler exited with status ${result.status}`); +} + +export function uploadClips({ input = defaultInput, manifestPath = defaultManifest, upload = put } = {}) { + input = resolve(input); + const files = new Set(readdirSync(input)); + const manifest = existsSync(manifestPath) ? JSON.parse(readFileSync(manifestPath, "utf8")) : {}; + for (const name of names) { + for (const format of formats) { + const filename = `${name}.${format}`; + if (!files.has(filename)) continue; + const file = join(input, filename); + const { key, url } = clipObject(name, format, readFileSync(file)); + if (manifest[name]?.[format] === url) continue; + upload(["r2", "object", "put", `fanout-assets/${key}`, "--file", file, + "--content-type", `video/${format}`, "--cache-control", "public, max-age=31536000, immutable", "--remote"]); + manifest[name] = { ...manifest[name], [format]: url }; + } + } + // Retakes may contain only one clip; preserve all other published URLs. + const sorted = Object.fromEntries(Object.keys(manifest).sort().map(name => [name, + Object.fromEntries(Object.entries(manifest[name]).sort(([a], [b]) => a.localeCompare(b))), + ])); + mkdirSync(dirname(manifestPath), { recursive: true }); + // Publish only after every upload succeeds, and never expose a partial JSON file. + const temporary = `${manifestPath}.tmp`; + writeFileSync(temporary, `${JSON.stringify(sorted, null, 2)}\n`); + renameSync(temporary, manifestPath); + return sorted; +} + +if (process.argv[1] && fileURLToPath(import.meta.url) === realpathSync(process.argv[1])) { + if (process.argv.length > 3) throw new Error("Usage: bash site/scripts/upload-clips.sh [encoded-directory]"); + uploadClips({ input: process.argv[2] }); +} diff --git a/site/scripts/upload-clips.sh b/site/scripts/upload-clips.sh new file mode 100755 index 000000000..e9a419a8f --- /dev/null +++ b/site/scripts/upload-clips.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -euo pipefail + +node "$(dirname "$0")/upload-clips.mjs" "$@" diff --git a/site/scripts/upload-clips.test.mjs b/site/scripts/upload-clips.test.mjs new file mode 100644 index 000000000..19d2699cf --- /dev/null +++ b/site/scripts/upload-clips.test.mjs @@ -0,0 +1,103 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { spawnSync } from "node:child_process"; +import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join } from "node:path"; +import { clipObject, uploadClips } from "./upload-clips.mjs"; + +function setup(t) { + const directory = mkdtempSync(join(tmpdir(), "fanout-upload-test-")); + t.after(() => rmSync(directory, { recursive: true, force: true })); + const input = join(directory, "encoded clips"); + const manifestPath = join(directory, "site/src/data/landing-media.json"); + mkdirSync(input); + mkdirSync(dirname(manifestPath), { recursive: true }); + return { directory, input, manifestPath }; +} + +test("object keys and public URLs use the first 12 hex digits of SHA-256", () => { + for (const format of ["webm", "mp4"]) { + assert.deepEqual(clipObject("chat-light", format, Buffer.from("abc")), { + key: `landing/chat-light-ba7816bf8f01.${format}`, + url: `https://assets.fanout.run/landing/chat-light-ba7816bf8f01.${format}`, + }); + assert.notEqual(clipObject("chat-light", format, Buffer.from("abcd")).key, + clipObject("chat-light", format, Buffer.from("abc")).key); + } +}); + +test("shell wrapper uploads all eight formats with exact Wrangler flags and skips unchanged keys", t => { + const { directory, input, manifestPath } = setup(t); + const scripts = join(directory, "site/scripts"); + const bin = join(directory, "bin"); + const log = join(directory, "uploads.jsonl"); + mkdirSync(scripts); + mkdirSync(bin); + for (const script of ["upload-clips.sh", "upload-clips.mjs"]) { + copyFileSync(new URL(`./${script}`, import.meta.url), join(scripts, script)); + } + writeFileSync(join(bin, "wrangler"), `#!/usr/bin/env node +require("node:fs").appendFileSync(process.env.CLIP_UPLOAD_LOG, JSON.stringify(process.argv.slice(2)) + "\\n"); +`, { mode: 0o755 }); + const names = ["chat-dark", "chat-light", "dashboard-dark", "dashboard-light"]; + for (const name of names) { + for (const format of ["mp4", "webm"]) writeFileSync(join(input, `${name}.${format}`), "abc"); + } + writeFileSync(join(input, "chat-light.png"), "poster"); + writeFileSync(join(input, "unrelated.mp4"), "unrelated"); + const run = args => { + const result = spawnSync("bash", [join(scripts, "upload-clips.sh"), ...args], { + cwd: tmpdir(), encoding: "utf8", + env: { ...process.env, PATH: `${bin}:${process.env.PATH}`, CLIP_UPLOAD_LOG: log }, + }); + assert.equal(result.status, 0, result.stderr); + }; + run([input]); + const uploads = readFileSync(log, "utf8").trim().split("\n").map(line => JSON.parse(line)); + assert.equal(uploads.length, 8); + const manifest = JSON.parse(readFileSync(manifestPath, "utf8")); + for (const [index, [name, format]] of names.flatMap(name => ["mp4", "webm"].map(format => [name, format])).entries()) { + const { key, url } = clipObject(name, format, Buffer.from("abc")); + assert.deepEqual(uploads[index], ["r2", "object", "put", `fanout-assets/${key}`, "--file", join(input, `${name}.${format}`), + "--content-type", `video/${format}`, "--cache-control", "public, max-age=31536000, immutable", "--remote"]); + assert.equal(manifest[name][format], url); + } + assert.deepEqual(Object.keys(manifest), names); + for (const clip of Object.values(manifest)) assert.deepEqual(Object.keys(clip), ["mp4", "webm"]); + assert.ok(readFileSync(manifestPath, "utf8").endsWith("\n")); + run([input]); + assert.equal(readFileSync(log, "utf8").trim().split("\n").length, 8); + // The default input is relative to the script, regardless of the caller's cwd. + mkdirSync(join(directory, "site/src/assets/landing"), { recursive: true }); + writeFileSync(join(directory, "site/src/assets/landing/chat-dark.mp4"), "abc"); + run([]); + assert.equal(readFileSync(log, "utf8").trim().split("\n").length, 8); +}); + +test("partial retakes upload changed content and preserve missing clips", t => { + const { input, manifestPath } = setup(t); + const original = JSON.parse(readFileSync(new URL("./fixtures/landing-media.json", import.meta.url), "utf8")); + writeFileSync(manifestPath, JSON.stringify(original)); + writeFileSync(join(input, "chat-light.mp4"), "retake"); + const uploads = []; + const actual = uploadClips({ input, manifestPath, upload: args => uploads.push(args) }); + assert.equal(uploads.length, 1); + const expected = structuredClone(original); + expected["chat-light"].mp4 = clipObject("chat-light", "mp4", Buffer.from("retake")).url; + assert.deepEqual(actual, expected); + assert.deepEqual(JSON.parse(readFileSync(manifestPath, "utf8")), expected); +}); + +test("upload failures leave the published manifest untouched", t => { + const { input, manifestPath } = setup(t); + writeFileSync(manifestPath, "{}\n"); + writeFileSync(join(input, "chat-dark.mp4"), "abc"); + writeFileSync(join(input, "chat-light.webm"), "retake"); + let calls = 0; + assert.throws(() => uploadClips({ input, manifestPath, upload: () => { + if (++calls === 2) throw new Error("upload failed"); + } }), /upload failed/); + assert.equal(calls, 2); + assert.equal(readFileSync(manifestPath, "utf8"), "{}\n"); +}); diff --git a/site/src/assets/landing/chat-dark.png b/site/src/assets/landing/chat-dark.png new file mode 100644 index 000000000..e7c46bc60 Binary files /dev/null and b/site/src/assets/landing/chat-dark.png differ diff --git a/site/src/assets/landing/chat-light.png b/site/src/assets/landing/chat-light.png new file mode 100644 index 000000000..7cb8ae8a1 Binary files /dev/null and b/site/src/assets/landing/chat-light.png differ diff --git a/site/src/assets/landing/dashboard-dark.png b/site/src/assets/landing/dashboard-dark.png new file mode 100644 index 000000000..3af26fcaf Binary files /dev/null and b/site/src/assets/landing/dashboard-dark.png differ diff --git a/site/src/assets/landing/dashboard-light.png b/site/src/assets/landing/dashboard-light.png new file mode 100644 index 000000000..ef2cf7016 Binary files /dev/null and b/site/src/assets/landing/dashboard-light.png differ diff --git a/site/src/assets/landing/overview-dark.png b/site/src/assets/landing/overview-dark.png index 8a57d6ef1..13c7decbe 100644 Binary files a/site/src/assets/landing/overview-dark.png and b/site/src/assets/landing/overview-dark.png differ diff --git a/site/src/assets/landing/overview-light.png b/site/src/assets/landing/overview-light.png index 5b03ff804..c3f5c1215 100644 Binary files a/site/src/assets/landing/overview-light.png and b/site/src/assets/landing/overview-light.png differ diff --git a/site/src/assets/landing/service-map-dark.png b/site/src/assets/landing/service-map-dark.png deleted file mode 100644 index 7d2f2def1..000000000 Binary files a/site/src/assets/landing/service-map-dark.png and /dev/null differ diff --git a/site/src/assets/landing/service-map-light.png b/site/src/assets/landing/service-map-light.png deleted file mode 100644 index 8135a936f..000000000 Binary files a/site/src/assets/landing/service-map-light.png and /dev/null differ diff --git a/site/src/assets/landing/trace-dark.png b/site/src/assets/landing/trace-dark.png deleted file mode 100644 index 3ca31c393..000000000 Binary files a/site/src/assets/landing/trace-dark.png and /dev/null differ diff --git a/site/src/assets/landing/trace-light.png b/site/src/assets/landing/trace-light.png deleted file mode 100644 index 79d73a280..000000000 Binary files a/site/src/assets/landing/trace-light.png and /dev/null differ diff --git a/site/src/components/SocialIcons.astro b/site/src/components/SocialIcons.astro new file mode 100644 index 000000000..4bded6fe3 --- /dev/null +++ b/site/src/components/SocialIcons.astro @@ -0,0 +1,14 @@ +--- +import SocialIcons from "@astrojs/starlight/components/SocialIcons.astro"; +--- + +Docs +Live demo + + + diff --git a/site/src/components/landing/CaptureRow.astro b/site/src/components/landing/CaptureRow.astro index 363d84fce..7f447cb45 100644 --- a/site/src/components/landing/CaptureRow.astro +++ b/site/src/components/landing/CaptureRow.astro @@ -1,6 +1,15 @@ -
-
-
+--- +interface Props { + eyebrow: string; + columns?: boolean; +} + +const { eyebrow, columns = false } = Astro.props; +--- + +
+
{eyebrow}
+ {Astro.slots.has("capture") &&
}
diff --git a/site/src/components/landing/CopyButton.astro b/site/src/components/landing/CopyButton.astro new file mode 100644 index 000000000..a85573b83 --- /dev/null +++ b/site/src/components/landing/CopyButton.astro @@ -0,0 +1,104 @@ +--- +import Icon from "../Icon.astro"; + +interface Props { + target: string; + event?: string; +} + +const { target, event } = Astro.props; +--- + + + + + + diff --git a/site/src/components/landing/CtaBar.astro b/site/src/components/landing/CtaBar.astro index 4f4d3af11..97bf82fbc 100644 --- a/site/src/components/landing/CtaBar.astro +++ b/site/src/components/landing/CtaBar.astro @@ -15,14 +15,14 @@ * the Clipboard API — so a button that only wrote to the clipboard would take * over the common path and stop the metric without anything looking broken. */ -import Icon from "../Icon.astro"; +import CopyButton from "./CopyButton.astro"; ---
-

Install it and point something at it.

+

Install Fanout. Send OpenTelemetry.

- One binary, one data directory. The installer checks the archive against the - release checksums before it extracts anything. + One binary and one data directory. Add an AI provider key to enable the + built-in agent.

curl -fsSL https://raw.githubusercontent.com/labstack/fanout/main/scripts/install.sh | sh
- +
+
- - diff --git a/site/src/components/landing/Hero.astro b/site/src/components/landing/Hero.astro index e634515f8..9b74fa9a9 100644 --- a/site/src/components/landing/Hero.astro +++ b/site/src/components/landing/Hero.astro @@ -1,6 +1,4 @@ --- -import ThroughputReplay from "./ThroughputReplay.astro"; - const { data } = Astro.locals.starlightRoute.entry; const { title = data.title, tagline, actions = [] } = data.hero ?? {}; --- @@ -28,7 +26,6 @@ const { title = data.title, tagline, actions = [] } = data.hero ?? {}; ) } - diff --git a/site/src/components/landing/MediaCaption.astro b/site/src/components/landing/MediaCaption.astro new file mode 100644 index 000000000..7121bfd3f --- /dev/null +++ b/site/src/components/landing/MediaCaption.astro @@ -0,0 +1,34 @@ +--- +interface Props { + id?: string; + caption: string; + light: string; + dark: string; +} + +const { id, caption, light, dark } = Astro.props; +--- + +
+ {caption} + + View full size + View full size + + +
+ + diff --git a/site/src/components/landing/ProductCapture.astro b/site/src/components/landing/ProductCapture.astro deleted file mode 100644 index e6f150052..000000000 --- a/site/src/components/landing/ProductCapture.astro +++ /dev/null @@ -1,53 +0,0 @@ ---- -import { Picture } from "astro:assets"; -import overviewLight from "../../assets/landing/overview-light.png"; -import overviewDark from "../../assets/landing/overview-dark.png"; -import mapLight from "../../assets/landing/service-map-light.png"; -import mapDark from "../../assets/landing/service-map-dark.png"; -import traceLight from "../../assets/landing/trace-light.png"; -import traceDark from "../../assets/landing/trace-dark.png"; - -interface Props { - view: "overview" | "service-map" | "trace"; - alt: string; - eager?: boolean; -} - -const { view, alt, eager = false } = Astro.props; -const captures = { - overview: { light: overviewLight, dark: overviewDark }, - "service-map": { light: mapLight, dark: mapDark }, - trace: { light: traceLight, dark: traceDark }, -}; -const capture = captures[view]; -const sizes = "(min-width: 71.5rem) 67.5rem, (min-width: 40rem) calc(100vw - 4rem), calc(100vw - 2rem)"; ---- - -
- {(["light", "dark"] as const).map(theme => ( - width <= capture[theme].width && widths.indexOf(width) === index)} sizes={sizes} - loading={eager ? "eager" : "lazy"} fetchpriority={eager ? "high" : "auto"} /> - ))} -
- - diff --git a/site/src/components/landing/ProductVideo.astro b/site/src/components/landing/ProductVideo.astro new file mode 100644 index 000000000..98722eb31 --- /dev/null +++ b/site/src/components/landing/ProductVideo.astro @@ -0,0 +1,84 @@ +--- +import MediaCaption from "./MediaCaption.astro"; +import { hasProductVideo, type LandingMedia } from "./landing-media"; +import chatLight from "../../assets/landing/chat-light.png"; +import chatDark from "../../assets/landing/chat-dark.png"; +import dashboardLight from "../../assets/landing/dashboard-light.png"; +import dashboardDark from "../../assets/landing/dashboard-dark.png"; + +interface Props { + view: "chat" | "dashboard"; + alt: string; + description: string; + eager?: boolean; + spedUp?: boolean; +} + +const { view, alt, description, eager = false, spedUp = false } = Astro.props; +const posters = { chat: { light: chatLight, dark: chatDark }, dashboard: { light: dashboardLight, dark: dashboardDark } }; +// Optional manifest: a checkout without published clips still builds with posters. +const manifests = import.meta.glob("../../data/landing-media.json", { eager: true, import: "default" }); +const clips = manifests["../../data/landing-media.json"] ?? {}; +const themes = (["light", "dark"] as const).map(theme => ({ + theme, poster: posters[view][theme], + webm: clips[`${view}-${theme}`]?.webm, + mp4: clips[`${view}-${theme}`]?.mp4, +})); +const id = `product-video-${view}`; +const available = hasProductVideo(clips, view); +--- + +
+
+ {themes.map(({ theme, poster, webm, mp4 }) => ( +
+ {available + {available && } +
+ ))} +
+

{description}

+ + + +
+ + + + diff --git a/site/src/components/landing/ProofStrip.astro b/site/src/components/landing/ProofStrip.astro index 19908a64d..a301f90ae 100644 --- a/site/src/components/landing/ProofStrip.astro +++ b/site/src/components/landing/ProofStrip.astro @@ -1,16 +1,4 @@ ---- -import { benchmark, formatRate } from "../../data/benchmark"; - -// Keep the Markdown statistic readable in llms.txt and enforce the shared report -// as its authority: a changed result requires updating the authored text too. -const content = await Astro.slots.render("default"); -const sustained = `${formatRate(benchmark.sustained.accepted_per_second)} items/s`; -if (!content.includes(`${sustained}`)) { - throw new Error(`Landing stat band must use the published sustained rate: ${sustained}`); -} ---- - -
+
diff --git a/site/src/components/landing/ThroughputReplay.astro b/site/src/components/landing/ThroughputReplay.astro index d5ac154e7..1fb1a5eb2 100644 --- a/site/src/components/landing/ThroughputReplay.astro +++ b/site/src/components/landing/ThroughputReplay.astro @@ -20,7 +20,6 @@ const paths = layers.map((_, layer) => { const lower = [...sustainedSeries].reverse().map(point => `${x(point.at_seconds).toFixed(2)},${y(bound(point, layer)).toFixed(2)}`); return `M${upper.join(" L")} L${lower.join(" L")} Z`; }); -const averageDuration = sustained.seconds >= 60 ? `${Math.round(sustained.seconds / 60)}-minute` : `${sustained.seconds}-second`; const clock = (time: number) => `${String(Math.floor(time / 60)).padStart(2, "0")}:${String(Math.floor(time % 60)).padStart(2, "0")}`; const rateWidth = `· ${formatRate(maximum)} items/s, 5 s rate`.length; const machine = host.description.split(",")[0].replace("Cloud ", ""); @@ -33,9 +32,9 @@ const description = `${benchmark.release}: ${formatRate(sustained.accepted_per_s
{benchmark.development_preview ? "Development preview · mixed ingest" : "Sustained mixed ingest"} - {formatRate(sustained.accepted_per_second)}items/s + {formatRate(sustained.accepted_per_second)}telemetry items/s - {averageDuration} {sustained.phase === "mixed-sustained" ? "average" : "preview average"} + Five-minute mixed-ingest average
Spans {formatRate(sustained.spans_per_second)} @@ -74,7 +73,7 @@ const description = `${benchmark.release}: ${formatRate(sustained.accepted_per_s
Full measured run{clock(seconds)} / {clock(seconds)}
-

Replay of the measured run · {machine} · {host.logical_cpus} vCPU

+

Replay of the measured run · {machine} · {host.logical_cpus} vCPUHow we measured →

{benchmark.development_preview &&

{benchmark.series_phase} · Partial run · Completion gate failed

} @@ -87,7 +86,7 @@ const description = `${benchmark.release}: ${formatRate(sustained.accepted_per_s margin: 0; padding: 1rem 1.5rem; border: 1px solid var(--sl-color-gray-5); - border-radius: 8px; + border-radius: var(--fo-frame-radius); background: var(--sl-color-black); font-family: var(--fo-font-display); color: var(--sl-color-white); @@ -96,7 +95,7 @@ const description = `${benchmark.release}: ${formatRate(sustained.accepted_per_s figcaption { display: grid; grid-template-columns: minmax(0, 1fr) auto 5rem; align-items: center; gap: 1rem; } .fo-replay-heading { display: grid; grid-template-columns: max-content auto; align-items: baseline; gap: 0.25rem 1rem; min-width: 0; } .fo-replay-eyebrow, .fo-replay-setup, .fo-replay-average { color: var(--sl-color-gray-2); font-size: 0.75rem; } - .fo-replay-setup { margin: 0.5rem 0 0; line-height: 1.7; text-wrap: pretty; } + .fo-replay-setup { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin: 0.5rem 0 0; line-height: 1.7; text-wrap: pretty; } .fo-replay-eyebrow { grid-column: 1 / -1; } .fo-replay-average { white-space: nowrap; } .fo-replay-headline { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.6rem; } diff --git a/site/src/components/landing/landing-media.ts b/site/src/components/landing/landing-media.ts new file mode 100644 index 000000000..dddb637b2 --- /dev/null +++ b/site/src/components/landing/landing-media.ts @@ -0,0 +1,9 @@ +export type LandingMedia = Record; + +/** A slot needs complete sources in both themes before playback is enabled. */ +export function hasProductVideo(manifest: LandingMedia, view: "chat" | "dashboard"): boolean { + return ["light", "dark"].every(theme => { + const clip = manifest[`${view}-${theme}`]; + return [clip?.webm, clip?.mp4].every(url => typeof url === "string" && url.length > 0); + }); +} diff --git a/site/src/components/landing/product-video.ts b/site/src/components/landing/product-video.ts new file mode 100644 index 000000000..3ec0a6e50 --- /dev/null +++ b/site/src/components/landing/product-video.ts @@ -0,0 +1,65 @@ +/** Templates keep autoplay and downloads inert until motion and visibility allow them. */ +export function mountProductVideo(root: HTMLElement) { + const slots = [...root.querySelectorAll("[data-video-theme]")]; + const control = root.querySelector("[data-video-control]")!; + if (!root.querySelector("template")) return () => {}; + const motion = matchMedia("(prefers-reduced-motion: reduce)"); + let visible = false, paused = false, disposed = false; + const videos = new Map(); + + function update() { + const theme = document.documentElement.dataset.theme === "light" ? "light" : "dark"; + const allowed = !disposed && visible && !document.hidden && !motion.matches; + control.hidden = !allowed; + control.textContent = paused ? "Play" : "Pause"; + control.setAttribute("aria-label", paused ? "Play clip" : "Pause clip"); + for (const slot of slots) { + const active = allowed && !paused && slot.dataset.videoTheme === theme; + let video = videos.get(slot); + if (active && !video) { + const template = slot.querySelector("template")!; + video = template.content.firstElementChild!.cloneNode(true) as HTMLVideoElement; + video.muted = true; + const player = video; + player.addEventListener("playing", () => { + if (!disposed && !motion.matches && !player.paused) slot.dataset.playing = ""; + }); + player.addEventListener("error", () => { delete slot.dataset.playing; }); + slot.append(player); + videos.set(slot, player); + } + if (video) { + if (active) void video.play().catch(error => { + delete slot.dataset.playing; + if (!disposed && error instanceof Error && error.name === "NotAllowedError") { + paused = true; + update(); + } + }); + else video.pause(); + } + if (motion.matches || slot.dataset.videoTheme !== theme) delete slot.dataset.playing; + } + } + + const intersection = new IntersectionObserver(entries => { + visible = entries.some(entry => entry.isIntersecting); + update(); + }); + const theme = new MutationObserver(update); + intersection.observe(root); + theme.observe(document.documentElement, { attributes: true, attributeFilter: ["data-theme"] }); + const toggle = () => { paused = !paused; update(); }; + control.addEventListener("click", toggle); + motion.addEventListener("change", update); + document.addEventListener("visibilitychange", update); + return () => { + disposed = true; + update(); + intersection.disconnect(); + theme.disconnect(); + control.removeEventListener("click", toggle); + motion.removeEventListener("change", update); + document.removeEventListener("visibilitychange", update); + }; +} diff --git a/site/src/components/landing/throughput-replay.ts b/site/src/components/landing/throughput-replay.ts index 003916f12..05dbf205d 100644 --- a/site/src/components/landing/throughput-replay.ts +++ b/site/src/components/landing/throughput-replay.ts @@ -123,7 +123,8 @@ export function mountReplay(root: HTMLElement, load: () => Promise cursor: { drag: { x: false, y: false }, points: { show: false } }, scales: { x: { time: false, auto: false, range: () => [frame.min, frame.max] }, y: { auto: false, range: () => [0, ceiling] } }, axes: [ - { stroke: () => ink, font, size: 36, space: 70, grid: { show: false }, ticks: { show: false }, + // Keep the first time label below the zero tick, even beside the y-axis. + { stroke: () => ink, font, size: 36, gap: 16, space: 70, grid: { show: false }, ticks: { show: false }, values: (_, ticks) => ticks.map(value => value < 0 ? "" : clock(value)) }, { stroke: () => ink, font, size: 52, grid: { stroke: () => grid, width: 0.5 }, ticks: { show: false }, splits: () => Array.from({ length: 4 }, (_, i) => i * step), diff --git a/site/src/content/docs/guides/connect-over-mcp.mdx b/site/src/content/docs/guides/connect-over-mcp.mdx index b102d21d9..3ec74293b 100644 --- a/site/src/content/docs/guides/connect-over-mcp.mdx +++ b/site/src/content/docs/guides/connect-over-mcp.mdx @@ -53,6 +53,16 @@ needs only the URL: You authorize it in the browser as yourself, which ties the agent to your account without delegating your first-party account role. +### Claude Code + +Add Fanout as a remote MCP server: + +```sh +claude mcp add --transport http fanout https://fanout.example.com/mcp +``` + +Use your instance's public URL, then authorize the connection in your browser. + ## Protocol Fanout serves MCP protocol version `2026-07-28` over stateless Streamable diff --git a/site/src/content/docs/index.mdx b/site/src/content/docs/index.mdx index f2343c74f..2dc2112d4 100644 --- a/site/src/content/docs/index.mdx +++ b/site/src/content/docs/index.mdx @@ -1,16 +1,13 @@ --- -title: Fanout -description: One binary that ingests OpenTelemetry, stores it, and answers questions about it. -summary: OpenTelemetry observability in one binary, with a system overview, service map and trace waterfall. +title: Observability your agents can operate. +description: Send OpenTelemetry to one binary. Investigate with Fanout's built-in agent, or connect yours over MCP. +summary: Investigate with Fanout's built-in agent, or use the same typed tools from your own agent over MCP. template: splash -# The landing page's content title is also the site title, so Starlight's -# default would be "Fanout · Fanout". A frontmatter title replaces that default -# instead of adding a second ; the same override gives social cards a -# useful proposition. The canonical stays at the public root even though the -# static file produced by Astro is named index.html. +# Override Starlight's title order consistently for search and social cards. +# The canonical stays at the public root even though Astro writes index.html. head: - tag: title - content: "Fanout · OpenTelemetry observability in one binary." + content: "Fanout · Observability your agents can operate." - tag: link attrs: rel: canonical @@ -18,14 +15,14 @@ head: - tag: meta attrs: property: og:title - content: "Fanout · OpenTelemetry observability in one binary." + content: "Fanout · Observability your agents can operate." - tag: meta attrs: property: og:url content: "https://fanout.run/" hero: - title: See what broke without operating an observability stack. - tagline: Send OpenTelemetry traces, logs and metrics to one binary to investigate incidents and run alerts. + title: Observability your agents can operate. + tagline: Send OpenTelemetry to one binary. Investigate with Fanout's built-in agent, or connect yours over MCP. actions: - text: Install Fanout link: /start/install @@ -36,54 +33,65 @@ status: shipped import ProofStrip from "../../components/landing/ProofStrip.astro"; import CaptureRow from "../../components/landing/CaptureRow.astro"; -import ProductCapture from "../../components/landing/ProductCapture.astro"; +import ProductVideo from "../../components/landing/ProductVideo.astro"; import CtaBar from "../../components/landing/CtaBar.astro"; +import McpCommand from "../../components/landing/McpCommand.astro"; +import ThroughputReplay from "../../components/landing/ThroughputReplay.astro"; import ThroughputReplayClient from "../../components/landing/ThroughputReplayClient.astro"; <ThroughputReplayClient /> {/* Keep prose as Markdown children: the Markdown and llms.txt routes strip component tags and retain their content. Keep MDX comments on one line. */} +<ThroughputReplay /> + <ProofStrip> -- [**415,859 items/s** sustained](/explanation/performance) -- **One binary** +- **MCP** for your agents - **OTLP** traces, logs and metrics - **Parquet** you own - **Apache-2.0** </ProofStrip> -<CaptureRow> +<CaptureRow eyebrow="Dashboards"> -## Every service on one screen. +## Dashboards from a sentence. -See request rate, errors and latency across your system. Open a dashboard -or ask a question to investigate the services that need attention. +Ask for checkout request rate, errors, p95 latency and slowest dependencies. The agent builds and saves the dashboard. -<ProductCapture slot="capture" view="overview" alt="Fanout System overview dashboard with request rate, error rate, latency and service panels." /> +<ProductVideo slot="capture" view="dashboard" eager spedUp alt="Fanout agent building and saving a checkout dashboard, then opening its panels." description="A request for checkout request rate, error rate, p95 latency and slowest dependencies becomes a saved dashboard with rendered panels." /> </CaptureRow> -<CaptureRow> +<CaptureRow eyebrow="Investigation"> -## See how your services connect. +## Ask what broke. -Follow calls across services and external dependencies, with health, traffic and -latency on the map. Open a service to inspect its traces. +The agent queries traces, logs and metrics, then explains what the evidence shows. Try it on the [live demo](https://demo.fanout.run/chat): sign in with your email, no password needed. -<ProductCapture slot="capture" view="service-map" alt="Fanout service map showing calls between services and external dependencies, with health and latency." /> +<ProductVideo slot="capture" view="chat" spedUp alt="Fanout agent investigating why checkout is slower, with telemetry evidence inline." description="A checkout latency question leads to queries across traces, logs and metrics, evidence inline and an explanation of what it shows." /> </CaptureRow> -<CaptureRow> +<CaptureRow eyebrow="MCP" columns> + +## Use the same tools from your agent. + +Query telemetry, inspect traces and save dashboards through typed MCP tools. -## Find where the time went. +<ul className="fo-mcp-tools"> + <li><code>get_telemetry_schema</code></li> + <li><code>query_telemetry</code></li> + <li><code>search_logs</code></li> + <li><code>inspect_trace</code></li> + <li><code>preview_panels</code></li> + <li><code>create_dashboard</code></li> +</ul> -Open a trace to see each operation in a waterfall, with duration, service and -error status alongside correlated logs. +<p><a className="fo-link" href="/guides/connect-over-mcp">Connect an agent over MCP →</a></p> -<ProductCapture slot="capture" view="trace" alt="Fanout trace waterfall showing operation durations across services and correlated logs." /> +<McpCommand slot="capture" /> </CaptureRow> diff --git a/site/src/data/landing-media.json b/site/src/data/landing-media.json new file mode 100644 index 000000000..22a89c5de --- /dev/null +++ b/site/src/data/landing-media.json @@ -0,0 +1,18 @@ +{ + "chat-dark": { + "mp4": "https://assets.fanout.run/landing/chat-dark-060356746cef.mp4", + "webm": "https://assets.fanout.run/landing/chat-dark-3afac098a9b8.webm" + }, + "chat-light": { + "mp4": "https://assets.fanout.run/landing/chat-light-3ff97d86374f.mp4", + "webm": "https://assets.fanout.run/landing/chat-light-3947b9e88408.webm" + }, + "dashboard-dark": { + "mp4": "https://assets.fanout.run/landing/dashboard-dark-edf139c5a5a1.mp4", + "webm": "https://assets.fanout.run/landing/dashboard-dark-288fcd70d685.webm" + }, + "dashboard-light": { + "mp4": "https://assets.fanout.run/landing/dashboard-light-b51d120624a4.mp4", + "webm": "https://assets.fanout.run/landing/dashboard-light-dc0e9675651a.webm" + } +} diff --git a/site/src/styles/fanout.css b/site/src/styles/fanout.css index f2262e681..86118e727 100644 --- a/site/src/styles/fanout.css +++ b/site/src/styles/fanout.css @@ -45,6 +45,8 @@ :root { --fo-font-display: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; --fo-font-body: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; + --fo-frame-radius: 8px; + --fo-frame-shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 8px 24px rgb(0 0 0 / 0.06); /* Mono owns the brand, navigation, headings and technical artifacts. Sans is opted into by prose, below. */ @@ -76,6 +78,7 @@ } :root[data-theme="light"] { + --fo-frame-shadow: 0 2px 4px rgb(23 27 36 / 0.04), 0 12px 32px rgb(23 27 36 / 0.08); --sl-color-accent-low: #ece3fb; --sl-color-accent: #7c4dcc; --sl-color-accent-high: #5b32a3; @@ -109,6 +112,35 @@ background: url("/favicon.svg") center / contain no-repeat; } +.fo-link { + color: var(--sl-color-accent-high); + text-decoration: none; + text-underline-offset: 0.25em; +} +.fo-link:hover { color: var(--sl-color-accent); text-decoration: underline; } +.fo-link:focus-visible { outline: 2px solid var(--sl-color-accent); outline-offset: 3px; } + +.fo-product-frame { + overflow: hidden; + border: 1px solid var(--sl-color-gray-5); + border-radius: var(--fo-frame-radius); + background: var(--sl-color-black); + box-shadow: var(--fo-frame-shadow); +} + +@media (max-width: 49.999rem) { + header.header .right-group { display: flex; flex-shrink: 0; } + header.header .header { gap: 0.5rem; } + header.header :is(.right-group, .social-icons) { gap: 0.75rem; } + header.header .social-icons::after { display: none; } +} + +@media (max-width: 39.999rem) { + header.header .site-title { font-size: 1.125rem; } + header.header starlight-theme-select select { width: 2rem; padding-inline: 0; color: transparent; } + header.header starlight-theme-select .caret { display: none; } +} + /* The landing page stays mono-led; the proportional face is reserved for the long-form documentation where it materially improves reading. */ body:has(.fo-hero) site-search { @@ -151,6 +183,24 @@ body:has(.fo-hero) .sl-markdown-content > * { margin: 0; } +.fo-mcp-tools { + display: flex; + flex-wrap: wrap; + gap: 0.5rem; + list-style: none; + padding: 0; + margin: 1.25rem 0 0; +} + +.fo-mcp-tools > li { + margin: 0; + padding: 0.25rem 0.5rem; + border: 1px solid var(--sl-color-gray-5); + border-radius: 4px; + font-size: 0.75rem; +} +.fo-mcp-tools code { font-family: var(--fo-font-display); } + @media (max-width: 71.999rem) { body:has(.fo-hero) { --fo-section-gap: 3.5rem; } } diff --git a/ui/host/e2e/global-setup.ts b/ui/host/e2e/global-setup.ts index 872e18b89..35595d933 100644 --- a/ui/host/e2e/global-setup.ts +++ b/ui/host/e2e/global-setup.ts @@ -49,7 +49,11 @@ function seed(binary: string | undefined, base: string, tokenFile: string, log: } export default async function globalSetup() { - // External landing captures use an existing instance and an in-memory session. + // Recordings require a real AI-enabled instance; never start the seeded server. + if (process.env.FANOUT_LANDING_RECORDINGS === "1" && !process.env.FANOUT_LANDING_BASE_URL) { + throw new Error("Landing recordings require FANOUT_LANDING_BASE_URL and FANOUT_LANDING_SESSION_COOKIE for an external instance"); + } + // External landing media use an existing instance and an in-memory session. if (process.env.FANOUT_LANDING_BASE_URL) return; const dir = await mkdtemp(join(tmpdir(), "fanout-e2e-")); diff --git a/ui/host/e2e/landing-captures.spec.ts b/ui/host/e2e/landing-captures.spec.ts index a886dd576..60ab53c9f 100644 --- a/ui/host/e2e/landing-captures.spec.ts +++ b/ui/host/e2e/landing-captures.spec.ts @@ -3,8 +3,6 @@ import { mkdir } from "node:fs/promises"; import { fileURLToPath } from "node:url"; import { cardSelector, readyCard, settle, test } from "./accessibility-support"; import type { DashboardSpec } from "../../panels/types"; -import type { Result, TraceDetail } from "../../contracts"; -import { compareTracePages, scoreTracePage } from "./landing-trace-support"; // Use either the real seeded server or an existing instance, without intercepts. const externalBaseURL = process.env.FANOUT_LANDING_BASE_URL; @@ -39,7 +37,7 @@ async function readyOverviewViewport(page: Page) { }).toEqual([]); } -test("capture the overview, service map and trace waterfall for the landing page", async ({ page, request }, info) => { +test("capture the README overview", async ({ page, request }, info) => { // The normal matrix also includes 1100px. Write each stable asset only once. test.skip(info.project.use.viewport?.width !== 1440, "landing captures use the 1440px projects"); const theme = info.project.use.colorScheme as "light" | "dark"; @@ -107,107 +105,4 @@ test("capture the overview, service map and trace waterfall for the landing page expect(clip.height).toBeGreaterThan(0); return clip; }); - - const mapPanel = dashboard.spec.panels.find(panel => panel.viz === "service_map"); - if (!mapPanel) throw new Error("System overview has no service map"); - const map = await readyCard(page, mapPanel); - await map.getByRole("button", { name: `${mapPanel.title} menu`, exact: true }).click(); - await page.getByRole("menuitem", { name: "View", exact: true }).click(); - const fullView = page.locator("[data-panel-fullscreen]"); - await expect(fullView).toBeVisible(); - const fullMap = fullView.locator(cardSelector(mapPanel.id)); - await expect(fullMap.locator('[aria-label="Loading panel"], [aria-label="Refreshing"]')).toHaveCount(0); - await expect(fullMap.getByRole("region", { name: /service dependency graph/ }).getByRole("button").first()).toBeVisible(); - await settle(page); - await page.waitForTimeout(250); - const wholeGraph = fullMap.getByRole("button", { name: `Show whole ${mapPanel.title} graph`, exact: true }); - if (await wholeGraph.isVisible()) await wholeGraph.click(); - await expect(fullMap.getByRole("region", { name: /service dependency graph/ }).getByRole("button").first()).toBeVisible(); - await expect(fullMap.locator("[data-panel-title]")).toHaveText(mapPanel.title); - await capture("service-map", fullMap, async () => { - // Crop the settled graph itself: resizing the card refits and recentres - // its contents, which can reintroduce the whitespace being removed. - const clip = await fullMap.getByRole("region", { name: /service dependency graph/ }).evaluate(region => { - const boxes = [...region.querySelectorAll("button, svg > g > path, span")] - .map(node => node.getBoundingClientRect()).filter(box => box.width > 0 || box.height > 0); - if (!boxes.length) throw new Error("The service graph has no rendered bounds"); - const left = Math.min(...boxes.map(box => box.left)), right = Math.max(...boxes.map(box => box.right)); - const top = Math.min(...boxes.map(box => box.top)), bottom = Math.max(...boxes.map(box => box.bottom)); - // Keep 24 CSS pixels (48 source pixels at 2x) beyond every rendered - // node, connector and label. Let the graph determine the aspect ratio. - const x = Math.floor(left - 24), y = Math.floor(top - 24); - return { x, y, width: Math.ceil(right + 24) - x, height: Math.ceil(bottom + 24) - y }; - }); - const viewport = page.viewportSize()!; - expect(clip.x).toBeGreaterThanOrEqual(0); expect(clip.x + clip.width).toBeLessThanOrEqual(viewport.width); - expect(clip.y).toBeGreaterThanOrEqual(0); expect(clip.y + clip.height).toBeLessThanOrEqual(viewport.height); - expect(clip.width).toBeGreaterThanOrEqual(clip.height); - return clip; - }); - - await page.getByRole("button", { name: "Close panel view", exact: true }).click(); - await expect(fullView).toHaveCount(0); - // The drawer needs enough vertical room for all eight visible waterfall - // spans, pagination and the first correlated log rows. - await page.setViewportSize({ width: 1440, height: 1200 }); - // Open a service, then one of its server-returned exemplar traces. - const inlineMap = page.locator(cardSelector(mapPanel.id)); - const inlineWholeGraph = inlineMap.getByRole("button", { name: `Show whole ${mapPanel.title} graph`, exact: true }); - if (await inlineWholeGraph.isVisible()) await inlineWholeGraph.click(); - const drawer = page.getByRole("dialog"); - const traceRows = drawer.getByRole("button", { name: / · .* · [\d.]+ ms$/ }); - if (externalBaseURL) { - const services = inlineMap.getByRole("region", { name: /service dependency graph/ }).getByRole("button"); - const labels = await services.evaluateAll(nodes => nodes.map(node => node.getAttribute("aria-label")!)); - // Prefer the demo's checkout path, then its frontend, before other services. - const priority = (label: string) => /checkout/i.test(label.split(",")[0]) ? 0 : /frontend/i.test(label.split(",")[0]) ? 1 : 2; - labels.sort((a, b) => priority(a) - priority(b) || a.localeCompare(b)); - if (!labels.length) throw new Error("The live service map has no services"); - const exemplarsReady = page.waitForResponse(response => new URL(response.url()).pathname === "/api/panels/exemplars" && response.request().method() === "POST"); - await inlineMap.getByRole("button", { name: labels[0], exact: true }).click(); - const exemplarsResponse = await exemplarsReady; - expect(exemplarsResponse.status()).toBe(200); - const { traces } = await exemplarsResponse.json() as { traces: { trace_id: string; namespace: string }[] }; - const selection = exemplarsResponse.request().postDataJSON() as { time: { from: string; to: string } }; - const candidates = await Promise.all(traces.map(async (trace, index) => { - const params = new URLSearchParams({ namespace: trace.namespace, from: selection.time.from, to: selection.time.to, limit: "200" }); - const response = await request.get(`/api/traces/${encodeURIComponent(trace.trace_id)}?${params}`); - expect(response.status()).toBe(200); - const { data } = await response.json() as Result<TraceDetail>; - return { index, data }; - })); - // Rank the actual first waterfall page of complete, error-free traces. - const ranked = candidates.flatMap(({ index, data }) => { - const score = scoreTracePage(data); - return score ? [{ index, score }] : []; - }).sort((a, b) => compareTracePages(a.score, b.score)); - if (!ranked.length) throw new Error("No complete, error-free live exemplar has at least 3 services on its first waterfall page and a positive duration; send more workload before capturing"); - await expect(drawer).toBeVisible(); - await expect(traceRows).toHaveCount(traces.length); - await traceRows.nth(ranked[0].index).click(); - } else { - await inlineMap.getByRole("button", { name: /^checkout, / }).click(); - await expect(drawer).toBeVisible(); - await traceRows.first().click(); - } - await expect(drawer.getByRole("button", { name: "Waterfall", exact: true })).toHaveAttribute("aria-pressed", "true"); - // Capture-only width gives the waterfall and logs a landscape frame without - // changing the product drawer or shrinking its text to fit a portrait crop. - await drawer.evaluate(dialog => Object.assign(dialog.style, { flex: "0 0 1200px", width: "1200px", maxWidth: "100vw" })); - await settle(page); - await expect(drawer.getByRole("columnheader", { name: "Timeline", exact: true })).toBeVisible(); - await expect(drawer.getByRole("img", { name: / took / }).first()).toBeVisible(); - await expect(drawer.getByRole("img", { name: / took / }).last()).toBeInViewport({ ratio: 1 }); - await expect(drawer.getByText("Correlated logs", { exact: true })).toBeVisible(); - const logs = drawer.locator("tbody tr").filter({ has: page.locator("[data-field=body]") }); - await expect(logs.first()).toBeVisible(); - const lastLog = logs.nth(Math.min(2, await logs.count() - 1)); - await expect(lastLog).toBeInViewport({ ratio: 1 }); - await expect(drawer.getByRole("alert")).toHaveCount(0); - await capture("trace", drawer, async () => { - const dialog = (await drawer.boundingBox())!, last = (await lastLog.boundingBox())!; - const clip = { x: dialog.x, y: dialog.y, width: dialog.width, height: Math.ceil(last.y + last.height - dialog.y) }; - expect(clip.width).toBeGreaterThanOrEqual(clip.height); - return clip; - }); }); diff --git a/ui/host/e2e/landing-recording-support.ts b/ui/host/e2e/landing-recording-support.ts new file mode 100644 index 000000000..43d61081f --- /dev/null +++ b/ui/host/e2e/landing-recording-support.ts @@ -0,0 +1,59 @@ +export type AgentEvent = { + type: string; + timestamp: number; + toolCallId?: string; + toolCallName?: string; + content?: string; +}; +export type WaitInterval = { kind: "model_thinking" | "tool_call"; start: number; end: number; tool?: string }; + +/** Observe the completed, unmodified SSE response; never route or replace requests. */ +export function recordingTimeline(stream: string, responseAt: number) { + const events = stream.split(/\r?\n\r?\n/).flatMap(frame => { + const data = frame.split(/\r?\n/).filter(line => line.startsWith("data:")).map(line => line.slice(5).trimStart()).join("\n"); + return data ? [JSON.parse(data) as AgentEvent] : []; + }); + const first = events.find(event => event.type === "RUN_STARTED"); + if (!first || !Number.isFinite(first.timestamp)) throw new Error("Agent stream has no timestamped RUN_STARTED event"); + if (events.some(event => event.type === "RUN_ERROR")) throw new Error("Agent run failed; inspect the instance before recording again"); + if (!events.some(event => event.type === "RUN_FINISHED")) throw new Error("Agent stream ended without RUN_FINISHED"); + const waits: WaitInterval[] = []; + const tools = new Map<string, { start: number; tool: string }>(); + const names = new Map<string, string>(); + let thinking: number | undefined, dashboardId: string | undefined; + const endThinking = (end: number) => { + if (thinking !== undefined && end > thinking) waits.push({ kind: "model_thinking", start: thinking, end }); + thinking = undefined; + }; + for (const event of events) { + if (!Number.isFinite(event.timestamp)) throw new Error(`Agent event ${event.type} has no timestamp`); + // Anchor server timestamps to receipt of the response headers to avoid clock skew. + const at = responseAt + (event.timestamp - first.timestamp) / 1000; + switch (event.type) { + case "RUN_STARTED": thinking = at; break; + case "REASONING_MESSAGE_START": case "TEXT_MESSAGE_START": endThinking(at); break; + case "REASONING_MESSAGE_END": if (thinking === undefined && tools.size === 0) thinking = at; break; + case "TOOL_CALL_START": + endThinking(at); + if (!event.toolCallId || !event.toolCallName) throw new Error("Tool call has no id or name"); + tools.set(event.toolCallId, { start: at, tool: event.toolCallName }); + names.set(event.toolCallId, event.toolCallName); + break; + case "TOOL_CALL_RESULT": { + const call = tools.get(event.toolCallId!); + if (!call) throw new Error("Tool result has no matching start event"); + if (at > call.start) waits.push({ kind: "tool_call", ...call, end: at }); + tools.delete(event.toolCallId!); + if (tools.size === 0) thinking = at; + if (names.get(event.toolCallId!) === "create_dashboard" && event.content) { + const result = JSON.parse(event.content) as { isError?: boolean; error?: unknown; dashboard?: { id?: string }; receipt?: unknown }; + if (!result.isError && !result.error && result.receipt && typeof result.dashboard?.id === "string") dashboardId = result.dashboard.id; + } + break; + } + case "RUN_FINISHED": endThinking(at); break; + } + } + if (tools.size) throw new Error("Agent finished with unresolved tool calls"); + return { waits: waits.sort((a, b) => a.start - b.start), dashboardId }; +} diff --git a/ui/host/e2e/landing-recordings.spec.ts b/ui/host/e2e/landing-recordings.spec.ts new file mode 100644 index 000000000..170286f5b --- /dev/null +++ b/ui/host/e2e/landing-recordings.spec.ts @@ -0,0 +1,147 @@ +import { expect, test } from "@playwright/test"; +import { mkdir, writeFile } from "node:fs/promises"; +import { fileURLToPath } from "node:url"; +import { cardSelector, readyCard, settle } from "./accessibility-support"; +import { recordingTimeline } from "./landing-recording-support"; +import type { DashboardSpec } from "../../panels/types"; + +const baseURL = process.env.FANOUT_LANDING_BASE_URL; +const directory = fileURLToPath(new URL("../test-results/landing-recordings/", import.meta.url)); +test.skip(process.env.FANOUT_LANDING_RECORDINGS !== "1", "set FANOUT_LANDING_RECORDINGS=1 to record real landing clips"); +test.setTimeout(8 * 60_000); +test.use({ + storageState: async ({}, use) => { + if (!baseURL) throw new Error("Landing recordings require FANOUT_LANDING_BASE_URL for an external instance"); + const match = /^([!#$%&'*+.^_`|~\w-]+)=([^;\s]+)$/.exec(process.env.FANOUT_LANDING_SESSION_COOKIE ?? ""); + if (!match) throw new Error("FANOUT_LANDING_SESSION_COOKIE must be a nonempty name=value session cookie"); + const url = new URL(baseURL); + await use({ cookies: [{ name: match[1], value: match[2], domain: url.hostname, path: "/", expires: -1, + httpOnly: true, secure: url.protocol === "https:", sameSite: "Lax" }], origins: [] }); + }, +}); + +const prompts = { + chat: "Why is checkout slower in the last hour?", + dashboard: "Build a dashboard for checkout: request rate, error rate, p95 latency, and its slowest dependencies", +}; + +for (const view of ["chat", "dashboard"] as const) { + test(`record ${view} on the OpenTelemetry Demo`, async ({ browser, storageState }, info) => { + test.skip(info.project.use.viewport?.width !== 1440, "use the 1440px projects to record each theme once at 1280 × 800 CSS pixels"); + const theme = info.project.use.colorScheme as "light" | "dark"; + await mkdir(directory, { recursive: true }); + const context = await browser.newContext({ baseURL, storageState, colorScheme: theme, + viewport: { width: 1280, height: 800 }, + recordVideo: { dir: directory, size: { width: 1280, height: 800 } } }); + try { + const status = await context.request.get("/api/auth/status"); + expect(status.ok(), "Cannot read runtime status from the external instance").toBe(true); + if (!(await status.json() as { agent_available: boolean }).agent_available) { + throw new Error("Chat is disabled on the external instance; configure an AI provider before recording landing clips"); + } + await context.addInitScript(value => localStorage.setItem("mantine-color-scheme-value", value), theme); + const startedAt = Date.now(); + const page = await context.newPage(); + const video = page.video()!; + await page.goto("/chat"); + // Use this page's session and the owner-scoped APIs to clear earlier takes. + await page.evaluate(async () => { + const request = async (path: string, method = "GET", headers: Record<string, string> = {}) => { + const response = await fetch(path, { method, credentials: "same-origin", redirect: "error", + headers: { "Fanout-Request": "1", ...headers } }).catch(() => { + throw new Error(`Landing recording cleanup failed: ${method} ${path} (request could not complete)`); + }); + if (!response.ok) throw new Error(`Landing recording cleanup failed: ${method} ${path} (HTTP ${response.status})`); + return response; + }; + // Finish pagination before deleting so removals cannot affect the scan. + const threadIds: string[] = []; + let cursor: string | null = null; + do { + const params = new URLSearchParams({ page_size: "100" }); + if (cursor) params.set("cursor", cursor); + const response = await request(`/api/agent/threads?${params}`); + const page = await response.json() as { items: { id: string }[]; next_cursor: string | null }; + threadIds.push(...page.items.map(thread => thread.id)); + cursor = page.next_cursor; + } while (cursor); + for (const id of threadIds) await request(`/api/agent/threads/${encodeURIComponent(id)}`, "DELETE"); + + const response = await request("/api/dashboards"); + const { dashboards } = await response.json() as { dashboards: { id: string; is_default: boolean }[] }; + for (const dashboard of dashboards) { + // Only an explicit non-default flag permits deletion; never touch the default. + if (dashboard.is_default !== false) continue; + await request(`/api/dashboards/${encodeURIComponent(dashboard.id)}`, "DELETE", + { "Fanout-Confirm-Delete": dashboard.id }); + } + }); + await page.reload(); + const navigation = page.getByRole("navigation", { name: "Navigation", exact: true }); + await expect(navigation.getByText("No chats yet", { exact: true })).toBeVisible(); + await expect(navigation.locator('a[href^="/dashboards/"]')).toHaveCount(1); + await expect(navigation.locator('a[href^="/dashboards/"]').getByText("System overview", { exact: true })).toBeVisible(); + await expect(page.locator("html")).toHaveAttribute("data-mantine-color-scheme", theme); + const input = page.getByRole("textbox", { name: "Message Fanout", exact: true }); + await expect(input, "Chat must be enabled and the session must allow agent runs").toBeEnabled(); + // The clip starts on the settled empty chat, not on page load and cleanup. + const start = (Date.now() - startedAt) / 1000; + await input.click(); + // A steady human typing cadence, including a short pause at punctuation. + for (const character of prompts[view]) { + await input.pressSequentially(character, { delay: /[,:?]/.test(character) ? 180 : 55 }); + } + const responseReady = page.waitForResponse(response => new URL(response.url()).pathname === "/api/agent/runs" + && response.request().method() === "POST", { timeout: 30_000 }); + await page.getByRole("button", { name: "Send message", exact: true }).click(); + const response = await responseReady; + const responseAt = (Date.now() - startedAt) / 1000; + expect(response.ok(), "Agent request failed; check chat configuration and the session's agent:run capability").toBe(true); + const timeline = recordingTimeline(await response.text(), responseAt); + // RUN_FINISHED in the real stream plus the UI's idle state gates the dwell. + await expect(page.getByRole("button", { name: "Stop", exact: true })).toHaveCount(0); + await expect(page.locator(".chat-pane .mantine-Loader-root")).toHaveCount(0); + await expect(page.locator(".chat-pane").getByRole("alert")).toHaveCount(0); + await expect(page.locator('[data-answer-position] [data-role="assistant"]')).toBeVisible(); + const views = page.locator('iframe[title="Fanout analysis view"]'); + for (let index = 0; index < await views.count(); index++) { + const frame = views.nth(index).contentFrame(); + await expect(frame.locator("[data-panel-body]").first()).toBeAttached(); + await expect(frame.locator(".mantine-Loader-root, [data-panel-error]")).toHaveCount(0); + } + + if (view === "dashboard") { + if (!timeline.dashboardId) throw new Error("No successful create_dashboard result with a committed save receipt; the recording requires a newly saved dashboard"); + const receipt = page.locator(`[data-dashboard-result="${timeline.dashboardId}"]`); + await receipt.getByRole("link", { name: "Open dashboard", exact: true }).click(); + await expect(page).toHaveURL(new RegExp(`/dashboards/${timeline.dashboardId}(?:\\?|$)`)); + const saved = await context.request.get(`/api/dashboards/${encodeURIComponent(timeline.dashboardId)}`); + expect(saved.ok()).toBe(true); + const { spec } = await saved.json() as { spec: DashboardSpec }; + expect(spec.panels.length, "The created dashboard must contain panels").toBeGreaterThan(0); + for (const panel of spec.panels) await readyCard(page, panel); + await page.evaluate(() => window.scrollTo(0, 0)); + // Lazy panels returning to the first fold must be settled too. + for (const panel of spec.panels) { + const card = page.locator(cardSelector(panel.id)); + await expect(card.locator('[aria-label="Loading panel"], [aria-label="Refreshing"], [data-panel-error]')).toHaveCount(0); + } + } + await settle(page); + await page.mouse.move(0, 0); + await page.waitForTimeout(view === "dashboard" ? 5_000 : 4_000); + const duration = (Date.now() - startedAt) / 1000; + await context.close(); + const rawFile = `${view}-${theme}.webm`; + await video.saveAs(`${directory}${rawFile}`); + await video.delete(); + // No cookies, request bodies, tool results or telemetry are persisted here. + await writeFile(`${directory}${view}-${theme}.json`, JSON.stringify({ version: 1, raw_file: rawFile, + viewport: { width: 1280, height: 800 }, theme, prompt: prompts[view], start, duration, + clock: "seconds from page creation; server event deltas anchored to response headers", + waits: timeline.waits }, null, 2) + "\n"); + } finally { + await context.close(); + } + }); +} diff --git a/ui/host/e2e/landing-trace-support.test.ts b/ui/host/e2e/landing-trace-support.test.ts deleted file mode 100644 index 0ac3255f9..000000000 --- a/ui/host/e2e/landing-trace-support.test.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { expect, it } from "vitest"; -import type { TraceDetail, TraceSpan } from "../../contracts"; -import { pageItems, TRACE_PAGE_SIZE } from "../src/dashboards/trace/pagination"; -import { compareTracePages, scoreTracePage } from "./landing-trace-support"; - -function span(id: string, start: number, duration: number, service = id): TraceSpan { - return { - span_id: id, service, operation: id, kind: "SERVER", status: "OK", - start: new Date(Date.UTC(2026, 9, 1) + start).toISOString(), duration_ms: duration, - }; -} - -function trace(spans: TraceSpan[], overrides: Partial<TraceDetail> = {}): TraceDetail { - const services = [...new Set(spans.map(span => span.service))]; - return { - trace_id: "trace", duration_ms: 100, has_error: false, services, spans, logs: [], - span_count: spans.length, service_count: services.length, truncated: false, ...overrides, - }; -} - -it("scores the union of overlapping intervals without counting gaps or nesting twice", () => { - const data = trace([span("a", 10, 30), span("b", 0, 20), span("c", 70, 10), span("d", 12, 3)]); - const original = [...data.spans]; - expect(scoreTracePage(data)).toEqual({ - traceID: "trace", coverage: 0.5, startSpread: 0.7, serviceCount: 4, fitsOnePage: true, - }); - expect(data.spans).toEqual(original); -}); - -it("uses the UI's first page in server order, even when later spans start earlier", () => { - const spans = Array.from({ length: TRACE_PAGE_SIZE }, (_, i) => span(`first-${i}`, 40 + i, 10, `service-${i % 3}`)); - spans.push(span("later", 0, 100)); - expect(pageItems(spans)).toEqual(spans.slice(0, TRACE_PAGE_SIZE)); - expect(pageItems(spans, 2)).toEqual([spans.at(-1)]); - expect(scoreTracePage(trace(spans))).toEqual({ - traceID: "trace", coverage: 0.17, startSpread: 0.07, serviceCount: 3, fitsOnePage: false, - }); - const tooFewServices = spans.map((item, i) => i < TRACE_PAGE_SIZE ? { ...item, service: "only" } : item); - expect(scoreTracePage(trace(tooFewServices))).toBeNull(); -}); - -it("normalizes coverage and start spread by trace duration", () => { - const data = trace([span("a", 0, 20), span("b", 40, 10), span("c", 90, 10)]); - const scaled = trace([span("a", 0, 200), span("b", 400, 100), span("c", 900, 100)], { duration_ms: 1000 }); - expect(scoreTracePage(data)).toEqual(scoreTracePage(scaled)); -}); - -it("prefers a distributed single-page trace over a long root and seven early slivers", () => { - const clustered = [span("root", 0, 834), ...Array.from({ length: 7 }, (_, i) => span(`early-${i}`, i + 1, 1))]; - clustered.push(...Array.from({ length: 186 }, (_, i) => span(`later-${i}`, 100 + i, 1))); - const busy = scoreTracePage(trace(clustered, { trace_id: "large", duration_ms: 834 }))!; - const distributed = scoreTracePage(trace([span("a", 0, 100), span("b", 30, 30), span("c", 70, 30)]))!; - expect(busy.coverage).toBe(1); - expect(distributed.coverage).toBe(1); - expect(compareTracePages(distributed, busy)).toBeLessThan(0); -}); - -it("rejects truncated, incomplete and erroneous traces, including errors beyond page one", () => { - const spans = [span("a", 0, 100), span("b", 30, 30), span("c", 70, 30)]; - for (const overrides of [{ truncated: true }, { span_count: 4 }, { has_error: true }, { duration_ms: 0 }]) { - expect(scoreTracePage(trace(spans, overrides))).toBeNull(); - } - const withError = [...spans, ...Array.from({ length: TRACE_PAGE_SIZE }, (_, i) => span(`extra-${i}`, 1, 1))]; - withError[withError.length - 1].status = "STATUS_CODE_ERROR"; - expect(scoreTracePage(trace(withError))).toBeNull(); -}); - -it("prefers one page on equal visual scores, then page services and trace ID", () => { - const spans = [span("a", 0, 100), span("b", 30, 30), span("c", 70, 30)]; - const single = scoreTracePage(trace(spans))!; - const multiple = scoreTracePage(trace([...spans, ...Array.from({ length: TRACE_PAGE_SIZE }, (_, i) => span(`extra-${i}`, 30, 1))]))!; - expect(single.coverage + single.startSpread).toBe(multiple.coverage + multiple.startSpread); - expect(compareTracePages(single, multiple)).toBeLessThan(0); - const moreServices = scoreTracePage(trace([...spans, span("d", 40, 1)]))!; - expect(compareTracePages(moreServices, single)).toBeLessThan(0); - const earlierID = scoreTracePage(trace(spans, { trace_id: "aaa" }))!; - const laterID = scoreTracePage(trace(spans, { trace_id: "zzz" }))!; - expect([laterID, earlierID].sort(compareTracePages)).toEqual([earlierID, laterID]); - expect(compareTracePages(single, single)).toBe(0); -}); diff --git a/ui/host/e2e/landing-trace-support.ts b/ui/host/e2e/landing-trace-support.ts deleted file mode 100644 index 4196d2115..000000000 --- a/ui/host/e2e/landing-trace-support.ts +++ /dev/null @@ -1,47 +0,0 @@ -import type { TraceDetail } from "../../contracts"; -import { pageItems } from "../src/dashboards/trace/pagination"; - -interface TracePageScore { - traceID: string; - coverage: number; - startSpread: number; - serviceCount: number; - fitsOnePage: boolean; -} - -export function scoreTracePage(trace: TraceDetail): TracePageScore | null { - if (trace.truncated || trace.spans.length !== trace.span_count || trace.has_error - || trace.spans.some(span => span.status.toUpperCase().includes("ERROR")) - || !Number.isFinite(trace.duration_ms) || trace.duration_ms <= 0) return null; - - const firstPage = pageItems(trace.spans); - const serviceCount = new Set(firstPage.map(span => span.service)).size; - if (serviceCount < 3) return null; - - const traceStart = Math.min(...trace.spans.map(span => new Date(span.start).valueOf())); - const intervals = firstPage.map(span => { - const start = new Date(span.start).valueOf() - traceStart; - return { start, end: start + span.duration_ms }; - }).sort((a, b) => a.start - b.start); - let covered = 0, coveredUntil = 0; - for (const { start, end } of intervals) { - covered += Math.max(0, end - Math.max(start, coveredUntil)); - coveredUntil = Math.max(coveredUntil, end); - } - return { - traceID: trace.trace_id, - coverage: covered / trace.duration_ms, - startSpread: (intervals.at(-1)!.start - intervals[0].start) / trace.duration_ms, - serviceCount, - fitsOnePage: firstPage.length === trace.spans.length, - }; -} - -export function compareTracePages(a: TracePageScore, b: TracePageScore): number { - // Equal weight for occupied time and distributed starts: a long root alone - // can fill the timeline while the other seven bars cluster at its left edge. - return (b.coverage + b.startSpread) - (a.coverage + a.startSpread) - || Number(b.fitsOnePage) - Number(a.fitsOnePage) - || b.serviceCount - a.serviceCount - || a.traceID.localeCompare(b.traceID); -} diff --git a/ui/host/playwright.config.ts b/ui/host/playwright.config.ts index b39df7a85..eb8e5f22a 100644 --- a/ui/host/playwright.config.ts +++ b/ui/host/playwright.config.ts @@ -10,7 +10,7 @@ export default defineConfig({ retries: 0, forbidOnly: Boolean(process.env.CI), timeout: 120_000, - globalTimeout: 12 * 60_000, + globalTimeout: (process.env.FANOUT_LANDING_RECORDINGS === "1" ? 40 : 12) * 60_000, expect: { timeout: 30_000 }, reporter: [["list"], ["./e2e/failure-report.ts", { outputFolder: "playwright-report" }]], outputDir: "test-results",