fix(tui): bounds-check scope picker selected index

Replace direct indexing (self.projects[self.selected_index - 1]) with
.get() to prevent panic if selected_index is somehow out of bounds.
Falls back to "All Projects" scope when the index is invalid instead
of panicking.
This commit is contained in:
teernisse
2026-02-18 23:59:04 -05:00
parent 45a989637c
commit bbfcfa2082

View File

@@ -76,12 +76,17 @@ impl ScopePickerState {
project_id: None, project_id: None,
project_name: None, project_name: None,
} }
} else { } else if let Some(project) = self.projects.get(self.selected_index - 1) {
let project = &self.projects[self.selected_index - 1];
ScopeContext { ScopeContext {
project_id: Some(project.id), project_id: Some(project.id),
project_name: Some(project.path.clone()), project_name: Some(project.path.clone()),
} }
} else {
// Out-of-bounds — fall back to "All Projects".
ScopeContext {
project_id: None,
project_name: None,
}
} }
} }