@@ -93,7 +93,7 @@ def get_file_content(
9393 fname : str ,
9494 generate_stub : bool = False ,
9595 context_management_enabled : bool = False ,
96- large_file_token_threshold : int = 1000 ,
96+ large_file_token_threshold : int = 8192 ,
9797 ) -> Optional [str ]:
9898 """
9999 Get file content with optional stub generation for large files.
@@ -111,7 +111,6 @@ def get_file_content(
111111 File content, stub for large files, or None if file cannot be read
112112 """
113113 abs_fname = os .path .abspath (fname )
114-
115114 # First, ensure file is in cache (read-through cache)
116115 if abs_fname not in cls ._file_contents_original :
117116 cls .add_file (fname )
@@ -129,14 +128,14 @@ def get_file_content(
129128 if not context_management_enabled :
130129 return content
131130
131+ coder = cls .get_coder ()
132+
132133 # Check if file is large
133- content_length = len (content )
134+ content_length = coder . main_model . token_count (content )
134135
135136 if content_length <= large_file_token_threshold :
136137 return content
137138
138- # File is large, generate stub
139- coder = cls .get_coder ()
140139 # Use RepoMap to generate file stub
141140 return RepoMap .get_file_stub (fname , coder .io , line_numbers = True )
142141
@@ -181,6 +180,7 @@ def generate_diff(cls, fname: str) -> Optional[str]:
181180
182181 # Read current content using coder.io.read_text()
183182 coder = cls .get_coder ()
183+ rel_fname = coder .get_rel_fname (fname )
184184 try :
185185 current_content = coder .io .read_text (abs_fname )
186186 except Exception :
@@ -199,8 +199,8 @@ def generate_diff(cls, fname: str) -> Optional[str]:
199199 diff_lines = difflib .unified_diff (
200200 snapshot_content .splitlines (),
201201 current_content .splitlines (),
202- fromfile = f"{ abs_fname } (snapshot)" ,
203- tofile = f"{ abs_fname } (current)" ,
202+ fromfile = f"{ rel_fname } (snapshot)" ,
203+ tofile = f"{ rel_fname } (current)" ,
204204 lineterm = "" ,
205205 n = 3 ,
206206 )
@@ -224,20 +224,25 @@ def update_file_diff(cls, fname: str) -> Optional[str]:
224224 Returns:
225225 Diff string or None if no changes
226226 """
227+ coder = cls .get_coder ()
227228 diff = cls .generate_diff (fname )
229+
228230 if diff :
229231 # Store diff
230232 abs_fname = os .path .abspath (fname )
231233 cls ._file_diffs [abs_fname ] = diff
232234
235+ rel_fname = fname
236+
237+ if coder :
238+ rel_fname = coder .get_rel_fname (fname )
239+
233240 # Add diff message to conversation
234241 diff_message = {
235242 "role" : "user" ,
236- "content" : f"File { fname } has changed:\n \n { diff } " ,
243+ "content" : f"File { rel_fname } has changed:\n \n { diff } " ,
237244 }
238245
239- # Determine tag based on file type
240- coder = cls .get_coder ()
241246 if coder and hasattr (coder , "abs_fnames" ):
242247 tag = (
243248 MessageTag .EDIT_FILES
0 commit comments