---
title: How a Code thread works
description: "Follow a Code task through its states, see how Ysra tells a question from a change, and what happens when a check fails, credits run out or you stop it."
---

A **Code thread** is a conversation about one piece of work; each change you
ask for in it runs as a **task**. This page explains the states a task goes
through, how each one ends, and what is kept. For how to steer a task while
it runs, see [Steering and saved points](steering.md).

## The rule

Ysra does what you asked, at the size you asked for, and says plainly what it
ran. A small ask gets a small change, with no tests or setup you didn't ask
for. Nothing you or Ysra did is thrown away in any end state.

## Is it a question or a change?

Every message in a thread is read first, and only a change starts paid work.

| You write | Ysra treats it as | What happens |
|---|---|---|
| "What's in this folder?", "Open this link", "How do I … in Ysra?" | A quick question | Answered straight away from the project's files, the web or Ysra's docs. Read-only, no task. |
| "Why does login fail?", "Can we add search?" | A question | Answered from the code. Read-only. |
| "Add search", "Can you fix login?" | A change | A task starts (after the one-time OK to work in this thread). |
| A question and a change together | A change | The task answers the question in its reply. |
| "Show me the preview", "aperçu", "vista previa" | Preview only | The [preview](previews.md) starts. Never a task, never charged. |

When it's unclear, Ysra treats the message as a question. Starting paid work
in a thread needs your OK once; after that, changes in the same thread start
directly.

## Task states

| State | What it means | Ends? |
|---|---|---|
| **Queued** | Waiting for a machine or a worker slot. | No |
| **Working** | Reading, changing, running checks. | No |
| **Needs your input** | Ysra asked you something and waits. The same task carries on after your answer. | No |
| **Your changes are ready** · **Done** | The work is built, and the project's own checks that ran pass. | Yes |
| **Needs you** | A question, an approval or a decision is waiting for you. | Yes |
| **Didn't work** | The result doesn't work yet: the project's checks fail, or the app doesn't start. Ysra says what failed, and the changes are kept. | Yes |
| **Stopped with a problem** | It couldn't go on. | Yes |
| **Stopped** | You stopped it. | Yes |

> Diagram: Every end state keeps the changes; Continue starts a new task from where the last one stopped.

**Continue** on **Didn't work**, **Stopped with a problem** or **Stopped** starts a new task from where the last one stopped.

## How a task ends { #how-a-task-ends }

Every ending has one plain receipt line that says what Ysra ran to check the
work, and how it went:

```text
Ran: `npm test` (passed).
Ran: `npm test` (failed); a look in the browser (desktop and phone).
Ran: nothing.
Ran: nothing (you asked me not to).
```

The same line goes into a pull request Ysra opens for the work.

### When you say “no tests” or “just the code”

“No tests”, “don't install anything”, “don't run anything” or “just the code”
is respected from start to finish: Ysra writes the change, installs nothing,
runs nothing to check it, and ends with “Ran: nothing (you asked me not to).”

### Small asks get small changes

Ysra sizes the work to the ask. Renaming a function or fixing a typo doesn't
come with new tests, a new project layout or a running preview. Ask for tests
or a check when you want them, and Ysra runs them and reports them in the
receipt.

## What happens when …

### A check fails

Ysra reads the failure and repairs the change, then runs the checks again.
It stops repairing when a fix no longer changes the result: trying again the
same way wouldn't help.

If the project's checks still fail after that, the task ends **Didn't work**
and says what failed. The change is kept; you can still use or deliver it.

### Ysra stops making progress

If a task keeps re-reading files without changing anything, or the same
check keeps failing in the same way, the task ends and says what blocks it
instead of spending more.

### A step runs too long

If a step can't finish, the task stops and says why in plain words. Your work
is always saved: **Continue** picks up from there.

### Credits run out

Before each paid step, the task checks the balance. With none left it pauses:
"I stopped at the limit set for this work. Your changes and what I checked
are kept; add credits or raise the limit, then tell me to continue."

### You set a limit on the task

A task can have a time, credit or step limit. When it reaches one, it stops
cleanly and says so; it never takes more on its own.

### You stop it

A queued or waiting task stops at once. A working task finishes its current
step, then stops: "Stopped at your request." The changes made so far are
kept.

### The machine is lost

If the machine running a task disappears, the task is picked up again
automatically. If it keeps happening, it stops and says so: "I used up my
automatic recovery attempts."

## What is kept

| In every end state | Detail |
|---|---|
| The changes | In the thread's files (and branch, for a repository). |
| Saved points | Up to 32 per thread, to go back to. |
| What was checked | Each check and its result, in the thread. |

**Undo changes…** (for a folder on your computer) puts changed files back and
removes the files the task created. If you edited one of those files yourself
since, it undoes nothing and says so, so your own work is never overwritten.
In the cloud, go back to a saved point instead; see
[Steering and saved points](steering.md#saved-points).

## How to continue

| From | You can |
|---|---|
| **Didn't work** | Use or deliver the change anyway, ask for a fix, or **Continue**. |
| **Needs you** | Answer the question or the card. |
| **Stopped with a problem** | **Continue**, or ask differently. |
| **Stopped** | **Continue**, or send the next message. |
| Paused for credits | Add credits, then tell Ysra to continue. |

## Limits

| Limit | Value |
|---|---|
| Longest a task runs | 4 hours; less in the cloud on some plans ([Limits and costs](../workspace/limits.md#cloud-machines)) |
| Saved points kept | 32 by default |

## Related

- [Plans and criteria](plans.md) — what "required checks" are and where they come from.
- [Review and verification](review.md) — reading the evidence before you deliver.
- [Previews](previews.md) — seeing the app while it runs.
- [Limits and costs](../workspace/limits.md) — credits, cloud time and every cap.
