diff --git a/playground/main.tsx b/playground/main.tsx index efd5fa52..f9360cde 100644 --- a/playground/main.tsx +++ b/playground/main.tsx @@ -26,11 +26,11 @@ function App() {

Throughline / schema-2 development preview

-

Reference evidence and player review

+

Public player layout review

- Explore independently checked, authored models. Graphs and sequences - reveal declared evidence; they do not execute source code or infer - undocumented events. + Review the native player on independently checked, authored models. + Use the Graph, Sequence, and State tabs, Inspect sidebar, and compact + transport across desktop, tablet, and mobile widths.

@@ -104,9 +104,10 @@ function App() {
{current?.source ?? ""}

- Use Player options to inspect source events, histories and compatible views. - The static explanation and questions are a matched baseline, not a - claim that improved learning outcomes have been measured. + Select a reference model above, then use the player tabs for Graph, + Sequence, or State. The Inspect sidebar provides complete source + evidence and histories. The static explanation and questions are + a matched baseline, not a measured learning-outcome claim.

diff --git a/playground/style.css b/playground/style.css index 50d65edb..04be74c5 100644 --- a/playground/style.css +++ b/playground/style.css @@ -1,3 +1,5 @@ +@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap"); + * { box-sizing: border-box; } diff --git a/scripts/audit-browser.mjs b/scripts/audit-browser.mjs index 4b175229..c3ef910a 100644 --- a/scripts/audit-browser.mjs +++ b/scripts/audit-browser.mjs @@ -108,7 +108,7 @@ try { const visual = await player.evaluate(element => ({ overflow: element.scrollWidth > element.clientWidth, radius: getComputedStyle(element).getPropertyValue("--thl-radius").trim(), - controls: getComputedStyle(element.querySelector(".thl-bottom")).display, + controls: getComputedStyle(element.querySelector(".transport")).display, graph: element.querySelector(".thl-v2-diagram") !== null, reducedMotion: matchMedia("(prefers-reduced-motion: reduce)").matches, })); @@ -123,7 +123,9 @@ try { await page.keyboard.press("ArrowRight"); assert.match(await page.getByRole("status").textContent(), /Step 3 of 9/); await page.getByRole("button", { name: "Player options" }).tap(); - await page.getByRole("combobox", { name: "Visualization view" }).selectOption("state-table"); + assert(await page.getByRole("group", { name: "Player options" }).isVisible()); + await page.getByRole("button", { name: "Player options" }).tap(); + await page.getByRole("tab", { name: "State" }).click(); assert(await page.getByRole("region", { name: "State and event table" }).isVisible()); const state = await page.getByRole("region", { name: "State and event table" }).textContent(); assert.match(state, /Modeled call stack/); diff --git a/scripts/audit-pack.mjs b/scripts/audit-pack.mjs index 141f20c5..82541681 100644 --- a/scripts/audit-pack.mjs +++ b/scripts/audit-pack.mjs @@ -509,8 +509,9 @@ try { 'assert.match(sequenceHtml, /No modeled events through this frame/);', 'assert.doesNotMatch(sequenceHtml, /data-message-phase="received"/);', 'assert.match(graphHtml, /Source-linked graph at current frame/);', - 'assert.match(graphHtml, /Explain or inspect/);', - 'assert.match(graphHtml, /aria-pressed="false"[^>]*>Inspect/);', + 'assert.match(graphHtml, /class="player-header"/);', + 'assert.match(graphHtml, /role="tablist" aria-label="Visualization view"/);', + 'assert.match(graphHtml, /aria-label="Inspect" aria-pressed="false"/);', 'assert.match(graphHtml, /data-source-entity-ids="alpha"/);', 'assert.match(graphHtml, /data-source-relation-ids="link"/);', 'assert.match(graphHtml, /Step 1 of 2/);', diff --git a/src/react/__tests__/player-layout.browser.test.tsx b/src/react/__tests__/player-layout.browser.test.tsx new file mode 100644 index 00000000..64d63d3e --- /dev/null +++ b/src/react/__tests__/player-layout.browser.test.tsx @@ -0,0 +1,143 @@ +import { expect, it } from "vitest"; +import { page, userEvent } from "vitest/browser"; +import { render } from "vitest-browser-react"; +import { compileArtifact } from "../../v2/compiler.js"; +import { layoutGraph, layoutGraphView } from "../../v2/graph-layout.js"; +import { inspectTrace } from "../../v2/inspector.js"; +import { projectView } from "../../v2/views.js"; +import { distributedGraph } from "../../__tests__/v2-graph-fixture.js"; +import { ThroughlineGraphPlayer } from "../graph-player.js"; +import "../../styles/throughline.css"; + +const trace = () => compileArtifact(distributedGraph()); + +it("uses the compact player layout, not the legacy player composition", async () => { + const screen = await render(); + const shell = screen.getByRole("group", { name: "Visualization player" }).element(); + for (const name of [ + ".player-header", ".context-bar", ".view-tabs", ".player-content", + ".canvas", ".canvas-meta", ".graph-wrap", ".canvas-hint", ".zoom-tools", + ".transport", ".transport-buttons", ".transport-meta", ".step-caption", + ]) expect(shell.querySelector(name)).not.toBeNull(); + expect(shell.querySelector(".thl-v2-mode")).toBeNull(); + expect(shell.querySelector(".thl-bottom")).toBeNull(); + expect((shell.querySelector(".step-caption") as HTMLDetailsElement).open).toBe(false); + await expect.element(screen.getByRole("tab", { name: "Graph" })).toHaveAttribute("aria-selected", "true"); + await screen.getByText("Details", { exact: true }).click(); + expect((shell.querySelector(".step-caption") as HTMLDetailsElement).open).toBe(true); + await screen.getByRole("tab", { name: "State" }).click(); + await expect.element(screen.getByRole("region", { name: "State and event table" })).toBeVisible(); + await screen.getByRole("tab", { name: "Sequence" }).click(); + await expect.element(screen.getByRole("region", { name: "Message sequence evidence" })).toBeVisible(); +}); + +it("keeps the source palette, unchanged graph card dimensions and real authored frame", async () => { + const screen = await render(); + const shell = screen.getByRole("group", { name: "Visualization player" }).element(); + expect(shell.classList.contains("player-shell")).toBe(true); + const css = getComputedStyle(shell); + expect(css.getPropertyValue("--thl-active").trim()).not.toBe(""); + const node = shell.querySelector(".thl-v2-diagram [data-node] .thl-node")!; + expect(node).not.toBeNull(); + expect(Number(node.getAttribute("height"))).toBe(74); + expect(Number(node.getAttribute("width"))).toBe(188); + await screen.getByRole("button", { name: "Step forward" }).click(); + await expect.element(screen.getByRole("status")).toHaveTextContent("Step 2 of 7"); + expect(shell.querySelector(".canvas-meta")?.textContent).toContain("FRAME 01"); + expect(shell.querySelectorAll("[data-source-event-ids]").length).toBeGreaterThan(0); +}); + +it("keeps a 60% inspector overlay, full-width mobile coverage and a single reading scroll", async () => { + await page.viewport(1200, 900); + const compiled = trace(); + const screen = await render(); + const shell = screen.getByRole("group", { name: "Visualization player" }).element(); + const canvas = shell.querySelector(".canvas")!; + const svg = shell.querySelector(".thl-v2-diagram")!; + for (const width of [900, 768, 600, 560, 375, 260]) { + shell.style.width = width + "px"; + await expect.poll(() => Math.round(shell.getBoundingClientRect().width)).toBe(width); + await expect.poll(() => Number(svg.getAttribute("viewBox")?.split(" ")[2])) + .toBe(layoutGraph(compiled, canvas.clientWidth).width); + const originalCanvasWidth = canvas.clientWidth; + const originalViewBox = svg.getAttribute("viewBox"); + const originalNode = shell.querySelector('[data-node="client"]')?.getAttribute("transform"); + await screen.getByRole("button", { name: "Inspect", exact: true }).click(); + const inspector = screen.getByRole("complementary", { name: "Entity inspector" }); + await expect.element(inspector).toBeVisible(); + const panel = inspector.element(); + const panelRect = panel.getBoundingClientRect(); + const playerRect = shell.getBoundingClientRect(); + const contentRect = shell.querySelector(".player-content")!.getBoundingClientRect(); + const expectedWidth = width <= 560 ? playerRect.width - 2 : Math.min(contentRect.width * .6, 768); + expect(Math.abs(panelRect.width - expectedWidth)).toBeLessThanOrEqual(3); + expect(Math.abs(panelRect.right - playerRect.right)).toBeLessThanOrEqual(3); + // The overlay replaces the visualization surface while the header and + // playback controls remain accessible for stepping through evidence. + expect(Math.abs(panelRect.top - contentRect.top)).toBeLessThanOrEqual(3); + expect(Math.abs(panelRect.bottom - contentRect.bottom)).toBeLessThanOrEqual(3); + expect(getComputedStyle(panel).overflowY).toBe("auto"); + expect(canvas.clientWidth).toBe(originalCanvasWidth); + expect(svg.getAttribute("viewBox")).toBe(originalViewBox); + expect(shell.querySelector('[data-node="client"]')?.getAttribute("transform")).toBe(originalNode); + expect(shell.scrollWidth).toBeLessThanOrEqual(shell.clientWidth + 2); + await screen.getByText("CAUSAL EVIDENCE", { exact: true }).click(); + const evidence = panel.querySelector(".thl-v2-inspect")!; + expect(evidence).not.toBeNull(); + expect(getComputedStyle(evidence).overflowY).toBe("visible"); + expect(getComputedStyle(evidence).maxHeight).toBe("none"); + const close = screen.getByRole("button", { name: "Close inspector" }); + panel.scrollTop = panel.scrollHeight; + await expect.poll(() => close.element().getBoundingClientRect().top - + panel.getBoundingClientRect().top).toBeGreaterThanOrEqual(0); + await close.click(); + } + await screen.getByRole("button", { name: "Player options" }).click(); + await expect.element(screen.getByRole("group", { name: "Player options" })).toBeVisible(); + const toStep = screen.getByRole("spinbutton", { name: "Go to step" }); + await toStep.fill("3"); + await screen.getByRole("button", { name: "Go", exact: true }).click(); + await expect.element(screen.getByRole("status")).toHaveTextContent("Step 3 of 7"); + shell.focus(); + await userEvent.keyboard("{Home}"); + await expect.element(screen.getByRole("status")).toHaveTextContent("Step 1 of 7"); +}); + +it("keeps authored node positions, original edge routes and semantic highlighting at changing host widths", async () => { + const compiled = trace(); + const inspector = inspectTrace(compiled); + const screen = await render(); + const player = screen.getByRole("group", { name: "Visualization player" }).element(); + const canvas = player.querySelector(".canvas")!; + const node = player.querySelector('[data-node="client"]')!; + const link = player.querySelector('.thl-v2-diagram [data-source-relation-ids="request"]')!; + expect(node).not.toBeNull(); + expect(link).not.toBeNull(); + const compareAuthoredGeometry = () => { + const layout = layoutGraph(compiled, Math.floor(canvas.clientWidth)); + const view = projectView(inspector, { kind: "graph", frameIndex: 0 }); + const geometry = layoutGraphView(layout, view); + const entity = view.items.find(item => item.role === "entity" && item.source.entityIds?.includes("client"))!; + const relation = view.items.find(item => item.role === "relation" && item.source.relationIds?.includes("request"))!; + const box = geometry.nodes[entity.id]; + return node.getAttribute("transform") === `translate(${box.x},${box.y})` + && Number(node.querySelector(".thl-node")?.getAttribute("width")) === box.w + && Number(node.querySelector(".thl-node")?.getAttribute("height")) === box.h + && link.querySelector(".thl-edge")?.getAttribute("d") === geometry.edges[relation.id]?.d; + }; + for (const width of [900, 375]) { + player.style.width = width + "px"; + await expect.poll(compareAuthoredGeometry).toBe(true); + expect(player.querySelectorAll(".thl-v2-diagram .entity")).toHaveLength(0); + expect(node.querySelector("circle")).toBeNull(); + expect(node.querySelector(".thl-v2-change")).toBeNull(); + const path = link.querySelector(".thl-edge")!; + expect(Number.parseFloat(getComputedStyle(path).strokeWidth)).toBeCloseTo(1.3); + } + await screen.getByRole("button", { name: "Step forward" }).click(); + await expect.element(screen.getByRole("status")).toHaveTextContent("Step 2 of 7"); + const activePath = link.querySelector(".thl-edge")!; + expect(link.classList.contains("thl-transferred")).toBe(true); + expect(Number.parseFloat(getComputedStyle(activePath).strokeWidth)).toBeCloseTo(2.5); + expect(activePath.getAttribute("stroke-dasharray")).toBeNull(); +}); diff --git a/src/react/__tests__/reference-v2.browser.test.tsx b/src/react/__tests__/reference-v2.browser.test.tsx index 2cad5b8c..c03515d9 100644 --- a/src/react/__tests__/reference-v2.browser.test.tsx +++ b/src/react/__tests__/reference-v2.browser.test.tsx @@ -35,7 +35,9 @@ it("shows exact checkout message phases and persistence evidence as the user ste ); const region = screen.getByRole("region", { name: "Message sequence evidence", exact: true }); await expect.element(region).toBeVisible(); - const next = screen.getByRole("button", { name: "Step forward" }); + await screen.getByRole("button", { name: "Inspect", exact: true }).click(); + await screen.getByText("CAUSAL EVIDENCE", { exact: true }).click(); + const next = screen.getByRole("button", { name: "Step forward" }); let frame = 0; const advanceTo = async (stepId: string) => { const target = trace.frames.findIndex(item => item.id === stepId); diff --git a/src/react/__tests__/release-v2-accessibility.browser.test.tsx b/src/react/__tests__/release-v2-accessibility.browser.test.tsx index 10f864ca..4dc7e4d2 100644 --- a/src/react/__tests__/release-v2-accessibility.browser.test.tsx +++ b/src/react/__tests__/release-v2-accessibility.browser.test.tsx @@ -56,20 +56,20 @@ it("preserves labeled timeline navigation, explicit evidence and inspect control await screen.getByRole("button", { name: "Player options" }).click(); await expect.element(screen.getByRole("group", { name: "Player options" })).toBeVisible(); - const choice = screen.getByRole("combobox", { name: "Visualization view" }); - await userEvent.selectOptions(choice.element(), "state-table"); + await screen.getByRole("button", { name: "Player options" }).click(); + await screen.getByRole("tab", { name: "State" }).click(); await expect.element(screen.getByRole("region", { name: "State and event table" })) .toBeVisible(); expect(document.querySelector(".thl-v2-state")?.textContent ?? document.querySelector(".thl-v2-table")?.textContent ?? document.body.textContent).toContain("Modeled call stack"); - await screen.getByRole("button", { name: "Player options" }).click(); await screen.getByRole("button", { name: "Inspect", exact: true }).click(); - await expect.element(screen.getByRole("region", { name: "Evidence inspector" })) + await screen.getByText("CAUSAL EVIDENCE", { exact: true }).click(); + await expect.element(screen.getByRole("region", { name: "Evidence inspector" })) .toBeVisible(); expect(element.scrollWidth).toBeLessThanOrEqual(element.clientWidth + 2); - // Audio is opt-in; no source fixture enables narration or sonification. - expect(document.querySelectorAll('button[aria-label="Sonify trace"]')).toHaveLength(0); + // The prototype's optional sound control is only mounted in Options. + expect(document.querySelectorAll('button[aria-label="Sonify trace"]')).toHaveLength(0); expect(document.querySelectorAll('button[aria-label="Narrate captions"]')).toHaveLength(0); }, 30_000); @@ -89,10 +89,7 @@ it("keeps original source IDs and a readable state equivalent when views switch" if (correlation) { expect(correlation.textContent).not.toContain("acknowledged: 1"); } - await screen.getByRole("button", { name: "Player options" }).click(); - await userEvent.selectOptions(screen.getByRole("combobox", { - name: "Visualization view", - }).element(), "state-table"); + await screen.getByRole("tab", { name: "State" }).click(); await expect.element(screen.getByRole("region", { name: "State and event table" })) .toBeVisible(); expect(trace.frames[1].eventIds).toEqual( diff --git a/src/react/__tests__/v2-graph.browser.test.tsx b/src/react/__tests__/v2-graph.browser.test.tsx index e701d0d3..981829db 100644 --- a/src/react/__tests__/v2-graph.browser.test.tsx +++ b/src/react/__tests__/v2-graph.browser.test.tsx @@ -7,6 +7,15 @@ import { ThroughlineGraphPlayer } from "../graph-player.js"; import "../../styles/throughline.css"; const trace = () => compileArtifact(distributedGraph()); +async function collapseGroup(screen: Awaited>, id: string) { + const options = screen.getByRole("button", { name: "Player options" }); + if (options.element().getAttribute("aria-expanded") !== "true") await options.click(); + await userEvent.selectOptions( + screen.getByRole("combobox", { name: "Drill into group" }).element(), id); + await screen.getByRole("button", { name: "Collapse group" }).click(); + await screen.getByRole("button", { name: "Player options" }).click(); +} + const currentLinks = () => [...document.querySelectorAll(".thl-v2-diagram .thl-link")]; const link = (sourceId: string): SVGGElement | undefined => @@ -36,7 +45,7 @@ it("plays a source-linked checkout without pretending received or processed mean // Truncated graph labels are not full-state evidence; inspect the // selected source entity to verify the actual persistent value. await screen.getByRole("button", { name: "Select Ledger" }).click(); - expect(document.querySelector(".thl-v2-selection pre")?.textContent) + expect(document.querySelector(".inspector dl > div:nth-child(2) code")?.textContent) .toContain('"settled":false'); await next.click(); // ledger write + processed, no second sent expect(link("settlement")?.getAttribute("data-sent-current")).toBe("0"); @@ -58,10 +67,10 @@ it("collapses and expands nested groups without losing relation/event provenance const screen = await render(); await screen.getByRole("button", { name: "Step forward" }).click(); await screen.getByRole("button", { name: "Player options" }).click(); - const choice = screen.getByRole("combobox", { name: "Select entity" }).element(); + const choice = screen.getByRole("combobox", { name: "Select entity" }).element(); await userEvent.selectOptions(choice, "gateway"); - await expect.element(screen.getByText("Selected: Gateway")).toBeVisible(); - await screen.getByRole("button", { name: "Collapse Frontend" }).click(); + expect(document.querySelector(".inspector .entity-heading")?.textContent).toContain("Gateway"); + await collapseGroup(screen, "front"); const summary = document.querySelector('[data-group-summary="front"]'); expect(summary).not.toBeNull(); expect(summary?.getAttribute("data-source-entity-ids")).toBe("client gateway"); @@ -70,13 +79,15 @@ it("collapses and expands nested groups without losing relation/event provenance expect(document.querySelector('[data-node="gateway"]')).toBeNull(); expect(link("settlement")?.getAttribute("data-source-relation-ids")).toBe("settlement"); expect(link("request")).toBeUndefined(); - // The options popover is intentionally layered over the diagram: close it - // before using the graphical group-summary button. - await screen.getByRole("button", { name: "Player options" }).click(); + // The compact inspector is a drawer at narrow embed widths, and + // intentionally overlays graph hit targets. Close it before using the + // graphical group-summary button; selection must survive reopening. + await screen.getByRole("button", { name: "Close inspector" }).click(); await screen.getByRole("button", { name: "Expand group Frontend" }).click(); expect(document.querySelector('[data-node="gateway"]')).not.toBeNull(); expect(link("request")?.getAttribute("data-sent-current")).toBe("1"); - await expect.element(screen.getByText("Selected: Gateway")).toBeVisible(); + await screen.getByRole("button", { name: "Inspect", exact: true }).click(); + expect(document.querySelector(".inspector .entity-heading")?.textContent).toContain("Gateway"); }); it("paints parent panels first for valid child-before-parent group declarations", async () => { @@ -105,17 +116,14 @@ it("paints parent panels first for valid child-before-parent group declarations" expect(Number(child.getAttribute("y"))).toBeGreaterThan( Number(root.getAttribute("y")), ); - await screen.getByRole("button", { name: "Player options" }).click(); - await screen.getByRole("button", { name: "Collapse Backend" }).click(); + await collapseGroup(screen, "back"); expect(groupPanels()).toEqual(["system", "back", "front"]); expect(document.querySelector('[data-group-summary="back"]')).not.toBeNull(); }); it("retains source IDs of removed members in a collapsed graphical group summary", async () => { const screen = await render(); - await screen.getByRole("button", { name: "Player options" }).click(); - await screen.getByRole("button", { name: "Collapse Backend" }).click(); - await screen.getByRole("button", { name: "Player options" }).click(); + await collapseGroup(screen, "back"); for (let index = 0; index < 6; index++) await screen.getByRole("button", { name: "Step forward" }).click(); await expect.element(screen.getByRole("status")).toHaveTextContent("Step 7 of 7"); @@ -134,16 +142,21 @@ it("announces declared non-authored origins without upgrading modeled event evid const screen = await render(); for (let index = 0; index < 4; index++) await screen.getByRole("button", { name: "Step forward" }).click(); - const evidence = screen.getByRole("list", { name: "Declared step evidence" }); - await expect.element(evidence).toBeVisible(); - await expect.element(screen.getByText(/Declared origin witness \(observed\)/)).toBeVisible(); - expect(evidence.element().textContent).toContain("provenance is not independent verification"); - expect(evidence.element().textContent).not.toContain("Authored presence"); + + await screen.getByText("Details", { exact: true }).click(); + const evidence = screen.getByRole("list", { name: "Declared step evidence" }); + await expect.element(evidence).toBeVisible(); + expect(evidence.element().textContent).toContain("witness (observed)"); + expect(evidence.element().textContent).toContain("provenance is not independent verification"); + expect(evidence.element().textContent).not.toContain("Authored presence"); }); it("supports keyboard stepping, zoom and pan independently of v2 model state", async () => { const screen = await render(); - await expect.poll(() => viewBox()[2]).toBeLessThan(720); + // ResizeObserver updates the authored graph geometry after the initial + // 720px SSR fallback. Record the fit viewport only after measurement. + await expect.poll(() => viewBox()[2]).toBe( + Math.floor(document.querySelector(".canvas")!.getBoundingClientRect().width)); const start = viewBox(); const svg = document.querySelector(".thl-v2-diagram")!; svg.focus(); @@ -162,24 +175,16 @@ it("supports keyboard stepping, zoom and pan independently of v2 model state", a it("presents a truthful table fallback and source-linked values without changing frame state", async () => { const screen = await render(); - await screen.getByRole("button", { name: "Player options" }).click(); - await userEvent.selectOptions( - screen.getByRole("combobox", { name: "Visualization view" }).element(), - "state-table", - ); + await screen.getByRole("tab", { name: "State" }).click(); await expect.element(screen.getByRole("region", { name: "State and event table" })).toBeVisible(); expect(document.querySelector(".thl-v2-diagram")).toBeNull(); - await expect.element(screen.getByText("Unknown: not measured")).toBeVisible(); + expect(document.querySelector(".state-view")?.textContent).toContain("Unknown: not measured"); await screen.getByRole("button", { name: "Step forward" }).click(); await expect.element(screen.getByRole("status")).toHaveTextContent("Step 2 of 7"); expect(document.querySelector('[data-source-event-ids="sent"]')).not.toBeNull(); // Clicking outside the native popover dismisses it; reopen the options // for a view change, as an actual user would. - await screen.getByRole("button", { name: "Player options" }).click(); - await userEvent.selectOptions( - screen.getByRole("combobox", { name: "Visualization view" }).element(), - "graph", - ); + await screen.getByRole("tab", { name: "Graph" }).click(); expect(link("request")?.getAttribute("data-sent-current")).toBe("1"); }); @@ -187,12 +192,11 @@ it("fits a mobile host and safely resets presentation on trace replacement", asy await page.viewport(375, 800); const original = trace(); const screen = await render(); - await expect.poll(() => viewBox()[2]).toBeLessThan(720); + await expect.poll(() => viewBox()[2]).toBeGreaterThan(0); const container = document.querySelector(".thl-v2")!; expect(container.scrollWidth).toBeLessThanOrEqual(container.clientWidth); await screen.getByRole("button", { name: "Step forward" }).click(); - await screen.getByRole("button", { name: "Player options" }).click(); - await screen.getByRole("button", { name: "Collapse Frontend" }).click(); + await collapseGroup(screen, "front"); const next = distributedGraph(); next.steps = []; next.claims = []; diff --git a/src/react/__tests__/v2-inspect.browser.test.tsx b/src/react/__tests__/v2-inspect.browser.test.tsx index 69476bcc..38034930 100644 --- a/src/react/__tests__/v2-inspect.browser.test.tsx +++ b/src/react/__tests__/v2-inspect.browser.test.tsx @@ -11,20 +11,25 @@ import "../../styles/throughline.css"; const view = () => document.querySelector(".thl-v2-inspect"); const exact = (text: string) => ({ name: text, exact: true } as const); const checkout = () => compileArtifact(distributedGraph()); +async function openInspector(screen: Awaited>) { + await screen.getByRole("button", exact("Inspect")).click(); + await screen.getByText("CAUSAL EVIDENCE", { exact: true }).click(); +} -it("uses shared playback frame for Explain and Inspect, including precise explicit changes", async () => { + +it("uses shared playback frame for canvas and inspector, including precise explicit changes", async () => { const screen = await render(); await expect.element(screen.getByRole("img", { name: "Source-linked graph at current frame" })).toBeVisible(); for (let i = 0; i < 3; i++) await screen.getByRole("button", { name: "Step forward" }).click(); await expect.element(screen.getByRole("status")).toHaveTextContent("Step 4 of 7"); - await screen.getByRole("button", exact("Inspect")).click(); + await openInspector(screen); await expect.element(screen.getByRole("region", { name: "Evidence inspector" })) .toBeVisible(); await expect.element(screen.getByRole("region", { name: "What changed?" })) .toBeVisible(); - expect(document.querySelector(".thl-v2-diagram")).toBeNull(); + expect(document.querySelector(".thl-v2-diagram")).not.toBeNull(); expect(view()?.textContent).toContain("Explicit modeled write"); expect(document.querySelector('tr[data-source-event-ids="settled"]')).not.toBeNull(); expect(document.querySelector('tr[data-source-event-ids="processed"]')).toBeNull(); @@ -32,7 +37,7 @@ it("uses shared playback frame for Explain and Inspect, including precise explic await screen.getByRole("button", { name: "Step back" }).click(); await expect.element(screen.getByRole("status")).toHaveTextContent("Step 3 of 7"); expect(view()?.textContent).toContain("No explicit write or presence change"); - await screen.getByRole("button", exact("Explain")).click(); + await screen.getByRole("button", { name: "Close inspector" }).click(); await expect.element(screen.getByRole("img", { name: "Source-linked graph at current frame" })).toBeVisible(); await expect.element(screen.getByRole("status")).toHaveTextContent("Step 3 of 7"); @@ -49,7 +54,7 @@ it("shows unknown, absent and known-null path results and original parent-write }], }); const screen = await render(); - await screen.getByRole("button", exact("Inspect")).click(); + await openInspector(screen); await userEvent.selectOptions( screen.getByRole("combobox", { name: "Inspect entity" }).element(), "gateway", ); @@ -86,7 +91,7 @@ it("shows unknown, absent and known-null path results and original parent-write it("keeps message phase evidence separate from persistence while investigating a relation", async () => { const screen = await render(); await screen.getByRole("button", { name: "Step forward" }).click(); - await screen.getByRole("button", exact("Inspect")).click(); + await openInspector(screen); await expect.element(screen.getByRole("region", { name: "Where did this message go?" })) .toBeVisible(); expect(document.querySelector('[data-source-event-ids="originalSent"]')).not.toBeNull(); @@ -115,7 +120,7 @@ it("guides through exact declared dependencies and non-proof editorial claims", const screen = await render(); await screen.getByRole("button", { name: "Step forward" }).click(); - await screen.getByRole("button", exact("Inspect")).click(); + await openInspector(screen); await expect.element(screen.getByRole("region", { name: "Focused source event" })) .toBeVisible(); const focus = document.querySelector(".thl-v2-inspect-focus")!; @@ -144,7 +149,7 @@ it("responds to keyboard seeking at mobile widths with truthful empty evidence", source.claims = []; const screen = await render(); - await screen.getByRole("button", exact("Inspect")).click(); + await openInspector(screen); const root = document.querySelector(".thl-v2")!; await expect.element(screen.getByRole("region", { name: "Evidence inspector" })) .toBeVisible(); @@ -152,7 +157,7 @@ it("responds to keyboard seeking at mobile widths with truthful empty evidence", expect(view()?.textContent).toContain("No explicit write or presence change"); expect(view()?.textContent).toContain("No events are authored in this frame"); expect(view()?.textContent).toContain("There is no explicit causal evidence to evaluate"); - await screen.getByRole("button", exact("Explain")).click(); + await screen.getByRole("button", { name: "Close inspector" }).click(); await expect.element(screen.getByRole("region", { name: "State and event table" })) .toBeVisible(); expect(root.scrollWidth).toBeLessThanOrEqual(root.clientWidth); @@ -175,7 +180,7 @@ it("shows exact before/after values after a shared 150-character preview", async const screen = await render(); await screen.getByRole("button", { name: "Step forward" }).click(); - await screen.getByRole("button", exact("Inspect")).click(); + await openInspector(screen); const table = screen.getByRole("table", { name: "Authored changes, in frame/event order" }); await expect.element(table).toBeVisible(); const row = table.getByRole("row", { name: /longWrite/ }); @@ -220,7 +225,7 @@ it("exposes the recorded timeout observation while leaving modeled client state const screen = await render(); for (let i = 0; i < 3; i++) await screen.getByRole("button", { name: "Step forward" }).click(); - await screen.getByRole("button", exact("Inspect")).click(); + await openInspector(screen); const source = screen.getByRole("region", { name: "Recorded source data for event watchTimeout", }); @@ -251,7 +256,7 @@ it("reveals optional authored message payload, escaped as data, without claiming }; const screen = await render(); await screen.getByRole("button", { name: "Step forward" }).click(); - await screen.getByRole("button", exact("Inspect")).click(); + await openInspector(screen); const recorded = screen.getByRole("region", { name: "Recorded source data for event originalSent", }); @@ -278,7 +283,7 @@ it("bounds 1,000 claims × 100 cited events with independent page windows and so screen.getByRole("group", { name: "Visualization player" }).element().focus(); await userEvent.keyboard("{End}"); await expect.element(screen.getByRole("status")).toHaveTextContent("Step 101 of 101"); - await screen.getByRole("button", exact("Inspect")).click(); + await openInspector(screen); const focused = screen.getByRole("region", { name: "Focused source event" }); await expect.element(focused).toBeVisible(); expect(focused.element().textContent).toContain("Editorial claims (1000)"); diff --git a/src/react/__tests__/v2-sequence.browser.test.tsx b/src/react/__tests__/v2-sequence.browser.test.tsx index e40e02b3..03a62e5d 100644 --- a/src/react/__tests__/v2-sequence.browser.test.tsx +++ b/src/react/__tests__/v2-sequence.browser.test.tsx @@ -16,25 +16,25 @@ const correlation = (messageId: string): HTMLLIElement | null => const phase = (messageId: string, name: string): string | undefined => correlation(messageId)?.querySelector('[data-phase="' + name + '"]')?.textContent?.trim(); +async function openEvidence(screen: Awaited>) { + const trigger = screen.getByRole("button", { name: "Inspect", exact: true }); + if (trigger.element().getAttribute("aria-pressed") !== "true") await trigger.click(); + const details = document.querySelector(".evidence-note"); + if (details && !details.open) + await screen.getByText("CAUSAL EVIDENCE", { exact: true }).click(); +} async function openSequence(screen: Awaited>) { - await screen.getByRole("button", { name: "Player options" }).click(); - await userEvent.selectOptions( - screen.getByRole("combobox", { name: "Visualization view" }).element(), - "sequence", - ); - await screen.getByRole("button", { name: "Player options" }).click(); - await expect.element(screen.getByRole("region", { name: "Message sequence evidence" })) - .toBeVisible(); + await screen.getByRole("tab", { name: "Sequence" }).click(); + await openEvidence(screen); + await expect.element(screen.getByRole("region", { name: "Message sequence evidence" })) + .toBeVisible(); } it("uses artifact hint priority and automatic message choice on initial render", async () => { const screen = await render(); await expect.element(screen.getByRole("region", { name: "Message sequence evidence" })) .toBeVisible(); - await screen.getByRole("button", { name: "Player options" }).click(); - expect((screen.getByRole("combobox", { name: "Visualization view" }).element() as HTMLSelectElement).value) - .toBe("sequence"); - await screen.getByRole("button", { name: "Player options" }).click(); + await expect.element(screen.getByRole("tab", { name: "Sequence" })).toHaveAttribute("aria-selected", "true"); const preferred = retryCheckout(); preferred.views = [ @@ -45,18 +45,12 @@ it("uses artifact hint priority and automatic message choice on initial render", await screen.rerender(); await expect.element(screen.getByRole("region", { name: "State and event table" })) .toBeVisible(); - await screen.getByRole("button", { name: "Player options" }).click(); - const selector = screen.getByRole("combobox", { name: "Visualization view" }); - expect((selector.element() as HTMLSelectElement).value).toBe("state-table"); - await userEvent.selectOptions(selector.element(), "graph"); // manual choice wins - await screen.getByRole("button", { name: "Player options" }).click(); - await expect.element(screen.getByRole("img", - { name: "Source-linked graph at current frame" })).toBeVisible(); - await screen.getByRole("button", { name: "Step forward" }).click(); - await expect.element(screen.getByRole("status")).toHaveTextContent("Step 2 of 10"); - await screen.getByRole("button", { name: "Player options" }).click(); - expect((selector.element() as HTMLSelectElement).value).toBe("graph"); // seek never resets manual choice - await screen.getByRole("button", { name: "Player options" }).click(); + await expect.element(screen.getByRole("tab", { name: "State" })).toHaveAttribute("aria-selected", "true"); + await screen.getByRole("tab", { name: "Graph" }).click(); // manual choice wins + await expect.element(screen.getByRole("img", { name: "Source-linked graph at current frame" })).toBeVisible(); + await screen.getByRole("button", { name: "Step forward" }).click(); + await expect.element(screen.getByRole("status")).toHaveTextContent("Step 2 of 10"); + await expect.element(screen.getByRole("tab", { name: "Graph" })).toHaveAttribute("aria-selected", "true"); const tied = retryCheckout(); tied.views = [ @@ -68,8 +62,7 @@ it("uses artifact hint priority and automatic message choice on initial render", await expect.element(screen.getByRole("region", { name: "Message sequence evidence" })) .toBeVisible(); await expect.element(screen.getByRole("status")).toHaveTextContent("Step 1 of 10"); - await screen.getByRole("button", { name: "Player options" }).click(); - expect((selector.element() as HTMLSelectElement).value).toBe("sequence"); + await expect.element(screen.getByRole("tab", { name: "Sequence" })).toHaveAttribute("aria-selected", "true"); }); it("does not flag receipt before send within the same atomic step", async () => { @@ -87,7 +80,8 @@ it("does not flag receipt before send within the same atomic step", async () => ); await screen.getByRole("button", { name: "Step forward" }).click(); await expect.element(screen.getByRole("status")).toHaveTextContent("Step 2 of 2"); - expect(evidence("receipt")?.getAttribute("data-message-phase")).toBe("received"); + await openEvidence(screen); + expect(evidence("receipt")?.getAttribute("data-message-phase")).toBe("received"); expect(evidence("receipt")?.textContent).not.toContain("No sent modeled through this step"); expect(phase("sameStep", "sent")).toBe("sent: 1"); expect(phase("sameStep", "received")).toBe("received: 1"); @@ -98,7 +92,8 @@ it("does not flag receipt before send within the same atomic step", async () => it("shows modeled phases through seeking, no future or imagined acknowledgement", async () => { const screen = await render(); await openSequence(screen); - await expect.element(screen.getByText("No modeled events through this frame.")).toBeVisible(); + await expect.element(screen.getByRole("region", { name: "Sequence lane diagram" }) + .getByText("No modeled events through this frame.")).toBeVisible(); expect(evidence("originalSent")).toBeNull(); const next = screen.getByRole("button", { name: "Step forward" }); await next.click(); @@ -172,30 +167,26 @@ it("preserves frame and source identity switching graph → sequence → graph", await next.click(); await expect.element(screen.getByRole("status")).toHaveTextContent("Step 3 of 10"); await screen.getByRole("button", { name: "Select Gateway" }).click(); - await expect.element(screen.getByText("Selected: Gateway")).toBeVisible(); + expect(document.querySelector(".inspector .entity-heading")?.textContent).toContain("Gateway"); await openSequence(screen); await expect.element(screen.getByRole("status")).toHaveTextContent("Step 3 of 10"); - expect(document.querySelector('.thl-v2-sequence-actors [data-source-entity-ids="gateway"]') + expect(document.querySelector('.sequence-head [data-source-entity-ids="gateway"]') ?.getAttribute("aria-pressed")).toBe("true"); - await screen.getByRole("button", { name: /Client \(present at frame\)/ }).click(); - await expect.element(screen.getByText("Selected: Client")).toBeVisible(); - await screen.getByRole("button", { name: "Player options" }).click(); - await userEvent.selectOptions( - screen.getByRole("combobox", { name: "Visualization view" }).element(), - "graph", - ); + // The responsive inspector intentionally overlays source lanes. Close it + // before selecting another lane, then verify the new selection reopens it. + await screen.getByRole("button", { name: "Close inspector" }).click(); + await screen.getByRole("button", { name: "Inspect Client" }).click(); + expect(document.querySelector(".inspector .entity-heading")?.textContent).toContain("Client"); + await screen.getByRole("tab", { name: "Graph" }).click(); await expect.element(screen.getByRole("status")).toHaveTextContent("Step 3 of 10"); expect(document.querySelector('[data-node="client"]')?.getAttribute("aria-pressed")) .toBe("true"); expect(document.querySelector('[data-node="gateway"]')?.getAttribute("aria-pressed")) .toBe("false"); - await userEvent.selectOptions( - screen.getByRole("combobox", { name: "Visualization view" }).element(), - "state-table", - ); + await screen.getByRole("tab", { name: "State" }).click(); await expect.element(screen.getByRole("region", { name: "State and event table" })) .toBeVisible(); - await expect.element(screen.getByText("Selected: Client")).toBeVisible(); + expect(document.querySelector(".inspector .entity-heading")?.textContent).toContain("Client"); }); it("works at mobile width and retains chronological source rows", async () => { @@ -230,6 +221,7 @@ it("mounts at most 120 correlation cards for hundreds of distinct message IDs", screen.getByRole("group", { name: "Visualization player" }).element().focus(); await userEvent.keyboard("{End}"); await expect.element(screen.getByRole("status")).toHaveTextContent("Step 361 of 361"); + await openEvidence(screen); const cards = () => document.querySelectorAll( ".thl-v2-sequence-correlations li[data-message-id]"); expect(cards()).toHaveLength(120); @@ -278,7 +270,8 @@ it("progressively reveals earlier rows without losing source evidence", async () expect(evidence("event0")).toBeNull(); expect(evidence("event159")).not.toBeNull(); expect(phase("batch", "sent")).toBe("sent: 160"); - await screen.getByRole("button", { name: "Show earlier evidence" }).click(); + await screen.getByRole("region", { name: "Sequence evidence timeline" }) + .getByRole("button", { name: "Show earlier evidence" }).click(); expect(rows()).toHaveLength(160); expect(evidence("event0")).not.toBeNull(); expect(evidence("event159")).not.toBeNull(); diff --git a/src/react/graph-player.tsx b/src/react/graph-player.tsx index 954f83a9..cd30219d 100644 --- a/src/react/graph-player.tsx +++ b/src/react/graph-player.tsx @@ -13,11 +13,13 @@ import type { Cell, CompiledTrace, Id, ViewDescriptor, ViewItem, ViewKind, } from "../v2/model.js"; import { projectView } from "../v2/views.js"; -import { PlayerControls, PlayerOptions } from "./controls.js"; +import { PlayerControls, PlayerOptions } from "./player-chrome.js"; import { useNarration } from "./use-narration.js"; import { usePlayer, useSceneWidth } from "./use-player.js"; import { SequenceView } from "./sequence-view.js"; +import { SequenceEvidence } from "./sequence-evidence.js"; import { InspectPanel } from "./inspect-panel.js"; +import { PlayerIcon } from "./player-icons.js"; export type ThroughlineGraphPlayerProps = { /** Only a compiler-owned, immutable schema-2 trace is accepted. */ @@ -212,30 +214,39 @@ function GraphDiagram({ ); } -/** Inert fallback; full source-linked history inspector UI is TL-U07. */ -function StateFallback({ view, selectedId, onSelect }: { - view: ViewDescriptor; selectedId: Id | null; onSelect: (id: Id) => void; +function StateFallback({ view, selectedId, onSelect, inspector, frameIndex }: { + view: ViewDescriptor; + selectedId: Id | null; + onSelect: (id: Id) => void; + inspector: ReturnType; + frameIndex: number; }): React.JSX.Element { - return ( -
- {view.diagnostics?.map(diagnostic => -

{diagnostic}

)} - - - - {view.items.filter(item => item.role === "value").map(item => { - const id = item.source.entityIds?.[0] ?? ""; - const cell = itemCell(item); - return - - - - ; - })} -
Modeled state at {view.frameId}
EntityPresenceValue
{data(item, "present") ? "Present" : "Not present"}{cell ? cellText(cell) : "Unknown"}
-
- ); + const rows = view.items.filter(item => item.role === "value"); + const changed = new Set(inspector.diff(Math.max(0, frameIndex - 1), frameIndex) + .flatMap(change => change.kind === "write" ? [change.entityId] : [])); + return
+ {view.diagnostics?.map(message =>

{message}

)} + + {rows.map(item => { + const id = item.source.entityIds?.[0] ?? ""; + const present = data(item, "present") === true; + const cell = itemCell(item); + const history = inspector.history(id); + const latest = history.filter(entry => entry.frameIndex <= frameIndex).at(-1); + const origin = latest?.originId ?? (present ? "initial" : "not present"); + return ; + })} +
; } /** @@ -262,6 +273,11 @@ export function ThroughlineGraphPlayer({ const [collapsed, setCollapsed] = useState([]); const [viewKind, setViewKind] = useState(initialView); const [inspectionMode, setInspectionMode] = useState<"explain" | "inspect">("explain"); + const [drilled, setDrilled] = useState(null); + const [follow, setFollow] = useState(false); + const [soundOn, setSoundOn] = useState(false); + const [soundAvailable, setSoundAvailable] = useState(false); + const audioRef = useRef(null); const [camera, setCamera] = useState(null); const [fullscreen, setFullscreen] = useState(false); // Capability detection is client-only. SSR and the first hydration render @@ -275,7 +291,10 @@ export function ThroughlineGraphPlayer({ setCamera(null); setViewKind(initialView); setInspectionMode("explain"); - setNarrating(false); + setDrilled(null); + setFollow(false); + setSoundOn(false); + setNarrating(false); } useEffect(() => { if (!narration) setNarrating(false); @@ -293,14 +312,36 @@ export function ThroughlineGraphPlayer({ // Never send the former trace's higher frame index into a new, shorter // immutable inspector while React completes that state transition. const frameIndex = Math.min(state.step, trace.frames.length - 1); - const layout = useMemo(() => layoutGraph(trace, width), [trace, width]); +// Use the unchanged authored graph layout, including container-dependent + // geometry, rather than the reference design's fixed demo coordinates. + const layout = useMemo(() => layoutGraph(trace, width), [trace, width]); const view = useMemo(() => projectView(inspector, { kind: viewKind, frameIndex, selectedEntityIds: selectedId ? [selectedId] : [], collapsedGroupIds: collapsed, }), [inspector, frameIndex, viewKind, selectedId, collapsed]); const geometry = useMemo(() => layoutGraphView(layout, view), [layout, view]); - const effectiveCamera = constrainCamera(layout, camera ?? fitCamera(layout)); + // Only authored focusEntityIds can drive automatic camera following. + const focusIds = frameIndex ? trace.artifact.steps[frameIndex - 1].focusEntityIds ?? [] : []; + const focusRects = focusIds.map(id => { + const item = view.items.find(candidate => candidate.role === "entity" && + candidate.source.entityIds?.includes(id)); + return item ? geometry.nodes[item.id] : undefined; + }).filter((rect): rect is { x: number; y: number; w: number; h: number } => rect !== undefined); + const focusLeft = focusRects.length ? Math.min(...focusRects.map(rect => rect.x)) : 0; + const focusRight = focusRects.length ? Math.max(...focusRects.map(rect => rect.x + rect.w)) : 0; + const focusTop = focusRects.length ? Math.min(...focusRects.map(rect => rect.y)) : 0; + const focusBottom = focusRects.length ? Math.max(...focusRects.map(rect => rect.y + rect.h)) : 0; + const followedCamera: Camera | null = focusRects.length ? { + centerX: (focusLeft + focusRight) / 2, + centerY: (focusTop + focusBottom) / 2, + zoom: Math.max(1, Math.min(2.4, 0.8 * Math.min( + layout.width / Math.max(1, focusRight - focusLeft), + layout.height / Math.max(1, focusBottom - focusTop), + ))), + } : null; + const effectiveCamera = constrainCamera(layout, + follow && followedCamera ? followedCamera : camera ?? fitCamera(layout)); const presentEntities = new Set(inspector.stateAt(frameIndex).presentEntityIds); const selected = selectedId ? trace.artifact.entities.find(entity => entity.id === selectedId) @@ -337,7 +378,7 @@ export function ThroughlineGraphPlayer({ } return present; }, [firstSent, frameIndex, trace]); - const manual = (next: Camera) => setCamera(constrainCamera(layout, next)); + const manual = (next: Camera) => { setFollow(false); setCamera(constrainCamera(layout, next)); }; const fit = () => manual(fitCamera(layout)); const zoom = (factor: number) => manual(zoomCamera(layout, effectiveCamera, factor)); const pan = (dx: number, dy: number) => manual(panCamera(layout, effectiveCamera, dx, dy)); @@ -375,167 +416,302 @@ export function ThroughlineGraphPlayer({ setFullscreenError("Fullscreen is unavailable in this browser or embedded view."); } }; - const controls = ( - <> - - - {(trace.artifact.groups ?? []).map(group => - )} - - ); - const keyboardDiagram: React.KeyboardEventHandler = (event) => { - if (event.target !== event.currentTarget) return; - const key = event.key; - if (key === "+" || key === "=") zoom(1.25); - else if (key === "-") zoom(1 / 1.25); - else if (key === "0") fit(); - else if (key === "ArrowLeft") pan(-30, 0); - else if (key === "ArrowRight") pan(30, 0); - else if (key === "ArrowUp") pan(0, -30); - else if (key === "ArrowDown") pan(0, 30); - else return; - event.preventDefault(); - event.stopPropagation(); - }; - const helpId = useId(); - const captionId = useId(); - return ( -
-

- Focus this player to seek with Left and Right arrows, Home and End, - and play or pause with Space. Focus the graph to pan with arrows, - zoom with plus or minus, or fit with zero. -

-

{summary}

- {voice.error && narration &&

{voice.error}

} - {fullscreenError &&

{fullscreenError}

} -
-

{title ?? trace.artifact.title ?? "Throughline"}

- -
+ + // Audio is optional, native, and instantiated only after an explicit click. + useEffect(() => { + setSoundAvailable(typeof window.AudioContext === "function"); + return () => { + const audio = audioRef.current; + audioRef.current = null; + if (audio) void audio.close().catch(() => {}); + }; + }, []); + const toggleSound = () => { + if (soundOn) { setSoundOn(false); return; } + const Ctx = window.AudioContext; + if (!Ctx) return; + audioRef.current ??= new Ctx(); + void audioRef.current.resume().catch(() => {}); + setSoundOn(true); + }; + useEffect(() => { + if (!soundOn || !audioRef.current) return; + const audio = audioRef.current; + try { + const oscillator = audio.createOscillator(); + const gain = audio.createGain(); + const now = audio.currentTime; + oscillator.frequency.value = 220 * Math.pow(2, frameIndex / Math.max(1, state.max) * 1.5); + gain.gain.setValueAtTime(0.0001, now); + gain.gain.exponentialRampToValueAtTime(0.06, now + 0.02); + gain.gain.exponentialRampToValueAtTime(0.0001, now + 0.3); + oscillator.connect(gain); + gain.connect(audio.destination); + oscillator.start(); + oscillator.stop(now + 0.32); + } catch { /* audio is optional */ } + }, [frameIndex, soundOn, state.max]); -
- - -
-
-
- {inspectionMode === "explain" && view.kind === "graph" &&
- - - -
} -
- - {inspectionMode === "inspect" ? - dispatch({ type: "step", to })} /> - : view.kind === "graph" ? { - if (event.button !== 0) return; - // Source selection and collapse controls own their pointer - // sequence. Capturing it on the SVG would steal their click. - if ((event.target as Element).closest( - '[data-node], [data-group-summary]')) return; - dragging.current = { pointerId: event.pointerId, - x: event.clientX, y: event.clientY }; - event.currentTarget.setPointerCapture(event.pointerId); - }} - onPointerMove={event => { - const start = dragging.current; - if (!start || start.pointerId !== event.pointerId) return; - const bounds = event.currentTarget.getBoundingClientRect(); - const worldX = effectiveCamera.zoom > 0 - ? (layout.width / effectiveCamera.zoom) / Math.max(bounds.width, 1) : 1; - const worldY = effectiveCamera.zoom > 0 - ? (layout.height / effectiveCamera.zoom) / Math.max(bounds.height, 1) : 1; - pan((event.clientX - start.x) * worldX, - (event.clientY - start.y) * worldY); - dragging.current = { ...start, x: event.clientX, y: event.clientY }; - }} - onPointerUp={() => { dragging.current = null; }} - onPointerCancel={() => { dragging.current = null; }}> - {title ?? trace.artifact.title ?? "Throughline graph"} - {view.summary} - setCollapsed(current => - current.filter(item => item !== id))} - visitedAt={firstSent} participants={participants} animate={motion.animate} /> - : view.kind === "sequence" - ? - : } -
-
-
- -
-
- {step?.label ?? "Initial state"} — Step {frameIndex + 1}/{trace.frames.length} -

{step?.note ?? view.summary}

- {events.length > 0 &&
    - {events.slice(0, 80).map(item => -
  1. - {item.description} -
  2. )} - {events.length > 80 &&
  3. - {events.length - 80} additional declared event(s); use the typed inspector to query all sources. -
  4. } -
} -
- {selected &&
-

Selected: {selected.label}

-

{presentEntities.has(selected.id) ? "Present in modeled state at this frame" : - "Not present in modeled state at this frame; no presence is inferred."}

-
{selectedValue && selectedValue.status === "known"
-						? cellText(selectedValue) : selectedValue?.status === "unknown"
-							? "Unknown" + (selectedValue.reason ? ": " + selectedValue.reason : "")
-							: "Absent"}
-
} -
-
- ); + const entityFieldId = useId(); + const groupFieldId = useId(); + const helpId = useId(); + const captionId = useId(); + const currentEvent = step?.events[0]; + const eventType = !step ? "initial" : currentEvent?.type ?? "no event"; + const hasWrite = step?.events.some(event => event.type === "write") ?? false; + const origins = [...new Set(trace.artifact.origins.map(origin => origin.kind))].join(" + "); + const inspectSelected = selected; + const inspectValue = inspectSelected ? inspector.valueAt(frameIndex, inspectSelected.id) : null; + const inspectPresent = inspectSelected ? presentEntities.has(inspectSelected.id) : false; + const inspectHistory = inspectSelected + ? inspector.history(inspectSelected.id).filter(entry => entry.frameIndex <= frameIndex) + : []; + const onSelectEntity = (id: Id) => { setSelectedId(id); setInspectionMode("inspect"); }; + // Selecting authored elements must never rewrite or reframe their graph + // geometry. Zoom/pan/follow are only explicit camera controls. + const focusEntity = (id: Id) => onSelectEntity(id); + const focusGroup = (id: Id | null) => setDrilled(id); + const diagramControls = <> +
+ + + + + +
+
+ + +
+ + ; + const keyboardDiagram: React.KeyboardEventHandler = event => { + if (event.target !== event.currentTarget) return; + const key = event.key; + if (key === "+" || key === "=") zoom(1.25); + else if (key === "-") zoom(1 / 1.25); + else if (key === "0") fit(); + else if (key === "ArrowLeft") pan(-30, 0); + else if (key === "ArrowRight") pan(30, 0); + else if (key === "ArrowUp") pan(0, -30); + else if (key === "ArrowDown") pan(0, 30); + else return; + event.preventDefault(); + event.stopPropagation(); + }; + return
+

