The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import type { ReactNode } from "react"; |
| 2 | import { AbsoluteFill, interpolate } from "remotion"; |
| 3 | import { hand, mono, sans, serif } from "../fonts.ts"; |
| 4 | import { brand, vscode } from "../theme.ts"; |
| 5 | import { Arrow, drawProgress, TONE } from "./draw.tsx"; |
| 6 | |
| 7 | /** |
| 8 | * Conceptual diagrams for the intro. Each board has numbered stages; a |
| 9 | * stage is one presenter step. `local` is frames since the stage began, |
| 10 | * so the new part of a stage animates in and earlier parts stay put. |
| 11 | */ |
| 12 | export interface BoardProps { |
| 13 | stage: number; |
| 14 | local: number; |
| 15 | } |
| 16 | |
| 17 | const fadeIn = (local: number, delay = 0, frames = 12) => |
| 18 | interpolate(local, [delay, delay + frames], [0, 1], { |
| 19 | extrapolateLeft: "clamp", |
| 20 | extrapolateRight: "clamp", |
| 21 | }); |
| 22 | |
| 23 | /** Visible in stage `from` onward; animates only in the stage it first appears. */ |
| 24 | const shown = (stage: number, from: number, local: number, delay = 0) => |
| 25 | stage > from ? 1 : stage === from ? fadeIn(local, delay) : 0; |
| 26 | |
| 27 | const Label = ({ |
| 28 | children, |
| 29 | color = brand.fgMuted, |
| 30 | size = 28, |
| 31 | }: { |
| 32 | children: ReactNode; |
| 33 | color?: string; |
| 34 | size?: number; |
| 35 | }) => <div style={{ fontFamily: sans, fontSize: size, color }}>{children}</div>; |
| 36 | |
| 37 | const Node = ({ |
| 38 | x, |
| 39 | y, |
| 40 | title, |
| 41 | kind, |
| 42 | color, |
| 43 | opacity = 1, |
| 44 | w = 230, |
| 45 | h = 96, |
| 46 | children, |
| 47 | }: { |
| 48 | x: number; |
| 49 | y: number; |
| 50 | title: string; |
| 51 | kind?: string; |
| 52 | color: string; |
| 53 | opacity?: number; |
| 54 | w?: number; |
| 55 | h?: number; |
| 56 | children?: ReactNode; |
| 57 | }) => ( |
| 58 | <div |
| 59 | style={{ |
| 60 | position: "absolute", |
| 61 | left: x - w / 2, |
| 62 | top: y - h / 2, |
| 63 | width: w, |
| 64 | minHeight: h, |
| 65 | padding: "16px 20px", |
| 66 | borderRadius: 16, |
| 67 | background: "#1c1a17", |
| 68 | border: `2px solid ${color}`, |
| 69 | boxShadow: "0 12px 30px rgba(0,0,0,0.4)", |
| 70 | opacity, |
| 71 | transform: `scale(${0.9 + 0.1 * opacity})`, |
| 72 | fontFamily: sans, |
| 73 | }} |
| 74 | > |
| 75 | <div style={{ display: "flex", alignItems: "center", gap: 10 }}> |
| 76 | <span style={{ width: 11, height: 11, borderRadius: 6, background: color }} /> |
| 77 | <span style={{ color: brand.fg, fontSize: 30, fontWeight: 600 }}>{title}</span> |
| 78 | </div> |
| 79 | {kind ? <div style={{ color: brand.fgMuted, fontSize: 18, marginTop: 6 }}>{kind}</div> : null} |
| 80 | {children} |
| 81 | </div> |
| 82 | ); |
| 83 | |
| 84 | const Svg = ({ children }: { children: ReactNode }) => ( |
| 85 | <svg |
| 86 | width={1920} |
| 87 | height={1080} |
| 88 | style={{ position: "absolute", left: 0, top: 0, overflow: "visible" }} |
| 89 | > |
| 90 | {children} |
| 91 | </svg> |
| 92 | ); |
| 93 | |
| 94 | const CodeCard = ({ |
| 95 | x, |
| 96 | y, |
| 97 | w, |
| 98 | text, |
| 99 | color, |
| 100 | opacity, |
| 101 | size = 24, |
| 102 | }: { |
| 103 | x: number; |
| 104 | y: number; |
| 105 | w: number; |
| 106 | text: string; |
| 107 | color: string; |
| 108 | opacity: number; |
| 109 | size?: number; |
| 110 | }) => ( |
| 111 | <pre |
| 112 | style={{ |
| 113 | position: "absolute", |
| 114 | left: x, |
| 115 | top: y, |
| 116 | width: w, |
| 117 | margin: 0, |
| 118 | padding: "16px 20px", |
| 119 | background: vscode.editorBg, |
| 120 | border: `2px solid ${color}`, |
| 121 | borderRadius: 12, |
| 122 | fontFamily: mono, |
| 123 | fontSize: size, |
| 124 | lineHeight: 1.45, |
| 125 | color: "#d4d4d4", |
| 126 | opacity, |
| 127 | whiteSpace: "pre-wrap", |
| 128 | }} |
| 129 | > |
| 130 | {text} |
| 131 | </pre> |
| 132 | ); |
| 133 | |
| 134 | const stroke2 = (d: string, color: string, progress: number) => ( |
| 135 | <path |
| 136 | d={d} |
| 137 | fill="none" |
| 138 | stroke={color} |
| 139 | strokeWidth={4} |
| 140 | strokeLinecap="round" |
| 141 | strokeDasharray={4000} |
| 142 | strokeDashoffset={4000 * (1 - progress)} |
| 143 | /> |
| 144 | ); |
| 145 | |
| 146 | // ── Act 3: history ─────────────────────────────────────────────────────── |
| 147 | const History = ({ local }: BoardProps) => { |
| 148 | const items = [ |
| 149 | { |
| 150 | year: "2018–19", |
| 151 | name: "Punchcard", |
| 152 | body: "Runtime code on top of the AWS CDK", |
| 153 | tone: "neutral" as const, |
| 154 | }, |
| 155 | { |
| 156 | year: "2022", |
| 157 | name: "Functionless", |
| 158 | body: "TypeScript compiled by reading its AST", |
| 159 | tone: "neutral" as const, |
| 160 | }, |
| 161 | { year: "now", name: "Alchemy", body: "Infrastructure as Effects", tone: "construct" as const }, |
| 162 | ]; |
| 163 | return ( |
| 164 | <AbsoluteFill> |
| 165 | <Svg>{stroke2("M 260 540 L 1660 540", brand.fgMuted, drawProgress(local, 0, 24))}</Svg> |
| 166 | {items.map((item, i) => { |
| 167 | const x = 330 + i * 630; |
| 168 | const p = fadeIn(local, 10 + i * 10); |
| 169 | return ( |
| 170 | <div |
| 171 | key={item.name} |
| 172 | style={{ |
| 173 | position: "absolute", |
| 174 | left: x - 180, |
| 175 | top: 400, |
| 176 | width: 360, |
| 177 | textAlign: "center", |
| 178 | opacity: p, |
| 179 | }} |
| 180 | > |
| 181 | <div style={{ fontFamily: mono, fontSize: 24, color: brand.fgMuted }}>{item.year}</div> |
| 182 | <div |
| 183 | style={{ |
| 184 | margin: "44px auto 0", |
| 185 | width: 26, |
| 186 | height: 26, |
| 187 | borderRadius: 13, |
| 188 | background: TONE[item.tone], |
| 189 | }} |
| 190 | /> |
| 191 | <div |
| 192 | style={{ |
| 193 | marginTop: 40, |
| 194 | fontFamily: serif, |
| 195 | fontSize: 52, |
| 196 | fontWeight: 600, |
| 197 | color: item.tone === "construct" ? TONE.construct : brand.fg, |
| 198 | }} |
| 199 | > |
| 200 | {item.name} |
| 201 | </div> |
| 202 | <div style={{ marginTop: 10 }}> |
| 203 | <Label size={24}>{item.body}</Label> |
| 204 | </div> |
| 205 | </div> |
| 206 | ); |
| 207 | })} |
| 208 | </AbsoluteFill> |
| 209 | ); |
| 210 | }; |
| 211 | |
| 212 | // ── Act 4: Context.Service + Layer ─────────────────────────────────────── |
| 213 | const Layers = ({ local }: BoardProps) => ( |
| 214 | <AbsoluteFill> |
| 215 | <CodeCard |
| 216 | x={170} |
| 217 | y={260} |
| 218 | w={620} |
| 219 | text={`class Storage extends Context.Service<\n Storage,\n { get(key: string): Effect<Buffer> }\n>()("Storage") {}`} |
| 220 | color={TONE.construct} |
| 221 | opacity={fadeIn(local, 0)} |
| 222 | /> |
| 223 | <div style={{ position: "absolute", left: 170, top: 200, opacity: fadeIn(local, 0) }}> |
| 224 | <Label color={TONE.construct} size={30}> |
| 225 | The interface |
| 226 | </Label> |
| 227 | </div> |
| 228 | <CodeCard |
| 229 | x={1130} |
| 230 | y={260} |
| 231 | w={620} |
| 232 | text={`const StorageS3 = Layer.effect(\n Storage,\n Effect.gen(function* () {\n // resources, bindings…\n return { get: … }\n }),\n)`} |
| 233 | color={TONE.runtime} |
| 234 | opacity={fadeIn(local, 12)} |
| 235 | /> |
| 236 | <div style={{ position: "absolute", left: 1130, top: 200, opacity: fadeIn(local, 12) }}> |
| 237 | <Label color={TONE.runtime} size={30}> |
| 238 | One implementation |
| 239 | </Label> |
| 240 | </div> |
| 241 | <CodeCard |
| 242 | x={560} |
| 243 | y={660} |
| 244 | w={800} |
| 245 | text={`program.pipe(Effect.provide(StorageS3))`} |
| 246 | color={brand.fgMuted} |
| 247 | opacity={fadeIn(local, 26)} |
| 248 | /> |
| 249 | <Svg> |
| 250 | <Arrow |
| 251 | x1={480} |
| 252 | y1={500} |
| 253 | x2={700} |
| 254 | y2={650} |
| 255 | color={brand.fgMuted} |
| 256 | progress={drawProgress(local, 30, 16)} |
| 257 | bend={0.1} |
| 258 | /> |
| 259 | <Arrow |
| 260 | x1={1440} |
| 261 | y1={560} |
| 262 | x2={1220} |
| 263 | y2={650} |
| 264 | color={brand.fgMuted} |
| 265 | progress={drawProgress(local, 36, 16)} |
| 266 | bend={-0.1} |
| 267 | /> |
| 268 | <text |
| 269 | x={960} |
| 270 | y={820} |
| 271 | textAnchor="middle" |
| 272 | fontFamily={hand} |
| 273 | fontSize={42} |
| 274 | fontWeight={700} |
| 275 | fill={TONE.construct} |
| 276 | opacity={fadeIn(local, 48)} |
| 277 | > |
| 278 | they only meet where you provide it |
| 279 | </text> |
| 280 | </Svg> |
| 281 | </AbsoluteFill> |
| 282 | ); |
| 283 | |
| 284 | // ── Act 4: the implementation wires permissions ────────────────────────── |
| 285 | const Fork = ({ local }: BoardProps) => { |
| 286 | const branch = ( |
| 287 | x: number, |
| 288 | title: string, |
| 289 | lines: string[], |
| 290 | delay: number, |
| 291 | tone: "construct" | "runtime", |
| 292 | ) => ( |
| 293 | <div |
| 294 | style={{ position: "absolute", left: x, top: 460, width: 700, opacity: fadeIn(local, delay) }} |
| 295 | > |
| 296 | <div style={{ fontFamily: serif, fontSize: 44, fontWeight: 600, color: TONE[tone] }}> |
| 297 | {title} |
| 298 | </div> |
| 299 | {lines.map((line, i) => ( |
| 300 | <div |
| 301 | key={i} |
| 302 | style={{ |
| 303 | marginTop: 18, |
| 304 | display: "flex", |
| 305 | gap: 14, |
| 306 | fontFamily: sans, |
| 307 | fontSize: 31, |
| 308 | color: brand.fg, |
| 309 | opacity: fadeIn(local, delay + 6 + i * 6), |
| 310 | }} |
| 311 | > |
| 312 | <span style={{ color: TONE[tone] }}>→</span> |
| 313 | {line} |
| 314 | </div> |
| 315 | ))} |
| 316 | </div> |
| 317 | ); |
| 318 | return ( |
| 319 | <AbsoluteFill> |
| 320 | <div |
| 321 | style={{ |
| 322 | position: "absolute", |
| 323 | left: 660, |
| 324 | top: 150, |
| 325 | width: 600, |
| 326 | padding: "22px 28px", |
| 327 | textAlign: "center", |
| 328 | borderRadius: 16, |
| 329 | border: `2px solid ${brand.fgMuted}`, |
| 330 | fontFamily: mono, |
| 331 | fontSize: 30, |
| 332 | color: brand.fg, |
| 333 | opacity: fadeIn(local, 0), |
| 334 | }} |
| 335 | > |
| 336 | AWS.S3.GetObjectHttp |
| 337 | </div> |
| 338 | <Svg> |
| 339 | <Arrow |
| 340 | x1={880} |
| 341 | y1={250} |
| 342 | x2={520} |
| 343 | y2={440} |
| 344 | color={TONE.construct} |
| 345 | progress={drawProgress(local, 8, 16)} |
| 346 | bend={0.1} |
| 347 | /> |
| 348 | <Arrow |
| 349 | x1={1040} |
| 350 | y1={250} |
| 351 | x2={1400} |
| 352 | y2={440} |
| 353 | color={TONE.runtime} |
| 354 | progress={drawProgress(local, 14, 16)} |
| 355 | bend={-0.1} |
| 356 | /> |
| 357 | </Svg> |
| 358 | {branch( |
| 359 | 200, |
| 360 | "On Lambda", |
| 361 | [ |
| 362 | "Adds s3:GetObject on this bucket", |
| 363 | "to the Function's IAM role", |
| 364 | "Uses the Function's credentials", |
| 365 | ], |
| 366 | 20, |
| 367 | "construct", |
| 368 | )} |
| 369 | {branch( |
| 370 | 1080, |
| 371 | "On a Cloudflare Worker", |
| 372 | [ |
| 373 | "Creates an IAM user that can only assume a role", |
| 374 | "Binds its keys to the Worker", |
| 375 | "Fetches short-lived credentials at runtime", |
| 376 | ], |
| 377 | 32, |
| 378 | "runtime", |
| 379 | )} |
| 380 | </AbsoluteFill> |
| 381 | ); |
| 382 | }; |
| 383 | |
| 384 | // ── Act 5: the compiler pipeline ───────────────────────────────────────── |
| 385 | const Pipeline = ({ local }: BoardProps) => { |
| 386 | const stages = [ |
| 387 | { title: "TypeScript", body: "checks Effect<A, Err, Req>\nand Layer<Out, Err, In>" }, |
| 388 | { title: "Run the program", body: "builds the graph of\nresources and bindings" }, |
| 389 | { title: "Plan", body: "diff the graph against\nwhat's deployed" }, |
| 390 | { title: "Apply", body: "converge the cloud,\nafter you review it" }, |
| 391 | ]; |
| 392 | return ( |
| 393 | <AbsoluteFill> |
| 394 | {stages.map((s, i) => { |
| 395 | const x = 105 + i * 435; |
| 396 | return ( |
| 397 | <div key={s.title}> |
| 398 | <div |
| 399 | style={{ |
| 400 | position: "absolute", |
| 401 | left: x, |
| 402 | top: 380, |
| 403 | width: 395, |
| 404 | height: 280, |
| 405 | padding: "30px 28px", |
| 406 | borderRadius: 20, |
| 407 | border: `2px solid ${i === 0 ? TONE.construct : brand.fgMuted}88`, |
| 408 | background: "#1c1a17", |
| 409 | opacity: fadeIn(local, i * 12), |
| 410 | }} |
| 411 | > |
| 412 | <div |
| 413 | style={{ |
| 414 | fontFamily: serif, |
| 415 | fontSize: 38, |
| 416 | fontWeight: 600, |
| 417 | whiteSpace: "nowrap", |
| 418 | color: i === 0 ? TONE.construct : brand.fg, |
| 419 | }} |
| 420 | > |
| 421 | {s.title} |
| 422 | </div> |
| 423 | <div |
| 424 | style={{ |
| 425 | marginTop: 18, |
| 426 | fontFamily: sans, |
| 427 | fontSize: 28, |
| 428 | lineHeight: 1.4, |
| 429 | color: brand.fgMuted, |
| 430 | whiteSpace: "pre-line", |
| 431 | }} |
| 432 | > |
| 433 | {s.body} |
| 434 | </div> |
| 435 | </div> |
| 436 | {i < stages.length - 1 ? ( |
| 437 | <Svg> |
| 438 | <Arrow |
| 439 | x1={x + 398} |
| 440 | y1={520} |
| 441 | x2={x + 432} |
| 442 | y2={520} |
| 443 | color={brand.fgMuted} |
| 444 | progress={drawProgress(local, i * 12 + 8, 10)} |
| 445 | bend={0} |
| 446 | /> |
| 447 | </Svg> |
| 448 | ) : null} |
| 449 | </div> |
| 450 | ); |
| 451 | })} |
| 452 | <div |
| 453 | style={{ |
| 454 | position: "absolute", |
| 455 | left: 0, |
| 456 | right: 0, |
| 457 | top: 730, |
| 458 | textAlign: "center", |
| 459 | fontFamily: hand, |
| 460 | fontSize: 44, |
| 461 | fontWeight: 700, |
| 462 | color: TONE.construct, |
| 463 | opacity: fadeIn(local, 54), |
| 464 | }} |
| 465 | > |
| 466 | the type system does the static analysis |
| 467 | </div> |
| 468 | </AbsoluteFill> |
| 469 | ); |
| 470 | }; |
| 471 | |
| 472 | // ── Act 6: components ──────────────────────────────────────────────────── |
| 473 | const Components = ({ stage, local }: BoardProps) => { |
| 474 | const tools = ["Terraform module", "CDK construct", "Pulumi component"]; |
| 475 | return ( |
| 476 | <AbsoluteFill> |
| 477 | {tools.map((tool, i) => { |
| 478 | const x = 170 + i * 560; |
| 479 | return ( |
| 480 | <div |
| 481 | key={tool} |
| 482 | style={{ |
| 483 | position: "absolute", |
| 484 | left: x, |
| 485 | top: 220, |
| 486 | width: 460, |
| 487 | opacity: stage > 0 ? 1 : fadeIn(local, i * 8), |
| 488 | }} |
| 489 | > |
| 490 | <div style={{ fontFamily: serif, fontSize: 36, fontWeight: 600, color: brand.fg }}> |
| 491 | {tool} |
| 492 | </div> |
| 493 | <div |
| 494 | style={{ |
| 495 | marginTop: 16, |
| 496 | padding: 20, |
| 497 | height: 230, |
| 498 | borderRadius: 18, |
| 499 | border: `2px solid ${brand.fgMuted}88`, |
| 500 | display: "flex", |
| 501 | flexWrap: "wrap", |
| 502 | gap: 12, |
| 503 | alignContent: "flex-start", |
| 504 | }} |
| 505 | > |
| 506 | {["Function", "Role", "Policy", "Table", "Queue"].map((r) => ( |
| 507 | <span |
| 508 | key={r} |
| 509 | style={{ |
| 510 | padding: "8px 14px", |
| 511 | borderRadius: 10, |
| 512 | background: "rgba(255,255,255,0.07)", |
| 513 | fontFamily: mono, |
| 514 | fontSize: 20, |
| 515 | color: brand.fgMuted, |
| 516 | }} |
| 517 | > |
| 518 | {r} |
| 519 | </span> |
| 520 | ))} |
| 521 | </div> |
| 522 | {stage >= 1 ? ( |
| 523 | <div style={{ marginTop: 60, opacity: fadeIn(local, 6 + i * 6) }}> |
| 524 | <pre |
| 525 | style={{ |
| 526 | margin: 0, |
| 527 | padding: 18, |
| 528 | borderRadius: 12, |
| 529 | border: `2px dashed ${TONE.bad}`, |
| 530 | fontFamily: mono, |
| 531 | fontSize: 19, |
| 532 | color: "#d4d4d4", |
| 533 | }} |
| 534 | > |
| 535 | {`handler = async (e) => {\n await table.get(…)\n}`} |
| 536 | </pre> |
| 537 | <div |
| 538 | style={{ |
| 539 | marginTop: 10, |
| 540 | fontFamily: hand, |
| 541 | fontSize: 34, |
| 542 | fontWeight: 700, |
| 543 | color: TONE.bad, |
| 544 | }} |
| 545 | > |
| 546 | runtime code lives outside |
| 547 | </div> |
| 548 | </div> |
| 549 | ) : null} |
| 550 | </div> |
| 551 | ); |
| 552 | })} |
| 553 | </AbsoluteFill> |
| 554 | ); |
| 555 | }; |
| 556 | |
| 557 | const BOARDS: Record<string, (p: BoardProps) => ReactNode> = { |
| 558 | history: History, |
| 559 | layers: Layers, |
| 560 | fork: Fork, |
| 561 | pipeline: Pipeline, |
| 562 | components: Components, |
| 563 | }; |
| 564 | |
| 565 | export const Board = ({ board, stage, local }: { board: string; stage: number; local: number }) => { |
| 566 | const View = BOARDS[board]; |
| 567 | if (!View) throw new Error(`no intro board "${board}"`); |
| 568 | return <View stage={stage} local={local} />; |
| 569 | }; |