@@ -248,11 +248,25 @@ export class ExperimentsModel extends ModelWithPersistence {
248248 }
249249
250250 public getRevisionIds ( ) {
251- return this . getCombinedList ( ) . map ( ( { id } ) => id )
251+ return this . getUniqueList ( ) . map ( ( { id } ) => id )
252252 }
253253
254254 public getSelectedRevisions ( ) {
255- return this . getSelectedFromList ( ( ) => this . getCombinedList ( ) )
255+ const acc : SelectedExperimentWithColor [ ] = [ ]
256+
257+ for ( const experiment of this . getUniqueList ( ) ) {
258+ const { id } = experiment
259+ const displayColor = this . coloredStatus [ id ]
260+ if ( displayColor ) {
261+ acc . push ( { ...experiment , displayColor } as SelectedExperimentWithColor )
262+ }
263+ }
264+
265+ return copyOriginalColors ( )
266+ . flatMap ( orderedItem =>
267+ acc . filter ( item => item . displayColor === orderedItem )
268+ )
269+ . filter ( Boolean )
256270 }
257271
258272 public setSelected ( selectedExperiments : Experiment [ ] ) {
@@ -273,7 +287,7 @@ export class ExperimentsModel extends ModelWithPersistence {
273287 }
274288
275289 public getLabels ( ) {
276- return this . getCombinedList ( ) . map ( ( { label } ) => label )
290+ return this . getUniqueList ( ) . map ( ( { label } ) => label )
277291 }
278292
279293 public getLabelsToDecorate ( ) {
@@ -283,7 +297,7 @@ export class ExperimentsModel extends ModelWithPersistence {
283297 }
284298
285299 public getWorkspaceAndCommits ( ) {
286- return [
300+ const experiments = [
287301 {
288302 ...this . addDetails ( this . workspace ) ,
289303 hasChildren : false ,
@@ -292,15 +306,18 @@ export class ExperimentsModel extends ModelWithPersistence {
292306 )
293307 ? ExperimentType . RUNNING
294308 : ExperimentType . WORKSPACE
295- } ,
296- ...this . commits . map ( commit => {
297- return {
298- ...this . addDetails ( commit ) ,
299- hasChildren : ! ! this . experimentsByCommit . get ( commit . id ) ,
300- type : ExperimentType . COMMIT
301- }
302- } )
309+ }
303310 ]
311+
312+ for ( const commit of this . getCommits ( ) ) {
313+ experiments . push ( {
314+ ...this . addDetails ( commit ) ,
315+ hasChildren : ! ! this . experimentsByCommit . get ( commit . id ) ,
316+ type : ExperimentType . COMMIT
317+ } )
318+ }
319+
320+ return experiments
304321 }
305322
306323 public getWorkspaceCommitsAndExperiments ( ) {
@@ -309,14 +326,14 @@ export class ExperimentsModel extends ModelWithPersistence {
309326
310327 public getErrors ( ) {
311328 return new Set (
312- this . getCombinedList ( )
329+ this . getUniqueList ( )
313330 . filter ( ( { error } ) => error )
314331 . map ( ( { label } ) => label )
315332 )
316333 }
317334
318335 public getExperimentParams ( id : string ) {
319- const params = this . getCombinedList ( ) . find (
336+ const params = this . getUniqueList ( ) . find (
320337 experiment => experiment . id === id
321338 ) ?. params
322339
@@ -330,7 +347,7 @@ export class ExperimentsModel extends ModelWithPersistence {
330347 }
331348
332349 public getCommitsAndExperiments ( ) {
333- return collectOrderedCommitsAndExperiments ( this . commits , commit =>
350+ return collectOrderedCommitsAndExperiments ( this . getCommits ( ) , commit =>
334351 this . getExperimentsByCommit ( commit )
335352 )
336353 }
@@ -387,16 +404,24 @@ export class ExperimentsModel extends ModelWithPersistence {
387404 }
388405
389406 public getExperimentCount ( ) {
390- return sum ( [ this . getExperimentsAndQueued ( ) . length , this . commits . length , 1 ] )
407+ return sum ( [
408+ this . getExperimentsAndQueued ( ) . length ,
409+ this . getCommits ( ) . length ,
410+ 1
411+ ] )
391412 }
392413
393414 public getFilteredCount ( ) {
394415 const filtered = this . getFilteredExperiments ( )
395416 return filtered . length
396417 }
397418
398- public getCombinedList ( ) {
399- return [ this . workspace , ...this . commits , ...this . getExperimentsAndQueued ( ) ]
419+ public getUniqueList ( ) {
420+ return [
421+ this . workspace ,
422+ ...this . getCommits ( ) ,
423+ ...this . getExperimentsAndQueued ( )
424+ ]
400425 }
401426
402427 public getExperimentsByCommitForTree ( commit : Experiment ) {
@@ -452,6 +477,20 @@ export class ExperimentsModel extends ModelWithPersistence {
452477 return this . currentSorts . findIndex ( ( { path } ) => path === pathToRemove )
453478 }
454479
480+ private getCommits ( ) {
481+ const ids = new Set < string > ( )
482+ const commits : Experiment [ ] = [ ]
483+ for ( const commit of this . commits ) {
484+ const { id } = commit
485+ if ( ids . has ( id ) ) {
486+ continue
487+ }
488+ commits . push ( commit )
489+ ids . add ( id )
490+ }
491+ return commits
492+ }
493+
455494 private getFilteredExperiments ( ) {
456495 const acc : Experiment [ ] = [ ]
457496
@@ -467,7 +506,10 @@ export class ExperimentsModel extends ModelWithPersistence {
467506 private getExperimentsByCommit ( commit : Experiment ) {
468507 const experiments = this . experimentsByCommit
469508 . get ( commit . id )
470- ?. map ( experiment => this . addDetails ( experiment ) )
509+ ?. map ( experiment => ( {
510+ ...this . addDetails ( experiment ) ,
511+ branch : commit . branch
512+ } ) )
471513 if ( ! experiments ) {
472514 return
473515 }
@@ -607,23 +649,6 @@ export class ExperimentsModel extends ModelWithPersistence {
607649 return color
608650 }
609651
610- private getSelectedFromList ( getList : ( ) => Experiment [ ] ) {
611- const acc : SelectedExperimentWithColor [ ] = [ ]
612-
613- for ( const experiment of getList ( ) ) {
614- const displayColor = this . coloredStatus [ experiment . id ]
615- if ( displayColor ) {
616- acc . push ( { ...experiment , displayColor } as SelectedExperimentWithColor )
617- }
618- }
619-
620- return copyOriginalColors ( )
621- . flatMap ( orderedItem =>
622- acc . filter ( item => item . displayColor === orderedItem )
623- )
624- . filter ( Boolean )
625- }
626-
627652 private reviveColoredStatus ( ) {
628653 const uniqueStatus : ColoredStatus = { }
629654 const colors = new Set < Color > ( )
0 commit comments