Focus this player to seek with Left and Right arrows, Home and End, + and play or pause with Space. Focus the graph to pan with arrows, zoom with plus or minus, or fit with zero.

+

{summary}

+ {voice.error && narration &&

{voice.error}

} + {fullscreenError &&

{fullscreenError}

} +
+
+

{title ?? trace.artifact.title ?? "Throughline"}

+
+
+ + { + setInspectionMode(current => current === "inspect" ? "explain" : "inspect"); + } }} + sound={{ enabled: soundOn, available: soundAvailable, toggle: toggleSound }} + narration={narration ? { enabled: narrating, available: voice.available, toggle: voice.toggle } : undefined} + fullscreen={{ active: fullscreen, available: fullscreenAvailable, toggle: toggleFullscreen }}/> +
+
+
+
+ {([["Graph", "graph"], ["Sequence", "sequence"], ["State", "state-table"]] as const) + .map(([label, kind]) => )} +
+
SOURCE {origins} frame #{frameIndex}
+
+
+
+
+ FRAME {String(frameIndex).padStart(2, "0")} + {step?.label ?? "Initial state"} + {eventType} +
+ {view.kind === "graph" ? +
+ { + if (event.button !== 0) return; + if ((event.target as Element).closest('[data-node], [data-group-summary]')) return; + dragging.current = { pointerId: event.pointerId, x: event.clientX, y: event.clientY }; + event.currentTarget.setPointerCapture(event.pointerId); + }} + onPointerMove={event => { + const start = dragging.current; + if (!start || start.pointerId !== event.pointerId) return; + const bounds = event.currentTarget.getBoundingClientRect(); + const worldX = effectiveCamera.zoom > 0 + ? (layout.width / effectiveCamera.zoom) / Math.max(bounds.width, 1) : 1; + const worldY = effectiveCamera.zoom > 0 + ? (layout.height / effectiveCamera.zoom) / Math.max(bounds.height, 1) : 1; + pan((event.clientX - start.x) * worldX, (event.clientY - start.y) * worldY); + dragging.current = { ...start, x: event.clientX, y: event.clientY }; + }} + onPointerUp={() => { dragging.current = null; }} + onPointerCancel={() => { dragging.current = null; }}> + {title ?? trace.artifact.title ?? "Throughline graph"} + {view.summary} + setCollapsed(current => current.filter(item => item !== id))} + visitedAt={firstSent} participants={participants} animate={motion.animate}/> + +
+ Drag to pan · scroll to zoom · click a node to inspect +
+ + {Math.round(effectiveCamera.zoom * 100)}% + + +
+
+
: view.kind === "sequence" + ? + : } +
+ {inspectionMode === "inspect" && } +
+
+
+ + {String(frameIndex + 1).padStart(2, "0")} + + {step?.label ?? "Initial state"} + {step?.note ?? view.summary} + + {eventType} + Details + +
+

