11import { datePrefixedLabel , formatRelativeTime , GitHub } from "@array/core" ;
2- import { cyan , dim , green , magenta , red , yellow } from "../utils/output" ;
2+ import {
3+ cyan ,
4+ dim ,
5+ formatChangeId ,
6+ formatCommitId ,
7+ green ,
8+ magenta ,
9+ red ,
10+ yellow ,
11+ } from "../utils/output" ;
312import { createJJ , unwrap } from "../utils/run" ;
413
514interface PRInfo {
@@ -12,7 +21,9 @@ export async function log(): Promise<void> {
1221 const jj = createJJ ( ) ;
1322 const github = new GitHub ( process . cwd ( ) ) ;
1423
15- const { entries, trunk, isOnTrunk } = unwrap ( await jj . getLog ( ) ) ;
24+ const { entries, trunk, isOnTrunk, hasEmptyWorkingCopy } = unwrap (
25+ await jj . getLog ( ) ,
26+ ) ;
1627
1728 if ( entries . length === 0 && isOnTrunk ) {
1829 console . log ( dim ( "No changes in stack" ) ) ;
@@ -49,20 +60,47 @@ export async function log(): Promise<void> {
4960
5061 console . log ( ) ;
5162
63+ // Show empty working copy if present
64+ if ( hasEmptyWorkingCopy ) {
65+ console . log ( `${ green ( "◉" ) } ${ dim ( "(working copy)" ) } ` ) ;
66+ console . log ( `│ ${ dim ( "Empty" ) } ` ) ;
67+ console . log ( `│` ) ;
68+ console . log ( `│ ${ dim ( "Edit files, then:" ) } ` ) ;
69+ console . log (
70+ `│ ${ cyan ( "arr create" ) } ${ dim ( '"message"' ) } ${ dim ( "to save as new change" ) } ` ,
71+ ) ;
72+ console . log (
73+ `│ ${ cyan ( "arr modify" ) } ${ dim ( "to update the change below" ) } ` ,
74+ ) ;
75+ console . log ( `│` ) ;
76+ }
77+
78+ let modifiedCount = 0 ;
79+
5280 for ( let i = 0 ; i < entries . length ; i ++ ) {
53- const { change, prefix, isCurrent, isLastInStack, stackIndex } = entries [ i ] ;
81+ const { change, prefix, isCurrent, isLastInStack, stackIndex, isModified } =
82+ entries [ i ] ;
5483 const label = datePrefixedLabel ( change . description , change . timestamp ) ;
5584
85+ // Track modified changes for summary
86+ if ( isModified ) modifiedCount ++ ;
87+
5688 // Determine status badges
5789 const badges : string [ ] = [ ] ;
90+ if ( isModified ) badges . push ( yellow ( "modified" ) ) ;
5891 if ( change . hasConflicts ) badges . push ( yellow ( "conflicts" ) ) ;
5992
60- const marker = isCurrent ? green ( "◉" ) : "○" ;
93+ // Don't show current marker on entries when empty WC is shown above
94+ const marker = isCurrent && ! hasEmptyWorkingCopy ? green ( "◉" ) : "○" ;
6195 const badgeStr =
6296 badges . length > 0 ? ` ${ dim ( "(" ) } ${ badges . join ( ", " ) } ${ dim ( ")" ) } ` : "" ;
6397
64- // Line 1: marker + branch name + badges
65- console . log ( `${ prefix } ${ marker } ${ label } ${ badgeStr } ` ) ;
98+ // Line 1: marker + branch name + change ID + badges
99+ const shortId = formatChangeId (
100+ change . changeId . slice ( 0 , 8 ) ,
101+ change . changeIdPrefix ,
102+ ) ;
103+ console . log ( `${ prefix } ${ marker } ${ label } ${ shortId } ${ badgeStr } ` ) ;
66104
67105 // Line 2: relative time
68106 console . log ( `${ prefix } │ ${ dim ( formatRelativeTime ( change . timestamp ) ) } ` ) ;
@@ -91,8 +129,12 @@ export async function log(): Promise<void> {
91129
92130 // Line 4: commit hash
93131 console . log ( `${ prefix } │` ) ;
132+ const shortCommitId = formatCommitId (
133+ change . commitId . slice ( 0 , 7 ) ,
134+ change . commitIdPrefix ,
135+ ) ;
94136 console . log (
95- `${ prefix } │ ${ dim ( change . commitId . slice ( 0 , 7 ) ) } - ${ change . description || dim ( "(no description)" ) } ` ,
137+ `${ prefix } │ ${ shortCommitId } - ${ change . description || dim ( "(no description)" ) } ` ,
96138 ) ;
97139 console . log ( `${ prefix } │` ) ;
98140
@@ -112,6 +154,15 @@ export async function log(): Promise<void> {
112154 console . log ( `○ ${ dim ( trunk ) } ` ) ;
113155 }
114156 console . log ( ) ;
157+
158+ // Show summary/guidance when there are modified changes
159+ if ( modifiedCount > 0 ) {
160+ const changeWord = modifiedCount === 1 ? "change" : "changes" ;
161+ console . log (
162+ `${ modifiedCount } ${ changeWord } modified. Run ${ cyan ( "arr submit" ) } to update PRs.` ,
163+ ) ;
164+ console . log ( ) ;
165+ }
115166}
116167
117168async function getRepoSlug ( github : GitHub ) : Promise < string > {
0 commit comments