Skip to content

feat(animation): implement typing animation engine - #16

Merged
unhappychoice merged 22 commits into
mainfrom
feat/typing-animation-engine
Nov 9, 2025
Merged

unhappychoice merged 22 commits into
mainfrom
feat/typing-animation-engine

Conversation

@unhappychoice

@unhappychoice unhappychoice commented Nov 8, 2025 •

Copy link
Copy Markdown
Owner

Summary

Implements the core typing animation engine (#7) that replays Git commits character by character.

Key Features

  • EditorBuffer: Tracks file state with line-by-line content, cursor position, and scroll offset
  • AnimationEngine: Generates and executes animation steps from Git diff hunks
    • Character insertion with typing effect
    • Line insertion and deletion
    • Cursor movement
    • Configurable pauses between edits
  • Blinking cursor: 500ms interval, white background on black text
  • Configurable speed: Uses --speed argument (default 30ms/char)
  • 60fps rendering: Non-blocking event polling for smooth animation

UI Integration

  • EditorPane: Renders buffer content with syntax-aware cursor
  • StatusBarPane: Shows commit hash, author, and message
  • FileTreePane: Displays changed files with color-coded status icons
    • + Green for additions
    • - Red for deletions
    • ~ Yellow for modifications
    • > Blue for renames

Implementation Details

  • Animation steps generated from diff hunks
  • Tracks old/new line numbers separately for accurate positioning
  • Handles context lines, additions, and deletions
  • Pauses: 1s initial, 2s between hunks, 3s at end

Testing

Build successful. Animation logic implemented and integrated with UI components.

Related

Closes #7

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Interactive animation playback that visualizes commit edits, cursor movement, file switching, and terminal output.
    • Dynamic file tree with per-file status and highlighting, and an enhanced status bar showing commit info.
    • Automatic commit loading and configurable animation speed with seamless UI integration.
  • Bug Fixes / Reliability

    • More robust repository handling and safer file/blob reads to avoid failures with large or missing data.

Add core animation system with the following features:
- EditorBuffer for tracking file state
- AnimationEngine with step-by-step playback
- Character-by-character typing animation
- Line insertion and deletion animations
- Blinking cursor effect (500ms interval)
- Configurable typing speed via --speed argument
- Pause between hunks (1-3s)

Integrate animation with UI:
- EditorPane renders buffer content with cursor
- StatusBarPane displays commit metadata
- FileTreePane shows changed files with status icons
- ~60fps event polling for smooth animation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 8, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a Rust-based typing animation system and integrates it into the UI: new animation module implements an editor buffer, granular animation steps, and an engine that generates and plays per-hunk edit sequences; main/UI and all panes updated to load commits, drive and render the animation, and surface commit metadata.

Changes

Cohort / File(s) Summary
New Animation System
src/animation.rs
Adds EditorBuffer, AnimationStep, AnimationState, and AnimationEngine with step generation (per-file, per-hunk), execution, timing, cursor blinking, scroll management, terminal I/O steps, and public API (new, set_viewport_height, load_commit, tick, is_finished).
Main Initialization
src/main.rs
Refactors startup to open repository, select commit (explicit or random), construct UI with speed/repo context, and load the selected commit into the UI before running.
UI Core & Loop
src/ui.rs
Replaces simple quit flag with UIState; constructor signature changed to new(speed_ms, is_commit_specified, repo); adds engine: AnimationEngine, metadata: Option<CommitMetadata>, load_commit() method; integrates engine tick, viewport sizing, and animation-driven state transitions into the run loop.
Editor Pane
src/panes/editor.rs
render signature updated to (..., engine: &AnimationEngine); renders visible buffer lines from EditorBuffer, per-line numbers/sep, highlights current line, draws blinking cursor glyph at column, and computes scroll/viewport.
File Tree Pane
src/panes/file_tree.rs
render signature updated to (..., metadata: Option<&CommitMetadata>, current_file_index: usize); builds a colored directory/file tree from commit changes with per-file status and current-file highlighting.
Status Bar Pane
src/panes/status_bar.rs
render signature updated to (..., metadata: Option<&CommitMetadata>); shows shortened commit hash, author, and first commit line when metadata present, otherwise “No commit loaded.”
Terminal Pane
src/panes/terminal.rs
render signature updated to (..., engine: &AnimationEngine); renders engine.terminal_lines, styles command lines, and shows terminal cursor/command prompt with blinking support.
Git Improvements
src/git.rs
Adds commit_cache: RefCell<Option<Vec<Oid>>>, limits blob read size, guards against missing parent/trees and diff/tree failures, and returns safe defaults for problematic diffs to improve robustness.

Sequence Diagram(s)

sequenceDiagram
    participant Main as main.rs
    participant UI as UI
    participant Engine as AnimationEngine
    participant Buffer as EditorBuffer
    participant Panes as Render Panes

    Main->>UI: new(speed_ms, is_commit_specified, repo)
    Main->>UI: load_commit(metadata)
    UI->>Engine: Engine::new(speed_ms)
    UI->>Engine: load_commit(metadata)
    Engine->>Engine: generate_steps_for_file()/hunk()
    UI->>Engine: set_viewport_height(h)
    
    loop UI loop (poll/tick)
        UI->>Engine: tick()
        alt step available
            Engine->>Engine: execute_step(step)
            Engine->>Buffer: mutate buffer (insert/delete/line)
            Engine->>Engine: update_scroll()
            Engine-->>UI: redraw_needed (true)
        else no step
            Engine-->>UI: redraw_needed (false)
        end
        UI->>Panes: render(engine, metadata)
        Panes->>Buffer: read visible lines
        Note over Panes,UI: cursor blink and terminal output handled from Engine state
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • Focus review on:
    • src/animation.rs: hunk-to-step translation, timing, step execution, and scroll/viewport math.
    • src/ui.rs: UI state transitions, tick integration, and resume scheduling.
    • Pane signature changes: ensure all call sites updated and borrow lifetimes for repo/metadata are correct.
    • src/git.rs: commit cache correctness and safe handling of large/binary blobs.

Possibly related PRs

Poem

🐰
I nibble keys and hop through time,
Lines appear in tidy rhyme,
A blinking nose marks every place,
I trace the diff with gentle pace,
Hooray — the commit comes to life!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.58% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main feature introduced in this pull request: implementing a typing animation engine for replaying Git commits character-by-character.
Linked Issues check ✅ Passed The pull request successfully implements all coding requirements from issue #7: virtual editor buffer (EditorBuffer), animation state machine (AnimationStep, AnimationState, AnimationEngine), configurable typing speed, blinking cursor (500ms interval), and scrolling support.
Out of Scope Changes check ✅ Passed All changes are scoped to the animation feature requirements. The modifications to UI components (editor pane, file tree, terminal, status bar) and git repository are necessary integrations to support the animation engine, not out-of-scope additions.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/typing-animation-engine

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 35178e5 and 49161be.

📒 Files selected for processing (7)
  • src/animation.rs (1 hunks)
  • src/git.rs (6 hunks)
  • src/main.rs (2 hunks)
  • src/panes/editor.rs (1 hunks)
  • src/panes/file_tree.rs (1 hunks)
  • src/panes/terminal.rs (1 hunks)
  • src/ui.rs (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (7)
src/panes/file_tree.rs (5)
src/ui.rs (2)
  • render (151-188)
  • new (39-51)
src/panes/editor.rs (1)
  • render (13-98)
src/panes/terminal.rs (1)
  • render (13-71)
src/panes/status_bar.rs (1)
  • render (13-34)
src/animation.rs (2)
  • new (38-45)
  • new (143-160)
src/panes/terminal.rs (3)
src/ui.rs (2)
  • render (151-188)
  • new (39-51)
src/panes/editor.rs (1)
  • render (13-98)
src/animation.rs (2)
  • new (38-45)
  • new (143-160)
src/git.rs (1)
src/ui.rs (1)
  • new (39-51)
src/panes/editor.rs (3)
src/ui.rs (2)
  • render (151-188)
  • new (39-51)
src/panes/terminal.rs (1)
  • render (13-71)
src/animation.rs (2)
  • new (38-45)
  • new (143-160)
src/main.rs (2)
src/git.rs (1)
  • open (99-106)
src/ui.rs (1)
  • new (39-51)
src/animation.rs (1)
src/ui.rs (2)
  • new (39-51)
  • load_commit (53-57)
src/ui.rs (1)
src/animation.rs (3)
  • new (38-45)
  • new (143-160)
  • load_commit (175-277)
🔇 Additional comments (14)
src/main.rs (2)

12-69: LGTM! Clean CLI argument design.

The clap-based argument parsing is well-structured with clear help text, sensible defaults, and thorough validation. The path canonicalization ensures consistent handling downstream.


71-92: LGTM! Startup flow correctly coordinates repository and UI initialization.

The conditional repo reference (line 86) elegantly differentiates single-commit mode from continuous random mode, and the two-phase UI initialization (new then load_commit) aligns with the updated UI API.

src/panes/terminal.rs (1)

1-72: LGTM! Terminal pane correctly renders engine-driven content.

The dynamic rendering logic properly:

  • Computes visible lines based on viewport height
  • Styles command lines (starting with $ ) in green/bold
  • Displays cursor only on the last line when the terminal is active
  • Handles empty terminal state gracefully
src/panes/file_tree.rs (1)

14-135: LGTM! File tree rendering with rich metadata display.

The hierarchical tree structure built from CommitMetadata is well-implemented:

  • BTreeMap ensures deterministic directory ordering
  • Per-file change statistics (+/-) provide useful context
  • Current file highlighting aids navigation
  • Color-coded status icons (+ green, - red, ~ yellow, > blue) align with Git conventions
src/panes/editor.rs (1)

13-98: LGTM! Editor pane correctly renders with UTF-8-safe cursor positioning.

The cursor rendering logic (lines 63-87) now correctly uses character indices throughout:

  • Line 65 collects characters into a Vec<char>
  • Lines 68-71, 74, 84-86 use character-based slicing
  • This avoids the byte/character index confusion that was previously flagged

The line number display, syntax-aware cursor highlight, and scroll-aware viewport are all implemented correctly.

src/git.rs (2)

120-151: LGTM! Commit caching optimizes random selection.

The lazy initialization of commit_cache (lines 122-141) avoids repeated repository walks, and the drop(cache) on line 149 correctly releases the borrow before calling extract_metadata_with_changes.

Note: The cache persists for the lifetime of the GitRepository instance, which is appropriate for the continuous random mode where the repository doesn't change.


176-197: LGTM! Safety guards improve robustness.

The defensive error handling in extract_changes prevents panics in edge cases:

  • Lines 179-182: Missing parent trees return empty changes instead of panicking
  • Lines 190-197: Failed diff operations are handled gracefully
  • Lines 228, 247: MAX_BLOB_SIZE (500KB) prevents reading large blobs

These guards ensure the animation engine can handle unusual repository states without crashing.

Also applies to: 228-233, 247-252

src/ui.rs (2)

19-57: LGTM! Clean separation of UI state and lifecycle.

The UIState enum (lines 19-24) elegantly models the three phases (Playing, WaitingForNext, Finished), and the two-phase initialization (new + load_commit) allows proper setup before entering the event loop.


79-149: LGTM! State machine correctly orchestrates animation lifecycle.

The run loop properly:

  • Calculates editor viewport height accounting for borders (lines 82-90)
  • Redraws only when engine.tick() signals changes (lines 92-97)
  • Transitions between states based on mode: single-commit exits on finish, random mode schedules next commit with appropriate delay (lines 110-145)

The 100x speed multiplier for inter-commit pauses (line 118) provides a natural rhythm for the screensaver.

src/animation.rs (5)

37-93: LGTM! EditorBuffer correctly handles UTF-8 text manipulation.

The buffer methods properly handle character-vs-byte indexing:

  • insert_char (lines 62-76) converts character index to byte index before insertion (lines 69-75)
  • insert_line and delete_line maintain buffer invariants (empty buffer always has one line)

5-122: LGTM! Animation step model and timing constants are well-designed.

The pause multiplier constants (lines 5-26) provide semantic timing (e.g., CURSOR_MOVE_SHORT_MULTIPLIER vs CURSOR_MOVE_LONG_MULTIPLIER), and the AnimationStep enum (lines 95-107) cleanly models all editor and terminal operations.

The distance-based cursor movement speed adjustment (lines 8-10) creates natural-feeling navigation.


175-277: LGTM! Commit animation sequence creates engaging narrative.

The load_commit method generates a well-paced animation sequence:

  • Time-travel intro with playful messaging (lines 184-203)
  • Per-file editing with appropriate pauses (lines 205-233)
  • Git workflow commands with whimsical output (lines 235-273)

The theatrical terminal output (e.g., "🚀 Launching code into the cloud...") enhances the screensaver experience.


279-420: LGTM! Diff-to-animation translation handles line tracking correctly.

The hunk processing logic properly:

  • Tracks buffer line offsets as edits accumulate (lines 282, 306-315)
  • Adjusts cursor movement speed based on distance (lines 322-356)
  • Generates appropriate steps for deletions, additions, and context lines (lines 358-420)

The line tracking fix (per past review) ensures accurate cursor positioning throughout multi-hunk files.


422-562: LGTM! Animation execution with polished timing and scrolling.

The tick-execute-scroll cycle is well-implemented:

  • 500ms cursor blink (line 425) matches the PR objectives
  • 70-130% typing speed variation (lines 463-468) creates natural rhythm
  • Viewport centering (lines 535-557) keeps the action visible

The pause handling (lines 431-436) correctly maintains cursor blinking during delays.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

unhappychoice and others added 6 commits November 9, 2025 07:39
Implement viewport-aware scrolling:
- Calculate viewport height from terminal size
- Update scroll_offset to center cursor line
- Keep cursor in middle of screen during animation
- Handle edge cases:
  - Top of file: scroll_offset stays at 0
  - Bottom of file: show maximum visible content
- Auto-update scroll after each animation step

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Support animating changes across multiple files:
- Add SwitchFile animation step to switch between files
- Track current_file_index in AnimationEngine
- Process all files in commit sequentially
- Add 1s pause before each file
- Add 2s pause between files
- Highlight current file in FileTreePane with dark gray background

Animation flow:
1. Switch to file -> pause 1s
2. Animate hunks with 1.5s pause between hunks
3. Pause 2s before next file
4. Final pause 3s at end

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Move cursor to hunk start position before animating:
- Add MoveCursor step at beginning of each hunk
- Add 500ms pause after cursor movement
- Makes hunk transitions more visible to user

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Replace instant cursor movement with smooth line-by-line animation:
- Track cursor position through hunk processing
- Generate MoveCursor steps for each line when moving between hunks
- Move cursor line by line with 50ms pause per line
- Move cursor during context lines within hunks
- Add 300ms pause after cursor movement completes

This makes cursor movement visible instead of teleporting, improving
the visual flow of the animation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Implement Terminal pane animations showing git workflow:

Before animation:
- git checkout <parent_hash>^ (simulated parent commit)
- Display checkout confirmation message

After file editing:
- git add . (stage changes)
- git commit -m "message" (commit with actual commit message)
  - Show commit hash and file count
- git push origin main (push simulation)
  - Enumerating objects
  - Counting objects
  - Writing objects
  - Show push confirmation

Terminal display:
- Command lines in green with bold ($-prefixed)
- Output lines in normal style
- Auto-scroll to show latest lines
- Keep last N lines visible based on terminal height

Animation flow:
1. Checkout parent -> 1s pause
2. (File editing animations)
3. git add -> 500ms pause
4. git commit -> show output -> 1s pause
5. git push -> progressive output -> 2s final pause

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Fix panic when inserting/deleting characters:
- Convert char index to byte index before string operations
- Handle multi-byte UTF-8 characters properly
- Use char_indices() to find correct byte positions
- Fix cursor rendering to use char indices not byte indices

This prevents panic on line 42 when col exceeds byte length
or when dealing with multi-byte characters like Japanese.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main.rs (1)

91-183: Remove the unused print_commit_info function (lines 91-183).

The function is defined but never called anywhere in the codebase. This is dead code and should be removed to keep the codebase clean.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a41b393 and 35178e5.

📒 Files selected for processing (7)
  • src/animation.rs (1 hunks)
  • src/main.rs (2 hunks)
  • src/panes/editor.rs (1 hunks)
  • src/panes/file_tree.rs (1 hunks)
  • src/panes/status_bar.rs (2 hunks)
  • src/panes/terminal.rs (1 hunks)
  • src/ui.rs (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (7)
src/panes/status_bar.rs (2)
src/ui.rs (1)
  • render (106-143)
src/panes/file_tree.rs (1)
  • render (13-65)
src/panes/editor.rs (2)
src/ui.rs (2)
  • render (106-143)
  • new (29-39)
src/animation.rs (2)
  • new (14-21)
  • new (112-127)
src/main.rs (3)
src/git.rs (1)
  • open (94-98)
src/animation.rs (2)
  • new (14-21)
  • new (112-127)
src/ui.rs (1)
  • new (29-39)
src/panes/file_tree.rs (5)
src/panes/terminal.rs (1)
  • render (13-48)
src/ui.rs (2)
  • render (106-143)
  • new (29-39)
src/panes/editor.rs (1)
  • render (13-70)
src/panes/status_bar.rs (1)
  • render (13-34)
src/animation.rs (2)
  • new (14-21)
  • new (112-127)
src/panes/terminal.rs (4)
src/ui.rs (2)
  • render (106-143)
  • new (29-39)
src/panes/file_tree.rs (1)
  • render (13-65)
src/panes/editor.rs (1)
  • render (13-70)
src/animation.rs (2)
  • new (14-21)
  • new (112-127)
src/ui.rs (1)
src/animation.rs (3)
  • new (14-21)
  • new (112-127)
  • load_commit (134-233)
src/animation.rs (1)
src/ui.rs (2)
  • new (29-39)
  • load_commit (41-44)
🔇 Additional comments (10)
src/main.rs (1)

71-89: LGTM! Clean integration flow.

The main function correctly orchestrates repository loading, commit selection, and UI initialization. Error handling is appropriate with Result propagation throughout.

src/panes/status_bar.rs (1)

12-35: LGTM! Safe string handling.

The metadata rendering logic correctly handles optional metadata with safe string slicing and fallback values. The hash truncation using 7.min(meta.hash.len()) prevents panics on short hashes, and the unwrap_or on message extraction provides a sensible fallback.

src/panes/file_tree.rs (1)

12-66: LGTM! Well-structured file tree rendering.

The file tree rendering correctly maps file change statuses to colored indicators with appropriate fallback handling. The current file highlighting using index comparison is clean and efficient.

src/panes/terminal.rs (1)

12-49: LGTM! Robust terminal rendering.

The terminal pane correctly handles dynamic content with safe arithmetic using saturating_sub. The conditional styling for command lines (prefixed with "$ ") provides good visual distinction.

src/ui.rs (3)

28-44: LGTM! Clean API integration.

The constructor and load_commit method provide a clean interface for initializing the UI with animation support. The delegation to the engine is appropriate.


68-77: Verify behavior on very small terminals.

The viewport height calculation uses multiple saturating_sub operations, which could result in a viewport height of 0 on very small terminals. For example, a terminal with 5 lines would result in viewport_height = 0 after the calculations.

Ensure the animation engine's update_scroll method (line 427-449 in src/animation.rs) handles viewport_height = 0 gracefully, which it appears to do with the early return on line 428-430.


79-100: LGTM! Efficient render loop.

The render loop correctly uses conditional redrawing based on the animation engine's tick result, avoiding unnecessary renders. The 16ms polling interval (~60fps) provides smooth animation while remaining responsive to user input.

src/animation.rs (3)

235-275: LGTM! Clear cursor movement logic.

The cursor movement generation correctly handles both upward and downward movement with appropriate range constructions. The line-by-line animation with pauses provides good visual feedback.


337-425: LGTM! Well-structured animation loop.

The tick/execute loop correctly handles cursor blinking, pauses, and step execution. The cursor continues blinking during pauses (line 348), which maintains visual continuity. All animation step variants are properly handled with appropriate cursor and buffer updates.


427-449: LGTM! Robust scroll management.

The scroll update logic correctly handles three cases (top, middle, bottom) to keep the cursor visible and centered when possible. The early return for zero viewport height prevents division issues.

Comment thread src/animation.rs Resolved
Comment thread src/animation.rs
Comment on lines +134 to +233
pub fn load_commit(&mut self, metadata: &CommitMetadata) {
self.steps.clear();
self.current_step = 0;
self.state = AnimationState::Playing;
self.current_file_index = 0;
self.terminal_lines.clear();

// Git checkout to parent commit (simulation)
let parent_hash = format!("{}^", &metadata.hash[..7]);
self.steps
.push(AnimationStep::TerminalCommand {
command: format!("git checkout {}", parent_hash),
});
self.steps.push(AnimationStep::Pause { duration_ms: 500 });
self.steps.push(AnimationStep::TerminalOutput {
text: format!("HEAD is now at {} Previous commit", parent_hash),
});
self.steps.push(AnimationStep::Pause { duration_ms: 1000 });

// Process all file changes
for (index, change) in metadata.changes.iter().enumerate() {
// Add file switch step
let content = change.old_content.clone().unwrap_or_default();
self.steps.push(AnimationStep::SwitchFile {
file_index: index,
content: content.clone(),
});

// Add pause before starting file animation
self.steps.push(AnimationStep::Pause { duration_ms: 1000 });

// Generate animation steps for this file
self.generate_steps_for_file(change);

// Add pause between files
if index < metadata.changes.len() - 1 {
self.steps.push(AnimationStep::Pause { duration_ms: 2000 });
}
}

// Git add
self.steps.push(AnimationStep::Pause { duration_ms: 2000 });
self.steps.push(AnimationStep::TerminalCommand {
command: "git add .".to_string(),
});
self.steps.push(AnimationStep::Pause { duration_ms: 500 });

// Git commit
let commit_message = metadata.message.lines().next().unwrap_or("Update");
self.steps
.push(AnimationStep::TerminalCommand {
command: format!("git commit -m \"{}\"", commit_message),
});
self.steps.push(AnimationStep::Pause { duration_ms: 800 });
self.steps.push(AnimationStep::TerminalOutput {
text: format!("[main {}] {}", &metadata.hash[..7], commit_message),
});
self.steps.push(AnimationStep::TerminalOutput {
text: format!(
" {} file{} changed",
metadata.changes.len(),
if metadata.changes.len() == 1 { "" } else { "s" }
),
});
self.steps.push(AnimationStep::Pause { duration_ms: 1000 });

// Git push
self.steps.push(AnimationStep::TerminalCommand {
command: "git push origin main".to_string(),
});
self.steps.push(AnimationStep::Pause { duration_ms: 500 });
self.steps.push(AnimationStep::TerminalOutput {
text: "Enumerating objects: 5, done.".to_string(),
});
self.steps.push(AnimationStep::Pause { duration_ms: 300 });
self.steps.push(AnimationStep::TerminalOutput {
text: "Counting objects: 100% (5/5), done.".to_string(),
});
self.steps.push(AnimationStep::Pause { duration_ms: 300 });
self.steps.push(AnimationStep::TerminalOutput {
text: "Writing objects: 100% (3/3), done.".to_string(),
});
self.steps.push(AnimationStep::Pause { duration_ms: 500 });
self.steps.push(AnimationStep::TerminalOutput {
text: format!("To https://github.com/user/repo.git"),
});
self.steps.push(AnimationStep::TerminalOutput {
text: format!(" {}..{} main -> main", &parent_hash[..7], &metadata.hash[..7]),
});
self.steps.push(AnimationStep::Pause { duration_ms: 2000 });

// Start with the first file's content
if let Some(change) = metadata.changes.first() {
if let Some(old_content) = &change.old_content {
self.buffer = EditorBuffer::from_content(old_content);
} else {
self.buffer = EditorBuffer::new();
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Potential panic on short commit hashes.

The load_commit method slices commit hashes without length checks on lines 142, 189, and 221:

  • &metadata.hash[..7] assumes the hash is at least 7 characters
  • &parent_hash[..7] similarly assumes sufficient length

While Git commit hashes are typically 40 characters, defensive programming suggests using 7.min(hash.len()) as done in status_bar.rs line 19.

Apply this diff to add safe slicing:

-        let parent_hash = format!("{}^", &metadata.hash[..7]);
+        let hash_short = &metadata.hash[..7.min(metadata.hash.len())];
+        let parent_hash = format!("{}^", hash_short);

And update other occurrences similarly (lines 189, 221).

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/animation.rs around lines 134-233, the code unsafely slices commit hashes
at lines ~142, ~189 and ~221 using &metadata.hash[..7] and &parent_hash[..7];
compute a safe short_hash = &metadata.hash[..metadata.hash.len().min(7)] and use
that everywhere instead of direct slicing; set parent_ref = format!("{}^",
short_hash) (don’t slice parent_ref), and when you need the parent short id use
short_hash (or a separately computed parent_short if you prefer) for formatting
the terminal outputs; replace all direct &...[..7] slices with these safe
values.

Comment thread src/animation.rs Resolved
Comment thread src/panes/editor.rs Resolved
unhappychoice and others added 15 commits November 9, 2025 07:58
Replace instant command display with typing animation:
- Add TerminalPrompt step to start command line with "$ "
- Add TerminalTypeChar step to type one character at a time
- Create add_terminal_command helper to generate typing steps
- Each character typed uses the same speed as editor typing

Terminal command flow:
1. TerminalPrompt - add "$ " line
2. TerminalTypeChar (repeated) - add each character to last line
3. Pause - wait before showing output
4. TerminalOutput - show command result

Commands now type out like:
$ g
$ gi
$ git
$ git
$ git a
$ git ad
$ git add
$ git add .

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Add terminal commands for file operations:
- open {fileName} - before switching to each file
- git add {fileName} - after editing each file
- Remove global git add . command

Animation flow per file:
1. Pause 1.5s (except first file)
2. Type "open {fileName}"
3. Switch file display
4. Pause 800ms
5. Animate file changes
6. Pause 1s
7. Type "git add {fileName}"
8. Pause 500ms

This makes the workflow clearer by showing:
- Which file is being opened
- Individual git add for each modified file
- Better visibility of file-by-file editing process

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Start with empty editor buffer instead of pre-loading first file:
- Editor shows empty state initially
- First file loads only after "open {fileName}" command
- Add 1s pause before first open command (after git checkout)
- Keep 1.5s pause before subsequent file opens

Animation flow:
1. git checkout - show parent commit
2. Empty editor visible
3. Pause 1s
4. Type "open src/main.rs"
5. Load and display file
6. Start editing animation

This makes it clearer that no file is open initially.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Fix line number misalignment during editing:
- Track actual buffer line position instead of diff line numbers
- Deletion: keep buffer_line same (next line moves up)
- Addition: increment buffer_line (inserted new line)
- Context: increment buffer_line (move to next line)

Previous bug:
- Used separate old_line and new_line counters
- Incorrectly incremented old_line on Addition
- Didn't track actual buffer state after edits

This fixes the issue where edits appeared at wrong line positions
after insertions/deletions shifted the buffer content.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Add line number display to editor pane:
- Show line numbers on the left side (right-aligned)
- Dynamic width based on total line count (min 3 digits)
- Current line: yellow + bold
- Other lines: dark gray
- Separator: "│" between line numbers and content

Display format:
  1 │ first line
  2 │ second line
  3 │ code here  <- current line (yellow + bold)
  4 │ more code

Line numbers start from 1 (human-readable, not 0-indexed).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Track which pane is currently active and show cursor there:
- Add ActivePane enum (Editor, Terminal)
- Track active_pane in AnimationEngine
- Update active_pane on each animation step:
  - Editor operations: Editor pane
  - Terminal operations: Terminal pane
- Show cursor only in active pane

Editor cursor:
- Shown during file editing (InsertChar, DeleteChar, etc.)
- At specific line and column position

Terminal cursor:
- Shown during command typing (TerminalPrompt, TerminalTypeChar)
- At end of last line (command prompt)
- Blinking white block after command text

This makes it clear which pane is being operated at any time.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Add animation finish detection
- Auto-reload with new random commit when not using --commit flag
- Exit normally when using --commit flag
- Implement continuous playback mode for screensaver use case
- Add 70-130% random variation to character typing speed
- Make typing more realistic and natural
- Only apply variation to InsertChar and TerminalTypeChar steps
- Other animation steps maintain consistent speed
- Track cumulative line offset from additions/deletions
- Adjust each hunk's target position by accumulated offset
- Fix line misalignment when processing multiple hunks
- Pass buffer_line position between hunk processing steps
- Reduce cursor movement pause from 50ms to 15ms
- Cursor now moves faster than typing (30ms default)
- Apply to both hunk navigation and context line movements
… indices

- Git diff line numbers start at 1 (1-indexed)
- Array indices start at 0 (0-indexed)
- Convert hunk.old_start by subtracting 1 before use
- Fix off-by-one error causing edits to appear one line below
- Define duration multipliers as constants at module level
- All pauses now scale proportionally with --speed flag
- Cursor movement: 0.5x speed
- Line operations: 6.7-10x speed
- Hunk transitions: 50x speed
- Git commands: 16.7-66.7x speed
- Faster speed setting now makes entire animation faster
…code

- Keep single UI instance in raw mode to prevent screen flicker
- Load next commits internally within same UI session
- Fix infinite loop issue by properly managing should_quit flag
- Remove unused code: delete_char, get_content, print_commit_info
- Remove unused constants and enum variants
- Simplify git2 usage in random_commit

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Fix integer underflow when hunk.old_start is 0 (new files)
- Add explicit UIState enum for robust state management
- Cache commits in GitRepository to avoid repeated scans
- Make inter-commit wait time proportional to typing speed
- Reset animation timing state on commit load

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Group files by directory in tree structure
- Add change statistics (+N -N) for each file
- Remove emoji icons for cleaner display
- Indent files under their parent directories

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement typing animation engine

1 participant