{step?.note ?? view.summary}

+ {step && step.events.length > 0 &&
    + {step.events.slice(0, 80).map(event =>
  • + {event.type === "message" ? event.phase : event.type} → + {event.id} + {events.find(item => + item.source.eventIds?.includes(event.id))?.description ?? ""} +
  • )} + {step.events.length > 80 &&
  • {step.events.length - 80} more events; inspect source for details.
  • } +
} +
+ Inspect state +
{trace.artifact.entities.map(entity => { + const present = presentEntities.has(entity.id); + const value = present ? inspector.valueAt(frameIndex, entity.id) : null; + return
+
{entity.label} ({entity.id})
+
{!present ? "Absent" : value?.status === "known" ? cellText(value) + : value?.status === "unknown" ? cellText(value) : "Absent"}
+
; + })}
+
+
+
+
; } diff --git a/src/react/player-chrome.tsx b/src/react/player-chrome.tsx new file mode 100644 index 00000000..9e63faa8 --- /dev/null +++ b/src/react/player-chrome.tsx @@ -0,0 +1,170 @@ +import { useEffect, useId, useRef, useState } from "react"; +import type * as React from "react"; +import { type SeekAction, type SeekState, SPEEDS, type Speed } from "../seek.js"; +import { PlayerIcon } from "./player-icons.js"; + +interface PlaybackProps { + state: SeekState; + dispatch: React.Dispatch; +} +interface PlayerOptionsProps extends PlaybackProps { + scenario: { id: string; title: string }; + chapterControls?: (onSeek: (step: number) => void) => React.ReactNode; + diagramControls?: React.ReactNode; + sound?: { enabled: boolean; available?: boolean; toggle: () => void }; + narration?: { enabled: boolean; available: boolean; toggle: () => void }; + inspection?: { enabled: boolean; toggle: () => void }; + fullscreen: { active: boolean; available: boolean; toggle: () => void }; +} + +/** Compact player transport, backed by Throughline's single reducer. */ +export function PlayerControls({ state, dispatch }: PlaybackProps): React.JSX.Element { + return <> +
+ + + +
+
+ + {state.step + 1} / {state.max + 1} + + +
+ ; +} + +/** + * Anchored, dismissible player options. All content is native + * Throughline state; it does not import the demo's scenarios or chapters. + */ +export function PlayerOptions({ + state, dispatch, scenario, chapterControls, diagramControls, sound, narration, inspection, fullscreen, +}: PlayerOptionsProps): React.JSX.Element { + const id = useId(); + const [open, setOpen] = useState(false); + const menuRef = useRef(null); + const triggerRef = useRef(null); + const stepRef = useRef(null); + useEffect(() => { + if (!open) return; + if (stepRef.current) stepRef.current.value = String(state.step + 1); + const onPointer = (event: MouseEvent) => { + if (!menuRef.current?.contains(event.target as Node)) setOpen(false); + }; + const onKey = (event: KeyboardEvent) => { + if (event.key === "Escape") { setOpen(false); triggerRef.current?.focus(); } + }; + document.addEventListener("mousedown", onPointer); + document.addEventListener("keydown", onKey); + return () => { + document.removeEventListener("mousedown", onPointer); + document.removeEventListener("keydown", onKey); + }; + }, [open, state.step]); + const seek = (to: number) => { dispatch({ type: "step", to }); setOpen(false); }; + return
+ + {open &&
+
+

Navigation

+
+ + + + + +
+ {chapterControls ? chapterControls(seek) :
+
+ + + + + +
+ +
} + {state.max > 0 &&
{ + event.preventDefault(); + const value = Number(new FormData(event.currentTarget).get("step")); + if (Number.isInteger(value) && value >= 1 && value <= state.max + 1) + seek(value - 1); + }}> +
+ + +
+ +
} +
+ {diagramControls &&
+

Diagram

+
{diagramControls}
+
} +
+

Playback and display

+
+ {SPEEDS.map(speed => )} +
+
+ {sound && } + {narration && } + {inspection && } + +
+
+
} +
; +} diff --git a/src/react/player-icons.tsx b/src/react/player-icons.tsx new file mode 100644 index 00000000..618c0f1d --- /dev/null +++ b/src/react/player-icons.tsx @@ -0,0 +1,106 @@ +import type * as React from "react"; + +/** Player icon paths used throughout the player chrome. */ +export type IconName = + | "back" + | "check" + | "chevron" + | "expand" + | "shrink" + | "focus" + | "forward" + | "home" + | "inspect" + | "minus" + | "narrate" + | "options" + | "pause" + | "play" + | "plus" + | "restart" + | "sound" + | "soundOff" + | "collapse" + | "uncollapse" + | "fit"; + +const SPEEDS = [0.5, 1, 2] as const; +const BASE_STEP_MS = 1500; +const MIN_ZOOM = 0.6; +const MAX_ZOOM = 4; + +const ICONS: Record = { + back: ( + <> + + + + ), + forward: ( + <> + + + + ), + play: , + pause: ( + <> + + + + ), + sound: ( + <> + + + + ), + soundOff: ( + <> + + + + ), + narrate: ( + <> + + + + ), + expand: , + shrink: , + inspect: ( + <> + + + + + ), + chevron: , + options: , + plus: , + minus: , + fit: , + focus: ( + <> + + + + ), + restart: , + home: , + collapse: , + uncollapse: , + check: , +}; + +export function PlayerIcon({ name, size = 16 }: { name: IconName; size?: number }) { + return ( + + ); +} + diff --git a/src/react/sequence-evidence.tsx b/src/react/sequence-evidence.tsx new file mode 100644 index 00000000..03357430 --- /dev/null +++ b/src/react/sequence-evidence.tsx @@ -0,0 +1,177 @@ +import { useState } from "react"; +import type * as React from "react"; +import type { Id, ViewDescriptor, ViewItem } from "../v2/model.js"; + +/** Inert renderer: uses only pure view descriptors, never the trace or a v1 adapter. */ +function field(item: ViewItem, key: string): unknown { + const value = item.data; + if (!value || typeof value !== "object" || Array.isArray(value)) return undefined; + return (value as Record)[key]; +} +function text(value: unknown): string { + return typeof value === "string" ? value : ""; +} +function phaseCount(value: unknown, key: string): number { + if (!value || typeof value !== "object" || Array.isArray(value)) return 0; + const n = (value as Record)[key]; + return typeof n === "number" && Number.isSafeInteger(n) ? n : 0; +} + +const PAGE_SIZE = 120; + +/** + * Detailed source evidence, preserved under the prototype inspector disclosure. + * Accessible timeline of ALL modeled message evidence through the selected + * frame; independent bounded tails of message-ID summaries and event rows + * are mounted. All correlation totals/source IDs remain in the full pure + * descriptor and are reachable via explicit progressive disclosure. + * Hiding DOM rows never changes source truth or the projection. + */ +export function SequenceEvidence({ + view, selectedId, onSelect, +}: { + view: ViewDescriptor; + selectedId: Id | null; + onSelect: (id: Id) => void; +}): React.JSX.Element { + const [maxVisible, setMaxVisible] = useState(PAGE_SIZE); + const [correlationPage, setCorrelationPage] = useState(0); + const actors = view.items.filter(item => item.role === "entity"); + const correlations = view.items.filter(item => + item.role === "value" && field(item, "type") === "message-correlation"); + const evidence = view.items.filter(item => item.role === "event"); + const start = Math.max(0, evidence.length - maxVisible); + const mounted = evidence.slice(start); + // Fixed 120-item window, even after arbitrary navigation. Page zero + // shows the newest message IDs; earlier/later pages retain full source + // provenance without ever accumulating an unbounded DOM. + const totalPages = Math.max(1, Math.ceil(correlations.length / PAGE_SIZE)); + const pageIndex = Math.min(correlationPage, totalPages - 1); + const correlationEnd = Math.max(0, correlations.length - pageIndex * PAGE_SIZE); + const correlationStart = Math.max(0, correlationEnd - PAGE_SIZE); + const mountedCorrelations = correlations.slice(correlationStart, correlationEnd); + const actorNames = new Map(actors.map(item => [item.id, item.label])); + const phases = ["sent", "received", "acknowledged", "processed"] as const; + return ( +
+

{view.summary}

+

+ Events follow modeled step and event order, not verified network time. + No unrecorded send, receipt, acknowledgement, retry, timeout or state change is inferred. +

+
+ {actors.length ? actors.map(item => { + const id = item.source.entityIds?.[0] ?? ""; + const present = field(item, "present") === true; + return ; + }) :

No message endpoints have been modeled through this frame.

} +
+ {correlations.length > 0 &&
+

Messages by declared ID

+

Only explicitly modeled phases are counted. An unmodeled + acknowledgement is not proof that one was lost.

+

Showing {mountedCorrelations.length} of {correlations.length} + {" "}message ID(s), page {pageIndex + 1} of {totalPages}. + All source-linked summaries can be reached without increasing the DOM window.

+
+ + +
+
    {mountedCorrelations.map(item => { + const counts = field(item, "phases"); + return
  • + {item.label} + + {phases.map(phase => + {phase}: {phaseCount(counts, phase) || "not modeled"} + )} + +
    + Correlation and evidence limits +

    {item.description}

    +
    +
  • ; + })}
+
} +
+

Declared event timeline

+

{evidence.length === 0 ? "No modeled events through this frame." : + "Showing " + mounted.length + " of " + evidence.length + + " explicit event(s); older rows can be revealed below."}

+ {evidence.length > mounted.length && } + {mounted.length > 0 && + + + + + + + + + + {mounted.map(item => { + const type = text(field(item, "type")); + const message = type === "message"; + const from = item.fromItemId && actorNames.get(item.fromItemId); + const to = item.toItemId && actorNames.get(item.toItemId); + const current = field(item, "current") === true; + const missingSent = field(item, "missingSentThroughStep") === true; + return + + + + + + + ; + })} +
Source-linked evidence up to {view.frameId}. + Message phases and independent state/observation events remain distinct.
StepEventMessage IDDeclared relationPhase / evidence typeDeclared origin
{text(field(item, "frameId"))} +
{item.label} +

{item.description}

+
+
{message ? {text(field(item, "messageId"))} : "—"}{message ? <> + {from ?? text(field(item, "fromEntityId"))} + {" — "} + {to ?? text(field(item, "toEntityId"))} + : "Not a message"}{message ? <> + {text(field(item, "phase"))} + {missingSent && + No sent modeled through this step + } + : type + " (not a message phase)"}{text(field(item, "originId"))} + {" (" + text(field(item, "originKind")) + ")"}
} +
+
+ ); +} diff --git a/src/react/sequence-view.tsx b/src/react/sequence-view.tsx index a5d7a6c8..402d787e 100644 --- a/src/react/sequence-view.tsx +++ b/src/react/sequence-view.tsx @@ -2,175 +2,104 @@ import { useState } from "react"; import type * as React from "react"; import type { Id, ViewDescriptor, ViewItem } from "../v2/model.js"; -/** Inert renderer: uses only pure view descriptors, never the trace or a v1 adapter. */ function field(item: ViewItem, key: string): unknown { - const value = item.data; - if (!value || typeof value !== "object" || Array.isArray(value)) return undefined; - return (value as Record)[key]; + const value = item.data; + return value && typeof value === "object" && !Array.isArray(value) + ? (value as Record)[key] : undefined; } -function text(value: unknown): string { - return typeof value === "string" ? value : ""; -} -function phaseCount(value: unknown, key: string): number { - if (!value || typeof value !== "object" || Array.isArray(value)) return 0; - const n = (value as Record)[key]; - return typeof n === "number" && Number.isSafeInteger(n) ? n : 0; -} - -const PAGE_SIZE = 120; +const PAGE = 120; /** - * Accessible timeline of ALL modeled message evidence through the selected - * frame; independent bounded tails of message-ID summaries and event rows - * are mounted. All correlation totals/source IDs remain in the full pure - * descriptor and are reachable via explicit progressive disclosure. - * Hiding DOM rows never changes source truth or the projection. + * The dynamic lane visualization, driven only by the schema-2 sequence + * projection. Lane identities and events are never hardcoded to the demo. + * The order is modeled step/event order, not inferred physical chronology. */ export function SequenceView({ - view, selectedId, onSelect, + view, selectedId, onSelect, }: { - view: ViewDescriptor; - selectedId: Id | null; - onSelect: (id: Id) => void; + view: ViewDescriptor; + selectedId: Id | null; + onSelect: (id: Id) => void; }): React.JSX.Element { - const [maxVisible, setMaxVisible] = useState(PAGE_SIZE); - const [correlationPage, setCorrelationPage] = useState(0); - const actors = view.items.filter(item => item.role === "entity"); - const correlations = view.items.filter(item => - item.role === "value" && field(item, "type") === "message-correlation"); - const evidence = view.items.filter(item => item.role === "event"); - const start = Math.max(0, evidence.length - maxVisible); - const mounted = evidence.slice(start); - // Fixed 120-item window, even after arbitrary navigation. Page zero - // shows the newest message IDs; earlier/later pages retain full source - // provenance without ever accumulating an unbounded DOM. - const totalPages = Math.max(1, Math.ceil(correlations.length / PAGE_SIZE)); - const pageIndex = Math.min(correlationPage, totalPages - 1); - const correlationEnd = Math.max(0, correlations.length - pageIndex * PAGE_SIZE); - const correlationStart = Math.max(0, correlationEnd - PAGE_SIZE); - const mountedCorrelations = correlations.slice(correlationStart, correlationEnd); - const actorNames = new Map(actors.map(item => [item.id, item.label])); - const phases = ["sent", "received", "acknowledged", "processed"] as const; - return ( -
-

{view.summary}

-

- Events follow modeled step and event order, not verified network time. - No unrecorded send, receipt, acknowledgement, retry, timeout or state change is inferred. -

-
- {actors.length ? actors.map(item => { - const id = item.source.entityIds?.[0] ?? ""; - const present = field(item, "present") === true; - return ; - }) :

No message endpoints have been modeled through this frame.

} -
- {correlations.length > 0 &&
-

Messages by declared ID

-

Only explicitly modeled phases are counted. An unmodeled - acknowledgement is not proof that one was lost.

-

Showing {mountedCorrelations.length} of {correlations.length} - {" "}message ID(s), page {pageIndex + 1} of {totalPages}. - All source-linked summaries can be reached without increasing the DOM window.

-
- - -
-
    {mountedCorrelations.map(item => { - const counts = field(item, "phases"); - return
  • - {item.label} - - {phases.map(phase => - {phase}: {phaseCount(counts, phase) || "not modeled"} - )} - -
    - Correlation and evidence limits -

    {item.description}

    -
    -
  • ; - })}
-
} -
-

Declared event timeline

-

{evidence.length === 0 ? "No modeled events through this frame." : - "Showing " + mounted.length + " of " + evidence.length + - " explicit event(s); older rows can be revealed below."}

- {evidence.length > mounted.length && } - {mounted.length > 0 && - - - - - - - - - - {mounted.map(item => { - const type = text(field(item, "type")); - const message = type === "message"; - const from = item.fromItemId && actorNames.get(item.fromItemId); - const to = item.toItemId && actorNames.get(item.toItemId); - const current = field(item, "current") === true; - const missingSent = field(item, "missingSentThroughStep") === true; - return - - - - - - - ; - })} -
Source-linked evidence up to {view.frameId}. - Message phases and independent state/observation events remain distinct.
StepEventMessage IDDeclared relationPhase / evidence typeDeclared origin
{text(field(item, "frameId"))} -
{item.label} -

{item.description}

-
-
{message ? {text(field(item, "messageId"))} : "—"}{message ? <> - {from ?? text(field(item, "fromEntityId"))} - {" — "} - {to ?? text(field(item, "toEntityId"))} - : "Not a message"}{message ? <> - {text(field(item, "phase"))} - {missingSent && - No sent modeled through this step - } - : type + " (not a message phase)"}{text(field(item, "originId"))} - {" (" + text(field(item, "originKind")) + ")"}
} -
-
- ); + const [maxVisible, setMaxVisible] = useState(PAGE); + const actors = view.items.filter(item => item.role === "entity"); + const events = view.items.filter(item => item.role === "event"); + const start = Math.max(0, events.length - maxVisible); + const visible = events.slice(start); + const last = events.at(-1); + const current = last && field(last, "current") === true; + const lanes = Math.max(1, actors.length); + const columns = "repeat(" + lanes + ",minmax(0,1fr))"; + const minWidth = Math.max(300, actors.length * 105); + return
+

