1- import { HTMLAttributes } from "react"
1+ import { HTMLAttributes , useState , useEffect } from "react"
22import { useAppTranslation } from "@/i18n/TranslationContext"
3- import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react"
3+ import { VSCodeCheckbox , VSCodeTextField } from "@vscode/webview-ui-toolkit/react"
44import { Glasses } from "lucide-react"
55import { telemetryClient } from "@/utils/TelemetryClient"
66
@@ -11,11 +11,18 @@ import { ExtensionStateContextType } from "@/context/ExtensionStateContext"
1111
1212interface UISettingsProps extends HTMLAttributes < HTMLDivElement > {
1313 reasoningBlockCollapsed : boolean
14+ accentColor ?: string
1415 setCachedStateField : SetCachedStateField < keyof ExtensionStateContextType >
1516}
1617
17- export const UISettings = ( { reasoningBlockCollapsed, setCachedStateField, ...props } : UISettingsProps ) => {
18+ export const UISettings = ( { reasoningBlockCollapsed, accentColor , setCachedStateField, ...props } : UISettingsProps ) => {
1819 const { t } = useAppTranslation ( )
20+ const [ colorValue , setColorValue ] = useState ( accentColor || "" )
21+
22+ // Sync local state with prop changes
23+ useEffect ( ( ) => {
24+ setColorValue ( accentColor || "" )
25+ } , [ accentColor ] )
1926
2027 const handleReasoningBlockCollapsedChange = ( value : boolean ) => {
2128 setCachedStateField ( "reasoningBlockCollapsed" , value )
@@ -26,6 +33,20 @@ export const UISettings = ({ reasoningBlockCollapsed, setCachedStateField, ...pr
2633 } )
2734 }
2835
36+ const handleAccentColorChange = ( value : string ) => {
37+ setColorValue ( value )
38+ // Only update if it's a valid color or empty
39+ const trimmedValue = value . trim ( )
40+ if ( trimmedValue === "" || / ^ # [ 0 - 9 A - F a - f ] { 6 } $ / . test ( trimmedValue ) ) {
41+ setCachedStateField ( "accentColor" , trimmedValue || undefined )
42+
43+ // Track telemetry event
44+ telemetryClient . capture ( "ui_settings_accent_color_changed" , {
45+ hasColor : trimmedValue !== "" ,
46+ } )
47+ }
48+ }
49+
2950 return (
3051 < div { ...props } >
3152 < SectionHeader >
@@ -49,6 +70,33 @@ export const UISettings = ({ reasoningBlockCollapsed, setCachedStateField, ...pr
4970 { t ( "settings:ui.collapseThinking.description" ) }
5071 </ div >
5172 </ div >
73+
74+ { /* Accent Color Setting */ }
75+ < div className = "flex flex-col gap-2" >
76+ < label className = "font-medium" htmlFor = "accent-color-input" >
77+ Accent Color
78+ </ label >
79+ < div className = "flex items-center gap-2" >
80+ < VSCodeTextField
81+ id = "accent-color-input"
82+ value = { colorValue }
83+ placeholder = "#007ACC"
84+ onInput = { ( e : any ) => handleAccentColorChange ( e . target . value ) }
85+ data-testid = "accent-color-input"
86+ style = { { flex : 1 } }
87+ />
88+ < input
89+ type = "color"
90+ value = { colorValue && / ^ # [ 0 - 9 A - F a - f ] { 6 } $ / . test ( colorValue ) ? colorValue : "#007ACC" }
91+ onChange = { ( e ) => handleAccentColorChange ( e . target . value ) }
92+ className = "h-8 w-16 cursor-pointer rounded border border-vscode-input-border"
93+ data-testid = "accent-color-picker"
94+ />
95+ </ div >
96+ < div className = "text-vscode-descriptionForeground text-sm" >
97+ Customize the accent color used throughout the extension. Leave empty to use the default theme color. Enter a hex color code (e.g., #007ACC) or use the color picker.
98+ </ div >
99+ </ div >
52100 </ div >
53101 </ Section >
54102 </ div >
0 commit comments