@@ -78,6 +78,10 @@ export class GitStatusManager extends EventEmitter {
7878 hasStaged : boolean ;
7979 hasUntracked : boolean ;
8080 hasConflicts : boolean ;
81+ modified : number ;
82+ staged : number ;
83+ untracked : number ;
84+ conflicted : number ;
8185 } > {
8286 const { stdout } = await this . gitExecutor . run ( {
8387 sessionId,
@@ -92,25 +96,38 @@ export class GitStatusManager extends EventEmitter {
9296 let hasUntracked = false ;
9397 let hasConflicts = false ;
9498
99+ let modified = 0 ;
100+ let staged = 0 ;
101+ let untracked = 0 ;
102+ let conflicted = 0 ;
103+
95104 for ( const line of stdout . split ( '\n' ) ) {
96105 if ( ! line ) continue ;
97106 if ( line . startsWith ( '??' ) ) {
98107 hasUntracked = true ;
108+ untracked ++ ;
99109 continue ;
100110 }
101111 if ( line . length < 2 ) continue ;
102112 const x = line [ 0 ] ;
103113 const y = line [ 1 ] ;
104114
105- if ( x !== ' ' && x !== '?' ) hasStaged = true ;
106- if ( y !== ' ' && y !== '?' ) hasModified = true ;
115+ if ( x !== ' ' && x !== '?' ) {
116+ hasStaged = true ;
117+ staged ++ ;
118+ }
119+ if ( y !== ' ' && y !== '?' ) {
120+ hasModified = true ;
121+ modified ++ ;
122+ }
107123
108124 if ( x === 'U' || y === 'U' || ( x === 'A' && y === 'A' ) || ( x === 'D' && y === 'D' ) ) {
109125 hasConflicts = true ;
126+ conflicted ++ ;
110127 }
111128 }
112129
113- return { hasModified, hasStaged, hasUntracked, hasConflicts } ;
130+ return { hasModified, hasStaged, hasUntracked, hasConflicts, modified , staged , untracked , conflicted } ;
114131 }
115132
116133 private async getAheadBehind ( worktreePath : string , sessionId : string , mainBranch : string ) : Promise < { ahead : number ; behind : number } > {
@@ -385,6 +402,12 @@ export class GitStatusManager extends EventEmitter {
385402 const summary = await this . getPorcelainSummary ( session . worktreePath , sessionId ) ;
386403 updatedStatus . hasUncommittedChanges = summary . hasModified || summary . hasStaged ;
387404 updatedStatus . hasUntrackedFiles = summary . hasUntracked ;
405+ updatedStatus . staged = summary . staged > 0 ? summary . staged : undefined ;
406+ updatedStatus . modified = summary . modified > 0 ? summary . modified : undefined ;
407+ updatedStatus . untracked = summary . untracked > 0 ? summary . untracked : undefined ;
408+ updatedStatus . conflicted = summary . conflicted > 0 ? summary . conflicted : undefined ;
409+ updatedStatus . clean =
410+ ! updatedStatus . hasUncommittedChanges && ! updatedStatus . hasUntrackedFiles && ! summary . hasConflicts ? true : undefined ;
388411 if ( summary . hasConflicts ) updatedStatus . state = 'conflict' ;
389412
390413 if ( updatedStatus . hasUncommittedChanges ) {
@@ -648,6 +671,16 @@ export class GitStatusManager extends EventEmitter {
648671 if ( cachedHasChanges !== currentHasChanges ) {
649672 return true ;
650673 }
674+
675+ // Detect state transitions that keep "has changes" true (e.g. stage/unstage operations).
676+ if (
677+ ( cached . status . staged ?? 0 ) !== quickStatus . staged ||
678+ ( cached . status . modified ?? 0 ) !== quickStatus . modified ||
679+ ( cached . status . untracked ?? 0 ) !== quickStatus . untracked ||
680+ ( cached . status . conflicted ?? 0 ) !== quickStatus . conflicted
681+ ) {
682+ return true ;
683+ }
651684
652685 // If both have no changes, check if ahead/behind changed
653686 if ( ! currentHasChanges ) {
@@ -804,6 +837,11 @@ export class GitStatusManager extends EventEmitter {
804837
805838 const result = {
806839 state,
840+ staged : quickStatus . staged > 0 ? quickStatus . staged : undefined ,
841+ modified : quickStatus . modified > 0 ? quickStatus . modified : undefined ,
842+ untracked : quickStatus . untracked > 0 ? quickStatus . untracked : undefined ,
843+ conflicted : quickStatus . conflicted > 0 ? quickStatus . conflicted : undefined ,
844+ clean : ! hasUncommittedChanges && ! hasUntrackedFiles && ! hasMergeConflicts ? true : undefined ,
807845 ahead : ahead > 0 ? ahead : undefined ,
808846 behind : behind > 0 ? behind : undefined ,
809847 additions : uncommittedDiff . stats . additions > 0 ? uncommittedDiff . stats . additions : undefined ,
0 commit comments