Aryaman25 commited on
Commit
7d10d2f
·
1 Parent(s): e481121

Self-heal sessions whose report failed to generate at session end

Browse files

A session's data (gaze/dom/mouse logs, screenshots) is written
independently of the final generate_report() call, so a one-off
failure right as tracking stops (transient, not reproducible from the
same data afterward) left otherwise-complete sessions permanently
unreachable from the landing page — listed with real stats but
un-clickable, with no way to retry. _recent_sessions_json() now
retries generate_report() for any listed session missing its report
before building the list, so it recovers automatically next time the
landing page loads. Verified against a real affected session: the
report rebuilds successfully from its existing data with no changes
to gaze/mouse capture or session recording.

Files changed (1) hide show
  1. browser_session.py +11 -0
browser_session.py CHANGED
@@ -424,6 +424,17 @@ def _recent_sessions_json(limit=5):
424
  out = []
425
  for ts, name, full in entries[:limit]:
426
  report_path = os.path.join(full, "analysis_report.html")
 
 
 
 
 
 
 
 
 
 
 
427
  report_url = None
428
  if os.path.exists(report_path):
429
  report_url = "file://" + report_path.replace(os.sep, "/")
 
424
  out = []
425
  for ts, name, full in entries[:limit]:
426
  report_path = os.path.join(full, "analysis_report.html")
427
+ if not os.path.exists(report_path):
428
+ # A report can fail to build once (e.g. a transient issue right
429
+ # as tracking stopped) even though the underlying session data
430
+ # is completely intact — self-heal here instead of leaving that
431
+ # session permanently unreachable from the landing page. Reuses
432
+ # the exact same generate_report() call gaze_worker() already
433
+ # makes at session end; no new report-building logic.
434
+ try:
435
+ generate_report(full)
436
+ except Exception as e:
437
+ print(f"[browser_session] could not (re)build report for {name}: {e}")
438
  report_url = None
439
  if os.path.exists(report_path):
440
  report_url = "file://" + report_path.replace(os.sep, "/")