Commit 1749639
fix(grzctl): handle empty submission states in TUI search results (#468)
Fixes #385
TUI crashes with `ValueError: max() iterable argument is empty` when
displaying submissions that have no state updates yet.
**Changes:**
- Replace direct `max(submission.states, ...)` with existing
`submission.get_latest_state()` method which returns `None` for empty
states
- Display "missing" (styled as italic yellow) for "Latest State" and
"State Timestamp" columns when no states exist, matching the existing
pattern used elsewhere in the TUI
```python
# Before: crashes on empty states
latest_state = max(submission.states, key=lambda st: st.timestamp)
# After: graceful handling with styled "missing" text
latest_state = submission.get_latest_state()
self.add_row(
submission.id,
submission.pseudonym,
latest_state.state if latest_state else rich.text.Text("missing", style="italic yellow"),
latest_state.timestamp if latest_state else rich.text.Text("missing", style="italic yellow"),
)
```
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tedil <7976289+tedil@users.noreply.github.com>1 parent 0bd31aa commit 1749639
1 file changed
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
248 | | - | |
249 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
250 | 255 | | |
251 | 256 | | |
252 | 257 | | |
| |||
0 commit comments