Summary
internal/tui/components/sessionlist.go contains three dot-rendering functions (lines 835–932) that follow the same structural pattern: nil-check the map, look up the session ID, switch on status to pick a style and icon, then handle the selected-row special case.
Anti-pattern
Copy-paste — three functions with identical control flow, differing only in which map they read and which style/icon constants they use.
| Function |
Lines |
Map field |
Status type |
| attentionDot |
835–882 |
attentionMap |
AttentionStatus (8 cases) |
| planDot |
887–898 |
planMap |
bool |
| workStatusDot |
903–932 |
workStatusMap |
WorkStatus (3 cases) |
Suggested fix
Introduce a small table-driven helper that accepts the icon and style for each status value:
`go
type dotEntry struct {
style lipgloss.Style
icon string
}
func renderDot(entry dotEntry, selected bool) string {
if selected {
return entry.icon + " "
}
return entry.style.Render(entry.icon + " ")
}
`
Each dot function then becomes a map lookup + a call to renderDot, eliminating the repeated nil-check → lookup → switch → selected-branch pattern.
Audit grade: C
Summary
internal/tui/components/sessionlist.go contains three dot-rendering functions (lines 835–932) that follow the same structural pattern: nil-check the map, look up the session ID, switch on status to pick a style and icon, then handle the selected-row special case.
Anti-pattern
Copy-paste — three functions with identical control flow, differing only in which map they read and which style/icon constants they use.
Suggested fix
Introduce a small table-driven helper that accepts the icon and style for each status value:
`go
type dotEntry struct {
style lipgloss.Style
icon string
}
func renderDot(entry dotEntry, selected bool) string {
if selected {
return entry.icon + " "
}
return entry.style.Render(entry.icon + " ")
}
`
Each dot function then becomes a map lookup + a call to renderDot, eliminating the repeated nil-check → lookup → switch → selected-branch pattern.
Audit grade: C