Create a Small UI State Machine

Have Copilot model UI states as a simple state machine, instead of scattered booleans.

category:frontend
state-machine
typescript
ux
0

Prompt

Model the following UI behaviour as a small state machine.
  
  Describe the states and transitions first, then implement:
  
  [Describe the UI flow: idle, loading, error, success, etc.]
  
  Use:
  - A TypeScript discriminated union for state.
  - A reducer or state machine-style handler for transitions.
  
  Explain how this is better than multiple boolean flags.