WebContainer boots a full Node.js environment in the browser using WebAssembly and SharedArrayBuffer. SharedArrayBuffer requires cross-origin isolation—but you cannot apply that globally without breaking third-party scripts. This part scopes the isolation headers to /project/* only, boots one WebContainer per tab, converts FileEntry rows into a nested mount tree, and runs...
[Read More]
Build your own X: A minimal AI app builder — Part 9: Rendering code that is still being written, and seeing what you sent the model
While the model is streaming, a fenced code block is open—there is no closing fence yet. Your renderer must handle that state without crashing or showing raw backticks. This part builds the segment scanner with a closed:false state, the collapsible CodeMirror card, and the context strip that shows exactly how...
[Read More]
Build your own X: A minimal AI app builder — Part 8: The sync problem — drafts, the 250 ms race, and "Updated" badges that do not lie
Three things write to the same file simultaneously: the user types a draft, the AI applies changes via a background transaction, and router.refresh() reloads server props. Without a merge policy, the user loses their draft every time the AI edits. This part builds the algorithm that keeps all three in...
[Read More]
Lab 3D khóa MIT 6.5840: Xây dựng thuật toán đồng thuận Raft - Phần 4: Log Compaction và Snapshot
Bài viết thứ sáu trong chuỗi bài về hệ thống phân tán qua các bài lab của khóa học MIT 6.5840. Phần này trình bày cách triển khai log compaction trong Raft — cắt ngắn log bằng snapshot để tránh log tăng trưởng vô hạn — và phân tích một...
[Read More]
MIT 6.5840 Lab 3D: Building Raft Consensus — Part 4: Log Compaction and Snapshots
The sixth post in the MIT 6.5840 distributed systems series. This post covers log compaction in Raft — trimming the log via snapshots to prevent unbounded growth — and a deep dive into the most counterintuitive design pitfall in Lab 3D: why clamping nextIndex destroys the entire InstallSnapshot mechanism.
[Read More]
Build your own X: A minimal AI app builder — Part 7: File tree UI, REST API with shared validation, and CodeMirror without SSR
The workbench needs three things: a file tree loaded from the database, a REST API to save/delete/rename with the same path rules as the parser, and a CodeMirror editor that cannot load during server-side rendering. Each reveals a different facet of building a database-backed IDE panel in Next.js.
[Read More]
Build your own X: A minimal AI app builder — Part 6: Context engineering — what the model knows when it edits
Without context, the model edits blind. On turn two it might rewrite a file it has never seen. This part builds the workspace snapshot: a selection algorithm that picks spine files first, fills remaining budget with the most recently edited files, and truncates gracefully—then records exactly what was sent so...
[Read More]
Lab 3C khóa MIT 6.5840: Xây dựng thuật toán đồng thuận Raft - Phần 3: Persistence và các lỗi ẩn dưới mạng nhiễu
Bài viết thứ năm trong chuỗi bài về hệ thống phân tán qua các bài lab của khóa học MIT 6.5840. Phần này trình bày cách triển khai persistence trong Raft — đảm bảo server không mất trạng thái khi crash — và phân tích hai lỗi an toàn tinh...
[Read More]
MIT 6.5840 Lab 3C: Building Raft Consensus — Part 3: Persistence and Hidden Bugs Under Network Chaos
The fifth post in the MIT 6.5840 distributed systems series. This post covers persistence in Raft — ensuring servers survive crashes without losing critical state — and a deep dive into two subtle safety bugs that only surface under an unreliable, high-reordering network.
[Read More]
Build your own X: A minimal AI app builder — Part 5: Parsing LLM output into database rows, safely
The model can output anything. Your parser must handle repeated paths (last wins), path traversal attempts (reject silently), unclosed fences (discard), and parse failures that must not roll back an already-saved message. This post builds the full parse → normalize → upsert pipeline with intentional two-layer error isolation.
[Read More]