Skip to content

Commit 4a008e6

Browse files
unhappychoiceclaude
andcommitted
fix: apply speed rules to all pause durations
Change Pause from fixed duration_ms to multiplier, calculating actual duration at execution time using current speed_ms. This ensures file-specific speed rules affect all animations, not just typing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 5f1621f commit 4a008e6

1 file changed

Lines changed: 36 additions & 36 deletions

File tree

‎src/animation.rs‎

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ pub enum AnimationStep {
177177
col: usize,
178178
},
179179
Pause {
180-
duration_ms: u64,
180+
multiplier: f64,
181181
},
182182
SwitchFile {
183183
file_index: usize,
@@ -359,19 +359,19 @@ impl AnimationEngine {
359359
let datetime_str = metadata.date.format("%Y-%m-%d %H:%M:%S").to_string();
360360
self.add_terminal_command(&format!("time-travel {}", datetime_str));
361361
self.steps.push(AnimationStep::Pause {
362-
duration_ms: (self.speed_ms as f64 * CHECKOUT_PAUSE) as u64,
362+
multiplier: CHECKOUT_PAUSE,
363363
});
364364
self.steps.push(AnimationStep::TerminalOutput {
365365
text: "⚡ Initializing temporal displacement field...".to_string(),
366366
});
367367
self.steps.push(AnimationStep::Pause {
368-
duration_ms: (self.speed_ms as f64 * CHECKOUT_OUTPUT_PAUSE * 0.5) as u64,
368+
multiplier: CHECKOUT_OUTPUT_PAUSE * 0.5,
369369
});
370370
self.steps.push(AnimationStep::TerminalOutput {
371371
text: "✨ Warping through spacetime...".to_string(),
372372
});
373373
self.steps.push(AnimationStep::Pause {
374-
duration_ms: (self.speed_ms as f64 * CHECKOUT_OUTPUT_PAUSE * 0.5) as u64,
374+
multiplier: CHECKOUT_OUTPUT_PAUSE * 0.5,
375375
});
376376
self.steps.push(AnimationStep::TerminalOutput {
377377
text: format!("🕰️ Arrived at {}", datetime_str),
@@ -384,7 +384,7 @@ impl AnimationEngine {
384384
),
385385
});
386386
self.steps.push(AnimationStep::Pause {
387-
duration_ms: (self.speed_ms as f64 * CHECKOUT_OUTPUT_PAUSE) as u64,
387+
multiplier: CHECKOUT_OUTPUT_PAUSE,
388388
});
389389

390390
// Apply new metadata after time-travel animation
@@ -410,7 +410,7 @@ impl AnimationEngine {
410410
});
411411

412412
self.steps.push(AnimationStep::Pause {
413-
duration_ms: (self.speed_ms as f64 * OPEN_FILE_PAUSE) as u64,
413+
multiplier: OPEN_FILE_PAUSE,
414414
});
415415
let reason = change
416416
.exclusion_reason
@@ -420,7 +420,7 @@ impl AnimationEngine {
420420
text: format!("📦 {} (skipped - {})", change.path, reason),
421421
});
422422
self.steps.push(AnimationStep::Pause {
423-
duration_ms: (self.speed_ms as f64 * OPEN_CMD_PAUSE) as u64,
423+
multiplier: OPEN_CMD_PAUSE,
424424
});
425425
}
426426
// For deleted files, skip editor animation and only run rm + git add
@@ -435,15 +435,15 @@ impl AnimationEngine {
435435
});
436436

437437
self.steps.push(AnimationStep::Pause {
438-
duration_ms: (self.speed_ms as f64 * GIT_ADD_PAUSE) as u64,
438+
multiplier: GIT_ADD_PAUSE,
439439
});
440440
self.add_terminal_command(&format!("rm {}", change.path));
441441
self.steps.push(AnimationStep::Pause {
442-
duration_ms: (self.speed_ms as f64 * GIT_ADD_CMD_PAUSE) as u64,
442+
multiplier: GIT_ADD_CMD_PAUSE,
443443
});
444444
self.add_terminal_command(&format!("git add {}", change.path));
445445
self.steps.push(AnimationStep::Pause {
446-
duration_ms: (self.speed_ms as f64 * GIT_ADD_CMD_PAUSE) as u64,
446+
multiplier: GIT_ADD_CMD_PAUSE,
447447
});
448448
}
449449
// For renamed/moved files, skip editor animation and only run mv + git add
@@ -459,35 +459,35 @@ impl AnimationEngine {
459459
});
460460

