Skip to content

fix(code_generator): emit unique, tutorial-specific output instead of identical boilerplate#78

Closed
Copilot wants to merge 4 commits intomainfrom
copilot/fix-code-generator-output
Closed

fix(code_generator): emit unique, tutorial-specific output instead of identical boilerplate#78
Copilot wants to merge 4 commits intomainfrom
copilot/fix-code-generator-output

Conversation

Copy link
Contributor

Copilot AI commented Mar 20, 2026

Both code_generator.py files produced the same static boilerplate regardless of which video was processed — extracted tutorial steps, keywords, and features were accepted as parameters but never used in the generated output.

src/youtube_extension/backend/code_generator.py

  • _generate_vanilla_main_js — was ignoring both tutorial_steps and features entirely. Now generates a named function per step (executeStep1(), …) wired into runTutorialSteps(), plus optional helpers keyed to detected features (setupFormHandlers, fetchInitialData, setupDarkModeToggle, initSearch).
  • _generate_fastapi_main — added extracted_info param; now inlines step comments, exposes /api/tutorial/steps listing the video's extracted steps, and creates one domain route per keyword (e.g. a FastAPI tutorial produces /api/fastapi). Removes the hardcoded generic /api/messages endpoints.
  • _generate_python_api — passes extracted_info through to _generate_fastapi_main.

Example diff for a "Build a REST API with FastAPI" video vs. "GraphQL with Python":

# Before — both produced identical:
@app.get("/api/messages")
async def get_messages():
    return [{"message": "Hello from your UVAI generated API!", ...}]

# After — FastAPI tutorial produces:
# Step 1: Install FastAPI and uvicorn
# Step 2: Create a basic FastAPI app
@app.get("/api/tutorial/steps")
async def get_tutorial_steps(): ...

@app.get("/api/fastapi")
async def get_fastapi(): ...

src/agents/specialized/code_generator.py

  • execute — propagates top-level video_title / tutorial_steps inputs into context before dispatch.
  • _generate_api_endpoint — prepends # Endpoint generated for: <title> + step comments; tutorial steps are reflected in the processing-logic block.
  • _generate_generic_api — now accepts intent and prepends a video/intent header, making each generated API unique to its source.
Original prompt

This section details on the original issue you should resolve

<issue_title>code_generator.py</issue_title>
<issue_description>fix code_generator.py so each video produces unique, tutorial-specific output instead of identical boilerplate. @claude </issue_description>

<agent_instructions>fix the file as stated
</agent_instructions>

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.


⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

@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:19am

Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix code_generator.py to produce unique tutorial-specific output fix(code_generator): emit unique, tutorial-specific output instead of identical boilerplate Mar 20, 2026
Copilot AI requested a review from groupthinking March 20, 2026 09:30
Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestions:

  1. Three methods in code_generator.py were partially fixed; two still ignore important parameters for feature-specific code generation
  1. User-derived content from video analysis (tutorial steps, technology names, features, and project titles) was directly inserted into generated JSX/HTML code without HTML escaping - FIXED
  1. Title and URL parameters are directly inserted into markdown without escaping, allowing markdown special characters to be interpreted as formatting syntax instead of literal text

Fix on Vercel

@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

2 participants