Improve handling of large output in embedded terminals (#32416)

#31922 made embedded terminals automatically grow to fit the content. We
since found some issues with large output which this PR addresses by:

- Only shaping / laying out lines that are visible in the viewport
(based on `window.content_mask`)
- Falling back to embedded scrolling after 1K lines. The perf fix above
actually makes it possible to handle a lot of lines, but:
- Alacrity uses a `u16` for rows internally, so we needed a limit to
prevent overflow.
- Scrolling through thousands of lines to get to the other side of a
terminal tool call isn't great UX, so we might as well set the limit
low.
- We can consider raising the limit when we make card headers sticky.

Release Notes:

- Agent: Improve handling of large terminal output
This commit is contained in:
Agus Zubiaga 2025-06-09 14:11:31 -07:00 committed by GitHub
parent ab70e524c8
commit b103d7621b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 199 additions and 87 deletions

View file

@ -258,7 +258,7 @@ impl Render for TerminalOutput {
cell: ic.cell.clone(),
});
let (cells, rects) =
TerminalElement::layout_grid(grid, &text_style, text_system, None, window, cx);
TerminalElement::layout_grid(grid, 0, &text_style, text_system, None, window, cx);
// lines are 0-indexed, so we must add 1 to get the number of lines
let text_line_height = text_style.line_height_in_pixels(window.rem_size());