Show a colour-coded team picker instead of cycling with T
T used to silently cycle Model.activeTeamID through the caller's teams with no visible list of choices. It now opens a full picker (modelled on the existing user picker) listing every team plus "All teams", each with a stable identity colour from a new six-colour theme palette. The same colour now also shows as a bullet next to "team: <name>" in the header, so the active team stays visible without opening the picker. Adds an Identity palette to the theme package (six hues, skipping the ones that already mean firing/critical), Styles.TeamColor to pick one by team id, and identity_1..6 as theme-file tokens alongside the existing twelve so a fully custom theme can still set every token.
This commit is contained in:
@@ -66,6 +66,36 @@ func TestStyles_EachBuiltinIsFullyPopulated(t *testing.T) {
|
||||
t.Errorf("%s: %s has no foreground", th.Name, what)
|
||||
}
|
||||
}
|
||||
for i := range th.Identity {
|
||||
if s.TeamColor(int64(i)).GetForeground() == (lipgloss.NoColor{}) {
|
||||
t.Errorf("%s: identity %d has no foreground", th.Name, i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestStyles_TeamColorIsStableAndDistinct checks the property the header badge
|
||||
// and the team picker both rely on: the same id always reads the same colour,
|
||||
// and ids that differ (up to the size of the palette) read as different
|
||||
// colours rather than all collapsing to one.
|
||||
func TestStyles_TeamColorIsStableAndDistinct(t *testing.T) {
|
||||
s := newStyles(theme.GruvboxDark)
|
||||
|
||||
seen := make(map[lipgloss.Color]bool)
|
||||
for id := int64(0); id < 6; id++ {
|
||||
seen[s.TeamColor(id).GetForeground().(lipgloss.Color)] = true
|
||||
}
|
||||
if len(seen) != 6 {
|
||||
t.Errorf("expected 6 distinct colours across 6 ids, got %d", len(seen))
|
||||
}
|
||||
|
||||
// ids repeat past the palette size, and a negative id (never sent by the
|
||||
// server, but cheap to guard) must not panic.
|
||||
if s.TeamColor(6).GetForeground() != s.TeamColor(0).GetForeground() {
|
||||
t.Error("the palette should wrap rather than index out of range")
|
||||
}
|
||||
if got := s.TeamColor(-1).GetForeground(); got == (lipgloss.NoColor{}) {
|
||||
t.Error("a negative id should still resolve to a colour, not panic or fall back to none")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user