Skip to content

fix: make code generator produce video-specific output instead of identical boilerplate#88

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/fix-code-generator-template-issue
Closed

fix: make code generator produce video-specific output instead of identical boilerplate#88
Copilot wants to merge 2 commits intomainfrom
copilot/fix-code-generator-template-issue

Conversation

Copy link
Contributor

Copilot AI commented Mar 20, 2026

All generated projects were byte-for-byte identical because _generate_vanilla_main_js() silently discarded its tutorial_steps and features parameters, returning the same hardcoded string every time. Two additional title extractions were also discarded (result not assigned), and _generate_repo_name() always fell through to "uvai-project".

Changes

code_generator.py

  • _generate_vanilla_main_js(): now embeds extracted tutorial_steps as a real JS array and generates named initXxx() stubs for each feature in features
  • AI path wired in: generate_project() delegates to AICodeGenerator.generate_fullstack_project() when GEMINI_API_KEY is present and the SDK is importable; falls back to templates on any failure
  • Discarded assignments fixed: _generate_web_project() and _generate_api_project() both called .get("title", ...) but threw the result away — now assigned
# Before — identical output regardless of input
def _generate_vanilla_main_js(self, tutorial_steps, features):
    return '''// UVAI Generated JavaScript\ndocument.addEventListener(...)...'''

# After — embeds actual video content
def _generate_vanilla_main_js(self, tutorial_steps, features):
    entries = ", ".join([f'"{step[:80]}"' for step in tutorial_steps[:8]])
    step_logs = f"const tutorialSteps = [{entries}];\n    tutorialSteps.forEach(..."
    # + per-feature initXxx() stubs

deployment_manager.py

  • _generate_repo_name(): checks project_config["title"] and project_config["video_title"] before falling back to "uvai-project", so repos get names derived from the video

tests/test_code_generator.py

  • Added test_vanilla_main_js_includes_tutorial_steps_and_features
  • Added test_two_different_videos_produce_different_code
  • Added test_generate_repo_name_uses_video_title
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 @copilot in this section)

Custom agent used: Mastering-Any-Task AI
A hybrid agentic framework for research-led planning and execution.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

@vercel
Copy link
Contributor

vercel bot commented Mar 20, 2026

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:46am

- Wire AICodeGenerator into generate_project(): delegates to Gemini
  when GEMINI_API_KEY is set, falls back to templates otherwise
- Fix _generate_vanilla_main_js() to embed actual tutorial_steps as
  a JS array and generate per-feature initialisation stubs instead of
  returning a hardcoded boilerplate string
- Fix discarded title assignments in _generate_web_project() and
  _generate_api_project() (results were thrown away, now assigned)
- Fix _generate_repo_name() in deployment_manager.py to prefer
  project_config['title'] / 'video_title' over the 'uvai-project'
  fallback, so repos get meaningful names derived from the video
- Add three new tests: vanilla JS uniqueness, two-video diff, and
  repo-name derivation

Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix identical output in code_generator.py for video projects fix: make code generator produce video-specific output instead of identical boilerplate Mar 20, 2026
Copilot AI requested a review from groupthinking March 20, 2026 10:46
@groupthinking
Copy link
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.

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