33 * Copyright 2025 Autohand AI LLC
44 * SPDX-License-Identifier: Apache-2.0
55 */
6- import chalk from 'chalk' ;
76import readline from 'node:readline' ;
87import { t } from '../i18n/index.js' ;
98import type { SlashCommandContext } from '../core/slashCommandTypes.js' ;
109import type { AutohandConfig } from '../types.js' ;
1110import { cleanupModalRender , prepareModalRender } from '../ui/ink/components/Modal.js' ;
11+ import { createCommandTheme } from './commandTheme.js' ;
1212import packageJson from '../../package.json' with { type : 'json' } ;
1313
1414export const metadata = {
@@ -104,12 +104,13 @@ function renderStatusUI(data: StatusData): Promise<void> {
104104 }
105105
106106 const render = ( ) => {
107+ const theme = createCommandTheme ( ) ;
107108 // Clear screen and move cursor to top
108109 process . stdout . write ( '\x1B[2J\x1B[H' ) ;
109110
110111 renderTabHeader ( tabs , currentTab ) ;
111112 renderTabContent ( tabs [ currentTab ] , data ) ;
112- console . log ( chalk . gray ( '\nEsc to exit' ) ) ;
113+ console . log ( theme . muted ( '\nEsc to exit' ) ) ;
113114 } ;
114115
115116 let buffer = '' ;
@@ -205,13 +206,14 @@ function renderStatusUI(data: StatusData): Promise<void> {
205206}
206207
207208function renderTabHeader ( tabs : TabName [ ] , currentIndex : number ) : void {
209+ const theme = createCommandTheme ( ) ;
208210 const header = tabs . map ( ( tab , i ) => {
209211 return i === currentIndex
210- ? chalk . bgWhite . black ( ` ${ tab } ` )
211- : chalk . gray ( ` ${ tab } ` ) ;
212+ ? theme . selectedTab ( tab )
213+ : theme . tab ( tab ) ;
212214 } ) . join ( ' ' ) ;
213215
214- console . log ( `Settings: ${ header } ${ chalk . gray ( '(tab to cycle)' ) } \n` ) ;
216+ console . log ( `Settings: ${ header } ${ theme . muted ( '(tab to cycle)' ) } \n` ) ;
215217}
216218
217219function renderTabContent ( tab : TabName , data : StatusData ) : void {
@@ -229,28 +231,30 @@ function renderTabContent(tab: TabName, data: StatusData): void {
229231}
230232
231233function renderStatusTab ( data : StatusData ) : void {
232- console . log ( chalk . bold ( `${ t ( 'commands.status.version' ) } :` ) , data . version ) ;
233- console . log ( chalk . bold ( `${ t ( 'commands.status.sessionId' ) } :` ) , data . sessionId ?? chalk . gray ( 'none' ) ) ;
234- console . log ( chalk . bold ( `${ t ( 'commands.status.cwd' ) } :` ) , data . cwd ) ;
235- console . log ( chalk . bold ( `${ t ( 'commands.status.provider' ) } :` ) , data . provider ) ;
236- console . log ( chalk . bold ( `${ t ( 'commands.status.model' ) } :` ) , data . model ) ;
234+ const theme = createCommandTheme ( ) ;
235+ console . log ( theme . bold ( `${ t ( 'commands.status.version' ) } :` ) , data . version ) ;
236+ console . log ( theme . bold ( `${ t ( 'commands.status.sessionId' ) } :` ) , data . sessionId ?? theme . muted ( 'none' ) ) ;
237+ console . log ( theme . bold ( `${ t ( 'commands.status.cwd' ) } :` ) , data . cwd ) ;
238+ console . log ( theme . bold ( `${ t ( 'commands.status.provider' ) } :` ) , data . provider ) ;
239+ console . log ( theme . bold ( `${ t ( 'commands.status.model' ) } :` ) , data . model ) ;
237240 console . log (
238- chalk . bold ( 'Context Compaction:' ) ,
239- data . contextCompactionEnabled ? chalk . green ( 'ON' ) : chalk . yellow ( 'OFF' )
241+ theme . bold ( 'Context Compaction:' ) ,
242+ data . contextCompactionEnabled ? theme . success ( 'ON' ) : theme . warning ( 'OFF' )
240243 ) ;
241244 console . log ( ) ;
242245 console . log (
243- chalk . bold ( `${ t ( 'commands.status.apiStatus' ) } :` ) ,
244- data . apiConnected ? chalk . green ( t ( 'commands.status.connected' ) ) : chalk . red ( t ( 'commands.status.disconnected' ) )
246+ theme . bold ( `${ t ( 'commands.status.apiStatus' ) } :` ) ,
247+ data . apiConnected ? theme . success ( t ( 'commands.status.connected' ) ) : theme . error ( t ( 'commands.status.disconnected' ) )
245248 ) ;
246- console . log ( chalk . bold ( `${ t ( 'commands.status.sessions' ) } :` ) , t ( 'commands.status.total' , { count : String ( data . sessionsCount ) } ) ) ;
247- console . log ( chalk . bold ( 'Memory:' ) , 'user (~/.autohand/memory/), project (.autohand/memory/)' ) ;
249+ console . log ( theme . bold ( `${ t ( 'commands.status.sessions' ) } :` ) , t ( 'commands.status.total' , { count : String ( data . sessionsCount ) } ) ) ;
250+ console . log ( theme . bold ( 'Memory:' ) , 'user (~/.autohand/memory/), project (.autohand/memory/)' ) ;
248251}
249252
250253function renderConfigTab ( data : StatusData ) : void {
254+ const theme = createCommandTheme ( ) ;
251255 const config = data . config ;
252256
253- console . log ( chalk . bold ( 'Autohand preferences\n' ) ) ;
257+ console . log ( theme . bold ( 'Autohand preferences\n' ) ) ;
254258
255259 const settings : Array < [ string , string ] > = [
256260 [ 'Theme' , config ?. ui ?. theme ?? 'dark' ] ,
@@ -264,26 +268,28 @@ function renderConfigTab(data: StatusData): void {
264268 ] ;
265269
266270 for ( const [ name , value ] of settings ) {
267- console . log ( ` ${ chalk . cyan ( name . padEnd ( 30 ) ) } ${ value } ` ) ;
271+ console . log ( ` ${ theme . accent ( name . padEnd ( 30 ) ) } ${ value } ` ) ;
268272 }
269273}
270274
271275function renderUsageTab ( data : StatusData ) : void {
276+ const theme = createCommandTheme ( ) ;
272277 const contextUsed = 100 - data . contextPercentLeft ;
273278
274- console . log ( chalk . bold ( 'Current session\n' ) ) ;
279+ console . log ( theme . bold ( 'Current session\n' ) ) ;
275280
276281 renderProgressBar ( 'Context used' , contextUsed , 100 ) ;
277282 console . log ( ) ;
278283
279- console . log ( chalk . bold ( 'Tokens used:' ) , formatTokens ( data . totalTokensUsed ) ) ;
284+ console . log ( theme . bold ( 'Tokens used:' ) , formatTokens ( data . totalTokensUsed ) ) ;
280285}
281286
282287function renderProgressBar ( label : string , value : number , max : number ) : void {
288+ const theme = createCommandTheme ( ) ;
283289 const width = 30 ;
284290 const filled = Math . round ( ( value / max ) * width ) ;
285291 const empty = width - filled ;
286- const bar = chalk . cyan ( '\u2588' . repeat ( filled ) ) + chalk . gray ( '\u2591' . repeat ( empty ) ) ;
292+ const bar = theme . progressFilled ( '\u2588' . repeat ( filled ) ) + theme . progressEmpty ( '\u2591' . repeat ( empty ) ) ;
287293 const percent = Math . round ( ( value / max ) * 100 ) ;
288294
289295 console . log ( label ) ;
0 commit comments