The open source coding agent.
TypeScript
feat: 0-255 color support in custom themes
adamdottvd127a1c4ebe3
diff --git a/internal/tui/theme/manager.go b/internal/tui/theme/manager.goindex 59d8c864429..5a5c791fb4b 100644--- a/internal/tui/theme/manager.go+++ b/internal/tui/theme/manager.go@@ -202,6 +202,54 @@ func LoadCustomTheme(customTheme map[string]any) (Theme, error) {theme.DiffAddedLineNumberBgColor = adaptiveColorcase "diffremovedlinenumberbg":theme.DiffRemovedLineNumberBgColor = adaptiveColor+ case "syntaxcomment":+ theme.SyntaxCommentColor = adaptiveColor+ case "syntaxkeyword":+ theme.SyntaxKeywordColor = adaptiveColor+ case "syntaxfunction":+ theme.SyntaxFunctionColor = adaptiveColor+ case "syntaxvariable":+ theme.SyntaxVariableColor = adaptiveColor+ case "syntaxstring":+ theme.SyntaxStringColor = adaptiveColor+ case "syntaxnumber":+ theme.SyntaxNumberColor = adaptiveColor+ case "syntaxtype":+ theme.SyntaxTypeColor = adaptiveColor+ case "syntaxoperator":+ theme.SyntaxOperatorColor = adaptiveColor+ case "syntaxpunctuation":+ theme.SyntaxPunctuationColor = adaptiveColor+ case "markdowntext":+ theme.MarkdownTextColor = adaptiveColor+ case "markdownheading":+ theme.MarkdownHeadingColor = adaptiveColor+ case "markdownlink":+ theme.MarkdownLinkColor = adaptiveColor+ case "markdownlinktext":+ theme.MarkdownLinkTextColor = adaptiveColor+ case "markdowncode":+ theme.MarkdownCodeColor = adaptiveColor+ case "markdownblockquote":+ theme.MarkdownBlockQuoteColor = adaptiveColor+ case "markdownemph":+ theme.MarkdownEmphColor = adaptiveColor+ case "markdownstrong":+ theme.MarkdownStrongColor = adaptiveColor+ case "markdownhorizontalrule":+ theme.MarkdownHorizontalRuleColor = adaptiveColor+ case "markdownlistitem":+ theme.MarkdownListItemColor = adaptiveColor+ case "markdownlistitemenum":+ theme.MarkdownListEnumerationColor = adaptiveColor+ case "markdownimage":+ theme.MarkdownImageColor = adaptiveColor+ case "markdownimagetext":+ theme.MarkdownImageTextColor = adaptiveColor+ case "markdowncodeblock":+ theme.MarkdownCodeBlockColor = adaptiveColor+ case "markdownlistenumeration":+ theme.MarkdownListEnumerationColor = adaptiveColordefault:slog.Warn("Unknown color key in custom theme", "key", key)}diff --git a/internal/tui/theme/theme.go b/internal/tui/theme/theme.goindex fffd316bad6..c97b9547872 100644--- a/internal/tui/theme/theme.go+++ b/internal/tui/theme/theme.go@@ -235,7 +235,19 @@ func ParseAdaptiveColor(value any) (lipgloss.AdaptiveColor, error) {}, nil}- // Case 2: Map with dark and light keys+ // Case 2: Int value between 0 and 255+ if numericVal, ok := value.(float64); ok {+ intVal := int(numericVal)+ if intVal < 0 || intVal > 255 {+ return lipgloss.AdaptiveColor{}, fmt.Errorf("invalid int color value (must be between 0 and 255): %d", intVal)+ }+ return lipgloss.AdaptiveColor{+ Dark: fmt.Sprintf("%d", intVal),+ Light: fmt.Sprintf("%d", intVal),+ }, nil+ }++ // Case 3: Map with dark and light keysif colorMap, ok := value.(map[string]any); ok {darkVal, darkOk := colorMap["dark"]lightVal, lightOk := colorMap["light"]@@ -248,7 +260,20 @@ func ParseAdaptiveColor(value any) (lipgloss.AdaptiveColor, error) {lightHex, lightIsString := lightVal.(string)if !darkIsString || !lightIsString {- return lipgloss.AdaptiveColor{}, fmt.Errorf("color values must be strings")+ darkVal, darkIsNumber := darkVal.(float64)+ lightVal, lightIsNumber := lightVal.(float64)++ if !darkIsNumber || !lightIsNumber {+ return lipgloss.AdaptiveColor{}, fmt.Errorf("color map values must be strings or ints")+ }++ darkInt := int(darkVal)+ lightInt := int(lightVal)++ return lipgloss.AdaptiveColor{+ Dark: fmt.Sprintf("%d", darkInt),+ Light: fmt.Sprintf("%d", lightInt),+ }, nil}if !hexColorRegex.MatchString(darkHex) || !hexColorRegex.MatchString(lightHex) {