From f029e98dc40ea467b4e536fefd7ca7b8006158f8 Mon Sep 17 00:00:00 2001 From: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com> Date: Fri, 20 Nov 2026 15:49:00 -0800 Subject: [PATCH 1/5] chore(skills): environments map launch-video staging Six real servers, link rows seeded into the stopped servers' databases, descriptor stubs so 7 of a 44-machine fleet answer the reachability probe, saved environments and routes seeded into the client's IndexedDB, and a live Link several from MacBook. Kit gains draw (SVG strokes), :text() targets, and handles nodes from a beat iframe's realm; beats record the viewport they were frozen at. Co-Authored-By: Claude Opus 5.5 --- .agents/skills/launch-video/SKILL.md | 15 +- .agents/skills/launch-video/assets/kit.js | 42 +- .agents/skills/launch-video/scripts/find.mjs | 9 +- .../skills/launch-video/scripts/snapshot.mjs | 4 + .../skills/launch-video/scripts/stage-env.mjs | 84 +++- .../stagings/environments-map/drive.mjs | 139 +++++++ .../stagings/environments-map/serve.mjs | 106 +++++ .../stagings/environments-map/story.html | 391 ++++++++++++++++++ 8 files changed, 773 insertions(+), 17 deletions(-) create mode 100644 .agents/skills/launch-video/stagings/environments-map/drive.mjs create mode 100644 .agents/skills/launch-video/stagings/environments-map/serve.mjs create mode 100644 .agents/skills/launch-video/stagings/environments-map/story.html diff --git a/.agents/skills/launch-video/SKILL.md b/.agents/skills/launch-video/SKILL.md index 82ef0bdd576d7..9f0a8270442e9 100644 --- a/.agents/skills/launch-video/SKILL.md +++ b/.agents/skills/launch-video/SKILL.md @@ -41,6 +41,13 @@ There are two ways to build one: `delegate_task`. Match generated titles with a `{ match: "title", repeat: true }` turn. `` is filled from the JSON file at `T3_DEV_REPLAY_VARS`, for ids that change every run. `fake-claude.log` in the home records the protocol, for debugging. + - Data a real flow can't produce cheaply goes into the app's own stores, never into pixels. + `stagings/environments-map/` shows the tools: `insertPeerLinks` writes link rows into a + stopped server, `serveDescriptors` makes fake machines answer the reachability probe, + and its drive seeds the client's saved environments and routes into IndexedDB + (`t3code:connection-runtime` / `catalog` / `document`). Route kinds come from hostnames: + `*.localhost` is LAN, `*.ts.net` is Tailscale; Chrome's + `--host-resolver-rules=MAP *.tail-demo.ts.net 127.0.0.1` makes fake tailnet names work. - The free replay agent (`apps/server/scripts/dev-replay-agent.ts`) still works without `claude`, but it shows as an ACP provider. 4. **Create the story:** `scripts/new.sh ~/launch-videos/`, then copy the beats in, or @@ -130,10 +137,14 @@ seeks every animation (in the story and inside each beat) to each frame's time. 1440×720 and `.app` scales them 1.0556× into the 1520×760 window, so beat point (x, y) is canvas (40 + 1.0556·x, 26 + 1.0556·y). - **Targets** are `" >> "` (or `"* >> "` for every beat). Prefer the app's - `data-*` and `aria-label` attributes; `find.mjs` prints them. + `data-*` and `aria-label` attributes; `find.mjs` prints them. A trailing `:text(words)` + keeps the matches containing those words, e.g. `[role=menuitem]:text(From MacBook)`. +- **Beat size.** Each beat records the viewport it was frozen at (`kit-viewport` meta). + Size `.app` and its iframes to match and scale them to the 1520×760 window + (1440×720 → 1.0556, 1600×800 → .95). - **`setup()`**: `Kit.beats([[name, at, fade?], ...])` gives each beat one visibility window. Then the motion, all at absolute times: - `Kit.pop / rise / slide / stagger / type / press / punch / fadeIn` animate elements inside + `Kit.pop / rise / slide / stagger / type / press / punch / fadeIn / draw` animate elements inside a beat; `Kit.glow(target, at)` draws a ring on the story layer, so app overflow can't clip it; `Kit.anim` takes raw keyframes; `Kit.text` makes a static edit (say so at handback). diff --git a/.agents/skills/launch-video/assets/kit.js b/.agents/skills/launch-video/assets/kit.js index 19e394484894d..f92152e481770 100644 --- a/.agents/skills/launch-video/assets/kit.js +++ b/.agents/skills/launch-video/assets/kit.js @@ -28,28 +28,44 @@ window.Kit = (() => { if (!f) throw new Error(`Kit: no beat named ${name}`); return f; }; + // CSS plus a trailing `:text(words)`, which keeps the matches whose text contains `words`. + const query = (doc, selector) => { + const match = /^(.*?):text\((.+)\)$/.exec(selector.trim()); + if (!match) return [...doc.querySelectorAll(selector)]; + return [...doc.querySelectorAll(match[1] || "*")].filter( + (node) => + node.textContent.includes(match[2]) && + ![...node.children].some( + (c) => c.textContent.includes(match[2]) && c.matches(match[1] || "*"), + ), + ); + }; const resolve = (target) => { - if (target instanceof Element) return { el: target, frame: null }; + // Nodes from a beat belong to its iframe's realm, so `instanceof Element` misses them. + if (typeof target !== "string") { + const view = target.ownerDocument.defaultView; + return { el: target, frame: view === window ? null : view.frameElement }; + } const split = target.indexOf(" >> "); if (split === -1) { - const el = document.querySelector(target); + const [el] = query(document, target); if (!el) throw new Error(`Kit: no element matches ${target}`); return { el, frame: null }; } const frame = beat(target.slice(0, split)); const sel = target.slice(split + 4); - const el = frame.contentDocument.querySelector(sel); + const [el] = query(frame.contentDocument, sel); if (!el) throw new Error(`Kit: no element matches ${sel} in beat ${frame.dataset.beat}`); return { el, frame }; }; // "* >> " matches in every beat. const all = (target) => { const split = target.indexOf(" >> "); - if (split === -1) return [...document.querySelectorAll(target)]; + if (split === -1) return query(document, target); const name = target.slice(0, split); const docs = name === "*" ? frames().map((f) => f.contentDocument) : [beat(name).contentDocument]; - return docs.flatMap((doc) => [...doc.querySelectorAll(target.slice(split + 4))]); + return docs.flatMap((doc) => query(doc, target.slice(split + 4))); }; // A static edit to the frozen page, e.g. a dev-only label. Say so when you hand the video back. const text = (targets, value) => { @@ -226,6 +242,22 @@ window.Kit = (() => { ], { at, dur, ease: "ease-out" }, ), + // Draws solid SVG strokes in (dashed ones keep their dashes and just fade in). + draw: (targets, at, dur = 0.6, step = 0.08) => + all(targets).map((path, i) => { + const start = at + i * step; + const view = path.ownerDocument.defaultView; + if (view.getComputedStyle(path).strokeDasharray !== "none" || !path.getTotalLength) { + return anim(path, [{ opacity: 0 }, { opacity: 1 }], { at: start, dur }); + } + const length = path.getTotalLength(); + path.style.strokeDasharray = `${length}`; + return anim(path, [{ strokeDashoffset: length }, { strokeDashoffset: 0 }], { + at: start, + dur, + ease: "cubic-bezier(.4,0,.2,1)", + }); + }), // A punch: brief scale-up pulse that draws the eye. punch: (t, at, scale = 1.06) => anim( diff --git a/.agents/skills/launch-video/scripts/find.mjs b/.agents/skills/launch-video/scripts/find.mjs index 4bce15adf1dfd..d6cdac26eb104 100644 --- a/.agents/skills/launch-video/scripts/find.mjs +++ b/.agents/skills/launch-video/scripts/find.mjs @@ -36,7 +36,14 @@ const browser = await chromium.launch({ args: ["--no-sandbox"], }); try { - const page = await browser.newPage({ viewport: { width: 1440, height: 720 } }); + const [width, height] = ( + /name="kit-viewport" content="(\d+)x(\d+)"/.exec(NodeFS.readFileSync(file, "utf8")) ?? [ + 0, 1440, 720, + ] + ) + .slice(1) + .map(Number); + const page = await browser.newPage({ viewport: { width, height } }); await page.goto(`http://127.0.0.1:${server.address().port}/${NodePath.basename(file)}`); const found = await page.evaluate((needle) => { // Short, stable selectors: data attributes and aria labels over generated classes. diff --git a/.agents/skills/launch-video/scripts/snapshot.mjs b/.agents/skills/launch-video/scripts/snapshot.mjs index b0e30de098a2b..8bef33d3622d5 100644 --- a/.agents/skills/launch-video/scripts/snapshot.mjs +++ b/.agents/skills/launch-video/scripts/snapshot.mjs @@ -86,6 +86,10 @@ async function freeze(known) { const styleEl = document.createElement("style"); styleEl.textContent = css; head.append(styleEl); + const viewport = document.createElement("meta"); + viewport.name = "kit-viewport"; + viewport.content = `${innerWidth}x${innerHeight}`; + head.append(viewport); const restore = document.createElement("script"); restore.textContent = `for (const el of document.querySelectorAll("[data-kit-scroll]")) { const [x, y] = el.dataset.kitScroll.split(",").map(Number); el.scrollLeft = x; el.scrollTop = y; }`; clone.querySelector("body").append(restore); diff --git a/.agents/skills/launch-video/scripts/stage-env.mjs b/.agents/skills/launch-video/scripts/stage-env.mjs index feec5508bfc7e..daa9911656f43 100644 --- a/.agents/skills/launch-video/scripts/stage-env.mjs +++ b/.agents/skills/launch-video/scripts/stage-env.mjs @@ -3,6 +3,7 @@ import * as NodeChildProcess from "node:child_process"; import * as NodeCrypto from "node:crypto"; import * as NodeFS from "node:fs"; +import * as NodeHttp from "node:http"; import * as NodeNet from "node:net"; import * as NodePath from "node:path"; import * as NodeURL from "node:url"; @@ -99,25 +100,33 @@ function spawn(args, env, log) { // Its own process group, so stopping it ends the dev runner's children too. detached: true, }); - children.push({ + const handle = { kill: (s) => { try { process.kill(-child.pid, s); } catch {} }, - }); + }; + children.push(handle); + child.stopGroup = () => + new Promise((resolve) => { + if (child.exitCode !== null) return resolve(); + child.once("exit", () => resolve()); + handle.kill("SIGTERM"); + }); return child; } /** * Starts a dev server on `home` (and the web client when `web` is set). Resolves when it listens, - * with its origin, the web origin and the startup pairing URL. + * with its origin, the web origin, the startup pairing URL, and `stop()`. Pass the previous + * `port` to restart a server where saved routes expect it. */ export async function startEnvironment( home, - { host = "127.0.0.1", web = false, allowedOrigins = [], env = {} } = {}, + { host = "127.0.0.1", port, web = false, allowedOrigins = [], env = {} } = {}, ) { - const serverPort = await freePort(); + const serverPort = port ?? (await freePort()); const webPort = web ? await freePort() : await freePort(); const webOrigin = `http://127.0.0.1:${webPort}`; const token = NodeCrypto.randomUUID().replaceAll("-", "").repeat(2); @@ -173,8 +182,9 @@ export async function startEnvironment( reject(new Error(`server on ${home} exited ${code}; see ${log}`)), ); }); + const processes = [server]; if (web) { - spawn(runner("dev:web", ["--", "--host", "127.0.0.1"]), baseEnv, log); + processes.push(spawn(runner("dev:web", ["--", "--host", "127.0.0.1"]), baseEnv, log)); for (let i = 0; ; i++) { try { if ((await fetch(`${webOrigin}/.well-known/t3/environment`)).ok) break; @@ -183,11 +193,14 @@ export async function startEnvironment( await new Promise((r) => setTimeout(r, 500)); } } - const origin = `http://127.0.0.1:${serverPort}`; + const reachableHost = host === "0.0.0.0" || host === "::" ? "127.0.0.1" : host; + const origin = `http://${reachableHost.includes(":") ? `[${reachableHost}]` : reachableHost}:${serverPort}`; const descriptor = await (await fetch(`${origin}/.well-known/t3/environment`)).json(); return { home, origin, + descriptor, + stop: () => Promise.all(processes.map((p) => p.stopGroup())), serverPort, webOrigin, pairingUrl, @@ -258,7 +271,7 @@ export async function createProject(environment, title, files = { "README.md": " } /** A Playwright page at the size beats are frozen at, dark, with production branding. */ -export async function openBrowser({ width = 1440, height = 720 } = {}) { +export async function openBrowser({ width = 1440, height = 720, args = [] } = {}) { const { createRequire } = await import("node:module"); const { chromium } = createRequire(NodePath.join(REPO, "scripts/package.json"))( "playwright-core", @@ -266,7 +279,7 @@ export async function openBrowser({ width = 1440, height = 720 } = {}) { const { findChrome } = await import("./chrome.mjs"); const browser = await chromium.launch({ executablePath: findChrome(chromium), - args: ["--no-sandbox"], + args: ["--no-sandbox", ...args], }); const context = await browser.newContext({ viewport: { width, height }, colorScheme: "dark" }); await context.addInitScript(() => { @@ -281,3 +294,56 @@ export async function openBrowser({ width = 1440, height = 720 } = {}) { const page = await context.newPage(); return { browser, context, page }; } + +/** + * Writes link rows straight into a stopped server's database, as if `t3 environment link` had + * made them. The server must have started once (migrations). The map probes each row's URLs + * live: a row is "reachable" only while something there answers as that environment. + * Rows: { environmentId, label, urls, access = "full-access", lastError = null }. + */ +export async function insertPeerLinks(home, rows) { + const { DatabaseSync } = await import("node:sqlite"); + const db = new DatabaseSync(NodePath.join(home, "userdata/statev2.sqlite")); + const now = Date.now(); + const insert = db.prepare( + `INSERT OR REPLACE INTO peer_environment_links + (environment_id, secret_name, label, urls_json, access, linked_at, expires_at, last_reached_at, last_error, fenced) + VALUES (?, ?, ?, ?, ?, ?, ?, NULL, ?, 1)`, + ); + for (const row of rows) { + insert.run( + row.environmentId, + `peer-link:${row.environmentId}`, + row.label, + JSON.stringify(row.urls), + row.access ?? "full-access", + new Date(now - 86_400_000).toISOString(), + new Date(now + 60 * 86_400_000).toISOString(), + row.lastError ?? null, + ); + } + db.close(); +} + +/** + * Answers the descriptor probe for machines that only need to look alive: one port per + * machine, each serving `template` (a real server's descriptor) under that machine's id and + * label. Returns the URL for each machine, by environment id. + */ +export async function serveDescriptors(template, machines) { + const urls = {}; + for (const machine of machines) { + const body = JSON.stringify({ + ...template, + environmentId: machine.environmentId, + label: machine.label, + }); + const server = NodeHttp.createServer((req, res) => + res.writeHead(200, { "content-type": "application/json" }).end(body), + ); + await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve)); + children.push({ kill: () => server.close() }); + urls[machine.environmentId] = `http://127.0.0.1:${server.address().port}`; + } + return urls; +} diff --git a/.agents/skills/launch-video/stagings/environments-map/drive.mjs b/.agents/skills/launch-video/stagings/environments-map/drive.mjs new file mode 100644 index 0000000000000..06d196f12573a --- /dev/null +++ b/.agents/skills/launch-video/stagings/environments-map/drive.mjs @@ -0,0 +1,139 @@ +// Drives the MacBook web client to the environments map and freezes beats into /beats. +// Needs serve.mjs running. Usage: drive.mjs +import * as NodeFS from "node:fs"; +import * as NodePath from "node:path"; + +import { saveBeat } from "../../scripts/snapshot.mjs"; +import { openBrowser } from "../../scripts/stage-env.mjs"; + +const out = NodePath.resolve(process.argv[2] ?? ""); +const stage = JSON.parse(NodeFS.readFileSync(NodePath.join(out, "stage.json"), "utf8")); +NodeFS.rmSync(NodePath.join(out, "beats"), { recursive: true, force: true }); +NodeFS.mkdirSync(NodePath.join(out, "shots"), { recursive: true }); + +// Fictional tailnet names resolve to this machine in the browser only. +const { browser, page } = await openBrowser({ + width: 1600, + height: 800, + args: ["--host-resolver-rules=MAP *.tail-demo.ts.net 127.0.0.1"], +}); +const started = Date.now(); +const beat = async (name) => { + await page.mouse.move(1439, 719); + await page.waitForTimeout(250); + await saveBeat(page, out, name); + await page.screenshot({ path: NodePath.join(out, "shots", `${name}.png`) }); + console.log(`beat ${name} at ${((Date.now() - started) / 1000).toFixed(1)}s`); +}; + +// The client's saved environments: one target per route, in order of preference. +const { machines, tailnetName } = stage; +const route = (machine, url, token = machine.token) => { + const origin = new URL(url).origin; + const connectionId = `bearer:${machine.environmentId}:${origin}`; + return { + target: { + _tag: "BearerConnectionTarget", + environmentId: machine.environmentId, + label: machine.label, + connectionId, + }, + profile: { + _tag: "BearerConnectionProfile", + connectionId, + environmentId: machine.environmentId, + label: machine.label, + httpBaseUrl: `${origin}/`, + wsBaseUrl: `${origin.replace(/^http/, "ws")}/`, + }, + credential: { connectionId, credential: { _tag: "BearerConnectionCredential", token } }, + }; +}; +const relay = (machine) => ({ + target: { + _tag: "RelayConnectionTarget", + environmentId: machine.environmentId, + label: machine.label, + }, +}); +const routes = [ + // studio: a LAN route whose sign-in is refused, Tailscale in use, a LAN and T3 Connect standby. + route(machines.studio, `http://studio.localhost:${machines.studio.port}`, "not-a-valid-token"), + route(machines.studio, `http://studio.tail-demo.ts.net:${machines.studio.port}`), + route(machines.studio, `http://10.0.0.24:${machines.studio.port}`), + relay(machines.studio), + route(machines.devbox, `http://devbox.tail-demo.ts.net:${machines.devbox.port}`), + relay(machines.devbox), + route(machines.nas, `http://nas.localhost:${machines.nas.port}`), + route(machines.nas, `http://nas.tail-demo.ts.net:${machines.nas.port}`), + route(machines.gpu1, `http://${tailnetName}:${machines.gpu1.port}`), + route(machines.gpu2, `http://${tailnetName}:${machines.gpu2.port}`), +]; +const catalog = JSON.stringify({ + schemaVersion: 1, + targets: routes.map((r) => r.target), + profiles: routes.flatMap((r) => (r.profile ? [r.profile] : [])), + credentials: routes.flatMap((r) => (r.credential ? [r.credential] : [])), + remoteDpopTokens: [], + disabledEnvironmentIds: [], +}); + +try { + await page.goto(stage.macbook.pairingUrl); + await page.waitForURL((url) => !url.pathname.startsWith("/pair"), { timeout: 120_000 }); + await page.waitForTimeout(3000); + await page.evaluate( + (document) => + new Promise((resolve, reject) => { + const open = indexedDB.open("t3code:connection-runtime", 5); + open.onerror = () => reject(open.error); + open.onsuccess = () => { + const tx = open.result.transaction("catalog", "readwrite"); + tx.objectStore("catalog").put(document, "document"); + tx.oncomplete = () => resolve(); + tx.onerror = () => reject(tx.error); + }; + }), + catalog, + ); + await page.reload(); + await page.waitForTimeout(4000); + // nas has been seen (its config is cached); now it goes offline. + NodeFS.writeFileSync(NodePath.join(out, "stop-nas"), ""); + await page.goto(new URL("/settings/connections", stage.macbook.webOrigin).href); + await page.getByText("fs-44", { exact: false }).first().waitFor({ timeout: 60_000 }); + await page.getByText("Reconnecting…", { exact: false }).first().waitFor({ timeout: 90_000 }); + await page.waitForTimeout(2000); + await beat("map"); + + const linkSeveral = page.getByRole("button", { name: "Link several…" }); + await linkSeveral.click(); + await page.getByRole("menuitem", { name: "From MacBook" }).waitFor({ timeout: 10_000 }); + await page.waitForTimeout(300); + await beat("link-menu"); + await page.getByRole("menuitem", { name: "From MacBook" }).click(); + const dialog = page.getByRole("dialog", { name: /Link several machines from MacBook/ }); + await dialog.getByText("gpu-1", { exact: true }).waitFor({ timeout: 30_000 }); + await page.waitForTimeout(800); + await beat("link-open"); + await dialog.getByText("gpu-1", { exact: true }).click(); + await dialog.getByText("gpu-2", { exact: true }).click(); + await page.waitForTimeout(300); + await beat("link-picked"); + await dialog.getByRole("button", { name: /^Link 2 machines/ }).click(); + await page.waitForTimeout(500); + await beat("linking"); + await dialog.getByText("Linked 2 machines", { exact: false }).waitFor({ timeout: 120_000 }); + await page.waitForTimeout(400); + await beat("link-done"); + await dialog.getByRole("button", { name: "Done" }).click(); + await dialog.waitFor({ state: "hidden", timeout: 10_000 }); + await page.getByText("2 links out", { exact: false }).first().waitFor({ timeout: 60_000 }); + await page.waitForTimeout(1500); + await beat("linked"); +} catch (error) { + await page.screenshot({ path: NodePath.join(out, "shots", "failure.png") }); + throw error; +} finally { + await browser.close(); +} diff --git a/.agents/skills/launch-video/stagings/environments-map/serve.mjs b/.agents/skills/launch-video/stagings/environments-map/serve.mjs new file mode 100644 index 0000000000000..be66dfa4f2298 --- /dev/null +++ b/.agents/skills/launch-video/stagings/environments-map/serve.mjs @@ -0,0 +1,106 @@ +// Machines for the environments-map video. Real servers: MacBook (web, this device), studio, +// devbox, and gpu-1/gpu-2 for "Link several"; nas starts once so the browser knows it, then +// stops (offline). Link rows are seeded: studio <-> devbox both ways, and devbox -> fs-44..fs-87 +// of which 7 answer through descriptor stubs. Writes /stage.json. Usage: serve.mjs +import * as NodeChildProcess from "node:child_process"; +import * as NodeCrypto from "node:crypto"; +import * as NodeFS from "node:fs"; +import * as NodePath from "node:path"; + +import { + REPO, + cli, + insertPeerLinks, + prepareHome, + serveDescriptors, + startEnvironment, +} from "../../scripts/stage-env.mjs"; + +const out = NodePath.resolve(process.argv[2] ?? ""); +if (!process.argv[2]) throw new Error("usage: serve.mjs "); +NodeFS.mkdirSync(out, { recursive: true }); +const root = NodePath.join(REPO, ".t3/launch/environments-map"); + +// gpu-1/gpu-2 are linked live, so the linking server must reach them at a non-loopback tailnet +// name: they bind this machine's tailnet address and are saved under its tailnet DNS name. +const tailscale = JSON.parse( + NodeChildProcess.execFileSync("tailscale", ["status", "--json"], { encoding: "utf8" }), +); +const tailnetName = tailscale.Self.DNSName.replace(/\.$/, ""); +const tailnetIp = tailscale.Self.TailscaleIPs.find((ip) => !ip.includes(":")); + +const linked = { linkedEnvironmentsEnabled: true }; +const machines = { + macbook: { label: "MacBook", machine: "laptop" }, + studio: { label: "studio", machine: "mac-studio" }, + devbox: { label: "devbox", machine: "cloud" }, + nas: { label: "nas", machine: "linux" }, + gpu1: { label: "gpu-1", machine: "cloud" }, + gpu2: { label: "gpu-2", machine: "cloud" }, +}; +for (const [name, identity] of Object.entries(machines)) { + prepareHome(NodePath.join(root, name), { ...identity, settings: linked }); +} + +const home = (name) => NodePath.join(root, name); +const macbook = await startEnvironment(home("macbook"), { web: true }); +const allowedOrigins = [macbook.webOrigin]; +let studio = await startEnvironment(home("studio"), { allowedOrigins }); +let devbox = await startEnvironment(home("devbox"), { allowedOrigins }); +const nas = await startEnvironment(home("nas"), { allowedOrigins }); +const gpu1 = await startEnvironment(home("gpu1"), { host: tailnetIp, allowedOrigins }); +const gpu2 = await startEnvironment(home("gpu2"), { host: tailnetIp, allowedOrigins }); +console.log("started 6 environments"); + +// Seeded links need the servers stopped: they read the table on start. +const fleet = Array.from({ length: 44 }, (_, i) => ({ + environmentId: NodeCrypto.randomUUID(), + label: `fs-${44 + i}`, +})); +const reachable = await serveDescriptors(devbox.descriptor, fleet.slice(3, 10)); +await Promise.all([studio.stop(), devbox.stop()]); +await insertPeerLinks(studio.home, [ + { environmentId: devbox.environmentId, label: "devbox", urls: [devbox.origin] }, +]); +await insertPeerLinks(devbox.home, [ + { environmentId: studio.environmentId, label: "studio", urls: [studio.origin] }, + ...fleet.map((machine, i) => ({ + ...machine, + access: "approval-required", + urls: [reachable[machine.environmentId] ?? `http://127.0.0.1:${9 + i}`], + })), +]); +studio = await startEnvironment(home("studio"), { port: studio.serverPort, allowedOrigins }); +devbox = await startEnvironment(home("devbox"), { port: devbox.serverPort, allowedOrigins }); +console.log("seeded links"); + +const token = (environment) => + cli(environment.home, ["auth", "session", "issue", "--token-only", "--label", "MacBook"]).trim(); +const stage = { + macbook, + tailnetName, + machines: Object.fromEntries( + Object.entries({ studio, devbox, nas, gpu1, gpu2 }).map(([name, env]) => [ + name, + { + environmentId: env.environmentId, + label: env.label, + port: env.serverPort, + token: token(env), + }, + ]), + ), +}; +NodeFS.writeFileSync(NodePath.join(out, "stage.json"), JSON.stringify(stage, null, 2)); +console.log(`ready: ${NodePath.join(out, "stage.json")}`); + +// drive.mjs writes /stop-nas once the browser has seen nas; then it goes offline. +const stopFile = NodePath.join(out, "stop-nas"); +NodeFS.rmSync(stopFile, { force: true }); +const watcher = setInterval(async () => { + if (!NodeFS.existsSync(stopFile)) return; + clearInterval(watcher); + await nas.stop(); + console.log("nas stopped"); +}, 500); +await new Promise(() => {}); diff --git a/.agents/skills/launch-video/stagings/environments-map/story.html b/.agents/skills/launch-video/stagings/environments-map/story.html new file mode 100644 index 0000000000000..5ee7457b06cee --- /dev/null +++ b/.agents/skills/launch-video/stagings/environments-map/story.html @@ -0,0 +1,391 @@ + + + + + + + + +
+
+
+
+ + + + + + +
+
+
+ + + +
+
+
+
+ 1Every machine and how you reach it. +
+
+ 2Fleets fold into one card. +
+
+ 3Link several in one go. +
+
+
+
+ +

Environments map
all your machines at a glance

+

Available now in T3 Code 0.1.12

+
t3.codes
+
+
+ + + + + From 1a312fb2bb9417602b5d1110d95a5395b589d3f8 Mon Sep 17 00:00:00 2001 From: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com> Date: Fri, 20 Nov 2026 16:50:22 -0800 Subject: [PATCH 2/5] feat(web): dev-only fake T3 Connect account; map video drags to link Dev builds read t3code:dev:fake-t3-connect from localStorage and, when it holds a fake account, use a fake relay client and session, so the environments map shows T3 Connect account machines (online and offline) without a Connect account. Production builds never read the key. The environments-map staging shows them, and links by dragging a node's plus onto a machine and onto a Shift-selected set. Kit gains reveal and css, and places overlays before the camera starts. Co-Authored-By: Claude Opus 5.5 --- .agents/skills/launch-video/assets/kit.js | 27 +- .../stagings/environments-map/drive.mjs | 107 ++++++-- .../stagings/environments-map/serve.mjs | 8 +- .../stagings/environments-map/story.html | 250 +++++++++++------- apps/web/src/cloud/devFakeConnect.test.ts | 75 ++++++ apps/web/src/cloud/devFakeConnect.ts | 146 ++++++++++ apps/web/src/cloud/managedRelayLayer.ts | 8 +- .../components/settings/EnvironmentsMap.tsx | 8 +- apps/web/src/connection/platform.ts | 64 +++-- docs/operations/development.md | 4 + 10 files changed, 542 insertions(+), 155 deletions(-) create mode 100644 apps/web/src/cloud/devFakeConnect.test.ts create mode 100644 apps/web/src/cloud/devFakeConnect.ts diff --git a/.agents/skills/launch-video/assets/kit.js b/.agents/skills/launch-video/assets/kit.js index f92152e481770..ce8f208c4a5f5 100644 --- a/.agents/skills/launch-video/assets/kit.js +++ b/.agents/skills/launch-video/assets/kit.js @@ -67,6 +67,14 @@ window.Kit = (() => { name === "*" ? frames().map((f) => f.contentDocument) : [beat(name).contentDocument]; return docs.flatMap((doc) => query(doc, target.slice(split + 4))); }; + // Extra CSS in beats ("*" for all), e.g. to uncap a scrolling modal so the whole page shows. + const css = (name, text) => { + for (const f of name === "*" ? frames() : [beat(name)]) { + const style = f.contentDocument.createElement("style"); + style.textContent = text; + f.contentDocument.head.append(style); + } + }; // A static edit to the frozen page, e.g. a dev-only label. Say so when you hand the video back. const text = (targets, value) => { for (const node of all(targets)) node.textContent = value; @@ -97,9 +105,9 @@ window.Kit = (() => { for (const cam of cams) cam.style.animation = "none"; for (const a of scripted) a.cancel(); try { - const result = fn(); + // Overlays first: fn() usually starts the camera, and they must be measured at rest. for (const place of overlays.splice(0)) place(); - return result; + return fn(); } finally { for (const cam of cams) cam.style.animation = ""; } @@ -258,6 +266,20 @@ window.Kit = (() => { ease: "cubic-bezier(.4,0,.2,1)", }); }), + // Wipes an element in from one side (dashed lines, a drag line following the pointer). + reveal: (t, at, dur = 0.5, from = "left") => { + const start = { + left: "inset(0 100% 0 0)", + right: "inset(0 0 0 100%)", + top: "inset(0 0 100% 0)", + bottom: "inset(100% 0 0 0)", + }[from]; + return anim(t, [{ clipPath: start }, { clipPath: "inset(0 0 0 0)" }], { + at, + dur, + ease: "linear", + }); + }, // A punch: brief scale-up pulse that draws the eye. punch: (t, at, scale = 1.06) => anim( @@ -377,6 +399,7 @@ window.Kit = (() => { visible, el, all, + css, text, rect, centerOf, diff --git a/.agents/skills/launch-video/stagings/environments-map/drive.mjs b/.agents/skills/launch-video/stagings/environments-map/drive.mjs index 06d196f12573a..07b5043f18524 100644 --- a/.agents/skills/launch-video/stagings/environments-map/drive.mjs +++ b/.agents/skills/launch-video/stagings/environments-map/drive.mjs @@ -12,11 +12,35 @@ NodeFS.rmSync(NodePath.join(out, "beats"), { recursive: true, force: true }); NodeFS.mkdirSync(NodePath.join(out, "shots"), { recursive: true }); // Fictional tailnet names resolve to this machine in the browser only. -const { browser, page } = await openBrowser({ +const { browser, context, page } = await openBrowser({ width: 1600, - height: 800, + height: 1300, args: ["--host-resolver-rules=MAP *.tail-demo.ts.net 127.0.0.1"], }); +// T3 Connect account machines this client isn't saved to, through the dev-only fake account. +await context.addInitScript( + (value) => localStorage.setItem("t3code:dev:fake-t3-connect", value), + JSON.stringify({ + account: { email: "demo@example.com" }, + environments: [ + { + environmentId: "connect-mac-mini", + label: "mac-mini", + online: true, + machine: "mac-mini", + os: "darwin", + arch: "arm64", + }, + { environmentId: "connect-office", label: "office-pc", online: true, machine: "desktop" }, + { + environmentId: "connect-thinkpad", + label: "old-thinkpad", + online: false, + machine: "laptop", + }, + ], + }), +); const started = Date.now(); const beat = async (name) => { await page.mouse.move(1439, 719); @@ -68,6 +92,7 @@ const routes = [ route(machines.nas, `http://nas.tail-demo.ts.net:${machines.nas.port}`), route(machines.gpu1, `http://${tailnetName}:${machines.gpu1.port}`), route(machines.gpu2, `http://${tailnetName}:${machines.gpu2.port}`), + route(machines.gpu3, `http://${tailnetName}:${machines.gpu3.port}`), ]; const catalog = JSON.stringify({ schemaVersion: 1, @@ -106,29 +131,63 @@ try { await page.waitForTimeout(2000); await beat("map"); - const linkSeveral = page.getByRole("button", { name: "Link several…" }); - await linkSeveral.click(); - await page.getByRole("menuitem", { name: "From MacBook" }).waitFor({ timeout: 10_000 }); - await page.waitForTimeout(300); - await beat("link-menu"); - await page.getByRole("menuitem", { name: "From MacBook" }).click(); - const dialog = page.getByRole("dialog", { name: /Link several machines from MacBook/ }); - await dialog.getByText("gpu-1", { exact: true }).waitFor({ timeout: 30_000 }); - await page.waitForTimeout(800); - await beat("link-open"); - await dialog.getByText("gpu-1", { exact: true }).click(); - await dialog.getByText("gpu-2", { exact: true }).click(); - await page.waitForTimeout(300); - await beat("link-picked"); - await dialog.getByRole("button", { name: /^Link 2 machines/ }).click(); - await page.waitForTimeout(500); - await beat("linking"); - await dialog.getByText("Linked 2 machines", { exact: false }).waitFor({ timeout: 120_000 }); + // Drags a node's plus handle onto `target`, freezing a beat halfway and one over the target. + const center = async (locator) => { + const box = await locator.boundingBox(); + return { x: box.x + box.width / 2, y: box.y + box.height / 2 }; + }; + const node = (label) => page.locator(`button[data-fleet-item][aria-label^="${label},"]`); + const dragLink = async (from, target, name) => { + const plus = page.getByRole("button", { name: `Link ${from} to another machine` }); + await plus.scrollIntoViewIfNeeded(); + const start = await center(plus); + const end = await center(node(target)); + await page.mouse.move(start.x, start.y); + await page.mouse.down(); + for (let i = 1; i <= 12; i++) { + await page.mouse.move( + start.x + ((end.x - start.x) * i) / 12, + start.y + ((end.y - start.y) * i) / 12, + ); + await page.waitForTimeout(30); + if (i === 6) await saveBeat(page, out, `${name}-mid`); + } + await page.waitForTimeout(300); + await saveBeat(page, out, `${name}-over`); + await page.screenshot({ path: NodePath.join(out, "shots", `${name}-over.png`) }); + await page.mouse.up(); + await page.waitForTimeout(800); + }; + + // One machine: drag MacBook's plus onto gpu-1. + await dragLink("MacBook", "gpu-1", "drag1"); + await beat("single-open"); + const single = page.getByRole("dialog", { name: /Link MacBook to gpu-1/ }); + await single.getByRole("button", { name: "Link", exact: true }).click(); + await single.waitFor({ state: "hidden", timeout: 60_000 }); + await page.getByText("1 link out", { exact: false }).last().waitFor({ timeout: 60_000 }); + await page.waitForTimeout(1500); + await beat("single-linked"); + + // Several: Shift-click gpu-2 and gpu-3, then drag MacBook's plus onto the selection. + await node("gpu-2").click({ modifiers: ["Shift"] }); + await page.waitForTimeout(250); + await beat("select-1"); + await node("gpu-3").click({ modifiers: ["Shift"] }); + await page.waitForTimeout(250); + await beat("select-2"); + await dragLink("MacBook", "gpu-3", "drag2"); + const batch = page.getByRole("dialog", { name: /Link several machines from MacBook/ }); + await batch.waitFor({ timeout: 10_000 }); + await page.waitForTimeout(600); + await beat("batch-open"); + await batch.getByRole("button", { name: /^Link 2 machines/ }).click(); + await batch.getByText("Linked 2 machines", { exact: false }).waitFor({ timeout: 120_000 }); await page.waitForTimeout(400); - await beat("link-done"); - await dialog.getByRole("button", { name: "Done" }).click(); - await dialog.waitFor({ state: "hidden", timeout: 10_000 }); - await page.getByText("2 links out", { exact: false }).first().waitFor({ timeout: 60_000 }); + await beat("batch-done"); + await batch.getByRole("button", { name: "Done" }).click(); + await batch.waitFor({ state: "hidden", timeout: 10_000 }); + await page.getByText("3 links out", { exact: false }).first().waitFor({ timeout: 60_000 }); await page.waitForTimeout(1500); await beat("linked"); } catch (error) { diff --git a/.agents/skills/launch-video/stagings/environments-map/serve.mjs b/.agents/skills/launch-video/stagings/environments-map/serve.mjs index be66dfa4f2298..e0e11735cebb7 100644 --- a/.agents/skills/launch-video/stagings/environments-map/serve.mjs +++ b/.agents/skills/launch-video/stagings/environments-map/serve.mjs @@ -1,5 +1,5 @@ // Machines for the environments-map video. Real servers: MacBook (web, this device), studio, -// devbox, and gpu-1/gpu-2 for "Link several"; nas starts once so the browser knows it, then +// devbox, and gpu-1..3 to link by dragging; nas starts once so the browser knows it, then // stops (offline). Link rows are seeded: studio <-> devbox both ways, and devbox -> fs-44..fs-87 // of which 7 answer through descriptor stubs. Writes /stage.json. Usage: serve.mjs import * as NodeChildProcess from "node:child_process"; @@ -37,6 +37,7 @@ const machines = { nas: { label: "nas", machine: "linux" }, gpu1: { label: "gpu-1", machine: "cloud" }, gpu2: { label: "gpu-2", machine: "cloud" }, + gpu3: { label: "gpu-3", machine: "cloud" }, }; for (const [name, identity] of Object.entries(machines)) { prepareHome(NodePath.join(root, name), { ...identity, settings: linked }); @@ -50,7 +51,8 @@ let devbox = await startEnvironment(home("devbox"), { allowedOrigins }); const nas = await startEnvironment(home("nas"), { allowedOrigins }); const gpu1 = await startEnvironment(home("gpu1"), { host: tailnetIp, allowedOrigins }); const gpu2 = await startEnvironment(home("gpu2"), { host: tailnetIp, allowedOrigins }); -console.log("started 6 environments"); +const gpu3 = await startEnvironment(home("gpu3"), { host: tailnetIp, allowedOrigins }); +console.log("started 7 environments"); // Seeded links need the servers stopped: they read the table on start. const fleet = Array.from({ length: 44 }, (_, i) => ({ @@ -80,7 +82,7 @@ const stage = { macbook, tailnetName, machines: Object.fromEntries( - Object.entries({ studio, devbox, nas, gpu1, gpu2 }).map(([name, env]) => [ + Object.entries({ studio, devbox, nas, gpu1, gpu2, gpu3 }).map(([name, env]) => [ name, { environmentId: env.environmentId, diff --git a/.agents/skills/launch-video/stagings/environments-map/story.html b/.agents/skills/launch-video/stagings/environments-map/story.html index 5ee7457b06cee..ae6793543e4d6 100644 --- a/.agents/skills/launch-video/stagings/environments-map/story.html +++ b/.agents/skills/launch-video/stagings/environments-map/story.html @@ -56,7 +56,7 @@ left: 40px; top: 26px; width: 1520px; - height: 760px; + height: 1235px; border-radius: 14px; overflow: hidden; background: #000; @@ -69,7 +69,7 @@ left: 0; top: 0; width: 1600px; - height: 800px; + height: 1300px; transform: scale(0.95); transform-origin: 0 0; } @@ -77,7 +77,7 @@ position: absolute; inset: 0; width: 1600px; - height: 800px; + height: 1300px; border: 0; opacity: 0; background: #000; @@ -199,10 +199,16 @@
- - - - + + + + + + + + + +
@@ -227,7 +233,12 @@ 2Fleets fold into one card.
- 3Link several in one go. + 3Drag to link a plus onto any machine. +
+
+ 4Select several and drop on them all.
@@ -253,17 +264,27 @@

Environments map
all your machines at a glance { at: from, dur: to - from, ease: "linear" }, ); const MAP = '[aria-label="Map of your machines"]'; - const node = (beat, label) => `${beat} >> button[data-fleet-item][aria-label^="${label}"]`; + const node = (beat, label) => `${beat} >> button[data-fleet-item][aria-label^="${label},"]`; + const handle = (beat, label) => + `${beat} >> button[aria-label="Link ${label} to another machine"]`; + const DRAG_LINE = `${MAP} path[stroke-dasharray="5 4"]`; const DIALOG = "[role=dialog][aria-labelledby]"; + const WIDE = { on: [800, 560], s: 0.78, y: 440 }; window.setup = () => { Kit.beats([ ["map", 0], - ["link-menu", 9.85], - ["link-open", 10.9], - ["link-picked", 11.55], - ["link-done", 13.1], - ["linked", 14.35], + ["drag1-mid", 13.0], + ["drag1-over", 13.45], + ["single-open", 14.05], + ["single-linked", 15.2], + ["select-1", 17.25], + ["select-2", 17.75], + ["drag2-mid", 18.35], + ["drag2-over", 18.8], + ["batch-open", 19.4], + ["batch-done", 20.6], + ["linked", 21.65], ]); Kit.anim( ".win", @@ -274,117 +295,156 @@

Environments map
all your machines at a glance { at: 0, dur: 0.8 }, ); - // 1. The map builds itself: machines, then the routes to them, then links. - Kit.stagger(`map >> ${MAP} button[data-fleet-item]`, 0.35, 0.07, "pop", { from: 0.85 }); - Kit.draw(`map >> ${MAP} svg path`, 0.5, 0.7, 0.025); - Kit.stagger(`map >> ${MAP} > span`, 0.9, 0.03, "pop", { from: 0.7 }); - Kit.glow(`map >> ${MAP} > span:text(LAN)`, 2.6, 1.6); - cap("#cap1", 0.9, 4.6); + // 1. The map builds itself. + Kit.stagger(`map >> ${MAP} button[data-fleet-item]`, 0.35, 0.06, "pop", { from: 0.85 }); + Kit.draw(`map >> ${MAP} svg path`, 0.5, 0.7, 0.02); + Kit.stagger(`map >> ${MAP} > span`, 0.9, 0.025, "pop", { from: 0.7 }); + Kit.glow(`map >> ${MAP} > span:text(LAN)`, 2.6, 1.4); + // Machines on the T3 Connect account that this app hasn't added: online and offline. + Kit.stagger( + `map >> ${MAP} button[data-fleet-item][aria-label*="T3 Connect account"]`, + 5.0, + 0.15, + "punch", + ); + Kit.glow(node("map", "old-thinkpad"), 5.6, 1.3); + cap("#cap1", 0.9, 6.8); - // 2. The fleet - Kit.glow(node("map", "fs-44"), 5.5, 2.0); - Kit.punch(node("map", "fs-44"), 5.5, 1.05); - cap("#cap2", 4.8, 8.6); + // 2. The fleet card. + Kit.glow(node("map", "fs-44 … fs-87"), 7.7, 1.8); + Kit.punch(node("map", "fs-44 … fs-87"), 7.7, 1.05); + cap("#cap2", 7.0, 10.1); - // 3. Link several - Kit.press(`map >> button[data-slot=tooltip-trigger]:text(Link several)`, 9.6); - Kit.pop("link-menu >> [role=menu]", 9.85, { from: 0.9, origin: "top right" }); - Kit.pop(`link-open >> ${DIALOG}`, 10.9, { from: 0.92 }); - Kit.stagger(`link-picked >> ${DIALOG} [data-slot=checkbox-indicator]`, 11.55, 0.5, "pop", { - from: 0.3, + // 3. Drag a plus onto a machine. + Kit.press(handle("map", "MacBook"), 12.7); + Kit.reveal(`drag1-mid >> ${DRAG_LINE}`, 13.0, 0.45, "bottom"); + Kit.pop(`drag1-over >> ${MAP} p[role=status]`, 13.5, { from: 0.6, origin: "left center" }); + Kit.pop(`single-open >> ${DIALOG}`, 14.05, { from: 0.92 }); + Kit.press(`single-open >> ${DIALOG} button:text(Link)`, 14.9); + Kit.draw( + `single-linked >> ${MAP} path[data-fleet-item]:text(Link from MacBook)`, + 15.25, + 0.7, + ); + Kit.stagger(`single-linked >> ${MAP} > span:text(Supervised)`, 15.7, 0.1, "pop", { + from: 0.6, }); - Kit.press(`link-picked >> ${DIALOG} [data-slot=dialog-footer] button:text(Link 2)`, 12.8); - Kit.rise(`link-done >> ${DIALOG} form > p`, 13.1, { y: 8 }); - Kit.stagger(`link-done >> ${DIALOG} li:text(Linked)`, 13.15, 0.12, "punch"); - Kit.press(`link-done >> button[data-slot=dialog-close]`, 14.15); - Kit.draw(`linked >> ${MAP} path[data-fleet-item]:text(Link from MacBook)`, 14.5, 0.7, 0.15); - Kit.stagger(`linked >> ${MAP} > span:text(Supervised)`, 15.0, 0.12, "pop", { from: 0.6 }); - Kit.glow(node("linked", "MacBook"), 15.3, 1.6); - cap("#cap3", 9.0, 16.8); + Kit.glow(node("single-linked", "gpu-1"), 15.7, 1.3); + cap("#cap3", 9.0, 16.9); - Kit.anim(".outro", [{ opacity: 0 }, { opacity: 1 }], { at: 17.0, dur: 0.5 }); - Kit.stagger(".outro .logo, .outro h2, .outro p, .outro .url", 17.05, 0.08, "rise", { + // 4. Select several, drop on the selection. + Kit.press(node("select-1", "gpu-2"), 17.2); + Kit.press(node("select-2", "gpu-3"), 17.7); + Kit.press(handle("select-2", "MacBook"), 18.2); + Kit.reveal(`drag2-mid >> ${DRAG_LINE}`, 18.35, 0.45, "bottom"); + Kit.pop(`drag2-over >> ${MAP} p[role=status]`, 18.85, { from: 0.6, origin: "left center" }); + Kit.pop(`batch-open >> ${DIALOG}`, 19.4, { from: 0.92 }); + Kit.press(`batch-open >> ${DIALOG} [data-slot=dialog-footer] button:text(Link 2)`, 20.35); + Kit.rise(`batch-done >> ${DIALOG} form > p`, 20.6, { y: 8 }); + Kit.press(`batch-done >> button[data-slot=dialog-close]`, 21.4); + Kit.draw(`linked >> ${MAP} path[data-fleet-item]:text(Link from MacBook)`, 21.7, 0.7, 0.12); + Kit.stagger(`linked >> ${MAP} > span:text(Supervised)`, 22.1, 0.1, "pop", { from: 0.6 }); + Kit.glow(node("linked", "MacBook"), 22.4, 1.6); + cap("#cap4", 17.0, 24.0); + + Kit.anim(".outro", [{ opacity: 0 }, { opacity: 1 }], { at: 24.2, dur: 0.5 }); + Kit.stagger(".outro .logo, .outro h2, .outro p, .outro .url", 24.25, 0.08, "rise", { y: 18, }); }; - window.layoutTime = 16.9; + window.layoutTime = 24.1; window.placeCursor = () => Kit.measure(() => { + const drag = [node("map", "gpu-2"), { dx: -40, s: 1.55, y: 430 }]; + const dialogAt = (beat) => ({ on: `${beat} >> ${DIALOG}`, s: 1.35, y: 430 }); Kit.camera([ - { t: 0, on: "full" }, - { t: 1.6, on: "full" }, + { t: 0, ...WIDE }, + { t: 1.6, ...WIDE }, { t: 2.2, on: node("map", "studio"), - dx: -120, + dx: -150, s: 1.8, y: 380, ease: "cubic-bezier(.3,1.2,.4,1)", }, - { t: 4.4, on: node("map", "studio"), dx: -120, s: 1.8, y: 380 }, - { t: 5.1, on: node("map", "fs-44"), dx: -200, s: 1.6, y: 420 }, - { t: 8.2, on: node("map", "fs-44"), dx: -200, s: 1.6, y: 420 }, - { - t: 8.9, - on: `map >> button[data-slot=tooltip-trigger]:text(Link several)`, - dx: -220, - dy: 140, - s: 1.3, - y: 360, - }, - { - t: 10.5, - on: `map >> button[data-slot=tooltip-trigger]:text(Link several)`, - dx: -220, - dy: 140, - s: 1.3, - y: 360, - }, - { t: 11.0, on: `link-open >> ${DIALOG}`, s: 1.3, y: 430 }, - { t: 14.2, on: `link-open >> ${DIALOG}`, s: 1.3, y: 430 }, - { t: 14.8, on: node("linked", "gpu-2"), dx: -60, dy: 40, s: 1.45, y: 420 }, - { t: 17.0, on: node("linked", "gpu-2"), dx: -60, dy: 40, s: 1.45, y: 420 }, + { t: 4.1, on: node("map", "studio"), dx: -150, s: 1.8, y: 380 }, + { t: 4.8, on: node("map", "office-pc"), dx: -120, s: 1.7, y: 420 }, + { t: 6.6, on: node("map", "office-pc"), dx: -120, s: 1.7, y: 420 }, + { t: 7.3, on: node("map", "fs-44 … fs-87"), dx: -200, s: 1.6, y: 420 }, + { t: 9.8, on: node("map", "fs-44 … fs-87"), dx: -200, s: 1.6, y: 420 }, + { t: 10.5, ...WIDE }, + { t: 11.4, ...WIDE }, + { t: 12.1, on: drag[0], ...drag[1] }, + { t: 13.9, on: drag[0], ...drag[1] }, + { t: 14.3, ...dialogAt("single-open") }, + { t: 15.0, ...dialogAt("single-open") }, + { t: 15.4, on: drag[0], ...drag[1] }, + { t: 19.2, on: drag[0], ...drag[1] }, + { t: 19.6, ...dialogAt("batch-open") }, + { t: 21.5, ...dialogAt("batch-open") }, + { t: 21.9, on: drag[0], ...drag[1] }, + { t: 24.1, on: drag[0], ...drag[1] }, ]); + const over = (beat, label) => ({ at: node(beat, label), dx: -30 }); Kit.cursor("#cur", [ - { t: 8.6, at: [1250, 620], hidden: true }, - { t: 8.8 }, + { t: 11.6, at: [1200, 760], hidden: true }, + { t: 11.8 }, + { t: 12.65, at: handle("map", "MacBook"), click: true }, + { t: 12.95 }, + { t: 13.9, ...over("drag1-over", "gpu-1") }, + { t: 14.0, hidden: true }, + { t: 14.4, at: `single-open >> ${DIALOG} button:text(Link)`, hidden: true }, + { t: 14.6 }, + { t: 14.85, at: `single-open >> ${DIALOG} button:text(Link)`, click: true }, + { t: 15.3, hidden: true }, + { t: 16.7, at: node("select-1", "gpu-2"), hidden: true }, + { t: 16.9 }, + { t: 17.15, at: node("select-1", "gpu-2"), click: true }, + { t: 17.65, at: node("select-2", "gpu-3"), click: true }, + { t: 18.15, at: handle("select-2", "MacBook"), click: true }, + { t: 18.3 }, + { t: 19.25, ...over("drag2-over", "gpu-3") }, + { t: 19.35, hidden: true }, { - t: 9.55, - at: `map >> button[data-slot=tooltip-trigger]:text(Link several)`, - click: true, + t: 19.9, + at: `batch-open >> ${DIALOG} [data-slot=dialog-footer] button:text(Link 2)`, + hidden: true, }, - { t: 10.55, at: "link-menu >> [role=menuitem]:text(From MacBook)", click: true }, - { t: 11.45, at: `link-picked >> ${DIALOG} li:text(gpu-1)`, dx: -120, click: true }, - { t: 11.95, at: `link-picked >> ${DIALOG} li:text(gpu-2)`, dx: -120, click: true }, + { t: 20.05 }, { - t: 12.75, - at: `link-picked >> ${DIALOG} [data-slot=dialog-footer] button:text(Link 2)`, + t: 20.3, + at: `batch-open >> ${DIALOG} [data-slot=dialog-footer] button:text(Link 2)`, click: true, }, - { t: 14.1, at: `link-done >> button[data-slot=dialog-close]`, click: true }, - { t: 14.5, hidden: true }, - { t: 17, hidden: true }, + { t: 21.35, at: "batch-done >> button[data-slot=dialog-close]", click: true }, + { t: 21.7, hidden: true }, + { t: 24, hidden: true }, ]); }); Kit.timeline([ [1.6, 0, 1.6], [0.8, 1.6, 2.2], - [2.6, 2.2, 4.4], - [0.8, 4.4, 5.1], - [3.4, 5.1, 8.2], - [0.8, 8.2, 8.9], - [1.2, 8.9, 9.85], - [0.9, 9.85, 10.6], - [0.6, 10.6, 11.0], - [1.6, 11.0, 12.1], - [1.0, 12.1, 12.8], - [0.8, 12.8, 13.1], - [1.6, 13.1, 14.2], - [0.6, 14.2, 14.8], - [2.2, 14.8, 16.9], - [0.7, 16.9, 17.6], - [2.8, 17.6, 17.6], + [2.4, 2.2, 4.1], + [0.8, 4.1, 4.8], + [2.4, 4.8, 6.6], + [0.8, 6.6, 7.3], + [2.8, 7.3, 9.8], + [0.8, 9.8, 10.5], + [0.9, 10.5, 11.4], + [1.0, 11.4, 12.1], + [0.8, 12.1, 12.9], + [1.4, 12.9, 14.0], + [1.4, 14.0, 15.1], + [1.8, 15.1, 16.6], + [1.2, 16.6, 17.8], + [1.4, 17.8, 19.3], + [1.4, 19.3, 20.4], + [1.4, 20.4, 21.6], + [2.2, 21.6, 24.1], + [0.7, 24.1, 24.8], + [2.8, 24.8, 24.8], ]); diff --git a/apps/web/src/cloud/devFakeConnect.test.ts b/apps/web/src/cloud/devFakeConnect.test.ts new file mode 100644 index 0000000000000..8b56e4e4f57c0 --- /dev/null +++ b/apps/web/src/cloud/devFakeConnect.test.ts @@ -0,0 +1,75 @@ +import { Connectivity, Wakeups } from "@t3tools/client-runtime/connection"; +import { ClientCapabilities } from "@t3tools/client-runtime/platform"; +import { Discovery, ManagedRelay } from "@t3tools/client-runtime/relay"; +import { describe, expect, it } from "@effect/vitest"; +import * as Effect from "effect/Effect"; +import * as Layer from "effect/Layer"; +import * as Option from "effect/Option"; +import * as Stream from "effect/Stream"; +import * as SubscriptionRef from "effect/SubscriptionRef"; + +import { + DEV_FAKE_CONNECT_TOKEN, + decodeDevFakeConnect, + layerDevFakeManagedRelay, +} from "./devFakeConnect"; + +const config = Option.getOrThrow( + decodeDevFakeConnect( + JSON.stringify({ + account: { email: "demo@example.com" }, + environments: [ + { environmentId: "studio", label: "Studio", online: true, machine: "mac-studio" }, + { environmentId: "vps", label: "VPS", online: false }, + ], + }), + ), +); + +describe("dev fake T3 Connect", () => { + it.effect("discovery lists the staged machines with their online state", () => + Effect.gen(function* () { + const discovery = yield* Discovery.RelayEnvironmentDiscovery; + yield* discovery.refresh; + const state = yield* SubscriptionRef.get(discovery.state); + expect(state.listed).toBe(true); + expect(Option.isNone(state.error)).toBe(true); + const studio = state.environments.get("studio"); + expect(studio?.availability).toBe("online"); + expect(Option.getOrThrow(studio!.status).descriptor?.platform.machine).toBe("mac-studio"); + expect(state.environments.get("vps")?.availability).toBe("offline"); + + const relay = yield* ManagedRelay.ManagedRelayClient; + const connect = yield* relay + .connectEnvironment({ + clerkToken: DEV_FAKE_CONNECT_TOKEN, + scopes: [], + environmentId: studio!.environment.environmentId, + }) + .pipe(Effect.flip); + expect(connect._tag).toBe("ManagedRelayRequestFailedError"); + }).pipe( + Effect.provide( + Discovery.layer.pipe( + Layer.provideMerge( + Layer.mergeAll( + layerDevFakeManagedRelay(config), + Layer.succeed( + ClientCapabilities.CloudSession, + ClientCapabilities.CloudSession.of({ + identity: Effect.succeedSome({ accountId: config.account.email }), + clerkToken: Effect.succeed(DEV_FAKE_CONNECT_TOKEN), + }), + ), + Layer.succeed(Connectivity.Connectivity, { + status: Effect.succeed("online" as const), + changes: Stream.never, + }), + Layer.succeed(Wakeups.ConnectionWakeups, { changes: Stream.never }), + ), + ), + ), + ), + ), + ); +}); diff --git a/apps/web/src/cloud/devFakeConnect.ts b/apps/web/src/cloud/devFakeConnect.ts new file mode 100644 index 0000000000000..8d9007305ebc9 --- /dev/null +++ b/apps/web/src/cloud/devFakeConnect.ts @@ -0,0 +1,146 @@ +import { ManagedRelay } from "@t3tools/client-runtime/relay"; +import { + EnvironmentMachineKind, + ExecutionEnvironmentPlatformArch, + ExecutionEnvironmentPlatformOs, + TrimmedNonEmptyString, +} from "@t3tools/contracts"; +import { + RelayManagedEndpointProviderKind, + type RelayClientEnvironmentRecord, + type RelayEnvironmentStatusResponse, +} from "@t3tools/contracts/relay"; +import * as Effect from "effect/Effect"; +import * as Layer from "effect/Layer"; +import * as Option from "effect/Option"; +import * as Schema from "effect/Schema"; + +// Dev-only: stages T3 Connect account machines for launch videos without a Connect account. +const DEV_FAKE_CONNECT_STORAGE_KEY = "t3code:dev:fake-t3-connect"; + +const DevFakeConnectEnvironment = Schema.Struct({ + environmentId: TrimmedNonEmptyString, + label: TrimmedNonEmptyString, + online: Schema.Boolean, + machine: Schema.optionalKey(EnvironmentMachineKind), + os: Schema.optionalKey(ExecutionEnvironmentPlatformOs), + arch: Schema.optionalKey(ExecutionEnvironmentPlatformArch), + serverVersion: Schema.optionalKey(TrimmedNonEmptyString), + providerKind: Schema.optionalKey(RelayManagedEndpointProviderKind), +}); + +const DevFakeConnect = Schema.Struct({ + account: Schema.Struct({ email: TrimmedNonEmptyString }), + environments: Schema.Array(DevFakeConnectEnvironment), +}); +export type DevFakeConnect = typeof DevFakeConnect.Type; + +export const decodeDevFakeConnect = Schema.decodeUnknownOption( + Schema.fromJsonString(DevFakeConnect), +); + +function readDevFakeConnect(): DevFakeConnect | null { + try { + const raw = window.localStorage.getItem(DEV_FAKE_CONNECT_STORAGE_KEY); + return raw === null ? null : Option.getOrNull(decodeDevFakeConnect(raw)); + } catch { + return null; + } +} + +/** The staged account, or null outside dev or without the localStorage key. */ +export const devFakeConnect: DevFakeConnect | null = + import.meta.env.DEV && typeof window !== "undefined" ? readDevFakeConnect() : null; + +export const DEV_FAKE_CONNECT_TOKEN = "dev-fake-t3-connect"; + +const CHECKED_AT = "2026-01-01T00:00:00.000Z"; + +function environmentRecord( + environment: DevFakeConnect["environments"][number], +): RelayClientEnvironmentRecord { + const host = `${environment.environmentId}.fake-connect.invalid`; + return { + environmentId: environment.environmentId as RelayClientEnvironmentRecord["environmentId"], + label: environment.label, + endpoint: { + httpBaseUrl: `https://${host}`, + wsBaseUrl: `wss://${host}`, + providerKind: environment.providerKind ?? "t3_relay", + }, + linkedAt: CHECKED_AT, + }; +} + +function environmentStatus( + environment: DevFakeConnect["environments"][number], +): RelayEnvironmentStatusResponse { + const record = environmentRecord(environment); + return { + environmentId: record.environmentId, + endpoint: record.endpoint, + status: environment.online ? "online" : "offline", + checkedAt: CHECKED_AT, + descriptor: { + environmentId: record.environmentId, + label: record.label, + platform: { + os: environment.os ?? "linux", + arch: environment.arch ?? "x64", + ...(environment.machine === undefined ? {} : { machine: environment.machine }), + }, + serverVersion: environment.serverVersion ?? "0.0.0-dev", + capabilities: { repositoryIdentity: false }, + }, + }; +} + +const unavailable = (action: ManagedRelay.ManagedRelayRequestAction) => () => + Effect.fail( + new ManagedRelay.ManagedRelayRequestFailedError({ + action, + cause: new Error("Staged T3 Connect machines cannot be reached."), + }), + ); + +const answer = + (value: A) => + () => + Effect.succeed(value); + +/** Answers account reads from the staged config; anything that would reach a machine fails. */ +function makeDevFakeManagedRelayClient(config: DevFakeConnect) { + const statuses = new Map( + config.environments.map((environment) => [ + environment.environmentId, + environmentStatus(environment), + ]), + ); + return ManagedRelay.ManagedRelayClient.of({ + relayUrl: "https://relay.fake-connect.invalid", + listEnvironments: answer(config.environments.map(environmentRecord)), + listDevices: answer([]), + createEnvironmentLinkChallenge: unavailable("create relay environment link challenge"), + linkEnvironment: unavailable("link relay environment"), + unlinkEnvironment: unavailable("unlink relay environment"), + getT3ChatLink: answer({ available: false, link: null }), + createT3ChatLinkRequest: unavailable("start T3 Chat linking"), + unlinkT3Chat: unavailable("unlink T3 Chat account"), + getEnvironmentStatus: Effect.fn("DevFakeConnect.getEnvironmentStatus")(function* (input: { + readonly environmentId: string; + }) { + const status = statuses.get(input.environmentId); + if (status === undefined) return yield* unavailable("get relay environment status")(); + return status; + }), + connectEnvironment: unavailable("connect relay environment"), + registerDevice: unavailable("register relay mobile device"), + unregisterDevice: unavailable("unregister relay mobile device"), + registerLiveActivity: unavailable("register relay live activity"), + getAgentActivitySnapshot: unavailable("read relay agent activity snapshot"), + resetTokenCache: Effect.void, + }); +} + +export const layerDevFakeManagedRelay = (config: DevFakeConnect) => + Layer.succeed(ManagedRelay.ManagedRelayClient, makeDevFakeManagedRelayClient(config)); diff --git a/apps/web/src/cloud/managedRelayLayer.ts b/apps/web/src/cloud/managedRelayLayer.ts index 4295e7773c7cc..775ec0fc3d438 100644 --- a/apps/web/src/cloud/managedRelayLayer.ts +++ b/apps/web/src/cloud/managedRelayLayer.ts @@ -2,6 +2,7 @@ import { DpopProof, ManagedRelay } from "@t3tools/client-runtime/relay"; import { RelayWebClientId } from "@t3tools/contracts/relay"; import * as Layer from "effect/Layer"; +import { devFakeConnect, layerDevFakeManagedRelay } from "./devFakeConnect"; import { loadOrCreateProofKey } from "./dpop"; const layerRelayDpopSigner = DpopProof.layerSigner({ @@ -9,7 +10,12 @@ const layerRelayDpopSigner = DpopProof.layerSigner({ loadOrCreateKey: loadOrCreateProofKey(), }); -export const layer = (relayUrl: string) => +const layerLive = (relayUrl: string) => ManagedRelay.layer({ relayUrl, clientId: RelayWebClientId }).pipe( Layer.provideMerge(layerRelayDpopSigner), ); + +export const layer = (relayUrl: string): ReturnType => + devFakeConnect === null + ? layerLive(relayUrl) + : Layer.merge(layerDevFakeManagedRelay(devFakeConnect), layerRelayDpopSigner); diff --git a/apps/web/src/components/settings/EnvironmentsMap.tsx b/apps/web/src/components/settings/EnvironmentsMap.tsx index 172e2ef917093..1a3650cd07fd1 100644 --- a/apps/web/src/components/settings/EnvironmentsMap.tsx +++ b/apps/web/src/components/settings/EnvironmentsMap.tsx @@ -48,6 +48,7 @@ import { useState, } from "react"; +import { devFakeConnect } from "~/cloud/devFakeConnect"; import { hasCloudPublicConfig } from "~/cloud/publicConfig"; import { isElectron } from "~/env"; import { useLiveRefresh } from "~/hooks/useLiveRefresh"; @@ -247,7 +248,12 @@ function useConnectMachines() { const discovery = useRelayEnvironmentDiscovery(); const refresh = useAtomCommand(relayEnvironmentDiscovery.refresh, { reportFailure: false }); const discoverIfUnasked = useEffectEvent(() => { - if (hasCloudPublicConfig() && !discovery.listed && !discovery.refreshing) void refresh(); + if ( + (hasCloudPublicConfig() || devFakeConnect !== null) && + !discovery.listed && + !discovery.refreshing + ) + void refresh(); }); // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- one T3 Connect listing when the map mounts, the request the list makes on mount useEffect(() => { diff --git a/apps/web/src/connection/platform.ts b/apps/web/src/connection/platform.ts index ee28ca37202f9..70b77d3b91027 100644 --- a/apps/web/src/connection/platform.ts +++ b/apps/web/src/connection/platform.ts @@ -61,6 +61,7 @@ import { readDesktopSecondaryBootstrapsResult, type DesktopSecondaryBootstrapsRead, } from "./desktopLocal"; +import { DEV_FAKE_CONNECT_TOKEN, devFakeConnect } from "../cloud/devFakeConnect"; import * as ConnectionStorage from "./storage"; import { clientPresentationMetadata } from "./clientMetadata"; import { m } from "../i18n/messages"; @@ -368,36 +369,41 @@ const layerCapabilities = Layer.effectContext( const presentation = ClientCapabilities.ClientPresentation.of({ metadata: currentClientMetadata(), }); - const cloudSession = ClientCapabilities.CloudSession.of({ - identity: Effect.sync(() => - Option.fromNullishOr(appAtomRegistry.get(managedRelaySessionAtom)), - ), - clerkToken: Effect.gen(function* () { - const session = appAtomRegistry.get(managedRelaySessionAtom); - if (session === null) { - return yield* new ConnectionBlockedError({ - reason: "authentication", - detail: m(msg("Sign in to T3 Connect to connect this environment.")), - }); - } - const token = yield* session.readClerkToken().pipe( - Effect.mapError( - (error) => - new ConnectionTransientError({ - reason: "network", - detail: error.message, - }), + const cloudSession = devFakeConnect + ? ClientCapabilities.CloudSession.of({ + identity: Effect.succeedSome({ accountId: devFakeConnect.account.email }), + clerkToken: Effect.succeed(DEV_FAKE_CONNECT_TOKEN), + }) + : ClientCapabilities.CloudSession.of({ + identity: Effect.sync(() => + Option.fromNullishOr(appAtomRegistry.get(managedRelaySessionAtom)), ), - ); - if (token === null) { - return yield* new ConnectionBlockedError({ - reason: "authentication", - detail: m(msg("The T3 Connect session is unavailable.")), - }); - } - return token; - }), - }); + clerkToken: Effect.gen(function* () { + const session = appAtomRegistry.get(managedRelaySessionAtom); + if (session === null) { + return yield* new ConnectionBlockedError({ + reason: "authentication", + detail: m(msg("Sign in to T3 Connect to connect this environment.")), + }); + } + const token = yield* session.readClerkToken().pipe( + Effect.mapError( + (error) => + new ConnectionTransientError({ + reason: "network", + detail: error.message, + }), + ), + ); + if (token === null) { + return yield* new ConnectionBlockedError({ + reason: "authentication", + detail: m(msg("The T3 Connect session is unavailable.")), + }); + } + return token; + }), + }); const identity = ClientCapabilities.RelayDeviceIdentity.of({ deviceId: Effect.succeedNone, }); diff --git a/docs/operations/development.md b/docs/operations/development.md index 0492bab862e6c..ff430c0aba552 100644 --- a/docs/operations/development.md +++ b/docs/operations/development.md @@ -100,6 +100,10 @@ and vendor frames, so Grok and fx recordings lose their vendor-only behavior. A request frame (`{ name, arguments }`) makes the agent call that T3 tool itself over its MCP session, and `` in any frame is filled from the JSON file at `T3_DEV_REPLAY_VARS`. +### Fake T3 Connect machines + +To stage T3 Connect account machines without an account (for launch videos), set localStorage `t3code:dev:fake-t3-connect` in the dev web client to `{"account":{"email":"demo@example.com"},"environments":[{"environmentId":"studio","label":"Studio","online":true,"machine":"mac-studio"}]}` and reload; see [devFakeConnect.ts](../../apps/web/src/cloud/devFakeConnect.ts) for the optional fields. + ### Profiling dev startup Run `vp run profile:startup` to capture the first 20 seconds of inherited Node processes under From fd0dda2e3e8c846ba7dc8b4bf4801205c5a06c6b Mon Sep 17 00:00:00 2001 From: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com> Date: Fri, 20 Nov 2026 16:59:37 -0800 Subject: [PATCH 3/5] chore(skills): keep the launch-video engine, drop per-video staging The environments-map staging and the dev-only fake T3 Connect account were built for one video; they stay out of the repo. The skill keeps the general pieces and documents the techniques. fake-claude reads FAKE_CLAUDE_VARS. Co-Authored-By: Claude Opus 5.5 --- .agents/skills/launch-video/SKILL.md | 20 +- .../launch-video/scripts/fake-claude.mjs | 2 +- .../stagings/environments-map/drive.mjs | 198 -------- .../stagings/environments-map/serve.mjs | 108 ----- .../stagings/environments-map/story.html | 451 ------------------ .../stagings/linked-environments/serve.mjs | 2 +- apps/web/src/cloud/devFakeConnect.test.ts | 75 --- apps/web/src/cloud/devFakeConnect.ts | 146 ------ apps/web/src/cloud/managedRelayLayer.ts | 8 +- .../components/settings/EnvironmentsMap.tsx | 8 +- apps/web/src/connection/platform.ts | 64 ++- docs/operations/development.md | 4 - 12 files changed, 45 insertions(+), 1041 deletions(-) delete mode 100644 .agents/skills/launch-video/stagings/environments-map/drive.mjs delete mode 100644 .agents/skills/launch-video/stagings/environments-map/serve.mjs delete mode 100644 .agents/skills/launch-video/stagings/environments-map/story.html delete mode 100644 apps/web/src/cloud/devFakeConnect.test.ts delete mode 100644 apps/web/src/cloud/devFakeConnect.ts diff --git a/.agents/skills/launch-video/SKILL.md b/.agents/skills/launch-video/SKILL.md index 9f0a8270442e9..f45e478568afa 100644 --- a/.agents/skills/launch-video/SKILL.md +++ b/.agents/skills/launch-video/SKILL.md @@ -39,17 +39,21 @@ There are two ways to build one: and tool rows. Each turn is `{ match, steps }`: `think`, `text`, `bash` (+ `output`, `ms`), `wait`, and `tool` (+ `input`), which calls that T3 MCP tool for real, e.g. `delegate_task`. Match generated titles with a `{ match: "title", repeat: true }` turn. - `` is filled from the JSON file at `T3_DEV_REPLAY_VARS`, for ids that change + `` is filled from the JSON file at `FAKE_CLAUDE_VARS`, for ids that change every run. `fake-claude.log` in the home records the protocol, for debugging. - Data a real flow can't produce cheaply goes into the app's own stores, never into pixels. - `stagings/environments-map/` shows the tools: `insertPeerLinks` writes link rows into a - stopped server, `serveDescriptors` makes fake machines answer the reachability probe, - and its drive seeds the client's saved environments and routes into IndexedDB - (`t3code:connection-runtime` / `catalog` / `document`). Route kinds come from hostnames: - `*.localhost` is LAN, `*.ts.net` is Tailscale; Chrome's + `insertPeerLinks` writes link rows into a stopped server; `serveDescriptors` makes fake + machines answer the reachability probe. The client's saved environments and routes live + in IndexedDB (`t3code:connection-runtime` / `catalog` / `document`): write the document + from the page after its first load, then reload. Route kinds come from hostnames + (`*.localhost` is LAN, `*.ts.net` Tailscale); Chrome's `--host-resolver-rules=MAP *.tail-demo.ts.net 127.0.0.1` makes fake tailnet names work. - - The free replay agent (`apps/server/scripts/dev-replay-agent.ts`) still works without - `claude`, but it shows as an ACP provider. + - Gestures: hold the mouse down, move in steps, and `saveBeat` mid-drag to freeze the + app's own drag line and highlight; animate between those beats with `Kit.reveal`. + - A capped, scrolling modal freezes at different scroll offsets per beat. Freeze at a + viewport tall enough that nothing scrolls, and size `.app` to match. + - Without `claude`, turns go to the dev replay agent (`apps/server/scripts/dev-replay-agent.ts`), + which shows as an ACP provider. 4. **Create the story:** `scripts/new.sh ~/launch-videos/`, then copy the beats in, or pass that directory as the staging's ``. Add one ` - - - - - - - - - - - -

- -
- - - -
- -
-
- 1Every machine and how you reach it. -
-
- 2Fleets fold into one card. -
-
- 3Drag to link a plus onto any machine. -
-
- 4Select several and drop on them all. -
- -
-
- -

Environments map
all your machines at a glance

-

Available now in T3 Code 0.1.12

-
t3.codes
-
-
- - - - - diff --git a/.agents/skills/launch-video/stagings/linked-environments/serve.mjs b/.agents/skills/launch-video/stagings/linked-environments/serve.mjs index 690f3bb151ff7..6398daf2f24b5 100644 --- a/.agents/skills/launch-video/stagings/linked-environments/serve.mjs +++ b/.agents/skills/launch-video/stagings/linked-environments/serve.mjs @@ -117,7 +117,7 @@ NodeFS.writeFileSync(vars, "{}"); const macbook = await startEnvironment(NodePath.join(root, "macbook"), { web: true, - env: { T3_DEV_REPLAY_VARS: vars }, + env: { FAKE_CLAUDE_VARS: vars }, }); console.log(`MacBook: ${macbook.label} ${macbook.environmentId} web ${macbook.webOrigin}`); const devbox = await startEnvironment(NodePath.join(root, "devbox"), { diff --git a/apps/web/src/cloud/devFakeConnect.test.ts b/apps/web/src/cloud/devFakeConnect.test.ts deleted file mode 100644 index 8b56e4e4f57c0..0000000000000 --- a/apps/web/src/cloud/devFakeConnect.test.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { Connectivity, Wakeups } from "@t3tools/client-runtime/connection"; -import { ClientCapabilities } from "@t3tools/client-runtime/platform"; -import { Discovery, ManagedRelay } from "@t3tools/client-runtime/relay"; -import { describe, expect, it } from "@effect/vitest"; -import * as Effect from "effect/Effect"; -import * as Layer from "effect/Layer"; -import * as Option from "effect/Option"; -import * as Stream from "effect/Stream"; -import * as SubscriptionRef from "effect/SubscriptionRef"; - -import { - DEV_FAKE_CONNECT_TOKEN, - decodeDevFakeConnect, - layerDevFakeManagedRelay, -} from "./devFakeConnect"; - -const config = Option.getOrThrow( - decodeDevFakeConnect( - JSON.stringify({ - account: { email: "demo@example.com" }, - environments: [ - { environmentId: "studio", label: "Studio", online: true, machine: "mac-studio" }, - { environmentId: "vps", label: "VPS", online: false }, - ], - }), - ), -); - -describe("dev fake T3 Connect", () => { - it.effect("discovery lists the staged machines with their online state", () => - Effect.gen(function* () { - const discovery = yield* Discovery.RelayEnvironmentDiscovery; - yield* discovery.refresh; - const state = yield* SubscriptionRef.get(discovery.state); - expect(state.listed).toBe(true); - expect(Option.isNone(state.error)).toBe(true); - const studio = state.environments.get("studio"); - expect(studio?.availability).toBe("online"); - expect(Option.getOrThrow(studio!.status).descriptor?.platform.machine).toBe("mac-studio"); - expect(state.environments.get("vps")?.availability).toBe("offline"); - - const relay = yield* ManagedRelay.ManagedRelayClient; - const connect = yield* relay - .connectEnvironment({ - clerkToken: DEV_FAKE_CONNECT_TOKEN, - scopes: [], - environmentId: studio!.environment.environmentId, - }) - .pipe(Effect.flip); - expect(connect._tag).toBe("ManagedRelayRequestFailedError"); - }).pipe( - Effect.provide( - Discovery.layer.pipe( - Layer.provideMerge( - Layer.mergeAll( - layerDevFakeManagedRelay(config), - Layer.succeed( - ClientCapabilities.CloudSession, - ClientCapabilities.CloudSession.of({ - identity: Effect.succeedSome({ accountId: config.account.email }), - clerkToken: Effect.succeed(DEV_FAKE_CONNECT_TOKEN), - }), - ), - Layer.succeed(Connectivity.Connectivity, { - status: Effect.succeed("online" as const), - changes: Stream.never, - }), - Layer.succeed(Wakeups.ConnectionWakeups, { changes: Stream.never }), - ), - ), - ), - ), - ), - ); -}); diff --git a/apps/web/src/cloud/devFakeConnect.ts b/apps/web/src/cloud/devFakeConnect.ts deleted file mode 100644 index 8d9007305ebc9..0000000000000 --- a/apps/web/src/cloud/devFakeConnect.ts +++ /dev/null @@ -1,146 +0,0 @@ -import { ManagedRelay } from "@t3tools/client-runtime/relay"; -import { - EnvironmentMachineKind, - ExecutionEnvironmentPlatformArch, - ExecutionEnvironmentPlatformOs, - TrimmedNonEmptyString, -} from "@t3tools/contracts"; -import { - RelayManagedEndpointProviderKind, - type RelayClientEnvironmentRecord, - type RelayEnvironmentStatusResponse, -} from "@t3tools/contracts/relay"; -import * as Effect from "effect/Effect"; -import * as Layer from "effect/Layer"; -import * as Option from "effect/Option"; -import * as Schema from "effect/Schema"; - -// Dev-only: stages T3 Connect account machines for launch videos without a Connect account. -const DEV_FAKE_CONNECT_STORAGE_KEY = "t3code:dev:fake-t3-connect"; - -const DevFakeConnectEnvironment = Schema.Struct({ - environmentId: TrimmedNonEmptyString, - label: TrimmedNonEmptyString, - online: Schema.Boolean, - machine: Schema.optionalKey(EnvironmentMachineKind), - os: Schema.optionalKey(ExecutionEnvironmentPlatformOs), - arch: Schema.optionalKey(ExecutionEnvironmentPlatformArch), - serverVersion: Schema.optionalKey(TrimmedNonEmptyString), - providerKind: Schema.optionalKey(RelayManagedEndpointProviderKind), -}); - -const DevFakeConnect = Schema.Struct({ - account: Schema.Struct({ email: TrimmedNonEmptyString }), - environments: Schema.Array(DevFakeConnectEnvironment), -}); -export type DevFakeConnect = typeof DevFakeConnect.Type; - -export const decodeDevFakeConnect = Schema.decodeUnknownOption( - Schema.fromJsonString(DevFakeConnect), -); - -function readDevFakeConnect(): DevFakeConnect | null { - try { - const raw = window.localStorage.getItem(DEV_FAKE_CONNECT_STORAGE_KEY); - return raw === null ? null : Option.getOrNull(decodeDevFakeConnect(raw)); - } catch { - return null; - } -} - -/** The staged account, or null outside dev or without the localStorage key. */ -export const devFakeConnect: DevFakeConnect | null = - import.meta.env.DEV && typeof window !== "undefined" ? readDevFakeConnect() : null; - -export const DEV_FAKE_CONNECT_TOKEN = "dev-fake-t3-connect"; - -const CHECKED_AT = "2026-01-01T00:00:00.000Z"; - -function environmentRecord( - environment: DevFakeConnect["environments"][number], -): RelayClientEnvironmentRecord { - const host = `${environment.environmentId}.fake-connect.invalid`; - return { - environmentId: environment.environmentId as RelayClientEnvironmentRecord["environmentId"], - label: environment.label, - endpoint: { - httpBaseUrl: `https://${host}`, - wsBaseUrl: `wss://${host}`, - providerKind: environment.providerKind ?? "t3_relay", - }, - linkedAt: CHECKED_AT, - }; -} - -function environmentStatus( - environment: DevFakeConnect["environments"][number], -): RelayEnvironmentStatusResponse { - const record = environmentRecord(environment); - return { - environmentId: record.environmentId, - endpoint: record.endpoint, - status: environment.online ? "online" : "offline", - checkedAt: CHECKED_AT, - descriptor: { - environmentId: record.environmentId, - label: record.label, - platform: { - os: environment.os ?? "linux", - arch: environment.arch ?? "x64", - ...(environment.machine === undefined ? {} : { machine: environment.machine }), - }, - serverVersion: environment.serverVersion ?? "0.0.0-dev", - capabilities: { repositoryIdentity: false }, - }, - }; -} - -const unavailable = (action: ManagedRelay.ManagedRelayRequestAction) => () => - Effect.fail( - new ManagedRelay.ManagedRelayRequestFailedError({ - action, - cause: new Error("Staged T3 Connect machines cannot be reached."), - }), - ); - -const answer = -
(value: A) => - () => - Effect.succeed(value); - -/** Answers account reads from the staged config; anything that would reach a machine fails. */ -function makeDevFakeManagedRelayClient(config: DevFakeConnect) { - const statuses = new Map( - config.environments.map((environment) => [ - environment.environmentId, - environmentStatus(environment), - ]), - ); - return ManagedRelay.ManagedRelayClient.of({ - relayUrl: "https://relay.fake-connect.invalid", - listEnvironments: answer(config.environments.map(environmentRecord)), - listDevices: answer([]), - createEnvironmentLinkChallenge: unavailable("create relay environment link challenge"), - linkEnvironment: unavailable("link relay environment"), - unlinkEnvironment: unavailable("unlink relay environment"), - getT3ChatLink: answer({ available: false, link: null }), - createT3ChatLinkRequest: unavailable("start T3 Chat linking"), - unlinkT3Chat: unavailable("unlink T3 Chat account"), - getEnvironmentStatus: Effect.fn("DevFakeConnect.getEnvironmentStatus")(function* (input: { - readonly environmentId: string; - }) { - const status = statuses.get(input.environmentId); - if (status === undefined) return yield* unavailable("get relay environment status")(); - return status; - }), - connectEnvironment: unavailable("connect relay environment"), - registerDevice: unavailable("register relay mobile device"), - unregisterDevice: unavailable("unregister relay mobile device"), - registerLiveActivity: unavailable("register relay live activity"), - getAgentActivitySnapshot: unavailable("read relay agent activity snapshot"), - resetTokenCache: Effect.void, - }); -} - -export const layerDevFakeManagedRelay = (config: DevFakeConnect) => - Layer.succeed(ManagedRelay.ManagedRelayClient, makeDevFakeManagedRelayClient(config)); diff --git a/apps/web/src/cloud/managedRelayLayer.ts b/apps/web/src/cloud/managedRelayLayer.ts index 775ec0fc3d438..4295e7773c7cc 100644 --- a/apps/web/src/cloud/managedRelayLayer.ts +++ b/apps/web/src/cloud/managedRelayLayer.ts @@ -2,7 +2,6 @@ import { DpopProof, ManagedRelay } from "@t3tools/client-runtime/relay"; import { RelayWebClientId } from "@t3tools/contracts/relay"; import * as Layer from "effect/Layer"; -import { devFakeConnect, layerDevFakeManagedRelay } from "./devFakeConnect"; import { loadOrCreateProofKey } from "./dpop"; const layerRelayDpopSigner = DpopProof.layerSigner({ @@ -10,12 +9,7 @@ const layerRelayDpopSigner = DpopProof.layerSigner({ loadOrCreateKey: loadOrCreateProofKey(), }); -const layerLive = (relayUrl: string) => +export const layer = (relayUrl: string) => ManagedRelay.layer({ relayUrl, clientId: RelayWebClientId }).pipe( Layer.provideMerge(layerRelayDpopSigner), ); - -export const layer = (relayUrl: string): ReturnType => - devFakeConnect === null - ? layerLive(relayUrl) - : Layer.merge(layerDevFakeManagedRelay(devFakeConnect), layerRelayDpopSigner); diff --git a/apps/web/src/components/settings/EnvironmentsMap.tsx b/apps/web/src/components/settings/EnvironmentsMap.tsx index 1a3650cd07fd1..172e2ef917093 100644 --- a/apps/web/src/components/settings/EnvironmentsMap.tsx +++ b/apps/web/src/components/settings/EnvironmentsMap.tsx @@ -48,7 +48,6 @@ import { useState, } from "react"; -import { devFakeConnect } from "~/cloud/devFakeConnect"; import { hasCloudPublicConfig } from "~/cloud/publicConfig"; import { isElectron } from "~/env"; import { useLiveRefresh } from "~/hooks/useLiveRefresh"; @@ -248,12 +247,7 @@ function useConnectMachines() { const discovery = useRelayEnvironmentDiscovery(); const refresh = useAtomCommand(relayEnvironmentDiscovery.refresh, { reportFailure: false }); const discoverIfUnasked = useEffectEvent(() => { - if ( - (hasCloudPublicConfig() || devFakeConnect !== null) && - !discovery.listed && - !discovery.refreshing - ) - void refresh(); + if (hasCloudPublicConfig() && !discovery.listed && !discovery.refreshing) void refresh(); }); // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- one T3 Connect listing when the map mounts, the request the list makes on mount useEffect(() => { diff --git a/apps/web/src/connection/platform.ts b/apps/web/src/connection/platform.ts index 70b77d3b91027..ee28ca37202f9 100644 --- a/apps/web/src/connection/platform.ts +++ b/apps/web/src/connection/platform.ts @@ -61,7 +61,6 @@ import { readDesktopSecondaryBootstrapsResult, type DesktopSecondaryBootstrapsRead, } from "./desktopLocal"; -import { DEV_FAKE_CONNECT_TOKEN, devFakeConnect } from "../cloud/devFakeConnect"; import * as ConnectionStorage from "./storage"; import { clientPresentationMetadata } from "./clientMetadata"; import { m } from "../i18n/messages"; @@ -369,41 +368,36 @@ const layerCapabilities = Layer.effectContext( const presentation = ClientCapabilities.ClientPresentation.of({ metadata: currentClientMetadata(), }); - const cloudSession = devFakeConnect - ? ClientCapabilities.CloudSession.of({ - identity: Effect.succeedSome({ accountId: devFakeConnect.account.email }), - clerkToken: Effect.succeed(DEV_FAKE_CONNECT_TOKEN), - }) - : ClientCapabilities.CloudSession.of({ - identity: Effect.sync(() => - Option.fromNullishOr(appAtomRegistry.get(managedRelaySessionAtom)), + const cloudSession = ClientCapabilities.CloudSession.of({ + identity: Effect.sync(() => + Option.fromNullishOr(appAtomRegistry.get(managedRelaySessionAtom)), + ), + clerkToken: Effect.gen(function* () { + const session = appAtomRegistry.get(managedRelaySessionAtom); + if (session === null) { + return yield* new ConnectionBlockedError({ + reason: "authentication", + detail: m(msg("Sign in to T3 Connect to connect this environment.")), + }); + } + const token = yield* session.readClerkToken().pipe( + Effect.mapError( + (error) => + new ConnectionTransientError({ + reason: "network", + detail: error.message, + }), ), - clerkToken: Effect.gen(function* () { - const session = appAtomRegistry.get(managedRelaySessionAtom); - if (session === null) { - return yield* new ConnectionBlockedError({ - reason: "authentication", - detail: m(msg("Sign in to T3 Connect to connect this environment.")), - }); - } - const token = yield* session.readClerkToken().pipe( - Effect.mapError( - (error) => - new ConnectionTransientError({ - reason: "network", - detail: error.message, - }), - ), - ); - if (token === null) { - return yield* new ConnectionBlockedError({ - reason: "authentication", - detail: m(msg("The T3 Connect session is unavailable.")), - }); - } - return token; - }), - }); + ); + if (token === null) { + return yield* new ConnectionBlockedError({ + reason: "authentication", + detail: m(msg("The T3 Connect session is unavailable.")), + }); + } + return token; + }), + }); const identity = ClientCapabilities.RelayDeviceIdentity.of({ deviceId: Effect.succeedNone, }); diff --git a/docs/operations/development.md b/docs/operations/development.md index ff430c0aba552..0492bab862e6c 100644 --- a/docs/operations/development.md +++ b/docs/operations/development.md @@ -100,10 +100,6 @@ and vendor frames, so Grok and fx recordings lose their vendor-only behavior. A request frame (`{ name, arguments }`) makes the agent call that T3 tool itself over its MCP session, and `` in any frame is filled from the JSON file at `T3_DEV_REPLAY_VARS`. -### Fake T3 Connect machines - -To stage T3 Connect account machines without an account (for launch videos), set localStorage `t3code:dev:fake-t3-connect` in the dev web client to `{"account":{"email":"demo@example.com"},"environments":[{"environmentId":"studio","label":"Studio","online":true,"machine":"mac-studio"}]}` and reload; see [devFakeConnect.ts](../../apps/web/src/cloud/devFakeConnect.ts) for the optional fields. - ### Profiling dev startup Run `vp run profile:startup` to capture the first 20 seconds of inherited Node processes under From 00b9b541024800edc67dc25105e89bf99d68e8ff Mon Sep 17 00:00:00 2001 From: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com> Date: Fri, 20 Nov 2026 17:05:37 -0800 Subject: [PATCH 4/5] fix(skills): camera moves start after cursor and overlays are measured A story whose camera starts zoomed measured every cursor waypoint through that zoom, so clicks landed off target. Kit.camera now defers its animation until Kit.measure has finished. Co-Authored-By: Claude Opus 5.5 --- .agents/skills/launch-video/assets/kit.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.agents/skills/launch-video/assets/kit.js b/.agents/skills/launch-video/assets/kit.js index ce8f208c4a5f5..7206ee0ae9104 100644 --- a/.agents/skills/launch-video/assets/kit.js +++ b/.agents/skills/launch-video/assets/kit.js @@ -104,14 +104,19 @@ window.Kit = (() => { ); for (const cam of cams) cam.style.animation = "none"; for (const a of scripted) a.cancel(); + // Everything is measured with the camera at rest; camera moves start only afterwards. + measuring = true; try { - // Overlays first: fn() usually starts the camera, and they must be measured at rest. for (const place of overlays.splice(0)) place(); return fn(); } finally { + measuring = false; + for (const start of afterMeasure.splice(0)) start(); for (const cam of cams) cam.style.animation = ""; } }; + let measuring = false; + const afterMeasure = []; // Overlays drawn on the story page over a target (so the app's own overflow cannot clip // them). They are measured and placed when placeCursor runs Kit.measure. const overlays = []; @@ -376,7 +381,9 @@ window.Kit = (() => { } return { offset: step.t / end, transform, easing: step.ease ?? "cubic-bezier(.65,0,.35,1)" }; }); - cam.animate(keys, { duration: end * 1000, fill: "both" }); + const start = () => cam.animate(keys, { duration: end * 1000, fill: "both" }); + if (measuring) afterMeasure.push(start); + else start(); }; // Segments: [realSeconds, animFrom, animTo]; animFrom == animTo holds the frame. From c1f9378f38cd34af5018f0dfe79d09252d6d5b93 Mon Sep 17 00:00:00 2001 From: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com> Date: Fri, 20 Nov 2026 17:39:48 -0800 Subject: [PATCH 5/5] fix(skills): captions can't overlap; template uses one visibility window per beat Kit.captions plays captions in order and throws when two windows overlap, which showed as garbled text between steps. The real-app template uses Kit.beats and Kit.captions instead of show/hide pairs. Co-Authored-By: Claude Opus 5.5 --- .agents/skills/launch-video/SKILL.md | 3 ++- .agents/skills/launch-video/assets/kit.js | 18 ++++++++++++++++++ .agents/skills/launch-video/template/real.html | 13 ++++--------- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/.agents/skills/launch-video/SKILL.md b/.agents/skills/launch-video/SKILL.md index f45e478568afa..37d67577b9a26 100644 --- a/.agents/skills/launch-video/SKILL.md +++ b/.agents/skills/launch-video/SKILL.md @@ -158,7 +158,8 @@ seeks every animation (in the story and inside each beat) to each frame's time. finished. Camera steps centre `on` at screen height `y` (default 420, clear of the captions) at scale `s`; repeat a step to hold. Cursor clicks draw a ripple. - **Captions** `.cap`: a numbered chip, a bold lead phrase and a muted rest. Short enough to - read in two seconds. + read in two seconds. Play them with `Kit.captions([[selector, from, to], ...])`, which + throws if two overlap; two captions crossfading read as garbled text. - **Pacing**: `Kit.timeline([[realSeconds, animFrom, animTo], ...])` maps video time to animation time; `animFrom == animTo` holds a frame. It also sets the video length. - **Outro** `.outro`: logo, a two-line headline, "Available now in **T3 Code** ``", diff --git a/.agents/skills/launch-video/assets/kit.js b/.agents/skills/launch-video/assets/kit.js index 7206ee0ae9104..0f682543415a5 100644 --- a/.agents/skills/launch-video/assets/kit.js +++ b/.agents/skills/launch-video/assets/kit.js @@ -175,6 +175,23 @@ window.Kit = (() => { ]; return anim(target, keys, { at: 0, dur: end, ease: "linear" }); }; + // Captions in order: [[selector, from, to], ...]. Each fades in and out inside its window, + // and overlapping windows throw, since two captions on screen read as garbled text. + const captions = (list) => + list.forEach(([target, from, to], i) => { + const next = list[i + 1]; + if (next && next[1] < to) throw new Error(`Kit: caption ${target} overlaps ${next[0]}`); + anim( + target, + [ + { opacity: 0, transform: "translateY(14px)" }, + { opacity: 1, transform: "none", offset: 0.06 }, + { opacity: 1, transform: "none", offset: 0.94 }, + { opacity: 0, transform: "translateY(-8px)" }, + ], + { at: from, dur: to - from, ease: "linear" }, + ); + }); // The beats in order: [[name, at, fade?], ...]. Each shows from its `at` until the next beat // has finished fading in over it. const beats = (sequence) => @@ -407,6 +424,7 @@ window.Kit = (() => { el, all, css, + captions, text, rect, centerOf, diff --git a/.agents/skills/launch-video/template/real.html b/.agents/skills/launch-video/template/real.html index 99be36d95345c..a2a290acd0dcc 100644 --- a/.agents/skills/launch-video/template/real.html +++ b/.agents/skills/launch-video/template/real.html @@ -232,15 +232,10 @@

Feature name
second line