Skip to content

Commit f89347f

Browse files
unhappychoiceclaude
andcommitted
refactor: show waiting screen instead of startup HEAD in watch mode
Replaying the startup HEAD into its final state was only a workaround for the blank screen, whose actual cause was the missing redraw. Show the empty editor with a waiting message instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 8a7158b commit f89347f

3 files changed

Lines changed: 5 additions & 33 deletions

File tree

‎docs/usage.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ gitlogue --watch --speed 10 # Faster typing for live demos
230230
- HEAD is polled every second; any commits reachable from the new HEAD but not from the previous one are queued (covers `git commit`, `git pull`, `git rebase`, etc.)
231231
- Merge commits are skipped (their changes are replayed via the merged commits)
232232
- Switching branches (`git checkout` / `git switch`) does not replay the commits of the new branch; only commits made afterwards are replayed
233-
- On startup, the current HEAD commit is shown in its final state (without animation) while waiting for new commits
233+
- While no new commits are queued, a waiting screen is shown
234234
- Queued commits are replayed back-to-back in chronological order
235235
- Typing speeds up automatically while commits are queued, linearly from 1x (empty queue) to 10x (100 queued commits)
236236
- At most 100 commits are queued; when more arrive, the oldest queued commits are dropped

‎src/ui.rs‎

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -399,22 +399,6 @@ impl<'a> UI<'a> {
399399
}
400400
}
401401

402-
/// Shows the startup HEAD commit in its final state so the idle screen is not empty.
403-
fn show_initial_head(&mut self) {
404-
let Some(metadata) = self
405-
.watcher
406-
.as_mut()
407-
.and_then(CommitWatcher::take_initial_head)
408-
.zip(self.repo)
409-
.and_then(|(hash, repo)| repo.get_commit(&hash).ok())
410-
else {
411-
return;
412-
};
413-
self.engine.load_commit(&metadata);
414-
while self.engine.manual_step(StepMode::Change) {}
415-
self.force_redraw = true;
416-
}
417-
418402
fn poll_watcher(&mut self, now: Instant) {
419403
let (Some(watcher), Some(repo)) = (self.watcher.as_mut(), self.repo) else {
420404
return;
@@ -520,7 +504,6 @@ impl<'a> UI<'a> {
520504
}
521505

522506
fn advance_state_after_tick(&mut self, now: Instant) -> bool {
523-
self.show_initial_head();
524507
self.poll_watcher(now);
525508

526509
match self.state {
@@ -1777,9 +1760,9 @@ mod tests {
17771760
}
17781761

17791762
#[test]
1780-
fn watch_mode_shows_head_in_final_state_without_playing_it() {
1763+
fn watch_mode_waits_without_playing_existing_commits() {
17811764
let test_repo = TestRepo::new();
1782-
let head = test_repo.commit_file("src/lib.rs", "fn old() {}\n", "existing", 1_700_000_000);
1765+
test_repo.commit_file("src/lib.rs", "fn old() {}\n", "existing", 1_700_000_000);
17831766
let repo = GitRepository::open(&test_repo.path).unwrap();
17841767
let now = Instant::now();
17851768
let mut ui = watch_ui(&repo, now);
@@ -1788,9 +1771,7 @@ mod tests {
17881771

17891772
assert_eq!(ui.state, UIState::Watching);
17901773
assert!(ui.history.is_empty());
1791-
assert!(ui.engine.is_finished());
1792-
assert_eq!(ui.engine.current_metadata().unwrap().hash, head);
1793-
assert!(ui.force_redraw);
1774+
assert!(ui.engine.current_metadata().is_none());
17941775
}
17951776

17961777
#[test]

‎src/watch.rs‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const MAX_SPEED_MULTIPLIER: f64 = 10.0;
1111

1212
/// Watches the repository HEAD and queues newly arrived commits for playback.
1313
pub struct CommitWatcher {
14-
initial_head: Option<String>,
1514
last_head: Option<String>,
1615
last_branch: Option<String>,
1716
pending: VecDeque<String>,
@@ -20,10 +19,8 @@ pub struct CommitWatcher {
2019

2120
impl CommitWatcher {
2221
pub fn new(repo: &GitRepository, now: Instant) -> Self {
23-
let head = repo.head_commit_id();
2422
Self {
25-
initial_head: head.clone(),
26-
last_head: head,
23+
last_head: repo.head_commit_id(),
2724
last_branch: repo.head_branch_name(),
2825
pending: VecDeque::new(),
2926
next_poll: now + POLL_INTERVAL,
@@ -39,11 +36,6 @@ impl CommitWatcher {
3936
self.check_head(repo);
4037
}
4138

42-
/// Takes the HEAD commit hash observed at startup (only once).
43-
pub fn take_initial_head(&mut self) -> Option<String> {
44-
self.initial_head.take()
45-
}
46-
4739
/// Takes the oldest pending commit hash.
4840
pub fn next_commit(&mut self) -> Option<String> {
4941
self.pending.pop_front()
@@ -102,7 +94,6 @@ mod tests {
10294

10395
fn watcher_with_pending(pending: &[&str]) -> CommitWatcher {
10496
CommitWatcher {
105-
initial_head: None,
10697
last_head: None,
10798
last_branch: None,
10899
pending: pending.iter().map(|hash| hash.to_string()).collect(),

0 commit comments

Comments
 (0)