Skip to content

Time Travel

Replay your entire AI programming session like watching a video, seeing code change with every conversation message.

What is Time Travel?

Imagine you've been pair programming with AI all day, writing hundreds of lines of code. Now you want to know when a particular function was added, or see how the AI refactored your code step by step.

Time Travel is Mantra's "replay" capability:

  • Click any conversation message
  • Instantly see the code state at that moment
  • Just like a video player's progress bar, jump to any point in time

Simple Explanation

If Git is your code's "save points," then Time Travel is the "time machine" that lets you freely travel between those save points.

Why Do You Need Time Travel?

When using AI coding assistants (like Cursor or Copilot Chat), you might encounter these challenges:

ProblemHow Time Travel Helps
Want to know when a feature was implementedClick along the conversation to find the right moment
Code broke, want to review previous versionClick earlier messages to see the code at that time
Want to understand how AI made changes step by stepClick messages sequentially to watch code evolution
Want to share coding approach with colleaguesReplay the entire programming session from the start

Interface Layout

Mantra uses a side-by-side layout so you can see both conversation and code:

Conversation Panel (Left)

The left panel displays the complete AI conversation history:

  • Message List: All exchanges between you and the AI, in chronological order
  • Timestamps: Each message has a precise timestamp
  • Message Types: Distinguishes user messages, AI responses, code executions, etc.
  • Current Position: Highlights the message you're currently viewing

Pro Tip

Conversations can get long. Use Message Filtering to show only the content you care about.

Code Snapshot Panel (Right)

The right panel shows the code state at the selected point in time:

  • File Tree: Displays the project's directory structure
  • Code Content: Shows the complete code of the selected file
  • Change Highlighting: Uses different colors to mark code changes
  • Multi-file Navigation: Browse any file in the project

Note

The code snapshot shows the code state at the time of the conversation, not the current content on your computer.

Basic Operations

Click Messages to View Code Changes

This is the core operation of Time Travel:

  1. Find the message you want to view in the left conversation panel
  2. Click on the message
  3. The right code panel instantly updates to show the code state at that time

Experience the "Aha Moment"

When trying this for the first time, click back and forth between two messages that are far apart. When you see the code instantly switch, you'll truly understand the magic of Time Travel!

Timeline Navigation

Besides clicking messages directly, you can also navigate using the timeline:

  1. Find the timeline component at the top of the interface
  2. Drag the timeline to your desired position
  3. The code automatically updates as you move the timeline

The timeline displays key nodes to help you quickly locate important code changes.

Browsing Historical Versions with File Tree

Time Travel isn't just for viewing single files—you can browse the entire project's state at any point in time:

  1. Use Time Travel to jump to a specific point in time
  2. Expand the file tree in the right code panel
  3. Click any file to view its content at that moment
  4. When switching files, the time point remains the same

Use Case

This feature is especially useful when you want to understand which files were changed during a refactoring.

Git Integration

How Code Snapshots Relate to Git History

You might wonder: How does Mantra know the code state at each point in time?

The answer is Git. Mantra analyzes your project's Git commit history and combines it with conversation timestamps to automatically match the closest code version.

How It Works

  1. Mantra reads timestamps from the conversation history
  2. Finds the most recent Git commit before that timestamp
  3. Extracts the code snapshot from that commit in Git history
  4. Displays this version of the code in the interface

Git Repository Requirements

Time Travel requires your project to meet these conditions:

  • Must be a Git repository: The project root needs a .git folder
  • Has commit history: At least some Git commit records are needed
  • Commit frequency affects precision: More frequent commits mean more precise Time Travel

Best Practice

When using AI coding assistants, develop a habit of making frequent small commits. This allows Mantra to more precisely restore code states at each point in time.

Impact of Git Working Directory

If you have uncommitted changes (working directory modifications), Time Travel behaves differently:

SituationWhat Time Travel Shows
Viewing the latest time pointShows code from the most recent Git commit
Viewing historical time pointsShows the Git version at that time
Untracked new filesWon't appear in the code snapshot

Note

Time Travel shows versions from Git, not the real-time state of your local files. If you just wrote code that hasn't been committed, Time Travel won't show it.

Advanced Tips

Keyboard Shortcuts

Use keyboard shortcuts to browse conversation history more efficiently:

ShortcutFunction
Cmd/Ctrl + JJump between messages
Cmd/Ctrl + KOpen search

Continuous Browsing

Press Cmd/Ctrl + J repeatedly to quickly jump between messages, like fast-forwarding/rewinding a video. Combine with Cmd/Ctrl + K search to quickly locate specific conversations.

For more shortcuts, see Keyboard Shortcuts Reference.

Combining with Message Filtering

When conversation history is long, Time Travel works better with Message Filtering:

  1. First use message filtering to show only key messages (like code-related ones)
  2. Use Time Travel within the filtered results
  3. This lets you skip irrelevant chat and focus on code evolution

File Tree Browsing Tips

Make full use of the file tree to get a more comprehensive code perspective:

  1. Collapse irrelevant directories: Only expand the code directories you care about
  2. Compare multiple files: Switch between different files at the same time point
  3. Track file creation: Observe when new files appear
  4. Track file deletion: Notice when files disappear after a certain point

Frequently Asked Questions

Code snapshot not showing?

Possible causes:

  1. Project is not a Git repository

    • Solution: Run git init in the project root to initialize a repository
  2. No Git commits exist

    • Solution: Create at least one commit with git add . && git commit -m "Initial commit"
  3. Git repository is corrupted

    • Solution: Check if the .git directory is intact; re-clone the repository if necessary
  4. File path issues

    • Solution: Ensure the project path doesn't contain special characters or excessively long paths
Git history matching failed?

Possible causes:

  1. Conversation time is earlier than the first commit

    • Explanation: If the conversation occurred before the first Git commit, no corresponding code version can be found
    • Solution: You can only view time periods covered by Git history
  2. Inaccurate timestamps

    • Explanation: Incorrect system time might cause matching errors
    • Solution: Check your computer's system time settings
  3. Low commit frequency

    • Explanation: Long gaps between commits may prevent precise restoration of intermediate states
    • Solution: Develop a habit of making frequent small commits
File shows as empty?

Possible causes:

  1. File didn't exist at that time point

    • Explanation: You're viewing a time point before the file was created
    • Solution: Jump to a time point after the file was created
  2. File was deleted

    • Explanation: The file was deleted in a subsequent commit
    • Solution: Jump to a time point before the file was deleted
  3. Git isn't tracking the file

    • Explanation: The file is in .gitignore or was never added to Git
    • Solution: Ensure important files are tracked by Git
Time Travel and IDE code are out of sync?

This is normal behavior.

Mantra shows code versions from Git history, while your IDE shows the current state of local files.

The difference:

  • Mantra Time Travel: Historical versions committed to Git
  • IDE/Editor: Real-time local file content (may include uncommitted changes)

If you want to see the latest code in Mantra, you need to git commit your changes first.

Next Steps

After mastering Time Travel, explore more features: