Fixing prompt cancelation
This commit is contained in:
parent
4f4e686ca1
commit
3babef4276
@ -111,6 +111,7 @@ class HendrikTUI:
|
||||
curses.use_default_colors()
|
||||
init_colors()
|
||||
stdscr.keypad(True)
|
||||
curses.raw() # Ctrl+C sebagai key code 3, bukan SIGINT → KeyboardInterrupt
|
||||
stdscr.refresh()
|
||||
|
||||
self.messages = [{"role": "system", "content": self.build_system_prompt(
|
||||
@ -140,7 +141,12 @@ class HendrikTUI:
|
||||
try:
|
||||
key = stdscr.getch()
|
||||
except KeyboardInterrupt:
|
||||
break
|
||||
if self.processing:
|
||||
self.llm.cancel_requested = True
|
||||
self.agent_done.set()
|
||||
else:
|
||||
break
|
||||
key = -1
|
||||
|
||||
handle_key(self, stdscr, key)
|
||||
|
||||
|
||||
@ -39,9 +39,9 @@ def handle_key(app, stdscr, key):
|
||||
processing = app.processing
|
||||
|
||||
# -- Always allowed (even during processing) --
|
||||
if key == 3: # Ctrl+C → cancel stream jika processing, exit jika tidak
|
||||
# Check for Ctrl+C (key 3) and also potential curses representation of Ctrl+C
|
||||
if key == 3 or key == 26: # 3 is Ctrl+C, 26 is Ctrl+Z (sometimes mapped)
|
||||
if processing:
|
||||
# Cancel stream yang sedang berjalan
|
||||
app.llm.cancel_requested = True
|
||||
log(app, "system", " Stream cancelled by user")
|
||||
else:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user