Skip to content

Commit 1af1c08

Browse files
nodeeeeeeclaude
andcommitted
Fix camera frames in notes and incomplete section caching
Bug 1 — Camera frames appearing in notes: - _discover_screenshare_lectures() had `except Exception: pass` that silently continued when alignment JSON was corrupted, including non-screenshare lectures as screenshare. Changed to `continue` so corrupted alignments are skipped, not included. Bug 2 — Incomplete/truncated notes cached and included: - Empty or too-short LLM drafts (< 100 chars) are no longer written to disk. Previously, an empty draft still wrote a heading-only file (~30 bytes) that got cached and included in final notes. - Raised section cache threshold from 50 to 500 bytes. A heading alone is ~30 bytes; 50 was too low and let truncated sections pass the cache check. 500 bytes ensures meaningful content. - merge_sections threshold also raised to 500 bytes to match. - When draft is empty/short, returns a placeholder message telling the user to re-run with force, without caching the bad result. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c3b987e commit 1af1c08

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

note_generation.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ def generate_section(
777777
"""Generate (or load from cache) one section and save it to sections_dir."""
778778
sec_file = _section_path(sections_dir, lec_num, ci, ld.file_idx)
779779

780-
if not force and sec_file.exists() and sec_file.stat().st_size > 50:
780+
if not force and sec_file.exists() and sec_file.stat().st_size > 500:
781781
if bar:
782782
fi = f"F{ld.file_idx} " if ld.file_idx > 1 else ""
783783
bar.set_postfix_str(f"L{lec_num}{fi}§{ci} cached")
@@ -813,8 +813,10 @@ def generate_section(
813813
draft = _call(NOTE_MODEL, _P("system"), user, _max_tokens(detail))
814814
tqdm.write(f" ✓ {len(draft):,} chars ({_time.monotonic()-_t0:.0f}s)")
815815

816-
if not draft:
817-
tqdm.write(f" [warn] Empty draft for L{lec_num} §{ci} — skipping")
816+
if not draft or len(draft.strip()) < 100:
817+
tqdm.write(f" [warn] Empty or too-short draft for L{lec_num} §{ci} — not caching")
818+
heading = f"### {lec_num}.{ci} {_chunk_title(chunk)}"
819+
return f"{heading}\n\n*(Section could not be generated — re-run with force to retry.)*", True
818820

819821
if VERIFY_NOTES and draft:
820822
terms = set()
@@ -1111,7 +1113,7 @@ def merge_sections(
11111113
file_parts: list[str] = []
11121114
for ci in range(1, n_chunks + 1):
11131115
sec_file = _section_path(sections_dir, ld.num, ci, ld.file_idx)
1114-
if sec_file.exists() and sec_file.stat().st_size > 50:
1116+
if sec_file.exists() and sec_file.stat().st_size > 500:
11151117
file_parts.append(sec_file.read_text(encoding="utf-8"))
11161118
else:
11171119
fi = f" F{ld.file_idx}" if multi_file else ""
@@ -1414,15 +1416,15 @@ def _discover_screenshare_lectures(course_dir: Path) -> list[LectureData]:
14141416
# Check for alignment
14151417
align_path = course_dir / "alignment" / f"{fdir.name}.json"
14161418
align = align_path if align_path.exists() else None
1417-
# Verify alignment source is screenshare
1419+
# Verify alignment source is screenshare — skip if not
14181420
if align:
14191421
try:
14201422
with open(align, encoding="utf-8") as f:
14211423
data = json.load(f)
14221424
if data.get("source") != "screenshare":
14231425
continue # This alignment is from traditional slide matching
14241426
except Exception:
1425-
pass
1427+
continue # Corrupted alignment — skip, don't include
14261428
else:
14271429
continue # No alignment yet — need frame_extractor to run first
14281430

test/test_language_and_skip.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,10 @@ def test_section_cache_respected(self, tmp_path):
370370
sections_dir = tmp_path / "sections"
371371
sections_dir.mkdir()
372372

373-
# Create a cached section file
373+
# Create a cached section file (must be > 500 bytes to pass cache check)
374374
sec_file = _section_path(sections_dir, 1, 1, 1)
375-
sec_file.write_text("### 1.1 Cached Content\n\nThis was previously generated.")
375+
content = "### 1.1 Cached Content\n\n" + ("This was previously generated. " * 30)
376+
sec_file.write_text(content)
376377

377378
assert sec_file.exists()
378379
assert sec_file.stat().st_size > 50

0 commit comments

Comments
 (0)