Spaces:
Running
Running
Commit History
-
Second-pass audit fixes: narrow exception catch, empty-cue early errorβ
ClaudeTwo real findings from a second-pass bug/security audit; the rest of the report was either already handled by existing code (sub-toggle sync runs on dispatched change event) or correctly identified as acceptable / non-bugs. P1 β except BaseException in the /jobs preview-cleanup block was overly broad. Narrow to Exception so KeyboardInterrupt / SystemExit still propagate without first running cleanup that could mask the signal. P2 β Empty transcript silently produced a guide with no narration under any segment. Both topic and non-topic paths now check `if not cues` immediately after _load_cues and raise PipelineError with a message naming the fix ("provide a non-empty VTT/SRT or enable auto-transcribe"). The topic-scene-preview endpoint already had its own empty-cue check; this brings the main pipeline to parity. Verified safe (no changes needed): - filename validation: endpoint regexes already cover /jobs/{id}/zip, /alts, /ocr, /audio - autoescape: Jinja2 select_autoescape([β¦e8ba7af -
P1/P2 bug audit fixes: index validation, cleanup race, cache purge, type whitelistβ
ClaudeFour real issues from a thorough audit of the recent feature work: P1 β Preview workdir leaked on validation failure. Between popping the preview cache entry in /jobs and entering the workdir try/finally, any HTTPException raised by index parsing or selection filtering would orphan the temp dir holding the user's uploaded video. Wrap the post-pop validation in its own try/except that cleans up the popped entry before re-raising. Marks the entry None so the outer finally doesn't double-delete. P1 β Out-of-range and negative selected_indices silently dropped. The previous parser used `if i.strip().isdigit()` which (a) accepts any positive integer regardless of frame count and (b) silently ignores negative numbers and any non-digit token. A user submitting "0,5,999" against a 5-frame preview got a 5-frame guide back with no error. Now we parse each token explicitly: ValueError on non-int, 400 on negative, 400 on out-of-range against the cached preview's valid index set (positional for tβ¦1361034
-
Topic prompt: video-type dropdown biases boundaries to genre structureβ
ClaudeGeneric topic segmentation works but produces splits that ignore genre conventions β a lab walkthrough is sliced like a lecture, a tutorial like a panel. Add a per-job "video type" hint the user can pick from a small dropdown; the orchestrator prepends a paragraph of structural guidance to the topic prompt so Claude knows what shape to bias toward. Five genres modeled today (each one paragraph of prompt): - Classroom lecture: intro β background β concept(s) β examples β wrap-up - Lab walkthrough: intro β theory β materials β procedure β results - How-to tutorial: intro β setup β steps β verification β troubleshooting - Interview / Q&A: boundaries at new questions or subject pivots - Talk / presentation: hook β thesis β supporting points β closer plus "General" which leaves the prompt untouched. Unknown values fall back to general so a stale form post can't break the call. Wired through extract_topics(video_type=...), LLMToggles .topic_video_type, the orchestrator, and both β¦6dd9ac4 -
Topic primary picking: any OCR text qualifies a scene as slide contentβ
ClaudeUser reported the iconic "HEAT PUMPS" title-card slide losing the primary-frame race to a longer talking-head shot in the same topic. Diagnosis: my pool threshold of 30 OCR characters was over-cautious. The slide's headline OCRs to roughly "HEAT PUMPS" β about 10 chars after the confidence + 3-char-run filters trim subtext. That falls under 30, drops the slide out of the slide_text pool, and if the face detector even misfires slightly on the AC unit's circular fan the slide ends up in the same borderline pool as real talking heads β where duration wins. `ocr_frame` already returns "" for noise-only frames (per-word confidence + alphanumeric-run filters), so any non-empty output is by construction real text. Relax the pool check from "β₯30 chars" to "non-empty after strip" β title cards, short labels, and labelled photos now win against any talking-head shot in the same topic. The 30-char constant is gone. New test pins the HEAT PUMPS scenario exactly: a long borderline talking-head loβ¦5d54c1c
-
Topic validation: repair reversed bounds and drop bad topics rather than failβ
ClaudeA deployed job failed entirely because the LLM returned one topic with end (31) < start (35). The previous validator raised on the first malformed topic, throwing away an otherwise-valid response and forcing the user to pay for another call. Soften validation: when end < start, swap them (the LLM clearly intended the smaller as start) and continue. When a topic is still zero-length or missing a title after repair, drop just that topic and proceed with the rest. Raise LLMTopicError only when EVERY topic is malformed β at that point the response really is unusable. Tests cover each of the repair paths plus the still-raises-when- nothing-usable case.4b46ff9 -
Topic primary picking: prefer scenes with OCR text over talking-headsβ
ClaudeUser reported that topic-segmented guides still surface talking-head shots as primaries β the face-area tiebreak couldn't help when every scene in a topic's time range was a talking-head (e.g. an intro stretch before the first slide appears). The previous logic would then fall back to longest-on-screen, which is exactly the longest talking-head. Make OCR-text presence the dominant signal: - Run the OCR pass before topic segmentation (it ran after). - Pass per-scene OCR text into _apply_topic_segmentation and pool scenes by content: "has slide text" (β₯30 chars), "clean visual" (face area < 3%), or "borderline" (everything else). - Pick longest-on-screen from the highest non-empty pool β so a short slide always beats a long talking-head when slide text is present, falling back to face area, then anything left. - Thread the primary's OCR text back through so the orchestrator doesn't need to re-OCR after rebucketing. Talking-head scenes still appear as switchaβ¦5d9159c -
Topic primary picking: prefer clean slide content over borderline facesβ
ClaudeThe instructor filter drops frames where the face area exceeds the threshold, but borderline-face frames (e.g. a partial face at 8% of the image, below the 12% drop line) survive. With scene-based output that's fine β each scene becomes its own segment regardless. With topic segmentation, a topic can span several scenes, and the "longest on screen" pick promoted those borderline shots ahead of clean slides whose scenes were shorter. Have the instructor filter record each kept scene's measured face_area_ratio on the SceneFrame. _apply_topic_segmentation now partitions a topic's scenes into "slide content" (ratio < 0.03) and "borderline" pools and picks the longest from the slide-content pool first, only falling back to the borderline pool when the topic has no clean scenes at all. Borderline scenes still appear as switchable alternates in the editor β only the default anchor changes.5c072a9 -
Topic prompt: explicitly ignore talking-head frames for boundariesβ
ClaudeSome webcam / podium / empty-stage frames slip past the instructor filter and end up in the slide thumbnails sent to Claude. Without guidance, the model occasionally anchors a topic boundary or representative frame on one of these instead of on the surrounding slide content. Add an explicit "treat talking-head thumbnails as transparent" clause to the image-augmented system prompt, with the sensible carve-out for a stretch (e.g. live Q&A) where there's no slide content at all. Test pins the guidance so it can't be silently dropped during a future prompt edit.5d1a426 -
Add image-augmented topic segmentation as a sub-toggleβ
ClaudeBuilds on the transcript-only topic segmentation: when the new "Also send slide images" sub-toggle is on (only available when the parent toggle is checked), the orchestrator hands extract_topics a list of (start_seconds, image_path) tuples and the function attaches thumbnailed slides to the Claude request alongside the transcript. Slides are downscaled to 768px max-dim before base64 encoding so Anthropic's image-token cost stays bounded; if more than 60 kept scenes exist, the set is uniformly sampled (preserving the first and last frames where chapter markers usually live). Two prompt variants β the system prompt for the image branch explicitly tells Claude how to interpret slide-vs-narration signals, so it doesn't double-count layout changes within the same topic. UI: the sub-toggle is hidden until the parent is checked, and gets unchecked automatically when the parent unchecks so a hidden box can't post stale state. Tests verify the request shape (image blocks present + image-awarβ¦9a92330 -
Add LLM topic-based segmentation as an opt-in toggleβ
ClaudeReplaces the scene-based one-segment-per-slide bucketing with topical sections generated by Claude from the transcript. One extra LLM call per job (transcript-only, no images) returns 3β15 sequential topics with titles and summaries; the orchestrator then re-buckets the kept scene frames so each topic-segment carries the longest-on-screen scene as its primary image and the other scenes as switchable alternates in the editor. Per the design discussion: - Opt-in via a new LLMToggles.topic_segmentation field; existing scene-based path stays the default. - Multi-slide topics keep every slide accessible (primary + cross- scene alts on top of the per-scene candidate alts). - LLM failure raises PipelineError so the job surfaces a clear error rather than silently falling back. The /alts and /ocr endpoints now also accept the scene_NNNN.jpg primary pattern because cross-scene alternates re-use those filenames.7e20c47