Skip to content

Commit f16c3a6

Browse files
authored
Fix missing exp selection quick pick details on inital extension render (#2694)
1 parent b71ec5a commit f16c3a6

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

extension/src/experiments/columns/model.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,40 @@ describe('ColumnsModel', () => {
194194
expect(model.getColumnOrder()).toStrictEqual(persistedState)
195195
})
196196

197+
it('should return the first three columns from the persisted state', () => {
198+
const persistedState = [
199+
{ path: 'A', width: 0 },
200+
{ path: 'B', width: 0 },
201+
{ path: 'C', width: 0 },
202+
{ path: 'D', width: 0 },
203+
{ path: 'E', width: 0 },
204+
{ path: 'F', width: 0 }
205+
]
206+
207+
const model = new ColumnsModel(
208+
exampleDvcRoot,
209+
buildMockMemento({
210+
[PersistenceKey.METRICS_AND_PARAMS_COLUMN_ORDER + exampleDvcRoot]:
211+
persistedState
212+
})
213+
)
214+
215+
expect(model.getFirstThreeColumnOrder()).toStrictEqual(
216+
persistedState.slice(1, 4)
217+
)
218+
})
219+
220+
it('should return first three columns collected from data if state is empty', async () => {
221+
const model = new ColumnsModel(exampleDvcRoot, buildMockMemento())
222+
await model.transformAndSet(outputFixture)
223+
224+
expect(model.getFirstThreeColumnOrder()).toStrictEqual([
225+
'Created',
226+
'metrics:summary.json:loss',
227+
'metrics:summary.json:accuracy'
228+
])
229+
})
230+
197231
it('should re-order the columns if a new columnOrder is set', () => {
198232
const model = new ColumnsModel(
199233
exampleDvcRoot,

extension/src/experiments/columns/model.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ export class ColumnsModel extends PathSelectionModel<Column> {
2929
}
3030

3131
public getFirstThreeColumnOrder(): string[] {
32-
return this.columnOrderState.slice(1, 4)
32+
return this.columnOrderState.length === 0
33+
? this.getFirstThreeColumnOrderFromData()
34+
: this.columnOrderState.slice(1, 4)
3335
}
3436

3537
public getColumnWidths(): Record<string, number> {
@@ -82,6 +84,13 @@ export class ColumnsModel extends PathSelectionModel<Column> {
8284
return this.data.length > 1
8385
}
8486

87+
private getFirstThreeColumnOrderFromData(): string[] {
88+
return this.data
89+
.filter(({ hasChildren }) => !hasChildren)
90+
.slice(0, 3)
91+
.map(({ path }) => path)
92+
}
93+
8594
private filterChildren(path?: string) {
8695
return this.data.filter(element =>
8796
path

0 commit comments

Comments
 (0)