@@ -225,7 +225,7 @@ def generate_summary(messages: list, cwd: str) -> str:
225225 return ""
226226
227227
228- def save_summary (cwd : str , summary : str , timestamp : str , session_id : str ):
228+ def save_summary (cwd : str , summary : str , timestamp : str , session_id : str , session_file : str = "" ):
229229 """Save summary to session-summary directory with session ID.
230230
231231 NOTE: This function is paired with `session_summary.py` which reads these files
@@ -241,6 +241,7 @@ def save_summary(cwd: str, summary: str, timestamp: str, session_id: str):
241241 summary: Summary text
242242 timestamp: Timestamp string (YYYYMMDD-HHMMSS)
243243 session_id: Session ID
244+ session_file: Path to the full session file (relative to cwd)
244245 """
245246 if not summary or not session_id :
246247 return
@@ -257,10 +258,15 @@ def save_summary(cwd: str, summary: str, timestamp: str, session_id: str):
257258 # Use existing file or create new one with timestamp
258259 summary_file = existing_file or summary_dir / f"{ timestamp } -summary-ID_{ session_id } .md"
259260
261+ # Append session file reference if available
262+ content = summary
263+ if session_file :
264+ content = f"{ summary } \n \n Full session: { session_file } "
265+
260266 try :
261267 # Always overwrite summary (update, don't append)
262268 with open (summary_file , "w" ) as f :
263- f .write (summary )
269+ f .write (content )
264270 os .chmod (summary_file , 0o600 )
265271 print (f"✓ Summary saved to { summary_file .name } " , file = sys .stderr )
266272 except Exception as e :
@@ -322,7 +328,9 @@ def save_session(cwd: str, messages: list, session_id: str, reason: str = ""):
322328 # Generate and save summary for next session (only on "clear" reason)
323329 if reason == "clear" :
324330 summary = generate_summary (messages , cwd )
325- save_summary (cwd , summary , timestamp , session_id )
331+ # Pass relative session file path
332+ session_file_rel = str (filepath .relative_to (cwd )) if filepath else ""
333+ save_summary (cwd , summary , timestamp , session_id , session_file_rel )
326334 elif reason :
327335 print (f"⊘ Summary skipped (reason='{ reason } ', need 'clear')" , file = sys .stderr )
328336
0 commit comments