461461
self.steps.push(AnimationStep::Pause {
462-
duration_ms: (self.speed_ms as f64 * GIT_ADD_PAUSE) as u64,
462+
multiplier: GIT_ADD_PAUSE,
463463
});
464464
if let Some(old_path) = &change.old_path {
465465
self.add_terminal_command(&format!("mv {} {}", old_path, change.path));
466466
self.steps.push(AnimationStep::Pause {
467-
duration_ms: (self.speed_ms as f64 * GIT_ADD_CMD_PAUSE) as u64,
467+
multiplier: GIT_ADD_CMD_PAUSE,
468468
});
469469
}
470470
self.add_terminal_command(&format!("git add {}", change.path));
471471
self.steps.push(AnimationStep::Pause {
472-
duration_ms: (self.speed_ms as f64 * GIT_ADD_CMD_PAUSE) as u64,
472+
multiplier: GIT_ADD_CMD_PAUSE,
473473
});
474474
}
475475
// Normal files (Added, Modified, etc.) - full editor animation
476476
(false, _) => {
477477
// Open file in editor
478478
if index == 0 {
479479
self.steps.push(AnimationStep::Pause {
480-
duration_ms: (self.speed_ms as f64 * OPEN_FILE_FIRST_PAUSE) as u64,
480+
multiplier: OPEN_FILE_FIRST_PAUSE,
481481
});
482482
} else {
483483
self.steps.push(AnimationStep::Pause {
484-
duration_ms: (self.speed_ms as f64 * OPEN_FILE_PAUSE) as u64,
484+
multiplier: OPEN_FILE_PAUSE,
485485
});
486486
}
487487
// Show "Open File..." dialog and type the file path
488488
self.steps.push(AnimationStep::OpenFileDialogStart);
489489
self.steps.push(AnimationStep::Pause {
490-
duration_ms: (self.speed_ms as f64 * 5.0) as u64,
490+
multiplier: 5.0,
491491
});
492492

493493
// Type each character of the file path
@@ -496,7 +496,7 @@ impl AnimationEngine {
496496
}
497497

498498
self.steps.push(AnimationStep::Pause {
499-
duration_ms: (self.speed_ms as f64 * OPEN_CMD_PAUSE) as u64,
499+
multiplier: OPEN_CMD_PAUSE,
500500
});
501501

502502
// Add file switch step with both old and new content
@@ -511,19 +511,19 @@ impl AnimationEngine {
511511

512512
// Add pause before starting file animation
513513
self.steps.push(AnimationStep::Pause {
514-
duration_ms: (self.speed_ms as f64 * FILE_SWITCH_PAUSE) as u64,
514+
multiplier: FILE_SWITCH_PAUSE,
515515
});
516516

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

520520
// Git add this file after editing
521521
self.steps.push(AnimationStep::Pause {
522-
duration_ms: (self.speed_ms as f64 * GIT_ADD_PAUSE) as u64,
522+
multiplier: GIT_ADD_PAUSE,
523523
});
524524
self.add_terminal_command(&format!("git add {}", change.path));
525525
self.steps.push(AnimationStep::Pause {
526-
duration_ms: (self.speed_ms as f64 * GIT_ADD_CMD_PAUSE) as u64,
526+
multiplier: GIT_ADD_CMD_PAUSE,
527527
});
528528
}
529529
}
@@ -533,7 +533,7 @@ impl AnimationEngine {
533533
let commit_message = metadata.message.lines().next().unwrap_or("Update");
534534
self.add_terminal_command(&format!("git commit -m \"{}\"", commit_message));
535535
self.steps.push(AnimationStep::Pause {
536-
duration_ms: (self.speed_ms as f64 * GIT_COMMIT_PAUSE) as u64,
536+
multiplier: GIT_COMMIT_PAUSE,
537537
});
538538
self.steps.push(AnimationStep::TerminalOutput {
539539
text: format!("💾 [main {}] {}", &metadata.hash[..7], commit_message),
@@ -546,37 +546,37 @@ impl AnimationEngine {
546546
),
547547
});
548548
self.steps.push(AnimationStep::Pause {
549-
duration_ms: (self.speed_ms as f64 * COMMIT_OUTPUT_PAUSE) as u64,
549+
multiplier: COMMIT_OUTPUT_PAUSE,
550550
});
551551

552552
// Git push
553553
self.add_terminal_command("git push origin main");
554554
self.steps.push(AnimationStep::Pause {
555-
duration_ms: (self.speed_ms as f64 * GIT_PUSH_PAUSE) as u64,
555+
multiplier: GIT_PUSH_PAUSE,
556556
});
557557
self.steps.push(AnimationStep::TerminalOutput {
558558
text: "🚀 Launching code into the cloud...".to_string(),
559559
});
560560
self.steps.push(AnimationStep::Pause {
561-
duration_ms: (self.speed_ms as f64 * PUSH_OUTPUT_PAUSE) as u64,
561+
multiplier: PUSH_OUTPUT_PAUSE,
562562
});
563563
self.steps.push(AnimationStep::TerminalOutput {
564564
text: "📦 Compressing digital dreams: 100% (5/5)".to_string(),
565565
});
566566
self.steps.push(AnimationStep::Pause {
567-
duration_ms: (self.speed_ms as f64 * PUSH_OUTPUT_PAUSE) as u64,
567+
multiplier: PUSH_OUTPUT_PAUSE,
568568
});
569569
self.steps.push(AnimationStep::TerminalOutput {
570570
text: "✍️ Signing with invisible ink: done.".to_string(),
571571
});
572572
self.steps.push(AnimationStep::Pause {
573-
duration_ms: (self.speed_ms as f64 * GIT_PUSH_PAUSE) as u64,
573+
multiplier: GIT_PUSH_PAUSE,
574574
});
575575
self.steps.push(AnimationStep::TerminalOutput {
576576
text: "📡 Beaming to origin/main via satellite...".to_string(),
577577
});
578578
self.steps.push(AnimationStep::Pause {
579-
duration_ms: (self.speed_ms as f64 * PUSH_OUTPUT_PAUSE) as u64,
579+
multiplier: PUSH_OUTPUT_PAUSE,
580580
});
581581
self.steps.push(AnimationStep::TerminalOutput {
582582
text: format!(
@@ -586,7 +586,7 @@ impl AnimationEngine {
586586
),
587587
});
588588
self.steps.push(AnimationStep::Pause {
589-
duration_ms: (self.speed_ms as f64 * PUSH_FINAL_PAUSE) as u64,
589+
multiplier: PUSH_FINAL_PAUSE,
590590
});
591591

592592
// Start with empty editor (no file opened yet)
@@ -644,7 +644,7 @@ impl AnimationEngine {
644644

645645
// Add pause between hunks
646646
self.steps.push(AnimationStep::Pause {
647-
duration_ms: (self.speed_ms as f64 * HUNK_PAUSE) as u64,
647+
multiplier: HUNK_PAUSE,
648648
});
649649
}
650650
}
@@ -702,8 +702,7 @@ impl AnimationEngine {
702702
}
703703

704704
// Generate movement steps
705-
let base_pause =
706-
(self.speed_ms as f64 * CURSOR_MOVE_PAUSE * base_speed_multiplier).max(1.0) as u64;
705+
let pause_multiplier = (CURSOR_MOVE_PAUSE * base_speed_multiplier).max(0.01);
707706

708707
for line in positions {
709708
if line != from_line {
@@ -714,7 +713,7 @@ impl AnimationEngine {
714713
.unwrap_or(0);
715714
self.steps.push(AnimationStep::MoveCursor { line, col });
716715
self.steps.push(AnimationStep::Pause {
717-
duration_ms: base_pause,
716+
multiplier: pause_multiplier,
718717
});
719718
}
720719
}
@@ -751,7 +750,7 @@ impl AnimationEngine {
751750
self.steps
752751
.push(AnimationStep::DeleteLine { line: buffer_line });
753752
self.steps.push(AnimationStep::Pause {
754-
duration_ms: (self.speed_ms as f64 * DELETE_LINE_PAUSE) as u64,
753+
multiplier: DELETE_LINE_PAUSE,
755754
});
756755
cursor_line = buffer_line;
757756
// After deletion, buffer_line stays the same
@@ -781,7 +780,7 @@ impl AnimationEngine {
781780
buffer_line += 1; // Move to next line after insertion
782781

783782
self.steps.push(AnimationStep::Pause {
784-
duration_ms: (self.speed_ms as f64 * INSERT_LINE_PAUSE) as u64,
783+
multiplier: INSERT_LINE_PAUSE,
785784
});
786785
}
787786
LineChangeType::Context => {
@@ -798,7 +797,7 @@ impl AnimationEngine {
798797
col,
799798
});
800799
self.steps.push(AnimationStep::Pause {
801-
duration_ms: (self.speed_ms as f64 * CURSOR_MOVE_PAUSE) as u64,
800+
multiplier: CURSOR_MOVE_PAUSE,
802801
});
803802
}
804803
cursor_line = buffer_line;
@@ -950,7 +949,8 @@ impl AnimationEngine {
950949
self.buffer.cursor_line = line;
951950
self.buffer.cursor_col = col;
952951
}
953-
AnimationStep::Pause { duration_ms } => {
952+
AnimationStep::Pause { multiplier } => {
953+
let duration_ms = (self.speed_ms as f64 * multiplier) as u64;
954954
self.pause_until = Some(Instant::now() + Duration::from_millis(duration_ms));
955955
}
956956
AnimationStep::OpenFileDialogStart => {

0 commit comments

Comments
 (0)