agent: Fix terminal command truncation in confirmation dialogs#40570
agent: Fix terminal command truncation in confirmation dialogs#40570danilo-leal merged 12 commits intozed-industries:mainfrom
Conversation
|
Hey @miguelcsx, thanks for the PR! Quick question, though, how can I easily test this? I want to check the UI given that adding overflow scroll in the tool call container might cause double scroll, which is something we avoid having. |
480d254 to
aa413fa
Compare
@danilo-leal I was able to test it by asking the AI to try and run the commands reported in the associated issue ( #40322 ) . Here's some screenshots of the before and after, in case it helps ↓
|
|
Hi team, @danilo-leal is right. With this not-that long Nix command it's not easy to notice the behavior, but with longer commands I'm running into an issue: instead inner scroll, I get a nested scroll. I tried two approaches:
Right now I'm working on making that inner box scrollable. The challenge is that the markdown rendering creates a pretty complex structure , so I need to adjust it to make the inner part scroll properly. |
aa413fa to
66dd4c8
Compare
|
I guess is ready for review, I added a scroll handle to track the scrolling in the inner box. Fell free to play with before I make it ready to review. Here is a preview: 2025-10-20-17-03-19.mp4 |
|
Thanks for the follow up @miguelcsx, appreciate it! I definitely feel like we shouldn't ship the double-scroll. But what we could do to improve the long command UX is: we should cap the container's height to an arbitrary max number of lines, so that if the command is bigger than, say, 8 lines, you need to click an "expand" button that would reveal the whole command (with no internal scroll). You can then of course always collapse that to clear out the UI again. Using @dinocosta's image there as a base, this is how I'm thinking of it:
But just instead of like, just 2 lines being visible above the button, imagine you'd see something around 4 or close. Then you can expand to see the rest. |
…ndustries#40322) When users run multi-line terminal commands, the confirmation dialog was only showing the first line with '- N more lines' truncated. This meant dangerous commands like 'rm -rf' or 'sudo' operations could be hidden from view, creating a security risk. Now terminal commands always display in full, with scroll support for very long commands (20+ lines) to keep the confirmation buttons visible. Other tools continue using truncation for better UI efficiency since they don't pose the same security concerns. Closes zed-industries#40322 Release Notes: - Fixed terminal command truncation in confirmation dialogs - dangerous multi-line commands are now fully visible before execution
66dd4c8 to
91b9ef1
Compare
|
I liked your idea @danilo-leal, I added a expand/collapse button, see it below: 2025-10-20-21-34-38.mp4 |
|
Nice, thanks for pushing it forward @miguelcsx! Also pushed a commit now making some progress on the design. However, this doesn't feel perfect yet... for a couple of reasons:
I appreciate how using the number of lines might not be trivial, though. I myself would need to look it up and maybe reach out for some deeper help to pull it off, so feel free to not do it if it's too daunting! |
|
@miguelcsx Are you still working on these changes? The related issue – #40322 – has just been marked as stale but I can see that the issue is still happening and, I believe, it's still worth improving on. If you currently don't have time to finish tackling Danilo's feedback, let us know, and I can push this over the finish line. Thanks! 🙂 |
- Update the way that the `TerminalTool` displays its command, returning back to the version where newlines are actually displayed, so if a multi-line command is used, it will be displayed as multiple lines. - Refactor the `AcpThreadView.render_terminal_command_preview` in order to show, at maximum, three lines of the command, with an expand button to show the full command if it is longer. The label in the expand button will inform the user of how many additional lines are hidden.
- Replace `MarkdownElement` with manual line rendering for command text - Only show expand/collapse button when command exceeds 3 lines - Display "N more lines" label when collapsed instead of always showing button - Remove `window` parameter from `render_terminal_command_preview`
|
@danilo-leal Here's a quick screen recording of what the current changes look like! I believe it's now ready for another review 🙇 CleanShot.2026-01-12.at.14.52.45.mp4 |
These changes ensure we're again able to just run `cargo test -p agent_ui` in order to run the test suite for the `agent_ui` crate.
Closes #40322 When users run multi-line terminal commands, the confirmation dialog was only showing the first line with '- N more lines' truncated. This meant dangerous commands like 'rm -rf' or 'sudo' operations could be hidden from view, creating a security risk. Now terminal commands always display in full, with scroll support for very long commands (20+ lines) to keep the confirmation buttons visible. Other tools continue using truncation for better UI efficiency since they don't pose the same security concerns. Release Notes: - Agent: Fixed terminal command truncation in the agent panel to better expose long commands (e.g., potentially dangerous multi-line commands are now fully visible before execution) --------- Co-authored-by: Danilo Leal <daniloleal09@gmail.com> Co-authored-by: dino <dinojoaocosta@gmail.com>
|
@danilo-leal Thank you for taking this one over the line! 🙌 |
…47148) Follow up to #40570. This PR removes the UI treatment where we collapse a terminal command into a disclosure component if it spans more than three lines. I initially thought having this fancy treatment in the UI would make it sleeker but it actually feels like a counter-productive move to arbitrarily hide command lines; they're arguably always important to see in full, even when they're super long. I'm happy to get some feedback here, but I think for now, I'd feel better if users could see them all without having to manually expand/collapse them. Release Notes: - N/A



Closes #40322
When users run multi-line terminal commands, the confirmation dialog was only showing the first line with '- N more lines' truncated. This meant dangerous commands like 'rm -rf' or 'sudo' operations could be hidden from view, creating a security risk.
Now terminal commands always display in full, with scroll support for very long commands (20+ lines) to keep the confirmation buttons visible.
Other tools continue using truncation for better UI efficiency since they don't pose the same security concerns.
Release Notes: