Skip to content

Bug: filter_generations uses stale data when content changes but count doesn't #31

@CarsonBurke

Description

@CarsonBurke

Summary

In tui/src/state/generation_browser.rs (lines 69-72), filter_generations() only updates filtered_generations when the search input is empty if the length differs from generations. If the content changes but the count stays the same (e.g., one generation directory removed and another added between load_generations() calls), filtered_generations retains stale data.

Current behavior

if self.search_input.is_empty() {
    if self.filtered_generations.len() != self.generations.len() {
        self.filtered_generations = self.generations.clone();
    }
}

The inner if only checks length, not content. When count is unchanged but entries differ, the update is skipped.

Expected behavior

When search is empty, filtered_generations should always reflect the current generations list.

Suggested fix

Remove the length guard when search is empty:

if self.search_input.is_empty() {
    self.filtered_generations = self.generations.clone();
}

Reproduction scenario

  1. Start TUI with N generation directories present.
  2. While TUI is running, delete one generation directory and create a new one (same total count).
  3. Trigger load_generations() (e.g., refresh). generations is rebuilt correctly, but filtered_generations still shows the old list because the length hasn't changed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority: lowLow severity bug

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions