@@ -381,6 +381,7 @@ def __init__(
381381 map_cache_dir = "." ,
382382 repomap_in_memory = False ,
383383 preserve_todo_list = False ,
384+ linear_output = False ,
384385 ):
385386 # initialize from args.map_cache_dir
386387 self .map_cache_dir = map_cache_dir
@@ -469,6 +470,7 @@ def __init__(
469470
470471 self .dry_run = dry_run
471472 self .pretty = self .io .pretty
473+ self .linear_output = linear_output
472474
473475 self .main_model = main_model
474476
@@ -1058,12 +1060,67 @@ async def run(self, with_message=None, preproc=True):
10581060 while self .io .confirmation_in_progress :
10591061 await asyncio .sleep (0.1 ) # Yield control and wait briefly
10601062
1063+ if self .linear_output :
1064+ return await self ._run_linear (with_message , preproc )
1065+
10611066 if self .io .prompt_session :
10621067 with patch_stdout (raw = True ):
10631068 return await self ._run_patched (with_message , preproc )
10641069 else :
10651070 return await self ._run_patched (with_message , preproc )
10661071
1072+ async def _run_linear (self , with_message = None , preproc = True ):
1073+ try :
1074+ if with_message :
1075+ self .io .user_input (with_message )
1076+ await self .run_one (with_message , preproc )
1077+ return self .partial_response_content
1078+
1079+ user_message = None
1080+ await self .io .cancel_input_task ()
1081+ await self .io .cancel_processing_task ()
1082+
1083+ while True :
1084+ try :
1085+ if self .commands .cmd_running :
1086+ await asyncio .sleep (0.1 )
1087+ continue
1088+
1089+ if not self .suppress_announcements_for_next_prompt :
1090+ self .show_announcements ()
1091+ self .suppress_announcements_for_next_prompt = True
1092+
1093+ self .io .input_task = asyncio .create_task (self .get_input ())
1094+ await asyncio .sleep (0 )
1095+ await self .io .input_task
1096+ user_message = self .io .input_task .result ()
1097+
1098+ self .io .processing_task = asyncio .create_task (
1099+ self ._processing_logic (user_message , preproc )
1100+ )
1101+
1102+ await self .io .processing_task
1103+
1104+ self .io .ring_bell ()
1105+ user_message = None
1106+ except KeyboardInterrupt :
1107+ if self .io .input_task :
1108+ self .io .set_placeholder ("" )
1109+ await self .io .cancel_input_task ()
1110+
1111+ if self .io .processing_task :
1112+ await self .io .cancel_processing_task ()
1113+ self .io .stop_spinner ()
1114+
1115+ self .keyboard_interrupt ()
1116+ except (asyncio .CancelledError , IndexError ):
1117+ pass
1118+ except EOFError :
1119+ return
1120+ finally :
1121+ await self .io .cancel_input_task ()
1122+ await self .io .cancel_processing_task ()
1123+
10671124 async def _run_patched (self , with_message = None , preproc = True ):
10681125 try :
10691126 if with_message :
0 commit comments