Skip to content

fix: skip caption generation when captionLength is none#132

Merged
sweetmantech merged 2 commits intomainfrom
feature/caption-default-none
Apr 14, 2026
Merged

fix: skip caption generation when captionLength is none#132
sweetmantech merged 2 commits intomainfrom
feature/caption-default-none

Conversation

@recoup-coding-agent
Copy link
Copy Markdown
Collaborator

@recoup-coding-agent recoup-coding-agent commented Apr 13, 2026

Summary

  • Adds none to CAPTION_LENGTHS, changes default from short to none
  • Skips caption generation API call when captionLength is none
  • Adds test verifying generateCaption is not called when none

Test plan

  • All 343 tasks tests pass
  • Verify captionless video output

Generated with Claude Code


Summary by cubic

Skip caption generation when captionLength is "none" and make "none" the default. This reduces API calls and produces captionless videos unless a length is specified.

  • Refactors

    • Added resolveCaptionText helper that returns "" for "none" or calls generateCaption for other lengths.
    • Updated createContentTask to use the helper; added unit tests for both paths.
  • Migration

    • To keep captions by default, set captionLength to "short" in requests.

Written for commit 7927ca7. Summary will update on new commits.

Summary by CodeRabbit

  • New Features

    • Users can now disable caption generation by selecting "none" as the caption length option.
    • Default caption setting changed from "short" to "none," providing more control over caption behavior.
  • Tests

    • Expanded test suite with coverage for caption resolution and skip scenarios.

Changes default captionLength from "short" to "none" in the content creation schema.
When "none", the task skips the caption generation API call and passes an empty string
to renderFinalVideo, producing a video without text overlay.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 13, 2026

📝 Walkthrough

Walkthrough

The changes introduce a new resolveCaptionText function that centralizes caption text resolution logic. The schema is updated to support "none" as a caption length option (now the default). Caption generation in createContentTask is replaced with a call to this resolver function that skips generation when caption length is "none".

Changes

Cohort / File(s) Summary
Caption Resolution Implementation
src/content/resolveCaptionText.ts
Added new async function that returns empty string when captionLength is "none", otherwise calls generateCaption API with topic, template, and length parameters.
Caption Length Schema
src/schemas/contentCreationSchema.ts
Expanded CAPTION_LENGTHS constant and CaptionLength type to include "none" option; changed default captionLength from "short" to "none".
Content Creation Task
src/tasks/createContentTask.ts
Replaced inline generateCaption usage with resolveCaptionText call; updated step 9 logging to include captionLength parameter; skips caption generation when captionLength === "none".
Test Coverage
src/content/__tests__/resolveCaptionText.test.ts, src/tasks/__tests__/createContentTask.test.ts
Added test suite for resolveCaptionText covering "none" and concrete caption length cases; added test case for skipped caption generation in createContentTask.

