Conversation State
A chat is more than a string: messages with ids and stages, a reducer, resent history, saved chats, edits and branches, and the races that corrupt them.
Until now Mitra answered one question at a time. A real assistant holds a conversation: many messages, some still arriving, some failed, some edited, in several chats the user can switch between. This phase is about the data behind that screen, and about keeping it correct while streams, clicks and page loads all change it at once.
You will give every message an id and a stage, move every change through one reducer, work out what really gets sent to the model each turn (the whole history, trimmed to fit), save chats so they survive a reload, and handle edits, branches and the races that appear when two things happen at the same time.
Every example runs real browser code against a scripted stand-in model, so it needs no key and prints the same thing every time. The model side of context windows and memory is taught in /llm-engineering; this phase covers what the screen and the browser must do about it. By the end, Mitra remembers: it holds several saved chats, trims its history safely and survives a reload.
Practise this phase
Hands-on exercises: write the code, see your page live, and press Check to have it tested automatically.