11import React , { useState , useContext } from 'react' ;
22import { Box , Text , useInput } from 'ink' ;
3- import { Toolset } from '../utils/types.js' ;
3+ import { Toolset , DEFAULT_SETTINGS } from '../utils/types.js' ;
44import { SettingsContext } from '../App.js' ;
55import { ToolsetEditView } from './ToolsetEditView.js' ;
66import Header from './Header.js' ;
7+ import { getCurrentClaudeCodeTheme } from '../utils/misc.js' ;
78
89interface ToolsetsViewProps {
910 onBack : ( ) => void ;
1011}
1112
1213export function ToolsetsView ( { onBack } : ToolsetsViewProps ) {
1314 const {
14- settings : { toolsets, defaultToolset } ,
15+ settings : { toolsets, defaultToolset, planModeToolset , themes } ,
1516 updateSettings,
1617 } = useContext ( SettingsContext ) ;
1718
19+ // Get current theme colors
20+ const currentThemeId = getCurrentClaudeCodeTheme ( ) ;
21+ const currentTheme = themes . find ( t => t . id === currentThemeId ) || themes [ 0 ] ;
22+
23+ const defaultTheme = DEFAULT_SETTINGS . themes [ 0 ] ; // Dark mode theme
24+ const planModeColor =
25+ currentTheme ?. colors . planMode || defaultTheme . colors . planMode ;
26+ const autoAcceptColor =
27+ currentTheme ?. colors . autoAccept || defaultTheme . colors . autoAccept ;
28+
1829 const [ selectedIndex , setSelectedIndex ] = useState ( 0 ) ;
1930 const [ editingToolsetIndex , setEditingToolsetIndex ] = useState < number | null > (
2031 null
@@ -43,6 +54,10 @@ export function ToolsetsView({ onBack }: ToolsetsViewProps) {
4354 if ( settings . defaultToolset === toolsetToDelete . name ) {
4455 settings . defaultToolset = null ;
4556 }
57+ // Clear plan mode if we're deleting the plan mode toolset
58+ if ( settings . planModeToolset === toolsetToDelete . name ) {
59+ settings . planModeToolset = null ;
60+ }
4661 } ) ;
4762
4863 if ( selectedIndex >= toolsets . length - 1 ) {
@@ -57,6 +72,13 @@ export function ToolsetsView({ onBack }: ToolsetsViewProps) {
5772 } ) ;
5873 } ;
5974
75+ const handleSetPlanModeToolset = ( index : number ) => {
76+ const toolset = toolsets [ index ] ;
77+ updateSettings ( settings => {
78+ settings . planModeToolset = toolset . name ;
79+ } ) ;
80+ } ;
81+
6082 useInput (
6183 ( input , key ) => {
6284 if ( key . escape ) {
@@ -70,10 +92,12 @@ export function ToolsetsView({ onBack }: ToolsetsViewProps) {
7092 setInputActive ( false ) ;
7193 } else if ( input === 'n' ) {
7294 handleCreateToolset ( ) ;
73- } else if ( input === 'd ' && toolsets . length > 0 ) {
95+ } else if ( input === 'x ' && toolsets . length > 0 ) {
7496 handleDeleteToolset ( selectedIndex ) ;
75- } else if ( input === 's ' && toolsets . length > 0 ) {
97+ } else if ( input === 'd ' && toolsets . length > 0 ) {
7698 handleSetDefaultToolset ( selectedIndex ) ;
99+ } else if ( input === 'p' && toolsets . length > 0 ) {
100+ handleSetPlanModeToolset ( selectedIndex ) ;
77101 }
78102 } ,
79103 { isActive : inputActive }
@@ -108,9 +132,12 @@ export function ToolsetsView({ onBack }: ToolsetsViewProps) {
108132 < Box marginBottom = { 1 } flexDirection = "column" >
109133 < Text dimColor > n to create a new toolset</ Text >
110134 { toolsets . length > 0 && (
111- < Text dimColor > s to set as default toolset</ Text >
135+ < Text dimColor > d to set as default toolset</ Text >
136+ ) }
137+ { toolsets . length > 0 && (
138+ < Text dimColor > p to set as plan mode toolset</ Text >
112139 ) }
113- { toolsets . length > 0 && < Text dimColor > d to delete a toolset</ Text > }
140+ { toolsets . length > 0 && < Text dimColor > x to delete a toolset</ Text > }
114141 { toolsets . length > 0 && < Text dimColor > enter to edit toolset</ Text > }
115142 < Text dimColor > esc to go back</ Text >
116143 </ Box >
@@ -121,17 +148,31 @@ export function ToolsetsView({ onBack }: ToolsetsViewProps) {
121148 < Box flexDirection = "column" >
122149 { toolsets . map ( ( toolset , index ) => {
123150 const isDefault = toolset . name === defaultToolset ;
151+ const isPlanMode = toolset . name === planModeToolset ;
124152 const isSelected = selectedIndex === index ;
153+
154+ // Determine the color for the entire line
155+ let lineColor : string | undefined = undefined ;
156+ if ( isSelected ) {
157+ lineColor = 'yellow' ;
158+ }
159+
125160 return (
126- < Text
127- key = { index }
128- color = { isSelected ? 'yellow' : undefined }
129- bold = { isDefault }
130- >
131- { isSelected ? '❯ ' : ' ' }
132- { toolset . name }
133- { isDefault && ' [DEFAULT]' } ({ getToolsetDescription ( toolset ) } )
134- </ Text >
161+ < Box key = { index } flexDirection = "row" >
162+ < Text color = { lineColor } >
163+ { isSelected ? '❯ ' : ' ' }
164+ { toolset . name } { ' ' }
165+ </ Text >
166+
167+ < Text color = { lineColor } >
168+ ({ getToolsetDescription ( toolset ) } )
169+ </ Text >
170+
171+ { isDefault && (
172+ < Text color = { autoAcceptColor } > ⏵⏵ accept edits</ Text >
173+ ) }
174+ { isPlanMode && < Text color = { planModeColor } > ⏸ plan mode</ Text > }
175+ </ Box >
135176 ) ;
136177 } ) }
137178 </ Box >
0 commit comments