1818 TimeRemainingColumn ,
1919)
2020from rich .syntax import Syntax
21+ from rich .table import Column
2122
2223from .config import ConfigManager , Config
2324from .services import QdrantClient , DockerManager , EmbeddingProviderFactory
2930
3031class GracefulInterruptHandler :
3132 """Handler for graceful interruption of long-running operations."""
32-
33+
3334 def __init__ (self , console : Console , operation_name : str = "Operation" ):
3435 self .console = console
3536 self .operation_name = operation_name
3637 self .interrupted = False
3738 self .original_sigint_handler = None
3839 self .progress_bar = None
39-
40+
4041 def __enter__ (self ):
41- self .original_sigint_handler = signal .signal (signal .SIGINT , self ._signal_handler )
42+ self .original_sigint_handler = signal .signal (
43+ signal .SIGINT , self ._signal_handler
44+ )
4245 return self
43-
46+
4447 def __exit__ (self , exc_type , exc_val , exc_tb ):
4548 # Restore original signal handler
4649 signal .signal (signal .SIGINT , self .original_sigint_handler )
47-
50+
4851 # If we were interrupted, show final message
4952 if self .interrupted :
5053 if self .progress_bar :
5154 self .progress_bar .stop ()
5255 self .console .print () # New line
53- self .console .print (f"🛑 { self .operation_name } interrupted by user" , style = "yellow" )
54- self .console .print ("📊 Progress has been saved and can be resumed later" , style = "cyan" )
56+ self .console .print (
57+ f"🛑 { self .operation_name } interrupted by user" , style = "yellow"
58+ )
59+ self .console .print (
60+ "📊 Progress has been saved and can be resumed later" , style = "cyan"
61+ )
5562 return True # Suppress the KeyboardInterrupt exception
56-
63+
5764 def _signal_handler (self , signum , frame ):
5865 """Handle SIGINT (Ctrl-C) gracefully."""
5966 self .interrupted = True
6067 if self .progress_bar :
6168 self .progress_bar .stop ()
6269 self .console .print () # New line
63- self .console .print (f"🛑 Interrupting { self .operation_name .lower ()} ..." , style = "yellow" )
64- self .console .print ("⏳ Finishing current file and saving progress..." , style = "cyan" )
65-
70+ self .console .print (
71+ f"🛑 Interrupting { self .operation_name .lower ()} ..." , style = "yellow"
72+ )
73+ self .console .print (
74+ "⏳ Finishing current file and saving progress..." , style = "cyan"
75+ )
76+
6677 def set_progress_bar (self , progress_bar ):
6778 """Set the progress bar to stop when interrupted."""
6879 self .progress_bar = progress_bar
@@ -700,12 +711,15 @@ def progress_callback(current, total, file_path, error=None, info=None):
700711 "•" ,
701712 TimeRemainingColumn (),
702713 "•" ,
703- TextColumn ("[cyan]{task.description}" , no_wrap = False ),
714+ TextColumn (
715+ "[cyan]{task.description}" ,
716+ table_column = Column (no_wrap = False , overflow = "fold" ),
717+ ),
704718 console = console ,
705719 )
706720 progress_bar .start ()
707721 task_id = progress_bar .add_task ("Starting..." , total = total )
708-
722+
709723 # Register progress bar with interrupt handler
710724 if interrupt_handler :
711725 interrupt_handler .set_progress_bar (progress_bar )
@@ -741,9 +755,7 @@ def progress_callback(current, total, file_path, error=None, info=None):
741755
742756 # Check for conflicting flags
743757 if clear and reconcile :
744- console .print (
745- "❌ Cannot use --clear and --reconcile together" , style = "red"
746- )
758+ console .print ("❌ Cannot use --clear and --reconcile together" , style = "red" )
747759 sys .exit (1 )
748760
749761 # Use graceful interrupt handling for the indexing operation
@@ -752,11 +764,11 @@ def progress_callback(current, total, file_path, error=None, info=None):
752764 operation_name = "Reconciliation"
753765 elif clear :
754766 operation_name = "Full reindexing"
755-
767+
756768 try :
757769 with GracefulInterruptHandler (console , operation_name ) as handler :
758770 interrupt_handler = handler
759-
771+
760772 stats = smart_indexer .smart_index (
761773 force_full = clear ,
762774 reconcile_with_database = reconcile ,
@@ -866,7 +878,10 @@ def progress_callback(
866878 "•" ,
867879 TimeRemainingColumn (),
868880 "•" ,
869- TextColumn ("[cyan]{task.description}" , no_wrap = False ),
881+ TextColumn (
882+ "[cyan]{task.description}" ,
883+ table_column = Column (no_wrap = False , overflow = "fold" ),
884+ ),
870885 console = console ,
871886 )
872887 progress_bar .start ()
@@ -1011,7 +1026,10 @@ def process_changes():
10111026 "•" ,
10121027 TimeElapsedColumn (),
10131028 "•" ,
1014- TextColumn ("[cyan]{task.description}" , no_wrap = False ),
1029+ TextColumn (
1030+ "[cyan]{task.description}" ,
1031+ table_column = Column (no_wrap = False , overflow = "fold" ),
1032+ ),
10151033 console = console ,
10161034 )
10171035 batch_progress .start ()
@@ -1145,7 +1163,10 @@ def process_changes():
11451163
11461164 try :
11471165 with GracefulInterruptHandler (console , "File watching" ) as handler :
1148- console .print ("👀 Watching for file changes... (Press Ctrl-C to stop)" , style = "dim" )
1166+ console .print (
1167+ "👀 Watching for file changes... (Press Ctrl-C to stop)" ,
1168+ style = "dim" ,
1169+ )
11491170 while not handler .interrupted :
11501171 time .sleep (1 )
11511172 except KeyboardInterrupt :
0 commit comments