( items: T[], getAgentType: (item: T) => string, )
| 72 | * so it renders at full width. |
| 73 | */ |
| 74 | export function splitByAgentSize<T>( |
| 75 | items: T[], |
| 76 | getAgentType: (item: T) => string, |
| 77 | ): T[][] { |
| 78 | if (items.length <= 1) return [items] |
| 79 | |
| 80 | const subGroups: T[][] = [] |
| 81 | let currentSmallGroup: T[] = [] |
| 82 | |
| 83 | for (const item of items) { |
| 84 | if (shouldCollapseByDefault(getAgentType(item))) { |
| 85 | currentSmallGroup.push(item) |
| 86 | } else { |
| 87 | if (currentSmallGroup.length > 0) { |
| 88 | subGroups.push(currentSmallGroup) |
| 89 | currentSmallGroup = [] |
| 90 | } |
| 91 | subGroups.push([item]) |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | if (currentSmallGroup.length > 0) { |
| 96 | subGroups.push(currentSmallGroup) |
| 97 | } |
| 98 | |
| 99 | return subGroups |
| 100 | } |
| 101 | |
| 102 | /** Convenience wrapper for splitting AgentContentBlock arrays by size. */ |
| 103 | export function splitAgentsBySize( |
no test coverage detected