> ## Documentation Index
> Fetch the complete documentation index at: https://help.emergent.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Rollback Feature

> Undo changes and return to a previous working version

## What is Rollback?

Rollback lets you turn back time on your project. If something breaks or the agent goes in the wrong direction, you can go back to any earlier point in your conversation and start fresh from there.

**Think of it like:**

* A save point in a video game
* The undo button, but for your entire project
* A checkpoint you can return to

Here's how it looks in Emergent:

<iframe src="https://www.youtube.com/embed/xXOXm7H6MLk" title="YouTube video player" frameborder="0" className="w-full aspect-video rounded-xl" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen />

## When Should You Use Rollback?

### Perfect Situations for Rollback

<CardGroup cols={2}>
  <Card title="Something Broke" icon="triangle-exclamation" color="#ef4444">
    The app was working, then the agent made changes and now it's broken.

    **Solution:** Roll back to when it worked!
  </Card>

  <Card title="Wrong Direction" icon="route" color="#f59e0b">
    The agent misunderstood and built something different than what you wanted.

    **Solution:** Roll back and explain better!
  </Card>

  <Card title="Stuck in Loop" icon="arrows-spin" color="#8b5cf6">
    The agent keeps trying the same fixes that don't work.

    **Solution:** Roll back to last stable point!
  </Card>

  <Card title="Want Different Approach" icon="lightbulb" color="#3b82f6">
    You realized there's a better way to build this feature.

    **Solution:** Roll back and try new approach!
  </Card>
</CardGroup>

## How to Use Rollback

<Steps>
  <Step title="Find the Rollback Button">
    **Desktop:** Look for the rollback button in the chat interface

    **Mobile:** Tap the clock icon
  </Step>

  <Step title="Choose Your Checkpoint">
    Scroll through your conversation history

    Click on the message where everything was still working

    **Tip:** Look for messages like:

    * "Everything works!"
    * "Feature complete"
    * Before problems started
  </Step>

  <Step title="Pick Rollback Type">
    You'll see two options:

    **Option 1:** "Erase all messages and generated code"

    * Goes back completely
    * Code returns to that point
    * Conversation resets
    * **Choose this if:** Code is broken

    **Option 2:** "Erase messages only"

    * Keeps the current code
    * Only removes conversation history
    * **Choose this if:** Just want to restart chat
  </Step>

  <Step title="Confirm">
    Click **Confirm**

    <Danger>
      This cannot be undone!
    </Danger>
  </Step>

  <Step title="Start Fresh">
    You're now back at that point

    Continue from here with a clearer prompt
  </Step>
</Steps>

## Example: When to Roll Back

### Scenario: Broken Payment Feature

```
You: "Add a checkout page with Stripe"
Agent: Builds checkout page - works great!

You: "Add a discount code field"
Agent: Adds discount field - still works!

You: "Make the button bigger and add animations"
Agent: Now checkout is completely broken!

You: "Why isn't it working?"
Agent: Tries fix #1... doesn't work
Agent: Tries fix #2... still broken
Agent: Tries fix #3... making it worse
```

**Time to roll back!**

1. Click rollback button
2. Go back to: "Add a discount code field" (when it worked)
3. Choose "Erase all messages and generated code"
4. Now try again with better instructions:

```
You: "Make the checkout button bigger - but test it carefully 
and make sure payments still work before finishing."
```

## Two Types of Rollback

### Complete Rollback (Recommended)

**"Erase all messages and generated code"**

<Note>
  **What happens:**

  * Code goes back to that point
  * Conversation resets to that point
  * Everything returns to that state

  **Best for:** When code is broken or you want a clean restart
</Note>

**Example:**

```
Working app at message #15
↓
Made changes, now broken at message #23
↓
Roll back to message #15
↓
Back to working app!
```

### Message-Only Rollback

**"Erase messages only"**

<Note>
  **What happens:**

  * Conversation history is cleared
  * Code stays as-is (current version)

  **Best for:** When code is fine but conversation is cluttered
</Note>

**Example:**

```
Long conversation with many back-and-forth messages
Code is actually working fine
Just want to clean up chat and start fresh
Roll back messages only
Code unchanged, conversation clean
```

## Important Things to Know

### You Cannot Undo Rollback

<Warning>
  **Once you roll back, you cannot undo it!**

  You'll lose all work done after that point.

  **Before rolling back:**

  * Are you sure you want to go back?
  * Could the agent fix it with better instructions instead?
  * Is there valuable work you'll lose?
</Warning>

### Send a Better Prompt After Rollback

After rolling back, **don't just repeat the same request**!

Give the agent more context:

**Don't do this:**

```
(After rollback)
You: "Add a checkout page"
(Same request that caused problems)
```

**Do this instead:**

```
(After rollback)
You: "Add a checkout page with Stripe integration.

Make sure to:
- Test the payment flow
- Handle errors gracefully
- Keep the existing discount code working
- Test everything before finishing"
```

**More details = Better results!**

### Does Rollback Cost Credits?

**Good news:** Rollback itself is **free.**

**However:**

* You'll need to spend credits again to rebuild features you lost
* If you rolled back 30 minutes of work, you'll need credits to redo it

**Example:**

