Skip to content

Commit

Permalink
[burn-train] Fix keys not working reliably to change metrics in termi…
Browse files Browse the repository at this point in the history
…nal UI (tracel-ai#1101)

* Exit event handler if KeyEvent is of release kind

* Switch logic to return on press

---------

Co-authored-by: Dilshod Tadjibaev <[email protected]>
  • Loading branch information
amfaber and antimora authored Jan 31, 2024
1 parent b7486b0 commit ff222b0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion burn-train/src/renderer/tui/metric_numeric.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::renderer::TrainingProgress;

use super::{FullHistoryPlot, RecentHistoryPlot, TerminalFrame};
use crossterm::event::{Event, KeyCode};
use crossterm::event::{Event, KeyCode, KeyEventKind};
use ratatui::{
prelude::{Alignment, Constraint, Direction, Layout, Rect},
style::{Color, Modifier, Style, Stylize},
Expand Down Expand Up @@ -107,6 +107,10 @@ impl NumericMetricsState {
/// Handle the current event.
pub(crate) fn on_event(&mut self, event: &Event) {
if let Event::Key(key) = event {
match key.kind {
KeyEventKind::Release | KeyEventKind::Repeat => (),
KeyEventKind::Press => return,
}
match key.code {
KeyCode::Right => self.next_metric(),
KeyCode::Left => self.previous_metric(),
Expand Down

0 comments on commit ff222b0

Please sign in to comment.