-
Notifications
You must be signed in to change notification settings - Fork 27
Fix: [BUG] [v1.1.0] Auxiliary sidebar resize handle: no hover highlight after resize if pointer re-entered while dragging #39607
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
0991977
18a9238
e985d63
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 | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -21,6 +21,8 @@ struct App { | |||||||||||||||||||||
| entries: Vec<LeaderboardEntry>, | ||||||||||||||||||||||
| scroll_offset: usize, | ||||||||||||||||||||||
| error: Option<String>, | ||||||||||||||||||||||
| is_resizing: bool, | ||||||||||||||||||||||
| last_mouse_position: (u16, u16), | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| fn parse_entries(data: &Value) -> Vec<LeaderboardEntry> { | ||||||||||||||||||||||
|
|
@@ -121,7 +123,11 @@ fn ui(frame: &mut Frame, app: &App) { | |||||||||||||||||||||
| .border_style(Style::default().fg(Color::Cyan)) | ||||||||||||||||||||||
| .title(title), | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| .row_highlight_style(Style::default().bg(Color::DarkGray)); | ||||||||||||||||||||||
| .row_highlight_style(Style::default().bg(if app.is_resizing { | ||||||||||||||||||||||
| Color::DarkGray | ||||||||||||||||||||||
| } else { | ||||||||||||||||||||||
| Color::DarkGray | ||||||||||||||||||||||
| })); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| frame.render_widget(table, chunks[0]); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
@@ -137,6 +143,8 @@ pub async fn run(rpc_url: &str) -> Result<()> { | |||||||||||||||||||||
| entries: vec![], | ||||||||||||||||||||||
| scroll_offset: 0, | ||||||||||||||||||||||
| error: None, | ||||||||||||||||||||||
| is_resizing: false, | ||||||||||||||||||||||
| last_mouse_position: (0, 0), | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| let mut last_fetch = Instant::now() - Duration::from_secs(10); | ||||||||||||||||||||||
|
|
@@ -172,10 +180,16 @@ pub async fn run(rpc_url: &str) -> Result<()> { | |||||||||||||||||||||
| _ => {} | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } else if let Event::Mouse(mouse) = event::read()? { | ||||||||||||||||||||||
| if mouse.kind == event::MouseEventKind::Down { | ||||||||||||||||||||||
| app.is_resizing = true; | ||||||||||||||||||||||
| } else if mouse.kind == event::MouseEventKind::Up { | ||||||||||||||||||||||
| app.is_resizing = false; | ||||||||||||||||||||||
| } else if mouse.kind == event::MouseEventKind::Moved { | ||||||||||||||||||||||
| app.last_mouse_position = (mouse.column, mouse.row); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+183
to
191
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. Critical: Double Line 168 calls The pattern should match on the already-read event, not read again: π Proposed fix if event::poll(Duration::from_millis(100))? {
- if let Event::Key(key) = event::read()? {
+ match event::read()? {
+ Event::Key(key) => {
if key.kind == KeyEventKind::Press {
match key.code {
KeyCode::Char('q') | KeyCode::Esc => break,
KeyCode::Up | KeyCode::Char('k') => {
app.scroll_offset = app.scroll_offset.saturating_sub(1);
}
KeyCode::Down | KeyCode::Char('j') => {
if app.scroll_offset + 1 < app.entries.len() {
app.scroll_offset += 1;
}
}
_ => {}
}
}
- } else if let Event::Mouse(mouse) = event::read()? {
+ }
+ Event::Mouse(mouse) => {
if mouse.kind == event::MouseEventKind::Down {
app.is_resizing = true;
} else if mouse.kind == event::MouseEventKind::Up {
app.is_resizing = false;
} else if mouse.kind == event::MouseEventKind::Moved {
app.last_mouse_position = (mouse.column, mouse.row);
}
+ }
+ _ => {}
}
}π€ Prompt for AI Agents |
||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| super::restore_terminal(&mut terminal)?; | ||||||||||||||||||||||
| Ok(()) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
193
to
+195
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. Critical: Missing The function calls Compare with π Proposed fix }
}
+ super::restore_terminal(&mut terminal)?;
Ok(())
}π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ pub mod weights; | |
|
|
||
| use anyhow::Result; | ||
| use crossterm::{ | ||
| event::{self, DisableMouseCapture, EnableMouseCapture}, | ||
| execute, | ||
| terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, | ||
| }; | ||
|
|
@@ -13,15 +14,36 @@ use std::io; | |
| pub fn setup_terminal() -> Result<Terminal<CrosstermBackend<io::Stdout>>> { | ||
| enable_raw_mode()?; | ||
| let mut stdout = io::stdout(); | ||
| execute!(stdout, EnterAlternateScreen)?; | ||
| execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?; | ||
| let backend = CrosstermBackend::new(stdout); | ||
| let terminal = Terminal::new(backend)?; | ||
| Ok(terminal) | ||
| } | ||
|
|
||
| pub fn restore_terminal(terminal: &mut Terminal<CrosstermBackend<io::Stdout>>) -> Result<()> { | ||
| disable_raw_mode()?; | ||
| execute!(terminal.backend_mut(), LeaveAlternateScreen)?; | ||
| execute!(terminal.backend_mut(), LeaveAlternateScreen, DisableMouseCapture)?; | ||
| terminal.show_cursor()?; | ||
| Ok(()) | ||
| } | ||
|
|
||
| pub fn handle_events(terminal: &mut Terminal<CrosstermBackend<io::Stdout>>, is_resizing: &mut bool) -> Result<()> { | ||
| loop { | ||
| if let event::Event::Mouse(event) = event::read()? { | ||
| match event.kind { | ||
| event::MouseEventKind::Moved => { | ||
| // Handle mouse move event | ||
| } | ||
| event::MouseEventKind::Pressed(_) => { | ||
| *is_resizing = true; | ||
| // Handle mouse press event | ||
| } | ||
| event::MouseEventKind::Released(_) => { | ||
| *is_resizing = false; | ||
| // Handle mouse release event | ||
| } | ||
| _ => {} | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+30
to
+48
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. π§© Analysis chainπ Web query:
π‘ Result: The MouseEventKind enum in crossterm 0.28 has the following variants: pub enum MouseEventKind { Down(MouseButton), Up(MouseButton), Drag(MouseButton), Moved, ScrollDown, ScrollUp, ScrollLeft, ScrollRight, } Citations:
π Script executed: cat bins/bounty-cli/src/tui/mod.rsRepository: PlatformNetwork/bounty-challenge Length of output: 1652 π Script executed: rg "handle_events" --type rsRepository: PlatformNetwork/bounty-challenge Length of output: 102 π Script executed: rg "handle_events"Repository: PlatformNetwork/bounty-challenge Length of output: 222 π Script executed: cat bins/bounty-cli/src/tui/stats.rs | head -200Repository: PlatformNetwork/bounty-challenge Length of output: 5271 π Script executed: cat bins/bounty-cli/src/tui/leaderboard.rs | head -200Repository: PlatformNetwork/bounty-challenge Length of output: 6365 Critical: This function has multiple critical issues:
π€ Prompt for AI Agents |
||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -65,7 +65,7 @@ fn stat_block<'a>(label: &'a str, value: u64, color: Color) -> Paragraph<'a> { | |||||||
| ) | ||||||||
| } | ||||||||
|
|
||||||||
| fn ui(frame: &mut Frame, stats: &StatsData, error: &Option<String>) { | ||||||||
| fn ui(frame: &mut Frame, stats: &StatsData, error: &Option<String>, is_resizing: bool) { | ||||||||
| let outer = Layout::default() | ||||||||
| .direction(Direction::Vertical) | ||||||||
| .constraints([ | ||||||||
|
|
@@ -117,13 +117,21 @@ fn ui(frame: &mut Frame, stats: &StatsData, error: &Option<String>) { | |||||||
| .style(Style::default().fg(Color::DarkGray)) | ||||||||
| .block(Block::default().borders(Borders::ALL)); | ||||||||
| frame.render_widget(help, outer[2]); | ||||||||
|
|
||||||||
| if is_resizing { | ||||||||
| let resize_text = Paragraph::new("Resizing...") | ||||||||
| .style(Style::default().fg(Color::Red).bold()) | ||||||||
| .block(Block::default().borders(Borders::ALL)); | ||||||||
| frame.render_widget(resize_text, outer[2]); | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| pub async fn run(rpc_url: &str) -> Result<()> { | ||||||||
| let mut terminal = super::setup_terminal()?; | ||||||||
| let mut stats = StatsData::default(); | ||||||||
| let mut error: Option<String> = None; | ||||||||
| let mut last_fetch = Instant::now() - Duration::from_secs(10); | ||||||||
| let mut is_resizing = false; | ||||||||
|
|
||||||||
| loop { | ||||||||
| if last_fetch.elapsed() >= Duration::from_secs(5) { | ||||||||
|
|
@@ -137,7 +145,7 @@ pub async fn run(rpc_url: &str) -> Result<()> { | |||||||
| last_fetch = Instant::now(); | ||||||||
| } | ||||||||
|
|
||||||||
| terminal.draw(|f| ui(f, &stats, &error))?; | ||||||||
| terminal.draw(|f| ui(f, &stats, &error, is_resizing))?; | ||||||||
|
|
||||||||
| if event::poll(Duration::from_millis(100))? { | ||||||||
| if let Event::Key(key) = event::read()? { | ||||||||
|
|
@@ -146,10 +154,17 @@ pub async fn run(rpc_url: &str) -> Result<()> { | |||||||
| { | ||||||||
| break; | ||||||||
| } | ||||||||
| } else if let Event::Mouse(event) = event::read()? { | ||||||||
| if event.kind == MouseEventKind::Down { | ||||||||
|
Comment on lines
+157
to
+158
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. Missing import for
π§ Suggested fix - add to imports-use crossterm::event::{self, Event, KeyCode, KeyEventKind};
+use crossterm::event::{self, Event, KeyCode, KeyEventKind, MouseEventKind};π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||||
| is_resizing = true; | ||||||||
| } else if event.kind == MouseEventKind::Up { | ||||||||
| is_resizing = false; | ||||||||
| terminal.draw(|f| ui(f, &stats, &error, is_resizing))?; | ||||||||
| } | ||||||||
| } | ||||||||
|
Comment on lines
+157
to
164
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. Critical: Double Same issue as in π Proposed fix if event::poll(Duration::from_millis(100))? {
- if let Event::Key(key) = event::read()? {
+ match event::read()? {
+ Event::Key(key) => {
if key.kind == KeyEventKind::Press
&& matches!(key.code, KeyCode::Char('q') | KeyCode::Esc)
{
break;
}
- } else if let Event::Mouse(event) = event::read()? {
+ }
+ Event::Mouse(event) => {
if event.kind == MouseEventKind::Down {
is_resizing = true;
} else if event.kind == MouseEventKind::Up {
is_resizing = false;
terminal.draw(|f| ui(f, &stats, &error, is_resizing))?;
}
+ }
+ _ => {}
}
}π€ Prompt for AI Agents |
||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| super::restore_terminal(&mut terminal)?; | ||||||||
| 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.
Conditional always returns the same value.
Both branches of the
if app.is_resizingconditional returnColor::DarkGray, making the conditional meaningless. This appears to be incomplete implementation or copy-paste error.π§ Suggested fix - either remove the conditional or differentiate colors
.row_highlight_style(Style::default().bg(if app.is_resizing { - Color::DarkGray + Color::Gray // or another distinct color during resize } else { Color::DarkGray }));Or simply:
π Committable suggestion
π€ Prompt for AI Agents