```
Built feature A: 500 credits
Built feature B: 300 credits
Built feature C: 400 credits (broke everything)

Roll back to before feature C
↓
Feature C work lost, but you get features A & B working

To rebuild C better: ~400 credits again
```

## Rollback vs Forking

<CardGroup cols={2}>
  <Card title="Rollback" icon="clock-rotate-left" color="#3b82f6">
    **When to use:**

    * Something broke recently
    * Want to undo last few changes
    * Quick fix needed

    **What you get:**

    * Same project, earlier state
    * Same conversation history up to that point

    **Cost:** Free (but need credits to rebuild)
  </Card>

  <Card title="Forking" icon="code-branch" color="#8b5cf6">
    **When to use:**

    * Project became too complex
    * Running out of context
    * Want to try different direction

    **What you get:**

    * New project with fresh start
    * Keeps all current code
    * New conversation

    **Cost:** Uses credits
  </Card>
</CardGroup>

## Real Examples

### Example 1: Broken After Styling Changes

```
Message 20: "App works perfectly!"

Message 25: "Changed colors, now buttons don't work"

Action: Roll back to Message 20
Result: App working again, can try styling more carefully
```

### Example 2: Agent Misunderstood

```
Message 15: "Build a simple blog"

Message 22: Agent built a complex social network instead

Action: Roll back to Message 15
New prompt: "Build a SIMPLE blog - just posts and comments, 
nothing else. Keep it minimal."
Result: Got what you wanted!
```

### Example 3: Repeated Failed Fixes

```
Message 30: "Database queries working"

Message 32: Database breaks
Message 33: Agent tries fix 1 - doesn't work
Message 34: Agent tries fix 2 - still broken
Message 35: Agent tries fix 3 - worse!

Action: Roll back to Message 30
New prompt: "The database queries were working. 
I just want to add pagination - please be very 
careful not to break existing queries."
Result: Pagination added without breaking things!
```

## Tips for Using Rollback Effectively

### Good Practices

1. **Roll back early** - If you see problems, don't wait
2. **Choose the right checkpoint** - Go back to last stable state
3. **Improve your prompt** - Add more detail when you restart
4. **Test after changes** - Ask agent to test before moving on

### Avoid These Mistakes

1. **Rolling back too far** - Don't go back further than needed
2. **Repeating same prompt** - If it failed once, explain better
3. **Not confirming it worked** - Test the feature before continuing
4. **Forgetting to save info** - Copy any important notes before rolling back

## Quick Decision Guide

**Should I roll back?**

```
Is something broken? → YES → Roll back!
Did agent misunderstand? → YES → Roll back!
Stuck in error loop? → YES → Roll back!

Is it just a small bug? → NO → Ask agent to fix it
Do I want to try something else? → MAYBE → Consider forking instead
```

## How to Access Rollback

### On Desktop

1. Look at the chat interface
2. Find the rollback button (usually top or side)
3. Click it
4. Select checkpoint
5. Confirm

### On Mobile

1. Look for the clock icon
2. Tap it
3. Browse conversation history
4. Select where to roll back to
5. Confirm

<Tip>
  **Can't find it?**  Check out the reference video at the beginning of this article!
</Tip>

## Remember

**Rollback is FREE** - No extra credits charged

**Cannot be undone** - Choose carefully!

**Lose work after that point** - Make sure that's okay

**Give better prompts after** - More detail helps

**Use early if stuck** - Don't wait too long

**Test after rolling back** - Make sure it's actually working

## Common Questions

<AccordionGroup>
  <Accordion title="Will I lose all my work?">
    You'll lose work done **after** the point you roll back to.

    Everything **before** that point is kept!

    **Example:**

    * Messages 1-20: ✅ Kept
    * Messages 21-30: ❌ Lost (if you roll back to 20)
  </Accordion>

  <Accordion title="Can I roll back after deploying?">
    Rollback affects your Preview/development version.

    Your deployed app stays as-is until you deploy again.

    **Safe to experiment in Preview!**
  </Accordion>

  <Accordion title="How far back can I roll back?">
    You can roll back to any point in your conversation history!

    Even back to the very beginning if needed.
  </Accordion>

  <Accordion title="What if I roll back by mistake?">
    Unfortunately, you **cannot undo a rollback**.

    The work is gone - you'll need to rebuild it.

    **Tip:** Always double-check before confirming!
  </Accordion>

  <Accordion title="Rollback vs starting over?">
    **Rollback:** Keep some work, lose recent changes

    **Starting over:** Lose everything, completely fresh start

    **Rollback is better** - You keep the good work!
  </Accordion>
</AccordionGroup>

## Still Stuck?

If rolling back didn't help:

1. **Try the troubleshoot agent** - It can find deeper issues
2. **Fork the project** - Start fresh with current code
3. **Ask for help** - Describe the problem clearly

Also, check out the [troubleshooting tips](https://emergent.mintlify.app/troubleshooting/design-tweaks) we have.

```
I rolled back but still having issues.

What was working: [describe]
What's broken: [describe]
What I tried: [describe]

Can you help?
```

**Pro tip:** Think of rollback as your "safety net" - don't be afraid to use it! It's better to roll back early than to let the agent struggle with a broken state.
