Repository navigation
Conversation
PR Summary by QodoShow the cursor while requesting user confirmation
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
| const bool cursor_was_hidden = libdnf5::cli::tty::is_cursor_hidden(); | ||
| std::cerr << libdnf5::cli::tty::cursor_show; |
There was a problem hiding this comment.
🟠 Medium
1. Redirected error output gains cursor codes 🐞 Bug ≡ Correctness
userconfirm() sends cursor_show to std::cerr on every call, while that manipulator decides whether to emit its escape sequence by checking stdout rather than the destination stream. When stdout remains a terminal but stderr is redirected, confirmations—including automatic yes/no confirmations—write a cursor-control code into captured stderr, and a previously hidden cursor adds a second code on return.
Agent Prompt
## Issue description
`userconfirm()` writes cursor-control sequences to redirected stderr whenever stdout is interactive, because `tty::is_interactive()` checks stdout.
## Fix Focus Areas
- libdnf5-cli/utils/userconfirm.cpp[35-42]
- libdnf5-cli/tty.cpp[48-66]
## Recommended Fix
Only issue the show and matching hide commands when the destination for those commands is a terminal. Preserve the original cursor state when no command is emitted.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
There was a problem hiding this comment.
while that manipulator decides whether to emit its escape sequence by checking stdout rather than the destination stream
That's fine, not the fault of this PR, is_interactive checks only std::cout.
including automatic yes/no confirmations
Valid, I adjusted this to not hide/show during automatic confirmations.
If the cursor is hidden when libdnf5::cli::utils::userconfirm is called, show it, then hide it again once userconfirm returns. This requires tracking whether the cursor is hidden with new helpers hide_cursor and show_cursor. Previously, the cursor would remain hidden if the user is prompted to import a GPG key during a transaction. Assisted-by: GPT-6 Luna
56b033b to
a78a5ab
Compare
|
I reworked this a bit to add new helpers, have side effects other than writing to |
4167de1
If the cursor is hidden when
libdnf5::cli::utils::userconfirmis called, show it, then hide it again once userconfirm returns.This requires tracking whether the cursor is hidden in cursor_show and cursor_hide.This requires tracking whether the cursor is hidden with new helpers hide_cursor and show_cursor.
Previously, the cursor would remain hidden if the user is prompted to import a GPG key during a transaction.
Assisted-by: GPT-6 Luna