From 17e3ad347a9d8f8e26dffc421f3f4bcd011aa8d3 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Wed, 4 Mar 2026 17:03:58 -0700 Subject: [PATCH] fix: Disable key debounce for text input entry and typing Co-authored-by: aider (gemini/gemini-2.5-pro) --- main.py | 5 +++-- tui.py | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 39aa30e..d95cf4a 100755 --- a/main.py +++ b/main.py @@ -45,13 +45,14 @@ def main_loop(stdscr): while True: c = stdscr.getch() if c != curses.ERR: + current_screen = screens[state.current_screen] # Rate limit key presses unless in a text input field - if not screens[state.current_screen].is_typing and time.time() < state.last_key_time + 1: + if not current_screen.is_typing and not current_screen.is_entry_key(c) and time.time() < state.last_key_time + 1: pass # Key press ignored due to rate limit else: state.c = c state.last_key_time = time.time() - screens[state.current_screen].handle_input(c) + current_screen.handle_input(c) if state.current_screen != state.prev_screen: logging.info('Switching to screen: %s', state.current_screen) diff --git a/tui.py b/tui.py index 2af0035..f90d642 100644 --- a/tui.py +++ b/tui.py @@ -44,6 +44,9 @@ class Screen: except: return None + def is_entry_key(self, c): + return False + def try_highlight(self, c): if c and time.time() - self.state.highlight_debounce > 0.6: self.state.highlight_debounce = time.time() @@ -394,6 +397,10 @@ class SignScreen(Screen): self.sign_to_send = '_' else: self.try_highlight(c) + def is_entry_key(self, c): + button = self.get_button(c) + return not self.is_typing and button == 'e' + class ProtovacSignScreen(Screen): def draw(self): self.stdscr.addstr(0, 1, 'PROTOVAC UNIVERSAL COMPUTER') @@ -541,6 +548,10 @@ class NametagScreen(Screen): elif button == 'g': self.nametag_guest = '_' else: self.try_highlight(c) + def is_entry_key(self, c): + button = self.get_button(c) + return not (self.nametag_member or self.nametag_guest) and button in ['m', 'g'] + class LabelScreen(Screen): # This screen is complex, breaking it down into sub-states def __init__(self, state, stdscr): @@ -688,6 +699,12 @@ class LabelScreen(Screen): else: self.try_highlight(c) else: self.try_highlight(c) + def is_entry_key(self, c): + if self.sub_screen == 'menu': + button = self.get_button(c) + return button in ['t', 's', 'g', 'c', 'f'] + return False + class GamesScreen(Screen): def draw(self): @@ -785,6 +802,10 @@ I will be terse in my responses.''')] elif button == 'e': self.is_typing = True; self.message_to_send = '_' else: self.try_highlight(c) + def is_entry_key(self, c): + button = self.get_button(c) + return not self.is_typing and button == 'e' + class ThinkScreen(Screen): def __init__(self, state, stdscr): @@ -855,6 +876,10 @@ class ThinkScreen(Screen): elif button == 'e': self.is_typing = True; self.think_to_send = '_' else: self.try_highlight(c) + def is_entry_key(self, c): + button = self.get_button(c) + return not self.is_typing and button == 'e' + class AboutScreen(Screen): def draw(self): self.stdscr.addstr(0, 1, 'PROTOVAC UNIVERSAL COMPUTER')