1
Step 2 Typing With Countdown
Tirsvad edited this page 2026-11-20 14:32:54 +01:00

English · Dansk · Bahasa Malaysia

Step 2: Typing with countdown

Typing with the countdown

While the writer types, the browser sends the whole text to POST /api/text on every change. The server keeps the text and the time of the last key press, and the page shows the seconds left. Every key press restarts the countdown at 5.

What was gained

  • The rule lives in Python. WritingSession.type_text(text, now) stores the text and restarts the countdown; time is passed in, so no clock is needed to test it.
  • Server-side state. The server decides what the state is, so the browser and the server cannot disagree (see ADR-0002).
  • Use cases. TypeText and GetWritingState carry the two system operations from the web layer to the session.
  • Tests with a fake clock. The behaviour is tested without waiting five real seconds.