@@ -246,4 +246,74 @@ describe('RightPanel - Zed-style Changes list', () => {
246246 'right-panel-file-untracked-dd.txt' ,
247247 ] ) ;
248248 } ) ;
249+
250+ it ( 'orders commits newest-first (working tree first, base last)' , async ( ) => {
251+ ( API . sessions . getExecutions as any ) . mockResolvedValue ( {
252+ success : true ,
253+ data : [
254+ {
255+ id : 0 ,
256+ commit_message : 'Uncommitted changes' ,
257+ timestamp : new Date ( '2026-01-01T00:00:00.000Z' ) . toISOString ( ) ,
258+ stats_additions : 0 ,
259+ stats_deletions : 0 ,
260+ stats_files_changed : 0 ,
261+ after_commit_hash : '' ,
262+ parent_commit_hash : null ,
263+ author : 'test' ,
264+ } ,
265+ {
266+ id : 1 ,
267+ commit_message : 'older commit' ,
268+ timestamp : new Date ( '2026-01-01T00:00:01.000Z' ) . toISOString ( ) ,
269+ stats_additions : 1 ,
270+ stats_deletions : 1 ,
271+ stats_files_changed : 1 ,
272+ after_commit_hash : '1111111111111111111111111111111111111111' ,
273+ parent_commit_hash : null ,
274+ author : 'test' ,
275+ } ,
276+ {
277+ id : 2 ,
278+ commit_message : 'newer commit' ,
279+ timestamp : new Date ( '2026-01-01T00:00:02.000Z' ) . toISOString ( ) ,
280+ stats_additions : 2 ,
281+ stats_deletions : 0 ,
282+ stats_files_changed : 1 ,
283+ after_commit_hash : '2222222222222222222222222222222222222222' ,
284+ parent_commit_hash : null ,
285+ author : 'test' ,
286+ } ,
287+ {
288+ id : - 1 ,
289+ commit_message : 'base' ,
290+ timestamp : new Date ( '2025-12-31T23:59:59.000Z' ) . toISOString ( ) ,
291+ stats_additions : 0 ,
292+ stats_deletions : 0 ,
293+ stats_files_changed : 0 ,
294+ after_commit_hash : 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' ,
295+ parent_commit_hash : null ,
296+ author : 'test' ,
297+ } ,
298+ ] ,
299+ } ) ;
300+
301+ const { container } = render ( < RightPanel { ...mockProps } /> ) ;
302+
303+ await waitFor ( ( ) => {
304+ expect ( screen . getByText ( / C o m m i t s / i) ) . toBeInTheDocument ( ) ;
305+ expect ( screen . getByLabelText ( 'Select commit uncommitted changes' ) ) . toBeInTheDocument ( ) ;
306+ } ) ;
307+
308+ const selectButtons = Array . from ( container . querySelectorAll ( 'button[aria-label^="Select commit"]' ) ) ;
309+ const labels = selectButtons . map ( ( el ) => el . getAttribute ( 'aria-label' ) ) ;
310+
311+ expect ( labels [ 0 ] ) . toBe ( 'Select commit uncommitted changes' ) ;
312+ expect ( labels [ 1 ] ) . toBe ( 'Select commit 2222222' ) ;
313+ expect ( labels [ 2 ] ) . toBe ( 'Select commit 1111111' ) ;
314+ expect ( labels [ 3 ] ) . toBe ( 'Select commit bbbbbbb' ) ;
315+ const commitTexts = container . textContent || '' ;
316+ expect ( commitTexts . indexOf ( 'newer commit' ) ) . toBeLessThan ( commitTexts . indexOf ( 'older commit' ) ) ;
317+ expect ( commitTexts . indexOf ( 'older commit' ) ) . toBeLessThan ( commitTexts . indexOf ( 'base' ) ) ;
318+ } ) ;
249319} ) ;
0 commit comments