Design Undo and Redo for CapCut's Timeline Editor
Last updated: November 29, 2026
Quick Overview
Design an undo and redo system for CapCut's web timeline editor that supports operations like inserting and trimming clips, with a bounded history and correct behavior when a new edit follows an undo.
ByteDance
November 29, 20260
0
0 solved
Design an undo and redo system for CapCut's web timeline editor that supports operations like inserting and trimming clips, with a bounded history and correct behavior when a new edit follows an undo.
CapCut's browser editor is a large frontend codebase at ByteDance, and undo/redo is a staple low-level design question for its frontend engineers. The interviewer checks the command pattern, the two-stack model, and that redo history is discarded after a fresh edit.
What the Interviewer Expects
- Use the command pattern with do and undo per operation
- Keep separate undo and redo stacks
- Clear the redo stack on any new command
- Store just enough state in each command to reverse it
- Bound history size for memory
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- Group a drag gesture's many small moves into one undo step.
- How would undo work in a collaborative project with two editors?
- Compare the command pattern to storing immutable snapshots.
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Operations: insert a clip at an index and trim a clip's length, extensible to more. undo reverts the latest applied operation; redo reapplies the latest undone one. A new operation after undo discards...
High-Level Design
Each edit is a Command object with do(doc) and undo(doc). History owns the document and two stacks. run executes and pushes to undo, then clears redo. undo pops, reverts and pushes to redo; redo does ...