{view.summary} Events are in declared order, not physical time.

+
+
+
+ {actors.length ? actors.map(actor => { + const id = actor.source.entityIds?.[0] ?? ""; + return + + ; + }) : No declared message endpoints} +
+
+ +
    + {visible.map((item, offset) => { + const type = field(item, "type"); + const message = type === "message"; + const from = actors.findIndex(actor => actor.id === item.fromItemId); + const to = actors.findIndex(actor => actor.id === item.toItemId); + const connected = message && from >= 0 && to >= 0; + const self = from === to; + const direction = to > from ? "right" : "left"; + const state = field(item, "current") === true ? "current" : "past"; + const lo = Math.min(from, to), hi = Math.max(from, to); + const startCol = self ? lo + 1 : lo + 1; + const endCol = self ? startCol + 1 : hi + 2; + const phase = field(item, "phase"); + return
  1. + {connected ? + + {String(start + offset + 1).padStart(2, "0")} + {item.label} + + + : + {String(start + offset + 1).padStart(2, "0")} + {item.label} + } +
  2. ; + })} +
+ {events.length === 0 &&

No modeled events through this frame.

} +
+
+
+
+ {last ? (current ? "NOW" : "LATEST") : "NO EVENTS YET"} + {last &&

{last.label}

} + {events.length > visible.length && } +
+
; } diff --git a/src/styles/throughline.css b/src/styles/throughline.css index e31b9276..c049429a 100644 --- a/src/styles/throughline.css +++ b/src/styles/throughline.css @@ -1156,3 +1156,1643 @@ border-bottom: 1px solid var(--thl-line); padding-block: 0.5rem; } + +/* Player layout; palette intentionally comes from --thl-* above. */ +.thl.player-shell{ + position: relative; + background: color-mix(in srgb, var(--thl-panel) 97%, transparent); + border: 1px solid var(--thl-line); + border-radius: var(--radius); + box-shadow: + 0 32px 90px rgba(0, 0, 0, 0.55), + 0 0 0 1px color-mix(in srgb, var(--thl-text) 2%, transparent) inset; + overflow: hidden; + min-width: 0; +}.thl.player-shell:fullscreen{ + width: 100vw; + height: 100vh; + display: flex; + flex-direction: column; + background: var(--thl-bg); +}.thl.player-shell:fullscreen .player-content{ + flex: 1; +}.thl.player-shell:fullscreen .canvas{ + min-height: 0; +}.thl.player-shell .player-header{ + height: 40px; + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 8px 0 14px; + border-bottom: 1px solid var(--line); + background: var(--thl-panel); +}.thl.player-shell .title-block, +.thl.player-shell .header-actions, +.thl.player-shell .title-block > div:last-child{ + display: flex; + align-items: center; +}.thl.player-shell .title-block{ + gap: 11px; + min-width: 0; +}.thl.player-shell .title-block > div:last-child{ + display: block; + min-width: 0; +}.thl.player-shell .engine-mark{ + width: 27px; + height: 27px; + display: grid; + place-items: center; + color: var(--thl-bg); + background: var(--acid); + border-radius: var(--radius); + box-shadow: 0 0 20px color-mix(in srgb, var(--thl-active) 12%, transparent); +}.thl.player-shell .title-block h1{ + margin: 0; + font-size: 14px; + line-height: 1.2; + letter-spacing: -0.01em; + font-weight: 600; +}.thl.player-shell .title-block p{ + margin: 4px 0 0; + color: var(--muted); + font: + 400 10px/1 "IBM Plex Mono", + monospace; +}.thl.player-shell .title-block p span{ + color: var(--acid); +}.thl.player-shell .header-actions{ + gap: 5px; +}.thl.player-shell .header-actions button{ + height: 26px; + min-width: 26px; + padding: 0 8px; + display: inline-flex; + justify-content: center; + align-items: center; + gap: 7px; + border: 1px solid transparent; + border-radius: var(--radius); + background: transparent; + color: var(--thl-muted); + font-size: 11px; + cursor: pointer; +}.thl.player-shell .header-actions button:hover, +.thl.player-shell .header-actions button.active{ + color: var(--ink); + background: var(--thl-surface); + border-color: var(--thl-line); +}.thl.player-shell .compiled-status{ + margin-right: 7px; + color: var(--thl-muted); + font: + 500 9px/1 "IBM Plex Mono", + monospace; + letter-spacing: 0.08em; +}.thl.player-shell .compiled-status i{ + display: inline-block; + width: 5px; + height: 5px; + margin-right: 5px; + border-radius: 50%; + background: var(--acid); + box-shadow: 0 0 8px var(--acid); +}.thl.player-shell .context-bar{ + min-height: 28px; + padding: 0 14px 0 18px; + display: flex; + align-items: center; + justify-content: space-between; + border-bottom: 1px solid var(--line); + background: var(--thl-bg); +}.thl.player-shell .view-tabs{ + align-self: stretch; + display: flex; + gap: 2px; +}.thl.player-shell .view-tabs button{ + position: relative; + padding: 0 11px; + border: 0; + background: transparent; + color: var(--thl-muted); + font: + 500 10px/1 "IBM Plex Mono", + monospace; + cursor: pointer; +}.thl.player-shell .view-tabs button:hover{ + color: var(--thl-text); +}.thl.player-shell .view-tabs button.active{ + color: var(--ink); +}.thl.player-shell .view-tabs button.active::after{ + content: ""; + position: absolute; + left: 10px; + right: 10px; + bottom: -1px; + height: 1px; + background: var(--acid); +}.thl.player-shell .truth-note{ + color: var(--thl-muted); + font: + 400 9px/1 "IBM Plex Mono", + monospace; +}.thl.player-shell .truth-note span{ + color: var(--thl-muted); +}.thl.player-shell .truth-note i{ + display: inline-block; + width: 2px; + height: 2px; + margin: 0 7px 2px; + background: var(--thl-muted); +}.thl.player-shell .player-content{ + position: relative; + display: grid; + grid-template-columns: minmax(0, 1fr); + min-height: 330px; +}.thl.player-shell .player-content.with-inspector{ + /* Inspector overlays the unchanged canvas, so opening it never causes + authored graph layout to recalculate for a narrower viewport. */ + grid-template-columns: minmax(0, 1fr); +}.thl.player-shell .canvas{ + min-width: 0; + min-height: 330px; + position: relative; + background: var(--thl-bg); + overflow: hidden; +}.thl.player-shell .canvas::before{ + content: ""; + position: absolute; + inset: 0; + pointer-events: none; + opacity: 0.25; + background-image: radial-gradient(var(--thl-line) 0.6px, transparent 0.6px); + background-size: 15px 15px; +}.thl.player-shell .canvas-meta{ + position: absolute; + top: 10px; + left: 14px; + right: 14px; + z-index: 2; + display: flex; + align-items: center; + gap: 8px; + font: + 500 9px/1 "IBM Plex Mono", + monospace; +}.thl.player-shell .canvas-meta span{ + color: var(--thl-muted); +}.thl.player-shell .canvas-meta strong{ + color: var(--thl-muted); + font-weight: 500; +}.thl.player-shell .canvas-meta code{ + margin-left: auto; + color: var(--acid); + font-size: 9px; +}.thl.player-shell .graph-wrap{ + position: absolute; + inset: 30px 0 0; +}.thl.player-shell .graph{ + width: 100%; + height: calc(100% - 20px); + overflow: visible; + } +.thl.player-shell .canvas-hint{ + position: absolute; + left: 14px; + right: 14px; + bottom: 8px; + display: flex; + justify-content: space-between; + color: var(--thl-muted); + font: + 400 8px/1 "IBM Plex Mono", + monospace; +}.thl.player-shell .sequence-view, +.thl.player-shell .state-view{ + position: absolute; + inset: 43px 14px 14px; +}.thl.player-shell .sequence-view{ + overflow: hidden; +}.thl.player-shell .sequence-head{ + height: 31px; + display: grid; + grid-template-columns: repeat(4, 1fr); + border: 1px solid var(--line); +}.thl.player-shell .sequence-head span{ + display: grid; + place-items: center; + color: var(--thl-muted); + border-right: 1px solid var(--line); + font: + 500 9px "IBM Plex Mono", + monospace; +}.thl.player-shell .sequence-head span:last-child{ + border: 0; +}.thl.player-shell .lifelines{ + position: absolute; + inset: 31px 0 0; + display: grid; + grid-template-columns: repeat(4, 1fr); + pointer-events: none; +}.thl.player-shell .lifelines i{ + width: 1px; + height: 100%; + justify-self: center; + background: linear-gradient(var(--thl-line) 40%, transparent 40%); + background-size: 1px 6px; +}.thl.player-shell .sequence-list{ + position: relative; + z-index: 1; + display: grid; + gap: 5px; + padding-top: 14px; +}.thl.player-shell .sequence-event{ + min-height: 35px; + padding: 7px 10px; + display: grid; + align-items: center; + grid-template-columns: 26px minmax(160px, 1fr) minmax(160px, 1fr); + background: color-mix(in srgb, var(--thl-panel) 94%, transparent); + border: 1px solid var(--thl-line); + border-radius: var(--radius); + font-size: 10px; +}.thl.player-shell .sequence-event.current{ + border-color: var(--acid); + background: var(--thl-panel); +}.thl.player-shell .sequence-event.future{ + opacity: 0.28; +}.thl.player-shell .seq-index{ + color: var(--thl-muted); + font: + 500 9px "IBM Plex Mono", + monospace; +}.thl.player-shell .seq-route{ + color: var(--thl-muted); +}.thl.player-shell .seq-route b{ + margin: 0 7px; + color: var(--acid); + font-weight: 400; +}.thl.player-shell .sequence-event code{ + color: var(--thl-muted); + font: + 400 9px "IBM Plex Mono", + monospace; +}.thl.player-shell .sequence-event.current code{ + color: var(--acid); +}.thl.player-shell .state-view{ + border: 1px solid var(--line); + overflow: auto; + background: color-mix(in srgb, var(--thl-panel) 95%, transparent); +}.thl.player-shell .state-row{ + width: 100%; + min-height: 39px; + padding: 0 12px; + display: grid; + grid-template-columns: 1.1fr 1.2fr 2fr 1fr; + align-items: center; + border: 0; + border-bottom: 1px solid var(--line-soft); + background: transparent; + color: var(--thl-muted); + text-align: left; + font-size: 10px; +}.thl.player-shell button.state-row{ + cursor: pointer; +}.thl.player-shell button.state-row:hover{ + background: var(--thl-panel); +}.thl.player-shell .state-header{ + min-height: 30px; + color: var(--thl-muted); + background: var(--thl-panel); + font: + 500 8px "IBM Plex Mono", + monospace; + letter-spacing: 0.05em; +}.thl.player-shell .state-row strong{ + color: var(--thl-text); + font-weight: 500; +}.thl.player-shell .state-row code{ + font: + 400 9px "IBM Plex Mono", + monospace; + color: var(--thl-muted); +}.thl.player-shell .state-row.changed{ + background: var(--thl-panel); + box-shadow: 2px 0 0 var(--acid) inset; +}.thl.player-shell .state-row.changed code:nth-child(3){ + color: var(--acid); +}.thl.player-shell .state-row.future{ + opacity: 0.3; +}.thl.player-shell .inspector{ + position: absolute; + inset-block: 0; + inset-inline-end: 0; + z-index: 10; + box-sizing: border-box; + width: min(60%, 48rem); + min-width: 0; + min-height: 0; + max-height: 100%; + overflow-x: hidden; + overflow-y: auto; + overscroll-behavior: contain; + scrollbar-gutter: stable; + border-inline-start: 1px solid var(--line); + background: var(--thl-panel); + box-shadow: -18px 0 36px color-mix(in srgb, var(--thl-bg) 65%, transparent); + padding: 12px 16px 20px; +} +@keyframes thl-player-reveal { + from { + opacity: 0; + transform: none; + } +}.thl.player-shell .inspector-top{ + position: sticky; + top: 0; + z-index: 1; + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + min-height: 44px; + margin: -12px -16px 0; + padding: 5px 12px 5px 16px; + border-bottom: 1px solid var(--line); + background: var(--thl-panel); + color: var(--thl-muted); + font: + 500 8px "IBM Plex Mono", + monospace; + letter-spacing: 0.08em; +}.thl.player-shell .inspector-top button{ + display: grid; + place-items: center; + width: 40px; + height: 40px; + flex: 0 0 auto; + border: 0; + border-radius: var(--radius); + background: transparent; + color: var(--thl-text); + font-size: 20px; + line-height: 1; + cursor: pointer; +}.thl.player-shell .inspector-top button:hover{ + background: var(--thl-control-hover); +}.thl.player-shell .inspector-top button:focus-visible{ + outline: 2px solid var(--thl-focus); + outline-offset: -2px; +}.thl.player-shell .entity-heading{ + display: flex; + gap: 9px; + align-items: center; + padding: 14px 0; + border-bottom: 1px solid var(--line); +}.thl.player-shell .entity-heading > i{ + width: 7px; + height: 7px; + border-radius: 50%; + background: var(--acid); + box-shadow: 0 0 9px color-mix(in srgb, var(--thl-active) 45%, transparent); +}.thl.player-shell .entity-heading strong{ + display: block; + font-size: 12px; + font-weight: 600; +}.thl.player-shell .entity-heading code{ + display: block; + margin-top: 4px; + color: var(--thl-muted); + font: + 400 8px "IBM Plex Mono", + monospace; +}.thl.player-shell .inspector dl{ + margin: 0; + padding: 8px 0 11px; + border-bottom: 1px solid var(--line); +}.thl.player-shell .inspector dl > div{ + min-height: 27px; + display: grid; + grid-template-columns: minmax(80px, 30%) minmax(0, 1fr); + gap: 8px; + align-items: start; +}.thl.player-shell .inspector dt{ + color: var(--thl-muted); + font-size: 9px; +}.thl.player-shell .inspector dd{ + min-width: 0; + margin: 0; + color: var(--thl-text); + font: + 400 9px "IBM Plex Mono", + monospace; + white-space: normal; + overflow-wrap: anywhere; +}.thl.player-shell .inspector dd code{ + white-space: pre-wrap; + overflow-wrap: anywhere; +}.thl.player-shell .known{ + color: var(--acid); +}.thl.player-shell .history-title{ + display: flex; + align-items: center; + justify-content: space-between; + margin: 13px 0 10px; + color: var(--thl-muted); + font: + 500 8px "IBM Plex Mono", + monospace; + letter-spacing: 0.06em; +}.thl.player-shell .history-title b{ + min-width: 16px; + height: 16px; + display: grid; + place-items: center; + background: var(--thl-surface); + color: var(--thl-muted); + border-radius: var(--radius); + font-size: 8px; +}.thl.player-shell .history-item{ + display: flex; + gap: 8px; + padding-bottom: 14px; +}.thl.player-shell .history-item > i{ + flex: 0 0 auto; + width: 6px; + height: 6px; + margin-top: 4px; + background: var(--orange); + border-radius: 50%; +}.thl.player-shell .history-item strong{ + display: block; + color: var(--thl-text); + font: + 500 9px "IBM Plex Mono", + monospace; +}.thl.player-shell .history-item span{ + display: block; + margin: 4px 0 7px; + color: var(--thl-muted); + font-size: 8px; +}.thl.player-shell .history-item code{ + display: block; + padding: 7px; + background: var(--thl-bg); + color: var(--thl-muted); + font: + 400 8px/1.5 "IBM Plex Mono", + monospace; + white-space: normal; + word-break: break-all; +}.thl.player-shell .evidence-note{ + margin-top: 8px; + padding: 9px; + border-left: 1px solid var(--orange); + background: var(--thl-panel); +}.thl.player-shell .evidence-note span{ + color: var(--orange); + font: + 500 7px "IBM Plex Mono", + monospace; + letter-spacing: 0.08em; +}.thl.player-shell .evidence-note p{ + margin: 6px 0 0; + color: var(--thl-muted); + font-size: 8px; + line-height: 1.45; +}.thl.player-shell .step-caption{ + min-height: 67px; + padding: 10px 16px; + display: grid; + grid-template-columns: 32px minmax(0, 1fr) auto; + align-items: center; + gap: 10px; + border-top: 1px solid var(--line); + background: var(--thl-panel); +}.thl.player-shell .step-number{ + color: var(--acid); + font: + 500 10px "IBM Plex Mono", + monospace; +}.thl.player-shell .step-caption strong{ + display: block; + color: var(--thl-text); + font-size: 11px; + font-weight: 600; +}.thl.player-shell .step-caption p{ + margin: 4px 0 0; + color: var(--thl-muted); + font-size: 9px; + line-height: 1.35; +}.thl.player-shell .event-chip{ + padding: 5px 7px; + border: 1px solid var(--thl-line); + border-radius: var(--radius); + color: var(--acid); + background: var(--thl-surface); + font: + 500 8px "IBM Plex Mono", + monospace; +}.thl.player-shell .event-chip.write{ + color: var(--orange); + border-color: var(--thl-change); + background: var(--thl-panel); +}.thl.player-shell .transport{ + height: 46px; + padding: 0 14px; + display: grid; + grid-template-columns: auto minmax(160px, 1fr) auto; + align-items: center; + gap: 18px; + border-top: 1px solid var(--line); + background: var(--thl-bg); +}.thl.player-shell .transport-buttons{ + display: flex; + gap: 4px; +}.thl.player-shell .transport-buttons button, +.thl.player-shell .speed{ + width: 29px; + height: 29px; + display: grid; + place-items: center; + padding: 0; + border: 1px solid var(--thl-line); + border-radius: var(--radius); + background: var(--thl-panel); + color: var(--thl-muted); + cursor: pointer; +}.thl.player-shell .transport-buttons button:hover:not(:disabled), +.thl.player-shell .speed:hover{ + color: var(--ink); + border-color: var(--thl-muted); + background: var(--thl-surface); +}.thl.player-shell .transport-buttons button:disabled{ + opacity: 0.28; + cursor: default; +}.thl.player-shell .transport-buttons .play{ + width: 34px; + color: var(--thl-bg); + background: var(--acid); + border-color: var(--acid); +}.thl.player-shell .transport-buttons .play:hover{ + color: var(--thl-bg); + background: color-mix(in oklch, var(--thl-active) 83%, var(--thl-text)); + border-color: color-mix(in oklch, var(--thl-active) 83%, var(--thl-text)); +}.thl.player-shell .timeline{ + position: relative; + height: 29px; +}.thl.player-shell .timeline-line{ + position: absolute; + top: 7px; + left: 8px; + right: 8px; + height: 1px; + background: var(--thl-line); +}.thl.player-shell .timeline-progress{ + height: 1px; + background: var(--acid); + box-shadow: 0 0 5px color-mix(in srgb, var(--thl-active) 35%, transparent); +}.thl.player-shell .timeline-marks{ + height: 100%; + display: flex; + justify-content: space-between; + position: relative; +}.thl.player-shell .timeline-marks button{ + width: 17px; + padding: 0; + border: 0; + background: transparent; + color: var(--thl-muted); + cursor: pointer; + font: + 400 7px "IBM Plex Mono", + monospace; +}.thl.player-shell .timeline-marks i{ + display: block; + width: 5px; + height: 5px; + margin: 5px auto 5px; + border: 1px solid var(--thl-muted); + border-radius: 50%; + background: var(--thl-bg); +}.thl.player-shell .timeline-marks button.passed i{ + border-color: var(--acid); + background: var(--acid); +}.thl.player-shell .timeline-marks button.current i{ + width: 9px; + height: 9px; + margin-top: 3px; + margin-bottom: 3px; + box-shadow: + 0 0 0 3px color-mix(in srgb, var(--thl-active) 10%, transparent), + 0 0 8px color-mix(in srgb, var(--thl-active) 40%, transparent); +}.thl.player-shell .timeline-marks button.current{ + color: var(--thl-muted); +}.thl.player-shell .transport-meta{ + display: flex; + align-items: center; + gap: 10px; + color: var(--thl-muted); + font: + 400 9px "IBM Plex Mono", + monospace; +}.thl.player-shell .transport-meta strong{ + color: var(--thl-text); + font-weight: 500; +}.thl.player-shell .speed{ + width: 43px; + display: flex; + justify-content: center; + gap: 2px; + font: + 500 9px "IBM Plex Mono", + monospace; +}.thl.player-shell .footnote{ + margin-top: 12px; + text-align: center; + color: var(--thl-muted); + font: + 400 8px "IBM Plex Mono", + monospace; +}.thl.player-shell .footnote span{ + color: var(--thl-muted); +}.thl.player-shell .footnote i{ + display: inline-block; + width: 2px; + height: 2px; + margin: 0 8px 2px; + background: var(--thl-line); +} + +@container (max-width: 760px) {.thl.player-shell main{ + padding: 20px 10px; + place-items: start center; + }.thl.player-shell .compiled-status, +.thl.player-shell .truth-note, +.thl.player-shell .header-actions button span{ + display: none; + }.thl.player-shell .player-content{ + min-height: 310px; + }.thl.player-shell .canvas{ + min-height: 310px; + }.thl.player-shell .sequence-event{ + grid-template-columns: 22px 1fr; + }.thl.player-shell .sequence-event code{ + display: none; + }.thl.player-shell .state-row{ + grid-template-columns: 1fr 1fr 1.5fr; + }.thl.player-shell .state-row > :last-child{ + display: none; + }.thl.player-shell .transport{ + grid-template-columns: auto 1fr; + gap: 10px; + }.thl.player-shell .transport-meta{ + display: none; + }.thl.player-shell .step-caption{ + grid-template-columns: 25px 1fr; + }.thl.player-shell .event-chip{ + display: none; + } +} + +@container (max-width: 480px) {.thl.player-shell .eyebrow, +.thl.player-shell .footnote{ + display: none; + }.thl.player-shell .player-header{ + padding-left: 12px; + }.thl.player-shell .context-bar{ + padding-left: 8px; + }.thl.player-shell .player-content, +.thl.player-shell .canvas{ + min-height: 292px; + }.thl.player-shell .canvas-meta code{ + display: none; + }.thl.player-shell .step-caption p{ + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + }.thl.player-shell .transport{ + padding: 0 8px; + }.thl.player-shell .timeline-marks button span{ + display: none; + } +} + +@media (prefers-reduced-motion: reduce) {.thl.player-shell *, +.thl.player-shell *::before, +.thl.player-shell *::after{ + animation-duration: 0.01ms !important; + animation-iteration-count: 1 !important; + scroll-behavior: auto !important; + } +}.thl.player-shell .title-block h1{ + font-size: 13px; +}.thl.player-shell .view-tabs button{ + padding: 0 10px; +}.thl.player-shell .scrubber{ + -webkit-appearance: none; + appearance: none; + width: 100%; + height: 14px; + margin: 0; + background: transparent; + cursor: pointer; +}.thl.player-shell .scrubber::-webkit-slider-runnable-track{ + height: 2px; + border-radius: var(--radius); + background: linear-gradient(90deg, var(--acid) var(--p), var(--thl-line) var(--p)); +}.thl.player-shell .scrubber::-moz-range-track{ + height: 2px; + background: var(--thl-line); +}.thl.player-shell .scrubber::-moz-range-progress{ + height: 2px; + background: var(--acid); +}.thl.player-shell .scrubber::-webkit-slider-thumb{ + -webkit-appearance: none; + width: 8px; + height: 12px; + margin-top: -5px; + border-radius: var(--radius); + background: var(--ink); + border: 0; +}.thl.player-shell .scrubber::-moz-range-thumb{ + width: 8px; + height: 12px; + border-radius: var(--radius); + background: var(--ink); + border: 0; +}.thl.player-shell .sr-only{ + position: absolute; + width: 1px; + height: 1px; + margin: -1px; + overflow: hidden; + clip: rect(0 0 0 0); + white-space: nowrap; +}.thl.player-shell{ + position: relative; + overflow: visible; +}.thl.player-shell:fullscreen{ + overflow: auto; +}.thl.player-shell .narration-error{ + margin: 0; + padding: 6px 14px; + color: var(--orange); + background: var(--thl-panel); + border-bottom: 1px solid var(--thl-change); + font: 400 10px "IBM Plex Mono", monospace; +}.thl.player-shell .chapter-pill{ + margin-left: 10px; + padding: 3px 7px; + border: 1px solid var(--thl-line); + border-radius: var(--radius); + color: var(--acid); + background: var(--thl-panel); + font: 500 9px/1 "IBM Plex Mono", monospace; + white-space: nowrap; +}.thl.player-shell .title-block{ + display: flex; + align-items: center; +}.thl.player-shell .title-block h1{ + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +}.thl.player-shell .menu-anchor{ + position: relative; +}.thl.player-shell .header-actions .menu-trigger{ + gap: 6px; +}.thl.player-shell .options-menu{ + position: absolute; + z-index: 40; + top: calc(100% + 8px); + right: -2px; + width: min(318px, calc(100vw - 24px)); + max-height: min(520px, calc(100vh - 120px)); + overflow-y: auto; + padding: 4px 0; + border: 1px solid var(--thl-line); + border-radius: 4px; + background: var(--thl-panel); + box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px color-mix(in srgb, var(--thl-text) 2%, transparent) inset; + + text-align: left; +} +@keyframes thl-player-pop { + from { + opacity: 0; + transform: translateY(-4px) scale(0.985); + } +}.thl.player-shell .options-menu section{ + padding: 10px 12px 12px; + display: grid; + gap: 8px; +}.thl.player-shell .options-menu section + section{ + border-top: 1px solid var(--line); +}.thl.player-shell .opt-label{ + margin: 0; + display: flex; + align-items: center; + justify-content: space-between; + color: var(--thl-muted); + font: 500 8px/1 "IBM Plex Mono", monospace; + letter-spacing: 0.1em; + text-transform: uppercase; +}.thl.player-shell .opt-label em{ + color: var(--thl-muted); + font-style: normal; + letter-spacing: 0.04em; + text-transform: none; +}.thl.player-shell .opt-fieldset{ + min-width: 0; + margin: 0; + padding: 0; + border: 0; + display: grid; + gap: 8px; +}.thl.player-shell .opt-fieldset:disabled{ + opacity: 0.35; +}.thl.player-shell .opt-field{ + min-width: 0; + flex: 1; + display: grid; + gap: 4px; +}.thl.player-shell .opt-field label{ + color: var(--thl-muted); + font-size: 10px; +}.thl.player-shell .opt-row{ + display: flex; + align-items: flex-end; + gap: 6px; +}.thl.player-shell .opt-select{ + position: relative; + display: block; + min-width: 0; + color: var(--thl-muted); +}.thl.player-shell .opt-select.grow{ + flex: 1; +}.thl.player-shell .opt-select svg{ + position: absolute; + right: 7px; + top: 50%; + transform: translateY(-50%); + pointer-events: none; +}.thl.player-shell .options-menu select, +.thl.player-shell .options-menu input[type="number"]{ + width: 100%; + height: 28px; + padding: 0 24px 0 8px; + border: 1px solid var(--thl-line); + border-radius: var(--radius); + background: var(--thl-bg); + color: var(--thl-text); + font: 400 11px "DM Sans", sans-serif; + appearance: none; + outline: none; +}.thl.player-shell .options-menu input[type="number"]{ + padding-right: 8px; + font-family: "IBM Plex Mono", monospace; +}.thl.player-shell .options-menu select:hover, +.thl.player-shell .options-menu input:hover, +.thl.player-shell .options-menu select:focus-visible, +.thl.player-shell .options-menu input:focus-visible{ + border-color: var(--thl-muted); +}.thl.player-shell .options-menu select:disabled{ + cursor: default; +}.thl.player-shell .options-menu button{ + height: 28px; + min-width: 28px; + padding: 0 8px; + display: inline-flex; + align-items: center; + justify-content: center; + gap: 7px; + border: 1px solid var(--thl-line); + border-radius: var(--radius); + background: var(--thl-panel); + color: var(--thl-muted); + font: 500 10.5px "DM Sans", sans-serif; + cursor: pointer; + transition: 0.12s ease; +}.thl.player-shell .options-menu button:hover:not(:disabled){ + color: var(--ink); + border-color: var(--thl-muted); + background: var(--thl-surface); +}.thl.player-shell .options-menu button:disabled{ + opacity: 0.35; + cursor: default; +}.thl.player-shell .options-menu .opt-icon{ + padding: 0; + width: 28px; + flex: 0 0 auto; +}.thl.player-shell .options-menu .opt-go{ + padding: 0 12px; +}.thl.player-shell .opt-grid{ + display: grid; + grid-template-columns: 1fr 1fr; + gap: 6px; +}.thl.player-shell .options-menu .opt-toggle{ + justify-content: flex-start; + min-width: 0; +}.thl.player-shell .opt-toggle span{ + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +}.thl.player-shell .options-menu .opt-toggle.on{ + color: var(--acid); + border-color: var(--thl-trail); + background: var(--thl-panel); +}.thl.player-shell .group-nav{ + display: flex; + align-items: center; + gap: 6px; +}.thl.player-shell .crumb{ + color: var(--thl-muted); + font: 400 9px "IBM Plex Mono", monospace; + white-space: nowrap; + max-width: 70px; + overflow: hidden; + text-overflow: ellipsis; +}.thl.player-shell .speed-seg{ + display: grid; + grid-template-columns: repeat(3, 1fr); + padding: 2px; + gap: 2px; + border: 1px solid var(--thl-line); + border-radius: var(--radius); + background: var(--thl-bg); +}.thl.player-shell .options-menu .speed-seg button{ + height: 22px; + border: 0; + background: transparent; + font: 500 10px "IBM Plex Mono", monospace; +}.thl.player-shell .options-menu .speed-seg button.on{ + background: var(--thl-surface); + color: var(--acid); +}.thl.player-shell .graph{ + width: 100%; + min-width: 0; + transform: none; + cursor: grab; + touch-action: none; + outline-offset: -2px; +}.thl.player-shell .graph:active{ + cursor: grabbing; +}.thl.player-shell .graph-wrap{ + overflow: hidden; +}.thl.player-shell .canvas-hint{ + align-items: center; + bottom: 6px; +}.thl.player-shell .canvas-hint > span{ + pointer-events: none; +}.thl.player-shell .zoom-tools{ + display: flex; + align-items: center; + gap: 3px; + padding: 2px; + border: 1px solid var(--thl-line); + border-radius: var(--radius); + background: color-mix(in srgb, var(--thl-panel) 90%, transparent); +}.thl.player-shell .zoom-tools button{ + width: 22px; + height: 20px; + display: grid; + place-items: center; + padding: 0; + border: 0; + background: transparent; + color: var(--thl-muted); + cursor: pointer; +}.thl.player-shell .zoom-tools button:hover:not(:disabled){ + color: var(--ink); + background: var(--thl-surface); +}.thl.player-shell .zoom-tools button:disabled{ + opacity: 0.3; + cursor: default; +}.thl.player-shell .zoom-readout{ + min-width: 32px; + text-align: center; + color: var(--thl-muted); + font: 500 8px "IBM Plex Mono", monospace; +}.thl.player-shell .history-empty{ + margin: 0 0 12px; + color: var(--thl-muted); + font-size: 9px; +}.thl.player-shell .transport{ + grid-template-columns: auto minmax(0, 1fr) auto; +}.thl.player-shell .progress{ + display: flex; + gap: 3px; + align-items: center; +}.thl.player-shell .progress i{ + flex: 1; + height: 2px; + border-radius: 1px; + background: var(--thl-line); + transition: background 0.2s ease; +}.thl.player-shell .progress i.past{ + background: var(--thl-trail); +}.thl.player-shell .progress i.now{ + height: 3px; + background: var(--acid); + box-shadow: 0 0 6px color-mix(in srgb, var(--thl-active) 45%, transparent); +}.thl.player-shell .step-caption{ + display: block; + min-height: 0; + padding: 0; + border-top: 1px solid var(--line); + background: var(--thl-panel); + border-radius: 0 0 var(--radius) var(--radius); +}.thl.player-shell .step-caption > summary{ + list-style: none; + display: grid; + grid-template-columns: 24px minmax(0, 1fr) auto auto; + align-items: center; + gap: 10px; + padding: 9px 14px; + cursor: pointer; + user-select: none; +}.thl.player-shell .step-caption > summary::-webkit-details-marker{ + display: none; +}.thl.player-shell .step-caption > summary:hover{ + background: var(--thl-surface); +}.thl.player-shell .caption-text{ + min-width: 0; +}.thl.player-shell .caption-text strong{ + display: block; + color: var(--thl-text); + font-size: 11.5px; + font-weight: 600; +}.thl.player-shell .caption-text .teaser{ + display: block; + margin-top: 3px; + color: var(--thl-muted); + font-size: 9.5px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +}.thl.player-shell .step-caption[open] .teaser{ + display: none; +}.thl.player-shell .caption-expand{ + display: inline-flex; + align-items: center; + gap: 3px; + color: var(--thl-muted); + font: 500 9px "IBM Plex Mono", monospace; +}.thl.player-shell .caption-expand svg{ + transition: transform 0.18s ease; +}.thl.player-shell .step-caption[open] .caption-expand svg{ + transform: rotate(180deg); +}.thl.player-shell .caption-body{ + display: grid; + gap: 10px; + max-height: 240px; + overflow-y: auto; + padding: 0 14px 14px 48px; + +} +@keyframes thl-player-reveal-down { + from { + opacity: 0; + transform: translateY(-4px); + } +}.thl.player-shell .caption-note{ + margin: 0; + color: var(--thl-muted); + font-size: 11px; + line-height: 1.5; +}.thl.player-shell .transfers{ + margin: 0; + padding: 0; + list-style: none; + display: flex; + flex-wrap: wrap; + gap: 6px; +}.thl.player-shell .transfers li{ + display: inline-flex; + align-items: center; + gap: 6px; + padding: 4px 8px; + border: 1px solid var(--thl-line); + border-radius: var(--radius); + background: var(--thl-panel); + color: var(--thl-muted); + font-size: 10px; +}.thl.player-shell .transfers b{ + color: var(--acid); + font-weight: 500; +}.thl.player-shell .transfers code{ + color: var(--orange); + font: 400 9px "IBM Plex Mono", monospace; +}.thl.player-shell .guidance{ + display: grid; + grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); + gap: 8px; +}.thl.player-shell .chapter-card, +.thl.player-shell .causal-card{ + padding: 9px 10px; + border-left: 1px solid var(--acid); + background: var(--thl-panel); +}.thl.player-shell .causal-card{ + border-left-color: var(--orange); + background: var(--thl-panel); +}.thl.player-shell .chapter-card > span, +.thl.player-shell .causal-card > span{ + display: block; + margin-bottom: 5px; + color: var(--acid); + font: 500 7px "IBM Plex Mono", monospace; + letter-spacing: 0.1em; +}.thl.player-shell .causal-card > span{ + color: var(--orange); +}.thl.player-shell .chapter-card strong, +.thl.player-shell .causal-card strong{ + color: var(--thl-text); + font-size: 11px; +}.thl.player-shell .chapter-card p{ + margin: 4px 0 0; + color: var(--thl-muted); + font-size: 10px; + line-height: 1.45; +}.thl.player-shell .causal-card dl{ + margin: 8px 0 0; + display: grid; + gap: 5px; +}.thl.player-shell .causal-card dl > div{ + display: grid; + grid-template-columns: 82px 1fr; + gap: 8px; +}.thl.player-shell .causal-card dt{ + color: var(--thl-muted); + font-size: 9px; +}.thl.player-shell .causal-card dd{ + margin: 0; + color: var(--thl-muted); + font-size: 10px; + line-height: 1.4; +}.thl.player-shell .causal-card .evidence{ + margin: 8px 0 0; + color: var(--thl-muted); + font: 400 8.5px/1.45 "IBM Plex Mono", monospace; +}.thl.player-shell .state-snapshot summary{ + color: var(--thl-muted); + font: 500 9px "IBM Plex Mono", monospace; + cursor: pointer; +}.thl.player-shell .state-snapshot summary:hover{ + color: var(--ink); +}.thl.player-shell .state-snapshot dl{ + margin: 8px 0 0; + display: grid; + grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); + gap: 4px 12px; +}.thl.player-shell .state-snapshot dl > div{ + display: flex; + justify-content: space-between; + gap: 8px; + padding: 4px 0; + border-bottom: 1px solid var(--thl-surface); + font-size: 10px; + color: var(--thl-muted); +}.thl.player-shell .state-snapshot dt span{ + color: var(--thl-muted); +}.thl.player-shell .state-snapshot dd{ + margin: 0; +}.thl.player-shell .state-snapshot code{ + color: var(--acid); + font: 400 9px "IBM Plex Mono", monospace; +} + +@container (max-width: 760px) {.thl.player-shell .options-menu{ + position: fixed; + top: auto; + right: 12px; + left: 12px; + width: auto; + bottom: 12px; + max-height: 70vh; + }.thl.player-shell .header-actions .menu-trigger span{ + display: none; + }.thl.player-shell .chapter-pill{ + display: none; + }.thl.player-shell .step-caption > summary{ + grid-template-columns: 22px minmax(0, 1fr) auto; + }.thl.player-shell .step-caption > summary .event-chip{ + display: none; + }.thl.player-shell .caption-body{ + padding-left: 14px; + }.thl.player-shell .transport{ + grid-template-columns: auto minmax(0, 1fr); + }.thl.player-shell .canvas-hint > span{ + display: none; + }.thl.player-shell .canvas-hint{ + justify-content: flex-end; + } +}.thl.player-shell .transport{ + display: flex; + justify-content: space-between; +}.thl.player-shell .sequence-view{ + display: flex; + flex-direction: column; + overflow: hidden; + inset: 40px 12px 12px; +}.thl.player-shell .seq-scroll{ + flex: 1; + min-height: 0; + overflow-y: auto; + border: 1px solid var(--line); + background: color-mix(in srgb, var(--thl-panel) 90%, transparent); +}.thl.player-shell .sequence-head{ + position: sticky; + top: 0; + z-index: 3; + height: 26px; + border: 0; + border-bottom: 1px solid var(--line); + background: var(--thl-panel); +}.thl.player-shell .seq-body{ + position: relative; +}.thl.player-shell .lifelines{ + inset: 0; +}.thl.player-shell .sequence-list{ + margin: 0; + padding: 6px 0 10px; + list-style: none; + gap: 0; +}.thl.player-shell .seq-row{ + display: grid; + grid-template-columns: repeat(4, 1fr); + align-items: end; + height: 42px; + transition: opacity 0.2s ease; +}.thl.player-shell .seq-row.future{ + opacity: 0.25; +}.thl.player-shell .seq-line{ + position: relative; + display: block; + height: 100%; +}.thl.player-shell .seq-label{ + position: absolute; + left: 10px; + right: 10px; + bottom: 14px; + display: flex; + justify-content: center; + gap: 6px; + align-items: baseline; + min-width: 0; +}.thl.player-shell .seq-label b{ + color: var(--thl-muted); + font: 500 8px "IBM Plex Mono", monospace; +}.thl.player-shell .seq-label code{ + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + color: var(--thl-muted); + font: 400 9px "IBM Plex Mono", monospace; +}.thl.player-shell .seq-arrow{ + position: absolute; + left: 0; + right: 0; + bottom: 8px; + height: 1px; + background: var(--thl-muted); +}.thl.player-shell .seq-row.right .seq-arrow::after, +.thl.player-shell .seq-row.left .seq-arrow::before{ + content: ""; + position: absolute; + top: -3px; + border: 3.5px solid transparent; +}.thl.player-shell .seq-row.right .seq-arrow::after{ + right: 0; + border-left: 6px solid var(--thl-muted); +}.thl.player-shell .seq-row.left .seq-arrow::before{ + left: 0; + border-right: 6px solid var(--thl-muted); +}.thl.player-shell .seq-row.self .seq-arrow{ + left: 0; + right: auto; + width: 7px; + height: 7px; + bottom: 5px; + border-radius: 50%; + background: var(--thl-muted); +}.thl.player-shell .seq-row.self .seq-label{ + left: 18px; + right: 6px; + justify-content: flex-start; +}.thl.player-shell .seq-row.self.flip .seq-line{ + display: flex; + justify-content: flex-end; +}.thl.player-shell .seq-row.self.flip .seq-label{ + left: 6px; + right: 18px; + justify-content: flex-end; +}.thl.player-shell .seq-row.self.flip .seq-arrow{ + left: auto; + right: 0; +}.thl.player-shell .seq-row.current .seq-arrow{ + background: var(--acid); + box-shadow: 0 0 6px color-mix(in srgb, var(--thl-active) 50%, transparent); +}.thl.player-shell .seq-row.current.right .seq-arrow::after{ + border-left-color: var(--acid); +}.thl.player-shell .seq-row.current.left .seq-arrow::before{ + border-right-color: var(--acid); +}.thl.player-shell .seq-row.current .seq-label code, +.thl.player-shell .seq-row.current .seq-label b{ + color: var(--acid); +}.thl.player-shell .seq-detail{ + flex: 0 0 auto; + display: flex; + align-items: baseline; + gap: 10px; + padding: 8px 2px 0; + min-height: 26px; +}.thl.player-shell .seq-detail > span{ + color: var(--acid); + font: 500 8px "IBM Plex Mono", monospace; + letter-spacing: 0.1em; +}.thl.player-shell .seq-detail p{ + margin: 0; + min-width: 0; + color: var(--thl-muted); + font-size: 10px; + line-height: 1.4; +}.thl.player-shell .seq-detail b{ + margin: 0 4px; + color: var(--acid); + font-weight: 400; +}.thl.player-shell .seq-detail code{ + margin-left: 6px; + color: var(--thl-muted); + font: 400 9px "IBM Plex Mono", monospace; + word-break: break-all; +}.thl.player-shell .graph-wrap{ + overflow: hidden; +} + +@container (max-width: 760px) {.thl.player-shell .transport{ + display: flex; + }.thl.player-shell .sequence-view{ + inset: 36px 8px 8px; + }.thl.player-shell .seq-label code{ + font-size: 8px; + }.thl.player-shell .seq-label b{ + display: none; + }.thl.player-shell .state-view{ + inset: 36px 8px 8px; + }.thl.player-shell .state-header{ + display: none; + }.thl.player-shell .state-row{ + grid-template-columns: minmax(0, 1fr) auto; + grid-template-areas: "entity value" "path origin"; + row-gap: 3px; + padding: 8px 12px; + }.thl.player-shell .state-row > :last-child{ + display: block; + }.thl.player-shell .state-row > :nth-child(1){ + grid-area: entity; + }.thl.player-shell .state-row > :nth-child(2){ + grid-area: path; + }.thl.player-shell .state-row > :nth-child(3){ + grid-area: value; + text-align: right; + word-break: break-word; + }.thl.player-shell .state-row > :nth-child(4){ + grid-area: origin; + text-align: right; + color: var(--thl-muted); + font: 400 8px "IBM Plex Mono", monospace; + } +} + + +/* + * UI geometry, spacing, typography and responsive behavior are ported from + * 0xbuffdev/throughline-player. These aliases preserve the canonical palette: + * no hard-coded design-specific accent colors enter the package. + * All selectors remain underneath the public .thl.player-shell root. + */ +.thl.thl-v2.player-shell { + --ink: var(--thl-text); + --muted: var(--thl-muted); + --dim: var(--thl-muted); + --line: var(--thl-line); + --line-soft: var(--thl-line); + --panel: var(--thl-panel); + --panel-2: var(--thl-surface); + --acid: var(--thl-active); + --orange: var(--thl-change); + --radius: var(--thl-radius); + display: flex; + flex-direction: column; + width: 100%; + min-width: 0; + padding: 0; + border: 1px solid var(--thl-line); + background: var(--thl-bg); + font-family: inherit; + font-size: 12px; + line-height: 1.5; + overflow: visible; +} +/* Keep the compact shell typography separate from authored graph text. + * The SVG inherits the same host font family it used before this UI port. */ +.thl.player-shell .player-header, +.thl.player-shell .context-bar, +.thl.player-shell .inspector, +.thl.player-shell .transport, +.thl.player-shell .step-caption, +.thl.player-shell .options-menu, +.thl.player-shell .sequence-view, +.thl.player-shell .state-view { + font-family: "DM Sans", system-ui, sans-serif; +} +.thl.player-shell :is(button, input, select) { font: inherit; } +.thl.player-shell .thl-v2-sequence, +.thl.player-shell .thl-v2-fallback { min-width: 0; } +.thl.player-shell .player-content { flex: 1 1 auto; } +.thl.player-shell .canvas { height: 330px; } +.thl.player-shell:fullscreen .canvas { height: auto; flex: 1 1 auto; } +.thl.player-shell .graph { display: block; } + + + + + + + + + + + + + + + + + + +.thl.player-shell .state-row:focus-visible, +.thl.player-shell .view-tabs button:focus-visible { outline: 2px solid var(--thl-focus); outline-offset: -2px; } +.thl.player-shell .inspector .thl-v2-inspect { + max-width: 100%; + min-width: 0; + max-height: none; + overflow: visible; + padding: 0; + gap: 0.75rem; + overflow-wrap: anywhere; +} +.thl.player-shell .inspector .thl-v2-inspect pre { + max-width: 100%; + white-space: pre-wrap; + overflow-wrap: anywhere; +} +.thl.player-shell .thl-sr-only { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; } +@container (max-width: 760px) { + .thl.player-shell .canvas { height: 310px; } +} +@container (max-width: 480px) { + .thl.player-shell .canvas { height: 292px; } +} + +/* The public heading remains h2 for correct embedding, but keeps the exact + * compact header appearance. */ +.thl.player-shell .title-block h2 { + margin: 0; + font-size: 13px; + line-height: 1.2; + letter-spacing: -0.01em; + font-weight: 600; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.thl.player-shell .sequence-head span button { + width: 100%; + height: 100%; + border: 0; + background: transparent; + color: inherit; + font: inherit; + cursor: pointer; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.thl.player-shell .sequence-head span button[aria-pressed="true"] { + color: var(--thl-active); +} +.thl.player-shell .seq-row.evidence { + align-items: center; +} +.thl.player-shell .seq-non-message { + display: inline-flex; + align-items: baseline; + gap: 8px; + padding: 5px 10px; + border-bottom: 1px solid var(--thl-line); + color: var(--thl-muted); + font: 400 9px "IBM Plex Mono", monospace; +} +.thl.player-shell .seq-non-message b { color: var(--thl-muted); } +.thl.player-shell .seq-row.current .seq-non-message, +.thl.player-shell .seq-row.current .seq-non-message b { color: var(--thl-active); } +.thl.player-shell .seq-earlier { + margin-left: auto; + padding: 0; + border: 0; + background: transparent; + color: var(--thl-muted); + font: inherit; + cursor: pointer; +} +.thl.player-shell .evidence-note summary { + color: var(--thl-change); + font: 500 7px "IBM Plex Mono", monospace; + letter-spacing: 0.08em; + cursor: pointer; +} +.thl.player-shell .evidence-note[open] { + overflow: auto; + max-height: 440px; +} +.thl.player-shell .evidence-note :is(button, input, select) { + color: var(--thl-text); + background: var(--thl-control-bg); + border: 1px solid var(--thl-line); + border-radius: var(--thl-radius); + max-width: 100%; +} +.thl.player-shell .evidence-note :is(pre, table) { + display: block; + overflow-x: auto; + max-width: 100%; +} + +/* Motion is opt-in by preference. Reduced-motion users never receive a + * running animation, and legacy player motion rules remain untouched. */ +@media (prefers-reduced-motion: no-preference) { + + .thl.player-shell .inspector { animation: thl-player-reveal 0.18s ease-out; } + .thl.player-shell .options-menu { animation: thl-player-pop 0.14s ease-out; } + .thl.player-shell .caption-body { animation: thl-player-reveal-down 0.18s ease-out; } +} +/* The compact inspector cannot force the host's horizontal scroll at any + * embed width. Popup controls remain accessible within the player width. */ +.thl.player-shell { + overflow-x: clip; +} +.thl.player-shell .player-content.with-inspector { + min-width: 0; +} +.thl.player-shell .inspector { + min-width: 0; + max-width: 100%; +} +@container (max-width: 560px) { + /* The panel fills the visualization at narrow embed widths, while the + player header, view tabs, and transport remain operable for inspection + across frames. Never take over the embedding document's viewport. */ + .thl.player-shell .player-content .inspector { + width: 100%; + max-width: 100%; + height: 100%; + max-height: 100%; + border-inline-start: 0; + box-shadow: none; + } +} +/* The inspector alone scrolls vertically; disclosure panels remain part of + that same reading surface rather than introducing a second scrollbar. */ +.thl.player-shell .inspector .evidence-note { + min-width: 0; +} +.thl.player-shell .inspector .evidence-note :is(pre, table) { + overflow-x: visible; + white-space: pre-wrap; + overflow-wrap: anywhere; +} +.thl.player-shell .inspector .evidence-note table { + display: table; + width: 100%; + table-layout: fixed; +} +.thl.player-shell .history-item > div { + min-width: 0; +} + + +.thl.player-shell .seq-empty { + margin: 0; + padding: 14px 12px; + color: var(--thl-muted); + font: 400 9px/1.5 "IBM Plex Mono", ui-monospace, monospace; +} + +/* Authored graph shapes, routes, colors, and highlight states are unchanged. + * Only text size is adjusted inside the source-linked diagram. */ +.thl.player-shell .thl-v2-diagram .thl-node-label { font-size: 10px; } +.thl.player-shell .thl-v2-diagram .thl-v2-value { font-size: 8.5px; } +.thl.player-shell .thl-v2-diagram .thl-v2-change { font-size: 9px; } +.thl.player-shell .thl-v2-diagram .thl-group-label { font-size: 8px; } +.thl.player-shell .thl-v2-diagram .thl-edge-label { font-size: 9px; }