agent_ui: Fix agent panel insertion to use cursor position (#38253)

Fix agent panel insertion to use cursor position

Closes #38216

Release Notes:
- Fixed agent panel text insertion to respect cursor position instead of
always appending to the end

## Before

[before.webm](https://github.com/user-attachments/assets/684d3cbe-4710-4724-8d2d-ac08f430dea8)

## After

[output.webm](https://github.com/user-attachments/assets/d1122d99-4efb-4a24-a408-db128814f98c)
5d561aa494Kyrilasa committed on 9/17/2025, 7:10:21 AM· committed by GitHubparent4ee2dae
1 file changedLine totals unavailable