()
| 2333 | } |
| 2334 | |
| 2335 | toggleToolOutputExpansion(): void { |
| 2336 | this.state.toolOutputExpanded = !this.state.toolOutputExpanded; |
| 2337 | const children = this.state.transcriptContainer.children; |
| 2338 | |
| 2339 | // A component is expandable only if it sits at or after the start of the |
| 2340 | // (totalTurns - expandTurns)-th turn — i.e. it belongs to one of the most |
| 2341 | // recent `expandTurns` turns. Position-based so it also covers streaming |
| 2342 | // components that have no entry in the metadata map. |
| 2343 | const boundaries: number[] = []; |
| 2344 | for (let i = 0; i < children.length; i++) { |
| 2345 | if (this.isTurnBoundaryComponent(children[i]!)) boundaries.push(i); |
| 2346 | } |
| 2347 | const expandCutoff = |
| 2348 | TRANSCRIPT_EXPAND_TURNS <= 0 |
| 2349 | ? children.length |
| 2350 | : boundaries.length > TRANSCRIPT_EXPAND_TURNS |
| 2351 | ? boundaries[boundaries.length - TRANSCRIPT_EXPAND_TURNS]! |
| 2352 | : 0; |
| 2353 | |
| 2354 | for (let i = 0; i < children.length; i++) { |
| 2355 | const child = children[i]!; |
| 2356 | if (!isExpandable(child)) continue; |
| 2357 | child.setExpanded(this.state.toolOutputExpanded && i >= expandCutoff); |
| 2358 | } |
| 2359 | // Expanding/collapsing shifts content above the viewport; the clamped |
| 2360 | // differential render would paint a second copy below the stale one in |
| 2361 | // scrollback. This is a deliberate user action (like /clear), so do a |
| 2362 | // destructive full render: scrollback holds exactly one copy and the |
| 2363 | // expanded output can be read by scrolling up. |
| 2364 | this.state.ui.requestRender(true); |
| 2365 | } |
| 2366 | |
| 2367 | toggleTodoPanelExpansion(): void { |
| 2368 | this.state.todoPanel.toggleExpanded(); |
no test coverage detected