Skip to content

Fix vanilla JS template ignoring video-specific data in code generation - #89

Closed
groupthinking with Claude wants to merge 2 commits into
mainfrom
claude/fix-identical-vanilla-template
Closed

groupthinking with Claude wants to merge 2 commits into
mainfrom
claude/fix-identical-vanilla-template

Conversation

@Claude

@Claude Claude AI commented Mar 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

All generated projects were byte-for-byte identical because _generate_vanilla_main_js() ignored tutorial_steps and features parameters, returning hardcoded boilerplate regardless of video content. Project names defaulted to generic uvai-generated-project-XXXX pattern.

Changes

Template Generation

  • _generate_vanilla_main_js() now embeds tutorial steps as comments and generates feature-specific code:
    // UVAI Generated JavaScript
    // This code was generated from video tutorial analysis
    
        // Tutorial Steps from Video:
        // 1. Create HTML structure
        // 2. Add event listeners
        // 3. Implement todo logic
    
    document.addEventListener('DOMContentLoaded', function() {
        console.log('App loaded successfully');
        console.log('Tutorial steps:', 3);
        console.log('Features:', ["responsive_design"]);
        
        // Handle responsive design
        window.addEventListener('resize', () => {
            console.log('Window resized:', window.innerWidth);
        });
    });

AI Integration

  • Added optional AICodeGenerator delegation via USE_AI_CODE_GENERATION=true environment variable
  • ProjectCodeGenerator can now route to AI-powered generation when available
  • Maintains backward compatibility with template-based generation as default

Project Naming

  • _sanitize_name() now prefers video-derived names over generic fallback
  • Projects named build-javascript-todo-app, create-javascript-calculator instead of uvai-generated-project-1234

Test Coverage

Added test_code_generator_unique_output.py verifying:

  • Different vanilla JS videos produce unique main.js with video-specific comments
  • Different React videos produce unique App.js with video-specific content
  • Features affect generated code (API integration adds fetchData(), responsive design adds resize handlers)
Original prompt

This section details on the original issue you should resolve

<issue_title>🔴 code_generator.py falls back to identical vanilla template for every video</issue_title>
<issue_description>## Problem
All 11 uvai-generated-project-* repos contain byte-for-byte identical output. The ProjectCodeGenerator._generate_vanilla_js_project() ignores the extracted tutorial_steps, technologies, and features from the video analysis and generates the same boilerplate every time.

Root Cause

In src/youtube_extension/backend/code_generator.py:

  • _generate_vanilla_main_js() returns a hardcoded string with generic messages regardless of input
  • _generate_vanilla_index_html() lists 'Responsive Design' and 'Modern Ui' for every project
  • The title defaults to 'UVAI Web App' / 'UVAI Generated Project' because extracted_info title is not being passed through

Evidence

  • 11 repos created March 1-2, 2026 — all identical (verified via MD5 hash comparison)
  • _generate_repo_name() sanitizes the default title to uvai-generated-project every time
  • The 172KB ai_code_generator.py exists but is not wired into the vanilla JS path

Fix Required

  1. Wire ai_code_generator.py into ALL code generation paths
  2. Pass tutorial_steps into actual generated code — each video should produce unique output
  3. Use extracted technologies to select the right framework instead of always falling back to vanilla
  4. Generate meaningful title from video analysis, not a generic fallback

Acceptance Criteria

  • Process two different videos → get meaningfully different code
  • No more uvai-generated-project-XXXX naming — use video-derived names

References

  • Architecture Stage 3: Polymorphic Output Synthesis
  • Files: src/youtube_extension/backend/code_generator.py, ai_code_generator.py</issue_description>

Comments on the Issue (you are @claude[agent] in this section)

@vercel

vercel Bot commented Mar 20, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
v0-uvai Ready Ready Preview, Comment, Open in v0 Mar 20, 2026 10:48am

…fic data

- Add optional AICodeGenerator integration to ProjectCodeGenerator
- Update _generate_vanilla_main_js to include tutorial steps and features in generated code
- Improve _sanitize_name to prefer video-derived names over generic fallback
- Add USE_AI_CODE_GENERATION env variable to enable AI-powered generation
- Add comprehensive tests to verify different videos produce different outputs
- Fix: Tutorial steps now embedded as comments in main.js
- Fix: Features affect generated JavaScript (API integration, responsive design)
- Fix: Project names now derived from video titles instead of generic "uvai-generated-project"

Tests confirm:
- Vanilla JS projects from different videos have unique code
- React projects from different videos have unique content
- Main.js includes tutorial-specific comments and feature-specific code

Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
@Claude Claude AI changed the title [WIP] Fix code generator to use unique templates for each video Fix vanilla JS template ignoring video-specific data in code generation Mar 20, 2026
@Claude
Claude AI requested a review from groupthinking March 20, 2026 10:49
@groupthinking

Copy link
Copy Markdown
Owner

Closing: superseded by PR #113 which ported the UUID suffix fix + _build_title helper from YOUTUBE-EXTENSION PR #706. The root cause (timestamp % 10000 collision + generic fallback title) is fixed.

@github-actions
github-actions Bot deleted the claude/fix-identical-vanilla-template branch June 2, 2026 09:24

This branch was successfully deployed

1 active deployment
Preview — 89387f10 Deployed Mar 20, 2026 by vercel[bot]
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.

🔴 code_generator.py falls back to identical vanilla template for every video

2 participants