55import os
66import re
77
8- COMPLETER_PATTERN = re .compile (r"[A-z0 -9-_.]+" )
8+ COMPLETER_PATTERN = re .compile (r"[a-zA-Z0 -9-_.]+" )
99
1010
1111class JumpCompleter (Completer ):
@@ -120,6 +120,7 @@ def __init__(self, message_handler=None):
120120 self .agent_completer = AgentCompleter ()
121121 self .jump_completer = JumpCompleter (message_handler )
122122 self .mcp_completer = MCPCompleter (message_handler )
123+ self .drop_completer = DropCompleter (message_handler )
123124
124125 def get_completions (self , document , complete_event ):
125126 text = document .text
@@ -137,6 +138,8 @@ def get_completions(self, document, complete_event):
137138 yield from self .mcp_completer .get_completions (document , complete_event )
138139 elif text .startswith ("/file " ):
139140 yield from self .file_completer .get_completions (document , complete_event )
141+ elif text .startswith ("/drop " ):
142+ yield from self .drop_completer .get_completions (document , complete_event )
140143 elif text .startswith ("/" ):
141144 yield from self .get_command_completions (document )
142145
@@ -169,6 +172,7 @@ def get_command_completions(self, document):
169172 "List MCP prompts or fetch specific prompt (usage: /mcp [server_id/prompt_name])" ,
170173 ),
171174 ("/file" , "Process a file (usage: /file <path>)" ),
175+ ("/drop" , "Remove a queued file from processing (usage: /drop <file_id>)" ),
172176 ("/list" , "List available conversations" ),
173177 ("/load" , "Load a conversation (usage: /load <conversation_id>)" ),
174178 ("/help" , "Show help message" ),
@@ -219,6 +223,43 @@ def get_completions(self, document, complete_event):
219223 )
220224
221225
226+ class DropCompleter (Completer ):
227+ """Completer that shows available queued files when typing /drop command."""
228+
229+ def __init__ (self , message_handler = None ):
230+ self .message_handler = message_handler
231+
232+ def get_completions (self , document , complete_event ):
233+ text = document .text
234+
235+ # Only provide completions for the /drop command
236+ if text .startswith ("/drop " ):
237+ word_before_cursor = document .get_word_before_cursor (
238+ pattern = COMPLETER_PATTERN
239+ )
240+
241+ # Get all queued attached files
242+ queued_files = (
243+ self .message_handler ._queued_attached_files
244+ if self .message_handler
245+ else []
246+ )
247+
248+ # Extract file paths from queued files and create completions
249+ for file_path in queued_files :
250+ if file_path .startswith (word_before_cursor ):
251+ yield Completion (
252+ file_path ,
253+ start_position = - len (word_before_cursor ),
254+ display = file_path ,
255+ )
256+ elif word_before_cursor .startswith ("drop" ):
257+ yield Completion (
258+ file_path ,
259+ display = file_path ,
260+ )
261+
262+
222263class DirectoryListingCompleter (Completer ):
223264 def __init__ (self ):
224265 # Use PathCompleter for the heavy lifting
@@ -230,7 +271,7 @@ def get_completions(self, document, complete_event):
230271 return
231272 # Look for patterns that might indicate a path
232273 # This regex searches for a potential directory path
233- path_match = re .search (r"((~|\.{1,2})?/[^\s]*|~)$" , text )
274+ path_match = re .search (r"((~|\.{1,2})?/[^\s/ ]*|~)$" , text )
234275
235276 if path_match :
236277 path = path_match .group (0 )
0 commit comments