From 65be4302df88097b66d7e1d4cd68f9123064acdb Mon Sep 17 00:00:00 2001 From: "detail-app[bot]" <180357370+detail-app[bot]@users.noreply.github.com> Date: Mon, 2 Nov 2026 21:55:47 +0000 Subject: [PATCH] chore: remove unused layout-tree helpers (closeGroup, paneRects, insertionIndex) --- .../devtools/src/utils/layout-tree.test.ts | 49 ------------------- packages/devtools/src/utils/layout-tree.ts | 38 -------------- 2 files changed, 87 deletions(-) diff --git a/packages/devtools/src/utils/layout-tree.test.ts b/packages/devtools/src/utils/layout-tree.test.ts index 34592893..028e6b2e 100644 --- a/packages/devtools/src/utils/layout-tree.test.ts +++ b/packages/devtools/src/utils/layout-tree.test.ts @@ -4,14 +4,11 @@ import { allGroups, appendPane, canSplit, - closeGroup, closeTab, flattenTabs, - insertionIndex, layoutRects, moveTab, nextGroupId, - paneRects, repairLayout, resetSplit, resize, @@ -154,20 +151,6 @@ describe('closeTab', () => { }) }) -describe('closeGroup', () => { - it('removes every tab in the group and prunes', () => { - const tree = split('row', [group('g0', ['a', 'b']), group('g1', ['c'])]) - const next = closeGroup(tree, 'g0') - expect(next).toEqual(group('g1', ['c'], 0)) - expectWellFormed(next) - }) - - it('is a no-op for an unknown group', () => { - const tree = group('g0', ['a']) - expect(closeGroup(tree, 'gX')).toEqual(tree) - }) -}) - describe('activateTab', () => { it('selects without moving', () => { const next = activateTab(group('g0', ['a', 'b', 'c']), 'c') @@ -485,17 +468,8 @@ describe('layoutRects', () => { }) }) - it('gives every tab in a group the group rect', () => { - const tree = split('row', [group('g0', ['a', 'b']), group('g1', ['c'])]) - const rects = paneRects(tree, BOX) - expect(rects.a).toEqual(rects.b) - expect(rects.a).toEqual({ left: 0, top: 0, width: 500, height: 400 }) - expect(rects.c!.left).toBe(500) - }) - it('returns nothing for an empty tree', () => { expect(layoutRects(null, BOX)).toEqual({}) - expect(paneRects(null, BOX)).toEqual({}) }) }) @@ -769,29 +743,6 @@ describe('zoneAt', () => { }) }) -describe('insertionIndex', () => { - const tabs = [ - { left: 0, top: 0, width: 100, height: 30 }, - { left: 100, top: 0, width: 100, height: 30 }, - { left: 200, top: 0, width: 100, height: 30 }, - ] - - it('inserts before a tab in its first half', () => { - expect(insertionIndex(10, tabs)).toBe(0) - expect(insertionIndex(120, tabs)).toBe(1) - }) - - it('inserts after a tab in its second half', () => { - expect(insertionIndex(80, tabs)).toBe(1) - expect(insertionIndex(180, tabs)).toBe(2) - }) - - it('appends past the end and handles an empty bar', () => { - expect(insertionIndex(999, tabs)).toBe(3) - expect(insertionIndex(0, [])).toBe(0) - }) -}) - describe('repairLayout', () => { const known = new Set(['a', 'b', 'c']) diff --git a/packages/devtools/src/utils/layout-tree.ts b/packages/devtools/src/utils/layout-tree.ts index 08b417f6..74a7e4fa 100644 --- a/packages/devtools/src/utils/layout-tree.ts +++ b/packages/devtools/src/utils/layout-tree.ts @@ -182,19 +182,6 @@ export const closeTab = ( return tree === null ? null : prune(strip(tree)) } -/** Remove a whole group and everything in it. */ -export const closeGroup = ( - tree: LayoutNode | null, - groupId: string, -): LayoutNode | null => { - const group = findGroupById(tree, groupId) - if (group === null) return tree - return group.tabs.reduce( - (acc, tabId) => closeTab(acc, tabId), - tree, - ) -} - /** * Replace a group's tab order wholesale, keeping the same tab selected. * @@ -583,21 +570,6 @@ export const splitterHandles = ( return handles } -/** Rect per plugin id, which is what the panes are keyed by. */ -export const paneRects = ( - tree: LayoutNode | null, - box: Size, - gutter = 0, -): Record => { - const byGroup = layoutRects(tree, box, gutter) - const out: Record = {} - for (const group of allGroups(tree)) { - const rect = byGroup[group.id] - if (rect) for (const tabId of group.tabs) out[tabId] = rect - } - return out -} - /** * Whether splitting a group leaves both halves at least `min`. The workspace is * short, so a split that would produce an unreadable cell is refused and the @@ -639,16 +611,6 @@ export const zoneAt = ( return distance <= edge ? zone : 'center' } -/** Insertion index for a tab dropped at `x` over a row of tab rects. */ -export const insertionIndex = (x: number, tabs: Array): number => { - let index = 0 - for (const rect of tabs) { - if (x < rect.left + rect.width / 2) break - index += 1 - } - return index -} - const isRawGroup = (value: Record): boolean => value.kind === 'group' && typeof value.id === 'string' &&