Build Mitra's Core
A capstone-sized build. The server is ready: /api/chat streams answers with streamText, has a tool lookupOrder, and refuses the fourth question with a 429 (retry-after: 3600). You write the whole page.
Requirements: a list #messages with one <li> per message; a text box #prompt and a button #send (disabled while empty or while Mitra is working); a button #stop that exists only while Mitra is working and keeps the partial answer; #status showing the useChat status; a lookup result drawn as <p class="card">ORD-1042 · Masala chai 250 g · shipped</p> (validate the tool output with zod before drawing it); and at the limit #error saying You have used all 3 questions for today. Try again in 1 hour. with the box locked.
What Check tests
- The page starts with an empty list,
#statusready and Send disabled - A question gets a streamed answer in
#messages(two items) - A lookup shows the card
ORD-1042 · Masala chai 250 g · shipped #stopexists while Mitra works, and stopping keeps the partial answer- The fourth question shows the limit message in
#errorand locks the box
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Your page
Console
Nothing logged yet.