DEV Community

彭钰璘(Dexter)
彭钰璘(Dexter)

Posted on

I Built a Visual Branching Code History Plugin for IntelliJ IDEA

Have you ever been coding, gone down a rabbit hole, and then wished you could just go back to where you started — but your undo history was long gone?
That's the problem I ran into constantly. So I built TimeRail: a free IntelliJ IDEA plugin that snapshots your editor state and lets you restore any past state with one click.
What Makes It Different from Local History?
IntelliJ already has a built-in Local History feature, but it only tracks file-level changes. TimeRail tracks your entire editor session — all your open tabs, their scroll positions, and what you were looking at — as a single snapshot.
The bigger difference: branching.
When you restore a past snapshot in TimeRail, it doesn't overwrite your history. It creates a new branch in the tree. So you can go back in time, try something different, and your "future" is still there waiting for you on another branch.
How It Works

Snap — Click the 📸 button to save your current editor state
Browse — The branching tree shows all your snapshots with screenshot thumbnails
Restore — Click any snapshot to jump back to that exact state

Every restore automatically branches the tree, so you always have a visual record of every direction you explored.
Show Image
The Tech Stack
Built with Kotlin on top of the IntelliJ Platform SDK. A few interesting technical challenges:

Screenshot capture: Using Robot.createScreenCapture() mapped to each editor window's screen coordinates
Branching tree rendering: A custom Swing canvas with paintComponent and g2.scale() for zoom — all rendering in a single pass for reliability
Scroll behavior: Implementing the Scrollable interface with getScrollableTracksViewportHeight() = false to get correct scroll range after zooming
Click detection: Hit-testing mouse coordinates divided by the current scale factor

One thing I learned the hard way: Mac trackpads don't deliver native pinch gestures to Java Swing as MouseWheelEvent. After spending way too long on this, I ended up implementing +/− zoom buttons instead — sometimes the simple solution is the right one.
Get It

🔌 JetBrains Marketplace: plugins.jetbrains.com/plugin/30869-timerail
💻 GitHub: github.com/DexterPeng117/TimeRail

Compatible with IntelliJ IDEA 2024.1+ (and other JetBrains IDEs based on the IntelliJ platform).
What's Next
A few things I'm thinking about:

Auto-snapshot on a timer
Snapshot labels / notes
Export/import snapshot history

If you try it out, I'd love any feedback — open an issue on GitHub or drop a comment here!

Top comments (0)