Skip to content

Add split metadata attribute to audio_files#379

Open
gianpaj wants to merge 3 commits into
mainfrom
claude/add-split-metadata-attribute-eBhV9
Open

Add split metadata attribute to audio_files#379
gianpaj wants to merge 3 commits into
mainfrom
claude/add-split-metadata-attribute-eBhV9

Conversation

@gianpaj

@gianpaj gianpaj commented May 14, 2026

Copy link
Copy Markdown
Owner

Track whether an audio file was generated via the split-text flag by
accepting a split param in the generate-voice API and persisting it in
the audio_files usage metadata. The frontend now sends split: true for
segment generations and retries.

https://claude.ai/code/session_01RBKEv4AdxCJPX3rCP9B7b6

Track whether an audio file was generated via the split-text flag by
accepting a `split` param in the generate-voice API and persisting it in
the audio_files usage metadata. The frontend now sends `split: true` for
segment generations and retries.

https://claude.ai/code/session_01RBKEv4AdxCJPX3rCP9B7b6
Copilot AI review requested due to automatic review settings May 14, 2026 17:10
@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@pullfrog

pullfrog Bot commented May 14, 2026

Copy link
Copy Markdown

lifecycle hook 'setup' failed with exit code 127. output: bash: line 1: pnpm: command not found. retry the operation if the failure looks flaky (network blips, transient rate limits). do NOT retry if the script is broken (missing commands, syntax errors) or the error is persistent.

Pullfrog  | Rerun failed job ➔View workflow run | via Pullfrog𝕏

@vercel

vercel Bot commented May 14, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
sexyvoice Ready Ready Preview, Comment May 14, 2026 9:46pm
sexyvoice-docs Ready Ready Preview, Comment May 14, 2026 9:46pm

Request Review

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces a split flag to the voice generation workflow, enabling the API to track segmented text processing. The API route now parses the split parameter and includes it in usage metadata, while the AudioGenerator component has been updated to pass this flag. Feedback suggests extending this tracking to usage_events and PostHog analytics for better feature visibility and consistency.

usage: {
...usage,
userHasPaid,
split: isSplit,

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.

medium

The split attribute is correctly added to the audio_files usage metadata here. However, for complete feature tracking and consistent analytics, this flag should also be included in the usage_events metadata (line 633) and the PostHog event tracking (lines 210 and 647). Ensuring consistency across all tracking mechanisms is recommended for better visibility into the adoption of the split-text feature.

@claude

claude Bot commented May 14, 2026

Copy link
Copy Markdown
Contributor

Claude finished @gianpaj's task in 2m 55s —— View job


Claude Code Review

  • Read changed files
  • Check existing usage_events / PostHog tracking
  • Analyze code quality, bugs, security, performance
  • Post review feedback

Summary

The PR cleanly threads a split boolean from the frontend (segment generations + retries) through the /api/generate-voice route into the audio_files.usage JSON. Implementation is small and focused, the server-side body.split === true check is appropriately defensive, and the frontend default param (split = false) keeps existing call sites unchanged.

Two things to address before merging — one definitely-breaking, one analytics-consistency:

🛑 Tests will fail on this branch

apps/web/tests/generate-voice.test.ts asserts the exact usage shape passed to saveAudioFile via toHaveBeenCalledWith (deep equality, no extra keys allowed):

Line Path Current expectation
454 Replicate (xtts-v2) usage: { userHasPaid: false }
572 Grok (xAI) usage: { userHasPaid: false }
754 Gemini paid (pro) usage: { promptTokenCount, candidatesTokenCount, totalTokenCount, userHasPaid: true }
851 Gemini free (flash) same shape, userHasPaid: false
945 Gemini fallback same shape, userHasPaid: true

After this PR, every call site adds split: false (or true) to that object → all five assertions will mismatch. Please update them and add at least one new case that posts split: true and asserts the flag is persisted.

⚠️ Analytics surfaces are inconsistent (also raised by gemini-code-assist)

split is recorded only in audio_files.usage. The other two tracking surfaces in the same handler are missing it:

  • insertUsageEvent (route.ts:633) — canonical credit/usage analytics. Without split in metadata, downstream usage_events queries can't slice by mode. This matters more than audio_files, because:
  • Cache-hit path (route.ts:204–220) skips saveAudioFile entirely. So if the same text was first generated single-mode and then re-requested via split, the cached audio_files row keeps its original split: false. usage_events is always written, so putting split there closes the gap.
  • sendPosthogEvent (route.ts:210 and 647, defined at 761) — needs a split?: boolean parameter threaded into properties so product analytics can measure adoption.

Minor / non-blocking

  • audio-generator.tsx:260...(split ? { split: true } : {}) is functionally fine; you could just send split unconditionally since the server validates === true. Stylistic only.
  • Naming: server uses isSplit, request body / DB uses split — slight asymmetry but harmless.
  • No security or performance concerns. Payload addition is one boolean. body.split === true rejects non-boolean truthy values, which is good.

Security & performance

  • ✅ No injection vector — split is coerced to a strict boolean before use.
  • ✅ No PII or auth concerns.
  • ✅ No measurable perf impact (one extra JSON key).

Inline comments left on route.ts:601-604 (analytics + tests) and audio-generator.tsx:260 (style nit).
• Branch: claude/add-split-metadata-attribute-eBhV9

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 56f176f4a3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/web/components/audio-generator.tsx Outdated

Copilot AI left a comment

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.

Pull request overview

Adds split-generation metadata tracking for audio files so split-text segment generations can be identified after persistence.

Changes:

  • Adds a split flag to frontend generate-voice requests for split segment generation and retries.
  • Parses the split request field in the generate-voice API.
  • Persists split into audio_files.usage metadata.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
apps/web/components/audio-generator.tsx Sends split: true for split segment generation and retry requests.
apps/web/app/api/generate-voice/route.ts Reads the split request field and stores it in audio file usage metadata.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/web/components/audio-generator.tsx Outdated
Comment thread apps/web/app/api/generate-voice/route.ts
@argos-ci

argos-ci Bot commented May 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 5 changed May 14, 2026, 9:48 PM

Comment thread apps/web/app/api/generate-voice/route.ts
Comment thread apps/web/app/api/generate-voice/route.ts
Comment thread apps/web/components/audio-generator.tsx Outdated
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.

3 participants