-
Notifications
You must be signed in to change notification settings - Fork 27
fix: [BUG] [v0.0.7] Pressing Ctrl+V while /logs panel is open closes the panel and pastes clipboard text into the CLI
#43213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,27 +1,15 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub mod leaderboard; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub mod stats; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub mod weights; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use anyhow::Result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use crossterm::{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| execute, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use ratatui::prelude::*; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use std::io; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub fn setup_terminal() -> Result<Terminal<CrosstermBackend<io::Stdout>>> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| enable_raw_mode()?; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let mut stdout = io::stdout(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| execute!(stdout, EnterAlternateScreen)?; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let backend = CrosstermBackend::new(stdout); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let terminal = Terminal::new(backend)?; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| terminal.set_handler(|event| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if let Event::Key(key) = event { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if key.code == KeyCode::Char('v') && key.modifiers.contains(Modifier::CONTROL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Ignore Ctrl+V when the Log Level panel is open | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Ok(terminal) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
1
to
15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reintroduce terminal restore path; current removal breaks existing caller and cleanup.
Proposed fix+pub fn restore_terminal(terminal: &mut Terminal<CrosstermBackend<io::Stdout>>) -> Result<()> {
+ disable_raw_mode()?;
+ execute!(terminal.backend_mut(), LeaveAlternateScreen)?;
+ terminal.show_cursor()?;
+ Ok(())
+}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub fn restore_terminal(terminal: &mut Terminal<CrosstermBackend<io::Stdout>>) -> Result<()> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| disable_raw_mode()?; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| execute!(terminal.backend_mut(), LeaveAlternateScreen)?; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| terminal.show_cursor()?; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Ok(()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scope Ctrl+V suppression to
/logs-panel-open state only.At Line 7-14, the handler drops Ctrl+V unconditionally for this terminal instance. Since
setup_terminal()is reused, this can suppress paste in unrelated TUI flows. Gate this with explicit panel state, or move filtering into the/logsinput path.As per coding guidelines "All user inputs must be validated before use".
🤖 Prompt for AI Agents
🧩 Analysis chain
🌐 Web query:
In ratatui version 0.29.0, doesTerminalhave aset_handlermethod? If yes, what is the exact method signature and expected closure return type? In crossterm version 0.28.0, what is the correct type/constant for checking Ctrl key modifiers onKeyEvent(KeyModifiers::CONTROLvs other names)?💡 Result:
No, the Terminal struct in ratatui 0.29.0 does not have a set_handler method. The documented methods include new, with_options, get_frame, draw, try_draw, hide_cursor, show_cursor, get_cursor_position, set_cursor_position, clear, flush, and resize, but no set_handler. Ratatui handles events via direct backend calls like crossterm::event::read, not via a handler on Terminal. In crossterm 0.28.0, the correct constant for checking Ctrl key modifiers on KeyEvent is KeyModifiers::CONTROL. It is explicitly listed as pub const CONTROL: Self in the KeyModifiers struct documentation.
Citations:
🏁 Script executed:
Repository: PlatformNetwork/bounty-challenge
Length of output: 4299
🏁 Script executed:
Repository: PlatformNetwork/bounty-challenge
Length of output: 108
🏁 Script executed:
Repository: PlatformNetwork/bounty-challenge
Length of output: 761
🏁 Script executed:
Repository: PlatformNetwork/bounty-challenge
Length of output: 701
🏁 Script executed:
Repository: PlatformNetwork/bounty-challenge
Length of output: 656
🏁 Script executed:
Repository: PlatformNetwork/bounty-challenge
Length of output: 151
🏁 Script executed:
Repository: PlatformNetwork/bounty-challenge
Length of output: 656
🏁 Script executed:
Repository: PlatformNetwork/bounty-challenge
Length of output: 111
🏁 Script executed:
sed -n '1,50p' ./bins/bounty-cli/src/tui/mod.rsRepository: PlatformNetwork/bounty-challenge
Length of output: 656
🏁 Script executed:
Repository: PlatformNetwork/bounty-challenge
Length of output: 761
🏁 Script executed:
Repository: PlatformNetwork/bounty-challenge
Length of output: 430
🏁 Script executed:
cat ./bins/bounty-cli/src/main.rs | head -100Repository: PlatformNetwork/bounty-challenge
Length of output: 2560
🏁 Script executed:
rg "use " ./bins/bounty-cli/src/tui/mod.rsRepository: PlatformNetwork/bounty-challenge
Length of output: 58
🏁 Script executed:
Repository: PlatformNetwork/bounty-challenge
Length of output: 1365
🏁 Script executed:
cat ./bins/bounty-cli/src/tui/leaderboard.rs | head -30Repository: PlatformNetwork/bounty-challenge
Length of output: 756
🏁 Script executed:
rg "set_handler" ./bins/bounty-cli/Repository: PlatformNetwork/bounty-challenge
Length of output: 143
🏁 Script executed:
rg "Terminal<" ./bins/bounty-cli/src/Repository: PlatformNetwork/bounty-challenge
Length of output: 184
🏁 Script executed:
rg "Modifier" ./bins/bounty-cli/src/Repository: PlatformNetwork/bounty-challenge
Length of output: 201
🏁 Script executed:
rg "Event" ./bins/bounty-cli/src/tui/mod.rsRepository: PlatformNetwork/bounty-challenge
Length of output: 116
🏁 Script executed:
rg "struct Modifier|type Modifier|enum Modifier" ./bins/bounty-cli/Repository: PlatformNetwork/bounty-challenge
Length of output: 58
🏁 Script executed:
rg "^use.*Modifier" ./bins/bounty-cli/Repository: PlatformNetwork/bounty-challenge
Length of output: 58
Remove
set_handlercall — method does not exist in ratatui 0.29.0.Terminal in ratatui 0.29.0 has no
set_handlermethod. Events must be handled separately usingcrossterm::event::read()in an event loop. Additionally,ModifierandEventare not imported; if importing from crossterm, useKeyModifiers::CONTROL(notModifier::CONTROL) for crossterm 0.28.0.🤖 Prompt for AI Agents