-
Notifications
You must be signed in to change notification settings - Fork 0
Codex/create ai demo video workflow #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
amaldinesh7
wants to merge
3
commits into
main
Choose a base branch
from
codex/create-ai-demo-video-workflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| /coverage | ||
| /playwright-report/ | ||
| /test-results/ | ||
| /demo-output/ | ||
|
|
||
| # next.js | ||
| /.next/ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Product Hunt Demo Video (45–60s) | ||
|
|
||
| This repo includes a deterministic, **safe** demo-video capture flow that **never posts to Reddit**. It uses a demo-only streamed queue endpoint and a Playwright spec that records the UI flow. | ||
|
|
||
| ## 1) Record the demo (Playwright) | ||
|
|
||
| ```bash | ||
| npm run demo:video | ||
| ``` | ||
|
|
||
| Notes: | ||
| - This sets `NEXT_PUBLIC_QUEUE_DEMO_MODE=1` so the client posts to `POST /api/queue/demo` (simulated streaming). | ||
| - Video is forced **on** via `playwright.demo.config.ts`. | ||
| - The capture includes simple title cards via `/demo/cards?variant=...`. | ||
| - The raw video is written under `test-results/` (Playwright output). | ||
|
|
||
| ## 2) Export to a shareable file | ||
|
|
||
| ```bash | ||
| npm run demo:export | ||
| ``` | ||
|
|
||
| Output: | ||
| - `demo-output/reddit-multi-poster_product-hunt_demo_60s_1080p.mp4` (if `ffmpeg` is installed) | ||
| - otherwise `demo-output/reddit-multi-poster_product-hunt_demo_60s_1080p.webm` | ||
|
|
||
| ## 3) Voiceover + captions (AI polish) | ||
|
|
||
| Suggested voiceover text: `docs/demo/product-hunt-demo-voiceover.md` | ||
|
|
||
| If you want to paste captions manually (or as a base for auto-captions): `docs/demo/product-hunt-demo.srt` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Voiceover (≈55s) | ||
|
|
||
| - Posting to multiple subreddits is tedious—and doing it too fast can get you flagged. | ||
| - Reddit Multi Poster lets you upload once, pick your communities, and post safely with smart scheduling. | ||
| - Paste your media, add a title, select your subreddits… and hit Start Posting. | ||
| - Watch the queue update in real time—done. | ||
| - Stop copy-pasting. Start creating. | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| 1 | ||
| 00:00:00,000 --> 00:00:03,000 | ||
| Post once. Reach 30+ communities. | ||
|
|
||
| 2 | ||
| 00:00:03,000 --> 00:00:09,000 | ||
| Copy/paste. Select flair. Repeat.\nRisk getting flagged if you post too quickly. | ||
|
|
||
| 3 | ||
| 00:00:09,000 --> 00:00:18,000 | ||
| Paste your media link.\nAdd a title. | ||
|
|
||
| 4 | ||
| 00:00:18,000 --> 00:00:30,000 | ||
| Pick 2–3 communities.\nHit “Start Posting”. | ||
|
|
||
| 5 | ||
| 00:00:30,000 --> 00:00:43,000 | ||
| Watch the queue update in real time.\nAll done. | ||
|
|
||
| 6 | ||
| 00:00:43,000 --> 00:00:53,000 | ||
| Stop copy-pasting.\nStart creating. | ||
|
|
||
| 7 | ||
| 00:00:53,000 --> 00:01:00,000 | ||
| Try it now: reddit-multi-poster.vercel.app | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| import type { NextApiRequest, NextApiResponse } from 'next'; | ||
|
|
||
| type QueueItemInput = { | ||
| subreddit: string; | ||
| }; | ||
|
|
||
| type DemoQueueRequestBody = { | ||
| items: QueueItemInput[]; | ||
| caption?: string; | ||
| prefixes?: { f?: boolean; c?: boolean }; | ||
| }; | ||
|
|
||
| const sleep = async (ms: number): Promise<void> => { | ||
| await new Promise<void>((resolve) => { | ||
| setTimeout(resolve, ms); | ||
| }); | ||
| }; | ||
|
|
||
| const writeLine = (res: NextApiResponse, payload: unknown): void => { | ||
| res.write(`${JSON.stringify(payload)}\n`); | ||
| }; | ||
|
|
||
| const isRecordLike = (value: unknown): value is Record<string, unknown> => | ||
| typeof value === 'object' && value !== null; | ||
|
|
||
| const parseBody = (req: NextApiRequest): DemoQueueRequestBody | null => { | ||
| const body = req.body as unknown; | ||
| if (!isRecordLike(body)) return null; | ||
| if (!('items' in body) || !Array.isArray(body.items)) return null; | ||
|
|
||
| const items = body.items | ||
| .map((item): QueueItemInput | null => { | ||
| if (!isRecordLike(item)) return null; | ||
| const subreddit = item.subreddit; | ||
| if (typeof subreddit !== 'string' || subreddit.trim().length === 0) return null; | ||
| return { subreddit }; | ||
| }) | ||
| .filter((item): item is QueueItemInput => item !== null); | ||
|
|
||
| if (items.length === 0) return null; | ||
|
|
||
| return { | ||
| items, | ||
| caption: typeof body.caption === 'string' ? body.caption : undefined, | ||
| prefixes: isRecordLike(body.prefixes) ? (body.prefixes as DemoQueueRequestBody['prefixes']) : undefined, | ||
| }; | ||
| }; | ||
|
|
||
| /** | ||
| * Demo-only queue processor. | ||
| * | ||
| * Purpose: | ||
| * - Provide a safe, deterministic, streamed queue for demo/video capture. | ||
| * - NEVER posts to Reddit. | ||
| * | ||
| * Enable client-side usage via NEXT_PUBLIC_QUEUE_DEMO_MODE=1 (see hooks/usePostingQueue.ts). | ||
| */ | ||
| export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
| if (req.method !== 'POST') { | ||
| res.setHeader('Allow', 'POST'); | ||
| return res.status(405).json({ error: 'Method not allowed' }); | ||
| } | ||
|
|
||
| const parsed = parseBody(req); | ||
| if (!parsed) { | ||
| return res.status(400).json({ error: 'Invalid request body' }); | ||
| } | ||
|
|
||
| res.statusCode = 200; | ||
| res.setHeader('Content-Type', 'text/plain; charset=utf-8'); | ||
| res.setHeader('Cache-Control', 'no-cache, no-transform'); | ||
| res.setHeader('Connection', 'keep-alive'); | ||
| res.flushHeaders?.(); | ||
|
|
||
| const delaySeconds = 2; | ||
| writeLine(res, { status: 'started', total: parsed.items.length }); | ||
| await sleep(700); | ||
|
|
||
| for (let index = 0; index < parsed.items.length; index++) { | ||
| const item = parsed.items[index]; | ||
| const subreddit = item.subreddit; | ||
|
|
||
| writeLine(res, { index, status: 'posting', subreddit }); | ||
| await sleep(900); | ||
|
|
||
| writeLine(res, { | ||
| index, | ||
| status: 'success', | ||
| subreddit, | ||
| url: `https://reddit.com/r/${subreddit}/comments/demo${index}`, | ||
| id: `demo${index}`, | ||
| }); | ||
| await sleep(600); | ||
|
|
||
| if (index < parsed.items.length - 1) { | ||
| writeLine(res, { index, status: 'waiting', delaySeconds }); | ||
| await sleep(delaySeconds * 1000); | ||
| } | ||
| } | ||
|
|
||
| writeLine(res, { status: 'completed' }); | ||
| return res.end(); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing demo-mode guard — endpoint is accessible even when demo mode is disabled.
Unlike
pages/api/queue/submit.tsandpages/api/queue/process.ts, which checkNEXT_PUBLIC_QUEUE_DEMO_MODEand thex-rmp-demoheader before entering demo logic, this endpoint has no such guard. In production (with demo mode off), anyone can hit/api/queue/demoand get simulated responses.Proposed fix
export default async function handler(req: NextApiRequest, res: NextApiResponse) { if (req.method !== 'POST') { res.setHeader('Allow', 'POST'); return res.status(405).json({ error: 'Method not allowed' }); } + const demoEnv = process.env.NEXT_PUBLIC_QUEUE_DEMO_MODE; + const demoHeader = req.headers['x-rmp-demo']; + const demoHeaderValue = Array.isArray(demoHeader) ? demoHeader[0] : demoHeader; + const isDemoEnabled = + (demoEnv === 'true' || demoEnv === '1') && demoHeaderValue === '1'; + + if (!isDemoEnabled) { + return res.status(403).json({ error: 'Demo mode is not enabled' }); + } + const parsed = parseBody(req);📝 Committable suggestion
🤖 Prompt for AI Agents