The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
| 1 | import { defineScene } from "../capture/scene.ts"; |
| 2 | |
| 3 | export default defineScene({ |
| 4 | title: "Durable Objects and hibernatable WebSockets", |
| 5 | chapter: "04-durable-objects", |
| 6 | notes: |
| 7 | "One LinkRoom Durable Object per link keeps the click count in transactional storage. The Worker calls it with typed RPC (record), and hands WebSocket upgrades to it; the sockets are hibernatable, so idle rooms can be evicted while connections stay open. The dashboard shows each count live, and a new test opens a socket, clicks, and expects the push.", |
| 8 | async run(s) { |
| 9 | await s.sync({ except: ["src/LinkRoom.ts", "src/Api.ts", "src/main.tsx", "test/api.test.ts"] }); |
| 10 | await s.editor.show("src/LinkRoom.ts"); |
| 11 | s.pause(1); |
| 12 | await s.editor.show("src/Api.ts"); |
| 13 | s.pause(0.5); |
| 14 | await s.editor.show("src/main.tsx"); |
| 15 | s.pause(1); |
| 16 | |
| 17 | await s.terminal(async (t) => { |
| 18 | await t.waitDev(); |
| 19 | await t.sleep(800); |
| 20 | await t.run("deploy", `for i in 1 2 3; do curl -s -o /dev/null localhost:1337/$CODE; done`); |
| 21 | }); |
| 22 | |
| 23 | await s.browser.open("http://localhost:5173", { waitFor: /alchemy\.run\s+\/\w+\s+3\b/ }); |
| 24 | s.pause(1.5); |
| 25 | await s.diagram({ |
| 26 | stage: `dev_${process.env.USER}`, |
| 27 | nodes: ["LinkRoom"], |
| 28 | edges: ["Api->LinkRoom"], |
| 29 | }); |
| 30 | s.pause(1); |
| 31 | |
| 32 | await s.editor.show("test/api.test.ts"); |
| 33 | s.pause(0.5); |
| 34 | await s.terminal(async (t) => { |
| 35 | await t.run("test", "pnpm test", { |
| 36 | until: /Ran \d+ tests? across[\s\S]*❯\s*$/, |
| 37 | timeout: 300_000, |
| 38 | }); |
| 39 | await t.sleep(1500); |
| 40 | }); |
| 41 | }, |
| 42 | }); |