22
33from textual .widget import Widget
44from textual .app import ComposeResult
5- from textual .widgets import Label , Input
5+ from textual .widgets import Label , TextArea
66from textual .reactive import reactive
7+ from textual .binding import Binding
78
89from agent_chat_cli .components .caret import Caret
910from agent_chat_cli .components .flex import Flex
@@ -20,6 +21,10 @@ class ToolPermissionPrompt(Widget):
2021 tool_name = reactive ("" )
2122 tool_input : dict [str , Any ] = reactive ({}, init = False ) # type: ignore[assignment]
2223
24+ BINDINGS = [
25+ Binding ("enter" , "submit" , "Submit" , priority = True ),
26+ ]
27+
2328 def __init__ (self , actions : "Actions" ) -> None :
2429 super ().__init__ ()
2530 self .actions = actions
@@ -32,14 +37,20 @@ def compose(self) -> ComposeResult:
3237
3338 with Flex ():
3439 yield Caret ()
35- yield Input (placeholder = "Yes" , id = "permission-input" )
40+ yield TextArea (
41+ "" ,
42+ show_line_numbers = False ,
43+ soft_wrap = True ,
44+ placeholder = "Yes" ,
45+ id = "permission-input" ,
46+ )
3647
3748 def watch_is_visible (self , is_visible : bool ) -> None :
3849 self .display = is_visible
3950
4051 if is_visible :
41- input_widget = self .query_one ("#permission-input" , Input )
42- input_widget .value = ""
52+ input_widget = self .query_one ("#permission-input" , TextArea )
53+ input_widget .clear ()
4354 input_widget .focus ()
4455
4556 def watch_tool_name (self , tool_name : str ) -> None :
@@ -59,24 +70,25 @@ def watch_tool_name(self, tool_name: str) -> None:
5970
6071 tool_display_label .update (tool_display )
6172
62- async def on_input_submitted (self , event : Input .Submitted ) -> None :
63- raw_value = event .value
64- response = event .value .strip () or "yes"
73+ async def action_submit (self ) -> None :
74+ input_widget = self .query_one ("#permission-input" , TextArea )
75+ raw_value = input_widget .text
76+ response = raw_value .strip () or "yes"
6577
6678 log_json (
6779 {
6880 "event" : "permission_input_submitted" ,
6981 "raw_value" : raw_value ,
70- "stripped_value" : event . value .strip (),
82+ "stripped_value" : raw_value .strip (),
7183 "final_response" : response ,
7284 }
7385 )
7486
7587 await self .actions .respond_to_tool_permission (response )
7688
77- async def on_input_blurred (self , event : Input . Blurred ) -> None :
89+ def on_descendant_blur (self ) -> None :
7890 if self .is_visible :
79- input_widget = self .query_one ("#permission-input" , Input )
91+ input_widget = self .query_one ("#permission-input" , TextArea )
8092 input_widget .focus ()
8193
8294 async def on_key (self , event ) -> None :
@@ -86,7 +98,8 @@ async def on_key(self, event) -> None:
8698 event .stop ()
8799 event .prevent_default ()
88100
89- input_widget = self .query_one ("#permission-input" , Input )
90- input_widget .value = "no"
101+ input_widget = self .query_one ("#permission-input" , TextArea )
102+ input_widget .clear ()
103+ input_widget .insert ("no" )
91104
92- await input_widget .action_submit ()
105+ await self .action_submit ()
0 commit comments