Interfaces for Non-Deterministic AI Systems
You can reserve a 192px reply slot so a finished stream scores 0 on layout shift, hold the live announcements to two status changes, mark a sentence whose fact is missing from both sources, and keep a delete disabled until the summary checkbox is checked.
- Level
- Navigator
- Time
- 25 h

Jump to
After this course you can
The student can build an AI workspace UI that implements deterministic state transitions across streaming, citation inspection, diff preview, user cancellation, upstream error recovery, and mandatory confirmation before destructive actions.
Reserve the slot, then stream inside it
Token streaming paints the reply one chunk at a time. The reply slot is an empty box in the first paint, 1280px wide, with min-height 192px. Eight lines at 24px is 8 × 24 = 192. The action bar under the slot is 1280 by 56, and the two boxes share a left edge. Chunks append inside the slot. The slot is already in the column, so the first chunk does not insert a new box above the bar.
One move scores as impact fraction times distance fraction, the same product as on the Tuesday diagram. The impact fraction is the viewport share of the union of the old box and the new box, for every element whose start position changed. The distance fraction is the greatest move divided by the larger side of the viewport. A box that grows downward and keeps its start position stays out of that union. This page uses a viewport of 1280 by 800. The area is 1280 × 800 = 1024000, and the larger side is 1280.
With no reserved height, the finished reply is 192px tall and the action bar moves down 192px. The move is greater than the bar height, so the old box and the new box do not overlap. The union area is the sum of the two boxes, 1280 × 56 × 2 = 143360. The impact fraction is 143360 / 1024000 = 0.14, which is 7/50. The distance fraction is 192 / 1280 = 0.15. The score is 0.14 × 0.15 = 0.021, which is 21/1000. That sits over the 0.02 line from the Tuesday page. With min-height 192px set before the first chunk, the action bar keeps its start position, no element moves, and the score is 0. Past 192px the slot scrolls on its own with overflow-y set to auto. A ninth line changes text inside the slot and leaves the bar where it is, so the score stays 0.
The status line speaks twice
The token box has aria-live set to off. Its text changes on every chunk. A live token box would speak each chunk. The status element is the same role status you already used for the hold sentence. It sits in the first paint, empty. Role status means aria-live polite and aria-atomic true, so a screen reader waits for a pause and then speaks the whole string. In the full trace the page appends 48 chunks. The status string changes twice. It becomes Writing a reply when the state enters streaming, and Reply ready when chunk 48 moves the state to ready. The token box makes 0 announcements. The check counter is a separate plain element, outside any live region, so a later change in that counter adds no announcement.
The slot's aria-busy is true while the state is streaming, and false when the state leaves streaming. Stop is a button named Stop, shown only in streaming. One click moves streaming to stopped, leaves the painted chunks in the slot, and sets the status to Stopped at 18 tokens after 18 chunks. That path still has two status changes. The stored note is untouched, and Apply stays disabled, because the trace stopped short of chunk 48. A dropped connection after those same 18 chunks moves streaming to error and sets the status to Reply failed at 18 tokens. The note was not changed. The reader hears that whole string in one pass. Retry clears the slot text back to empty inside the same 192px box, returns the state to streaming, and sets the status to Writing a reply again. The action bar does not move on that clear.
Mark a fact neither source holds
Two sources sit in the window. U is the user message. N is the note. A fact on this page is one of four kinds: a clock time written as digits, a colon, and digits; a weekday from Monday through Sunday; a personal name from the closed list Dana, Sam, and Rio; or an integer that stands as its own word, bounded by a space or by punctuation. A clock time consumes its digits, so 14:00 is one fact, and the pieces 14 and 00 stay off the fact list. A fact is covered when that same string appears in U or in N. Each uncovered fact puts the word check on its sentence, and the counter adds one for that sentence.
The source row opens under the sentence, inside the scrolling slot. The button's visible text and its accessible name are the same string, Sources for sentence 3, with the digit matching the sentence. The row quotes U, quotes N, and names the uncovered fact. Closing the row removes it. The row leaves the action bar's start position alone, because the extra lines scroll inside the 192px slot.
U is Move the Tuesday hold for Dana to 14:00 and keep the note. N is Desk 14, Dana, Tuesday, projector. Sentence 1 reads Hold moved to 14:00 for Dana. The facts 14:00 and Dana both appear in U, so sentence 1 has no marker. Sentence 2 reads The projector stays on Desk 14. The integer word 14 appears in N. Projector is outside the four fact kinds, so sentence 2 has no marker. Sentence 3 reads The room fee is 40. The integer word 40 appears in neither source, so sentence 3 is marked check. Sentence 4 reads Sam confirmed the move. Sam appears in neither source, so sentence 4 is marked check. The counter reads 2. The source row for sentence 3 says 40 is absent from both quotes. The source row for sentence 4 says Sam is absent from both quotes.
Diff, rollback, and the delete gate
A note edit can be undone, so the page shows a diff before it writes. Review builds the diff and leaves the stored note as it is. Strip commas and periods, split on spaces, and drop empty pieces. Added words are the extra copies in the proposed list, written in that list's order. Removed words are the extra copies in the current list. The current note is Desk 14, Dana, Tuesday, projector. The proposed note is Desk 14, Dana, Tuesday 14:00, projector. Current words are Desk, 14, Dana, Tuesday, projector: 5 words. Proposed words are Desk, 14, Dana, Tuesday, 14:00, projector: 6 words. Added is the one word 14:00. Removed is 0. The preview shows both full strings, the added word, and the removed count. The stored note still equals Desk 14, Dana, Tuesday, projector. Sentences 3 and 4 stay in the reply with their check markers. They do not enter the proposed note. The counter stays at 2 as a warning on the reply. Apply is enabled in preview, because this edit only replaces the note string and Rollback can write the previous string back.
Apply copies the proposed string onto the note and keeps the previous string beside it. The state moves from preview to applied. Rollback is a button named Rollback. One click writes the saved string back and returns the state to preview. After Apply and then Rollback, the note is Desk 14, Dana, Tuesday, projector. The shift score for that text swap is 0, because the note sits in a box whose height was already reserved and whose start position does not change.
Delete hold removes the record, so the page treats it as irreversible. The click does not delete. It opens a dialog and moves the state from preview to blocked. The hold count is still 1. The dialog reads Delete 1 hold for Dana at Desk 14 on Tuesday? The checkbox reads I have read the one-line summary. While the checkbox is unchecked, the confirm button named Delete hold now stays disabled, and a click on it changes the hold count by 0. Cancel closes the dialog, returns the state to preview, and leaves the hold count at 1. Checking the box enables Delete hold now. Confirming sets the hold count from 1 to 0 and returns the state to preview. In the counted path the reader presses Cancel, so the hold count stays 1. The states you cross on the note path are idle, streaming, ready, preview, applied, and preview again: Send, chunk 48, Review, Apply, Rollback. That is 5 transitions, and the note ends on the original string.
The Tuesday reply, counted through
The slot is 1280 by 192 in the first paint, on a 1280 by 800 viewport of area 1024000. An unreserved drop of the 1280 by 56 action bar by 192px scores 0.021. The reserved slot scores 0, and a ninth line that scrolls inside the slot still scores 0. The token box has aria-live off. aria-busy is true only while the state is streaming.
The full trace appends 48 chunks. The status string changes twice, first to Writing a reply and then to Reply ready. The token box announces 0 times. The check counter is plain text. Sentences 3 and 4 are marked check, for the uncovered facts 40 and Sam, so the counter reads 2. Each source row quotes U and N.
The diff adds the one word 14:00 and removes 0. Apply writes Desk 14, Dana, Tuesday 14:00, projector. Rollback restores Desk 14, Dana, Tuesday, projector. A second trace presses Stop after 18 chunks. The status becomes Stopped at 18 tokens, Apply stays disabled, and the note stays on the original string. A drop at the same count sets Reply failed at 18 tokens. The note was not changed. Delete hold and then Cancel leaves the hold count at 1.
Check it on paper
Use the same 1280 by 800 viewport, the same 1280 by 56 action bar, and the same fact rules. The slot was reserved at 144px and the reply paints 192px, so the bar moves 48px. Compute the union height, the impact fraction, the distance fraction, and the score. U is Add Rio to the Tuesday note. N is Desk 14, Dana, Tuesday, projector. Mark each sentence, and say what the counter reads: Rio is added to the Tuesday note. The fee becomes 40. Dana keeps Desk 14. Write the diff from N to Desk 14, Dana, Tuesday, projector, Rio. Then take a stream that Stop interrupts at 9 chunks. State the two status strings, the token-box announcement count, whether Apply is enabled, the note after Stop, and the hold count after Delete hold followed by Cancel.
The move is smaller than the bar height, so the union height is 56 + 48 = 104. The union area is 1280 × 104 = 133120. The impact fraction is 133120 / 1024000 = 0.13, which is 13/100. The distance fraction is 48 / 1280 = 0.0375. The score is 0.13 × 0.0375 = 0.004875, which is 39/8000. Sentence 1 has Rio and Tuesday, both in U, so it has no marker. Sentence 2 has the integer word 40, in neither source, so it is marked check. Sentence 3 has Dana and the integer word 14, both in N, so it has no marker. The counter reads 1. N has 5 words. The proposed list is Desk, 14, Dana, Tuesday, projector, Rio: 6 words. Added is Rio. Removed is 0. The status strings are Writing a reply and then Stopped at 9 tokens. The token box announces 0 times. Apply stays disabled. The note stays Desk 14, Dana, Tuesday, projector. The hold count stays 1.
Check questions
On the 1280 by 800 page, what is the layout-shift score when the 1280 by 56 action bar moves down 192px, and what is the score when the 192px slot was reserved before the first chunk?
0.021 when the bar moves 192px, and 0 when the slot was reserved. The reserved score stays 0 when a ninth line scrolls inside the slot.
The full trace appends 48 chunks and reaches ready. How many times does the status string change, what are the two strings, and how many announcements does the token box make?
The status string changes twice: Writing a reply, then Reply ready. The token box makes 0 announcements, because aria-live is off.
In the four-sentence Tuesday reply, which facts are uncovered, which sentences are marked check, and what does the counter read?
40 is uncovered in sentence 3, and Sam is uncovered in sentence 4. Those two sentences are marked check. The counter reads 2.
After Apply and then Rollback, what is the stored note? After Delete hold and then Cancel, what is the hold count, and what does the confirm button do while the checkbox is unchecked?
The note is Desk 14, Dana, Tuesday, projector. The hold count stays 1. Delete hold now stays disabled, and a click on it changes the hold count by 0.
The 192px slot keeps this stream's shift score at 0, the status line changes twice, a sentence is marked check when its fact is missing from both U and N, Apply writes only the string the diff showed, and Delete hold now stays disabled until the checkbox is checked.
Final task
Submit an AI interface tested by 30 automated Playwright state-machine tests verifying SSE stream rendering, 1-click stream cancellation, diff preview before apply, ARIA live updates, and blocked execution until the human approval gate is confirmed.
Terms in this course
This course has no terms of its own in the glossary yet. Terms from earlier courses are used here too.
The first lesson is open to read. The rest of the course is being written, and tests and diplomas come later. Join the waitlist