Skip to content

Commit 5703729

Browse files
committed
refactor(app): drop unused sidebar openKeys
1 parent d710243 commit 5703729

2 files changed

Lines changed: 1 addition & 20 deletions

File tree

‎packages/app/src/shell/titlebar/sidebar-view.test.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ describe("sidebarView", () => {
171171
["server:c", true, 1],
172172
])
173173
expect(view.groups[0]?.children?.map((child) => child.collapsed)).toEqual([false, true])
174-
expect(view.openKeys).toEqual(["a1", "b2"])
175174

176175
const flat = sidebarView(
177176
rows,
@@ -182,6 +181,5 @@ describe("sidebarView", () => {
182181
["project:p1", true],
183182
["project:p2", true],
184183
])
185-
expect(flat.openKeys).toEqual(["b2"])
186184
})
187185
})

‎packages/app/src/shell/titlebar/sidebar-view.ts‎

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ export type SidebarGroup<R extends SidebarRow> = {
5656

5757
export type SidebarView<R extends SidebarRow> = {
5858
groups: SidebarGroup<R>[]
59-
/** Open row keys in on-screen order; a collapsed group adds only its active row. Drives ⌘1–9 and next/previous. */
60-
openKeys: string[]
6159
}
6260

6361
export const SIDEBAR_STATUSES: readonly SidebarStatus[] = ["running", "input", "unread", "failed", "idle"]
@@ -88,9 +86,7 @@ export function sidebarView<R extends SidebarRow>(rows: readonly R[], state: Sid
8886
...(children.get(row.key) ?? []).toSorted((a, b) => b.updated - a.updated || byKey(a, b)).flatMap(withChildren),
8987
]
9088

91-
const groups = buildGroups(top, withChildren, state)
92-
93-
return { groups, openKeys: groups.flatMap(openKeys) }
89+
return { groups: buildGroups(top, withChildren, state) }
9490
}
9591

9692
const ATTENTION: Record<SidebarStatus, number> = { input: 0, failed: 1, unread: 2, running: 3, idle: 4 }
@@ -210,16 +206,3 @@ function leaf<R extends SidebarRow>(
210206
children: undefined,
211207
}
212208
}
213-
214-
// A collapsed group still shows its active row, so that row keeps its place in the order.
215-
function openKeys<R extends SidebarRow>(group: SidebarGroup<R>): string[] {
216-
if (group.collapsed) {
217-
const rows = group.children ? group.children.flatMap((child) => child.rows) : group.rows
218-
219-
return rows.filter((row) => row.open && row.active).map((row) => row.key)
220-
}
221-
222-
if (group.children) return group.children.flatMap(openKeys)
223-
224-
return group.rows.filter((row) => row.open).map((row) => row.key)
225-
}

0 commit comments

Comments
 (0)