Possibly Related PRs

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A caption resolver hops into view,
With "none" as the default, sleek and true,
Skip generation? No problem at all,
This function abstracts the API call!
Tests verify each whisker and trail,
Our captions now dance to a better tale! 🎬

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: skipping caption generation when captionLength is set to 'none', which aligns with the core functionality added across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/caption-default-none

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Comment thread src/tasks/createContentTask.ts Outdated
Comment on lines +119 to +137
let captionText = "";
if (payload.captionLength !== "none") {
logStep("Generating caption via API");
const captionTopic = [
`Song: "${audioClip.songTitle}"`,
audioClip.clipLyrics ? `Lyrics: "${audioClip.clipLyrics}"` : null,
audioClip.clipMood ? `Mood: ${audioClip.clipMood}` : null,
artistContext ? `Artist: ${artistContext}` : null,
audienceContext ? `Audience: ${audienceContext}` : null,
].filter(Boolean).join(". ");

captionText = await generateCaption({
topic: captionTopic,
template: payload.template,
length: payload.captionLength,
});
} else {
logStep("Skipping caption generation (captionLength=none)");
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SRP

  • actual: caption generation / skip logic is in the createContentTask function file.
  • required: new function file for caption generation / skip logic.

Moves the caption generation/skip logic out of createContentTask into
its own module. The task now delegates to resolveCaptionText, which
returns "" for "none" and calls generateCaption otherwise.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/tasks/createContentTask.ts (1)

118-132: ⚠️ Potential issue | 🟠 Major

Caption skip is too late; default path still does unnecessary context I/O.

Because captionLength now defaults to "none", the task still pays for fetchArtistContext/fetchAudienceContext (Lines 77-84) before the skip branch is reached at Line 118. That adds avoidable latency and external calls on the default path.

⚡ Suggested fix
-    // --- Step 4: Fetch artist/audience context ---
-    logStep("Fetching artist context");
-    const artistContext = await fetchArtistContext(
-      payload.githubRepo, payload.artistSlug, fetchGithubFile,
-    );
-    const audienceContext = await fetchAudienceContext(
-      payload.githubRepo, payload.artistSlug, fetchGithubFile,
-    );
+    let artistContext: string | null = null;
+    let audienceContext: string | null = null;

@@
-    // --- Step 9: Resolve caption text (skipped when captionLength === "none") ---
-    logStep("Resolving caption", true, { captionLength: payload.captionLength });
-    const captionTopic = [
-      `Song: "${audioClip.songTitle}"`,
-      audioClip.clipLyrics ? `Lyrics: "${audioClip.clipLyrics}"` : null,
-      audioClip.clipMood ? `Mood: ${audioClip.clipMood}` : null,
-      artistContext ? `Artist: ${artistContext}` : null,
-      audienceContext ? `Audience: ${audienceContext}` : null,
-    ].filter(Boolean).join(". ");
-
-    const captionText = await resolveCaptionText({
-      captionLength: payload.captionLength,
-      topic: captionTopic,
-      template: payload.template,
-    });
+    // --- Step 9: Resolve caption text (skip all caption prep when captionLength === "none") ---
+    let captionText = "";
+    if (payload.captionLength !== "none") {
+      logStep("Fetching artist context");
+      artistContext = await fetchArtistContext(
+        payload.githubRepo, payload.artistSlug, fetchGithubFile,
+      );
+      audienceContext = await fetchAudienceContext(
+        payload.githubRepo, payload.artistSlug, fetchGithubFile,
+      );
+
+      logStep("Resolving caption", true, { captionLength: payload.captionLength });
+      const captionTopic = [
+        `Song: "${audioClip.songTitle}"`,
+        audioClip.clipLyrics ? `Lyrics: "${audioClip.clipLyrics}"` : null,
+        audioClip.clipMood ? `Mood: ${audioClip.clipMood}` : null,
+        artistContext ? `Artist: ${artistContext}` : null,
+        audienceContext ? `Audience: ${audienceContext}` : null,
+      ].filter(Boolean).join(". ");
+
+      captionText = await resolveCaptionText({
+        captionLength: payload.captionLength,
+        topic: captionTopic,
+        template: payload.template,
+      });
+    } else {
+      logStep("Resolving caption", true, { captionLength: payload.captionLength, skipped: true });
+    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/tasks/createContentTask.ts` around lines 118 - 132, The code still calls
fetchArtistContext/fetchAudienceContext and builds artistContext/audienceContext
even when payload.captionLength defaults to "none", causing unnecessary I/O;
change the flow in createContentTask so you check payload.captionLength ===
"none" (or use a guard like if (payload.captionLength === "none") skip caption
resolution early) before invoking fetchArtistContext/fetchAudienceContext and
before building captionTopic/logging; only call resolveCaptionText, build
captionTopic, and fetch contexts when captionLength !== "none" (references:
captionLength, resolveCaptionText, fetchArtistContext, fetchAudienceContext,
captionTopic, logStep).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/tasks/createContentTask.ts`:
- Around line 118-132: The code still calls
fetchArtistContext/fetchAudienceContext and builds artistContext/audienceContext
even when payload.captionLength defaults to "none", causing unnecessary I/O;
change the flow in createContentTask so you check payload.captionLength ===
"none" (or use a guard like if (payload.captionLength === "none") skip caption
resolution early) before invoking fetchArtistContext/fetchAudienceContext and
before building captionTopic/logging; only call resolveCaptionText, build
captionTopic, and fetch contexts when captionLength !== "none" (references:
captionLength, resolveCaptionText, fetchArtistContext, fetchAudienceContext,
captionTopic, logStep).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4f572683-a2ea-46d1-bde8-efa71ad0a32d

📥 Commits

Reviewing files that changed from the base of the PR and between a0523c5 and 7927ca7.

📒 Files selected for processing (5)
  • src/content/__tests__/resolveCaptionText.test.ts
  • src/content/resolveCaptionText.ts
  • src/schemas/contentCreationSchema.ts
  • src/tasks/__tests__/createContentTask.test.ts
  • src/tasks/createContentTask.ts

@sweetmantech sweetmantech merged commit ddf9404 into main Apr 14, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants