# Screens per case

> Every use case that happens in your app gets its screens, with every ending and every failure, before it is built.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://design.docs.sypnia.com/screens/screens-per-case/

For agents: Screen file design/screens/<case-id>.screen.yaml: format 1, case (id), where (place id in the Cases navigation tree, e.g. shop.order-for-today; path shown as breadcrumb), pattern (gallery pattern id), guide (version), status draft|approved|built, approved_by/at, regions {region: [pieces with content]}, states {loading, empty, outcome.<name>, failure.<FailureName> (message from case failures[].tell), offline}, phone/desktop notes, first_screen: true for entry screens. Cases without `where` (external, scheduled, event) need no screen; their effects on other screens are designed there. Renders: Cloud renders every state at phone 390×844 and desktop 1366×700 and 1876×951, light and dark. A screen is built only after approval; when the case changes (new failure) the screen file becomes out of date and design check reports the missing state.

## Which cases get screens

Every use case that happens inside your app has a `where` in [Sypnia Cases](https://cases.docs.sypnia.com/): its place in the app's navigation tree, such as `shop.order-for-today`, whose path people see as «Orders → Order for today». Each of those cases gets a **screen file**. Cases that start outside the app (another system calls, a scheduled job, an event) have no screen of their own; where they change what people see, that change is designed on the screens that show it.

## The screen file

`design/screens/place-order.screen.yaml`

```yaml
format: 1
case: place-order
where: shop.order-for-today
pattern: do-something
guide: 3
status: approved
approved_by: ana@laespiga.co
first_screen: true
regions:
  header: [{ piece: title, text: "Order for today" }, { piece: pickup-hours }]
  content: [{ piece: product-card, repeat: today's products }]
  action: [{ piece: button, variant: primary, text: "Reserve my bread" }]
states:
  loading: product cards as skeletons
  empty: { piece: notice, text: "Today's bread is sold out. Come back tomorrow from 6 am." }
  outcome.reserved: [{ piece: pickup-code }, { piece: notice, text: "We keep it until closing time." }]
  failure.OutOfStock: { piece: notice, tone: warning, near: the product, text: from case }
  failure.Closed: { piece: notice, tone: danger, replaces: content, text: from case }
  offline: products stay visible; «Reserve» waits for the connection and says so
phone: one product per row; the action stays at the bottom
desktop: products in a grid; the summary and the action on the right
```

| Field              | What it is                                                                                       |
| ------------------ | ------------------------------------------------------------------------------------------------ |
| `case`, `where`    | the use case and its place in the navigation tree                                                |
| `pattern`          | the [screen pattern](https://design.docs.sypnia.com/components/patterns) it follows              |
| `guide`            | the guide version it was designed with                                                           |
| `status`           | `draft`, `approved` or `built`                                                                   |
| `regions`          | what each part of the screen holds, using only gallery pieces                                    |
| `states`           | loading, empty, each outcome, each failure (`text: from case` takes the case's message), offline |
| `phone`, `desktop` | how the layout changes                                                                           |
| `first_screen`     | for screens people land on: the main content fits without scrolling                              |

## Pictures of every state

In Sypnia Cloud, every state is rendered as a picture: on a phone (390 × 844), a laptop (1366 × 700) and a large screen (1876 × 951), in light and dark. You approve the screens by looking at them, not by reading YAML.

## Approved before built

The agent builds a screen only after its file is `approved`. When the case changes (say a new failure, `PaymentRefused`), the screen file is out of date and `design check` reports the missing state until it is designed and approved.
