11import type { ExecutionMode } from "@features/sessions/stores/sessionStore" ;
2- import { Pause , Pencil , ShieldCheck } from "@phosphor-icons/react" ;
2+ import { useCwd } from "@features/sidebar/hooks/useCwd" ;
3+ import { Circle , Pause , Pencil , ShieldCheck } from "@phosphor-icons/react" ;
34import { Flex , Text } from "@radix-ui/themes" ;
5+ import { trpcVanilla } from "@renderer/trpc" ;
6+ import { useQuery } from "@tanstack/react-query" ;
47
58interface ModeIndicatorInputProps {
69 mode : ExecutionMode ;
10+ taskId ?: string ;
711}
812
913const modeConfig : Record <
@@ -31,8 +35,23 @@ const modeConfig: Record<
3135 } ,
3236} ;
3337
34- export function ModeIndicatorInput ( { mode } : ModeIndicatorInputProps ) {
38+ export function ModeIndicatorInput ( { mode, taskId } : ModeIndicatorInputProps ) {
3539 const config = modeConfig [ mode ] ;
40+ const repoPath = useCwd ( taskId ?? "" ) ;
41+
42+ const { data : diffStats } = useQuery ( {
43+ queryKey : [ "diff-stats" , repoPath ] ,
44+ queryFn : ( ) =>
45+ trpcVanilla . git . getDiffStats . query ( {
46+ directoryPath : repoPath as string ,
47+ } ) ,
48+ enabled : ! ! repoPath && ! ! taskId ,
49+ staleTime : 5000 ,
50+ refetchInterval : 5000 ,
51+ placeholderData : ( prev ) => prev ,
52+ } ) ;
53+
54+ const hasDiffStats = diffStats && diffStats . filesChanged > 0 ;
3655
3756 return (
3857 < Flex align = "center" justify = "between" py = "1" >
@@ -59,6 +78,30 @@ export function ModeIndicatorInput({ mode }: ModeIndicatorInputProps) {
5978 >
6079 (shift+tab to cycle)
6180 </ Text >
81+ { hasDiffStats && (
82+ < Text
83+ size = "1"
84+ style = { {
85+ color : "var(--gray-9)" ,
86+ fontFamily : "monospace" ,
87+ display : "flex" ,
88+ alignItems : "center" ,
89+ gap : "6px" ,
90+ } }
91+ >
92+ < Circle size = { 4 } weight = "fill" style = { { margin : "0 4px" } } />
93+ < span style = { { color : "var(--gray-11)" } } >
94+ { diffStats . filesChanged } { " " }
95+ { diffStats . filesChanged === 1 ? "file" : "files" }
96+ </ span >
97+ < span style = { { color : "var(--green-9)" } } >
98+ +{ diffStats . linesAdded }
99+ </ span >
100+ < span style = { { color : "var(--red-9)" } } >
101+ -{ diffStats . linesRemoved }
102+ </ span >
103+ </ Text >
104+ ) }
62105 </ Flex >
63106 </ Flex >
64107 ) ;
0 commit comments