1- import { Box , Text } from 'ink' ;
1+ import { Box , Text , useInput } from 'ink' ;
22import { useAtom } from 'jotai' ;
3- import React from 'react' ;
3+ import { EventEmitter } from 'node:events' ;
4+ import React , { useState } from 'react' ;
45
6+ import { ProcessName } from '../../../events/context.js' ;
7+ import { RenderEvent } from '../../reporters/reporter.js' ;
58import { store } from '../../store/index.js' ;
69import Spinner from './spinner.js' ;
710
@@ -21,8 +24,21 @@ export interface ProgressState {
2124 } > | null ;
2225}
2326
24- export function ProgressDisplay ( ) {
27+ export function ProgressDisplay ( props : { emitter : EventEmitter } ) {
28+ const { emitter } = props ;
2529 const [ progress ] = useAtom ( store . progressState ) ;
30+ const [ isVerbose , setIsVerbose ] = useState ( false ) ;
31+
32+ const isApplyOrDestroy = progress ?. name === ProcessName . APPLY || progress ?. name === ProcessName . DESTROY ;
33+
34+ useInput ( ( input ) => {
35+ if ( ! isApplyOrDestroy ) return ;
36+ if ( input === 'v' ) {
37+ setIsVerbose ( ( prev ) => ! prev ) ;
38+ emitter . emit ( RenderEvent . TOGGLE_VERBOSITY ) ;
39+ }
40+ } ) ;
41+
2642 if ( ! progress ) {
2743 return ;
2844 }
@@ -38,6 +54,9 @@ export function ProgressDisplay() {
3854 < Box flexDirection = "column" marginLeft = { 2 } >
3955 < SubProgressDisplay subProgresses = { subProgresses } />
4056 </ Box >
57+ { isApplyOrDestroy && (
58+ < Text dimColor > { isVerbose ? '[v] Hide verbose logs' : '[v] Show verbose logs' } </ Text >
59+ ) }
4160 </ Box >
4261}
4362
0 commit comments