Compare commits

...
Author SHA1 Message Date
Andrew Beveridge ☄️ b466ebf068 Merge pull request #109 from nomadkaraoke/fix/download-links-auth
fix: include auth token in frontend download URLs
2025-12-28 15:23:32 -05:00
Andrew Beveridge ☄️ d5da92847d Merge branch 'main' into fix/download-links-auth 2025-12-28 15:17:07 -05:00
Andrew BeveridgeandClaude Opus 4.5 a897ac8cbd chore: add frontend/e2e/screenshots/ to .gitignore
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 15:11:31 -05:00
Andrew BeveridgeandClaude Opus 4.5 c10dae3759 docs: add lessons learned for state_data and GDrive escaping bugs
Documents two gotchas discovered while fixing PR #109:
- Stale object references after async operations can overwrite DB changes
- Google Drive API queries need single quotes escaped in filenames

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 15:08:01 -05:00
Andrew Beveridge ☄️ 42c3235513 Merge pull request #110 from nomadkaraoke/fix/tab-and-jobcard-styling
fix(frontend): improve tab visibility and job card styling for light mode
2025-12-28 15:03:29 -05:00
Andrew BeveridgeandClaude Opus 4.5 d2a917827c fix: escape single quotes in Google Drive API queries
Filenames containing apostrophes (e.g., "Nobody's Home") were causing
Google Drive API 400 errors because single quotes need to be escaped
in the query string syntax.

Added escaping for both filename and folder_name in queries.

Fixes job 47475700 where GDrive upload failed with:
"Invalid Value" in query: name='NOMAD-1187 - Avril Lavigne - Nobody's Home.mp4'

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 15:02:13 -05:00
Andrew BeveridgeandClaude Opus 4.5 973215357f fix(frontend): improve tab visibility and job card styling for light mode
- Add amber background to active tab for clear visibility in both modes
- Fix job card to use CSS variables instead of hardcoded slate colors
- Update OutputLinks, JobLogs, JobActions with proper theme variables
- Progress bar now uses CSS variables for background

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 14:58:04 -05:00
Andrew BeveridgeandClaude Opus 4.5 5bc521016e fix: preserve dropbox_link and gdrive_files in final state_data update
The video worker was overwriting state_data after distribution completed,
using the OLD job.state_data from before _handle_native_distribution ran.
This discarded the dropbox_link and gdrive_files that were just saved.

Now explicitly includes these values from the result dict in the final
state_data update, ensuring distribution links are preserved.

This fixes the issue where Dropbox folder link wasn't showing in the UI
even though the upload succeeded.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 14:56:36 -05:00
Andrew BeveridgeandClaude Opus 4.5 05c2e84455 fix: include auth token in frontend download URLs
Download links were failing with "Authentication required" because the
frontend was generating bare URLs without authentication tokens. The
browser navigates directly to these URLs without the Authorization header.

Fixed by appending the user's token as a query parameter (?token=...) to
download URLs, which the backend accepts as an alternative to the Bearer
header.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 14:45:45 -05:00
Andrew Beveridge ☄️ 7e2b4f1afc Merge pull request #108 from nomadkaraoke/feature/version-display-and-ui
feat(frontend): add version display and improve UI
2025-12-28 14:44:23 -05:00
Andrew BeveridgeandClaude Opus 4.5 4415ac8527 feat(frontend): add version display and improve UI
- Add version footer showing frontend and backend versions
- Make Search the default tab (reordered: Search, Upload, URL)
- Remove theme description text from selector
- Add "Show preview" button for theme thumbnails (lazy load)
- Fix light mode colors using CSS variables throughout
- Sync frontend package.json version with pyproject.toml

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 14:41:05 -05:00
Andrew Beveridge ☄️ 95659fe52b Merge pull request #107 from nomadkaraoke/feature/fix-local-whisper-env-vars
fix: make local-whisper respect WHISPER_MODEL_SIZE and WHISPER_DEVICE env vars
2025-12-28 14:30:07 -05:00
Andrew BeveridgeandClaude Opus 4.5 260550ddb9 fix: update test mock to support os.getenv with default argument
The os.getenv mock in test_transcribe_lyrics_new_transcription only
accepted one argument, but TranscriberConfig now calls os.getenv with
a default value (e.g., os.getenv("WHISPER_MODEL_SIZE", "medium")).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 14:22:33 -05:00
Andrew BeveridgeandClaude Opus 4.5 fbc0a3ac5d fix: make local-whisper respect WHISPER_MODEL_SIZE and WHISPER_DEVICE env vars
TranscriberConfig was using hardcoded defaults for local whisper settings
instead of reading from environment variables. This caused the env vars
WHISPER_MODEL_SIZE and WHISPER_DEVICE to be ignored.

The fix uses field(default_factory=...) to read from environment variables
at instantiation time, matching the documented behavior in LocalWhisperTranscriber.

Closes #93

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 14:14:41 -05:00
Andrew Beveridge ☄️ dbe39c9ad5 Merge pull request #106 from nomadkaraoke/fix/always-deploy-backend
fix: deploy backend on every push to main
2025-12-28 14:10:34 -05:00
Andrew BeveridgeandClaude Opus 4.5 6e8997eae8 fix: deploy backend on every push to main
Previously, backend deployment would skip if the version tag already existed.
This caused issues when multiple PRs merged with the same version - only the
first one would deploy.

Changes:
- Remove version tag check from deploy-backend job
- Deploy on every push to main regardless of version
- Docker caching still works efficiently for unchanged layers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 14:09:02 -05:00
Andrew Beveridge ☄️ 3ba3dc2d02 Merge pull request #105 from nomadkaraoke/feature/frontend-outputs-ui
feat(frontend): combine output links and fix React 19 test compatibility
2025-12-28 14:02:07 -05:00
Andrew BeveridgeandClaude Opus 4.5 257f592ef7 feat(frontend): combine output links and fix React 19 test compatibility
- Combine Distribution and Downloads sections into single Outputs row
- Fix dropbox_folder_url -> dropbox_link key to match backend state_data
- Upgrade @testing-library/react to v16.3.1 for React 19 support
- Upgrade @testing-library/jest-dom to v6.9.1

Fixes #102

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 13:59:40 -05:00
Andrew Beveridge ☄️ 9a33b6a6e0 Merge pull request #104 from nomadkaraoke/feature/scale-runners-to-10
feat: scale GitHub Actions runners from 5 to 10
2025-12-28 13:53:49 -05:00
Andrew BeveridgeandClaude Opus 4.5 4508c27ade feat: scale GitHub Actions runners from 5 to 10
- Increase NUM_RUNNERS from 5 to 10 for more parallel CI capacity
- Add ignoreChanges for existing runners (1-5) to prevent replacement
- Update documentation to reflect 10 runners

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 13:53:06 -05:00
Andrew Beveridge ☄️ 8e3bd636c4 Merge pull request #59 from nomadkaraoke/feature/agentic-playwright-tests-docs
Add agentic correction Playwright E2E tests and update documentation
2025-12-28 13:48:43 -05:00
23 changed files with 418 additions and 974 deletions

No files matched your search

+4 -36
View File
@@ -638,14 +638,10 @@ jobs:
BASE_IMAGE_NAME: karaoke-backend-base
APP_IMAGE_NAME: karaoke-backend
steps:
# ============================================
# Check if deployment is needed FIRST
# ============================================
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: false
fetch-depth: 0 # Need full history for tag check
- name: Set up Python 3.13
uses: actions/setup-python@v5
@@ -655,26 +651,15 @@ jobs:
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Extract version and check if deployment needed
- name: Extract version
id: version_check
run: |
VERSION=$(poetry version --short)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "📋 Current version: $VERSION"
if git ls-remote --tags origin | grep -q "refs/tags/v$VERSION$"; then
echo "needs_deploy=false" >> $GITHUB_OUTPUT
echo "⏭️ Tag v$VERSION already exists - skipping backend deployment"
echo " (Bump version in pyproject.toml to trigger a new deployment)"
else
echo "needs_deploy=true" >> $GITHUB_OUTPUT
echo "✨ Tag v$VERSION does not exist - proceeding with deployment"
fi
# No disk cleanup needed - self-hosted runner has 200GB SSD
echo "🚀 Deploying on every push to main"
- name: Authenticate to Google Cloud (Workload Identity)
if: steps.version_check.outputs.needs_deploy == 'true'
id: auth
uses: google-github-actions/auth@v2
with:
@@ -682,13 +667,11 @@ jobs:
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Set up Cloud SDK
if: steps.version_check.outputs.needs_deploy == 'true'
uses: google-github-actions/setup-gcloud@v2
with:
version: "latest"
- name: Configure Docker for Artifact Registry
if: steps.version_check.outputs.needs_deploy == 'true'
run: gcloud auth configure-docker ${{ env.REGISTRY }} --quiet
# ============================================
@@ -698,11 +681,9 @@ jobs:
# ============================================
- name: Set up Docker Buildx
if: steps.version_check.outputs.needs_deploy == 'true'
uses: docker/setup-buildx-action@v3
- name: Calculate base image hash
if: steps.version_check.outputs.needs_deploy == 'true'
id: base-hash
run: |
# Hash both poetry.lock AND Dockerfile.base - rebuild if either changes
@@ -711,7 +692,6 @@ jobs:
echo "📋 Base content hash: $CURRENT_HASH"
- name: Check if base image exists and is current
if: steps.version_check.outputs.needs_deploy == 'true'
id: check-base
run: |
BASE_IMAGE="${{ env.REGISTRY }}/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.BASE_IMAGE_NAME }}:latest"
@@ -738,7 +718,7 @@ jobs:
fi
- name: Build and push base image (if needed)
if: steps.version_check.outputs.needs_deploy == 'true' && steps.check-base.outputs.needs_rebuild == 'true'
if: steps.check-base.outputs.needs_rebuild == 'true'
uses: docker/build-push-action@v6
with:
context: .
@@ -759,7 +739,6 @@ jobs:
provenance: false
- name: Build and push app image
if: steps.version_check.outputs.needs_deploy == 'true'
uses: docker/build-push-action@v6
with:
context: .
@@ -780,7 +759,6 @@ jobs:
# ============================================
- name: Deploy to Cloud Run
if: steps.version_check.outputs.needs_deploy == 'true'
run: |
VERSION="${{ steps.version_check.outputs.version }}"
IMAGE="${{ env.REGISTRY }}/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.APP_IMAGE_NAME }}:${{ github.sha }}"
@@ -806,7 +784,6 @@ jobs:
--set-secrets "AUDIOSHAKE_API_TOKEN=audioshake-api-key:latest,GENIUS_API_TOKEN=genius-api-key:latest,SPOTIFY_COOKIE_SP_DC=spotify-cookie:latest,RAPIDAPI_KEY=rapidapi-key:latest,DEFAULT_DISCORD_WEBHOOK_URL=discord-releases-webhook:latest,ADMIN_TOKENS=admin-tokens:latest,RED_API_KEY=red-api-key:latest,RED_API_URL=red-api-url:latest,OPS_API_KEY=ops-api-key:latest,OPS_API_URL=ops-api-url:latest,FLACFETCH_API_URL=flacfetch-api-url:latest,FLACFETCH_API_KEY=flacfetch-api-key:latest"
- name: Verify deployment and version
if: steps.version_check.outputs.needs_deploy == 'true'
run: |
EXPECTED_VERSION="${{ steps.version_check.outputs.version }}"
SERVICE_URL=$(gcloud run services describe karaoke-backend \
@@ -847,7 +824,7 @@ jobs:
done
- name: Summary
if: steps.version_check.outputs.needs_deploy == 'true' && success()
if: success()
run: |
echo "🎉 Deployment successful!"
echo "Version: ${{ steps.version_check.outputs.version }}"
@@ -857,12 +834,3 @@ jobs:
echo ""
echo "📊 Built on self-hosted GCP runner (200GB SSD, no disk space issues)"
echo " Runner: gcp-runner with 4 vCPU, 16GB RAM"
- name: Skipped deployment summary
if: steps.version_check.outputs.needs_deploy == 'false'
run: |
echo "⏭️ Backend deployment skipped - version ${{ steps.version_check.outputs.version }} already deployed"
echo ""
echo "To deploy a new version:"
echo " 1. Update version in pyproject.toml"
echo " 2. Commit and push to main"
+1
View File
@@ -47,6 +47,7 @@ frontend/coverage/
frontend/test-results/
frontend/playwright-report/
frontend/playwright/.cache/
frontend/e2e/screenshots/
# TypeScript
frontend/*.tsbuildinfo
+6 -2
View File
@@ -136,8 +136,10 @@ class GoogleDriveService:
logger.info(f"Looking for folder '{folder_name}' in parent {parent_id}")
# Search for existing folder
# Escape single quotes in folder name for Google Drive API query syntax
escaped_folder_name = folder_name.replace("'", "\\'")
query = (
f"name='{folder_name}' and '{parent_id}' in parents "
f"name='{escaped_folder_name}' and '{parent_id}' in parents "
f"and mimeType='application/vnd.google-apps.folder' and trashed=false"
)
results = self.service.files().list(q=query, fields="files(id, name)").execute()
@@ -203,8 +205,10 @@ class GoogleDriveService:
# Check for existing file with same name
if replace_existing:
# Escape single quotes in filename for Google Drive API query syntax
escaped_filename = filename.replace("'", "\\'")
query = (
f"name='{filename}' and '{parent_id}' in parents and trashed=false"
f"name='{escaped_filename}' and '{parent_id}' in parents and trashed=false"
)
results = self.service.files().list(q=query, fields="files(id)").execute()
for existing_file in results.get("files", []):
+5
View File
@@ -291,11 +291,16 @@ async def generate_video(job_id: str) -> bool:
)
# Store result metadata in job
# NOTE: Must include dropbox_link and gdrive_files from result, since
# _handle_native_distribution already saved them but job.state_data
# is stale (fetched before distribution ran)
job_manager.update_job(job_id, {
'state_data': {
**job.state_data,
'brand_code': result.get('brand_code'),
'youtube_url': result.get('youtube_url'),
'dropbox_link': result.get('dropbox_link'),
'gdrive_files': result.get('gdrive_files'),
}
})
+42
View File
@@ -94,6 +94,48 @@ if job.input_media_gcs_path:
await trigger_worker()
```
### Stale Object References After Async Operations
**Problem**: Fetching a job object, then calling async functions that update the job in the database, then using the original object's data to make another update - this overwrites the async function's changes.
```python
# BAD - loses distribution results
job = job_manager.get_job(job_id) # Fetch job
await _handle_native_distribution(...) # Updates job.state_data in DB
job_manager.update_job(job_id, {
'state_data': {**job.state_data, 'foo': 'bar'} # STALE! Overwrites dropbox_link!
})
```
**Solution**: Either re-fetch the job, or include async results explicitly:
```python
# GOOD - include results from async operation
job_manager.update_job(job_id, {
'state_data': {
**job.state_data,
'dropbox_link': result.get('dropbox_link'), # From distribution
'gdrive_files': result.get('gdrive_files'),
}
})
```
### Google Drive API Query Escaping
**Problem**: Single quotes in filenames break Google Drive API queries.
```python
# BAD - fails for "Nobody's Home"
query = f"name='{filename}' and '{parent_id}' in parents"
# Results in: name='NOMAD-1187 - Artist - Nobody's Home.mp4' → 400 Invalid Value
```
**Solution**: Escape single quotes with backslash:
```python
# GOOD
escaped = filename.replace("'", "\\'")
query = f"name='{escaped}' and '{parent_id}' in parents"
```
## Testing Insights
### Emulator Tests Catch Real Bugs
+2 -11
View File
@@ -10,6 +10,7 @@ import { JobCard } from "@/components/job"
import { JobSubmission } from "@/components/job/JobSubmission"
import { AuthStatus } from "@/components/auth"
import { AutoProcessor } from "@/components/AutoProcessor"
import { VersionFooter } from "@/components/version-footer"
import { useTheme } from "@/lib/theme"
import {
Tooltip,
@@ -229,17 +230,7 @@ export default function HomePage() {
</div>
</main>
{/* Footer */}
<footer className="border-t mt-12 py-6" style={{ borderColor: 'var(--card-border)' }}>
<div className="px-4 text-center text-sm" style={{ color: 'var(--text-muted)' }}>
<p>
Powered by{" "}
<a href="https://github.com/nomadkaraoke/karaoke-gen" className="text-amber-500 hover:underline">
karaoke-gen
</a>
</p>
</div>
</footer>
<VersionFooter />
</div>
)
}
+13 -10
View File
@@ -31,14 +31,15 @@ function ColorField({ id, label, description, value, onChange, disabled }: Color
return (
<div className="space-y-1">
<div className="flex items-center justify-between">
<Label htmlFor={id} className="text-sm text-slate-300">
<Label htmlFor={id} className="text-sm" style={{ color: 'var(--text)' }}>
{label}
</Label>
{value && (
<button
type="button"
onClick={() => onChange(undefined)}
className="text-xs text-slate-500 hover:text-slate-300"
className="text-xs"
style={{ color: 'var(--text-muted)' }}
disabled={disabled}
>
Reset
@@ -47,8 +48,8 @@ function ColorField({ id, label, description, value, onChange, disabled }: Color
</div>
<div className="flex items-center gap-2">
<div
className="w-8 h-8 rounded border border-slate-600 flex-shrink-0"
style={{ backgroundColor: value || "#333333" }}
className="w-8 h-8 rounded border flex-shrink-0"
style={{ backgroundColor: value || "#333333", borderColor: 'var(--card-border)' }}
/>
<Input
id={id}
@@ -64,7 +65,8 @@ function ColorField({ id, label, description, value, onChange, disabled }: Color
}
}}
disabled={disabled}
className="bg-slate-800 border-slate-700 text-white placeholder:text-slate-500 font-mono text-sm"
className="font-mono text-sm"
style={{ backgroundColor: 'var(--secondary)', borderColor: 'var(--card-border)', color: 'var(--text)' }}
/>
<Input
type="color"
@@ -74,7 +76,7 @@ function ColorField({ id, label, description, value, onChange, disabled }: Color
className="w-10 h-8 p-0 border-0 bg-transparent cursor-pointer"
/>
</div>
<p className="text-xs text-slate-500">{description}</p>
<p className="text-xs" style={{ color: 'var(--text-muted)' }}>{description}</p>
</div>
)
}
@@ -106,7 +108,8 @@ export function ColorOverridesPanel({ value, onChange, disabled }: ColorOverride
<Button
variant="ghost"
type="button"
className="w-full justify-between px-3 py-2 h-auto text-slate-300 hover:text-white hover:bg-slate-700/50"
className="w-full justify-between px-3 py-2 h-auto"
style={{ color: 'var(--text)' }}
>
<span className="flex items-center gap-2">
<Paintbrush className="w-4 h-4" />
@@ -126,9 +129,9 @@ export function ColorOverridesPanel({ value, onChange, disabled }: ColorOverride
</CollapsibleTrigger>
<CollapsibleContent className="mt-2">
<div className="space-y-4 p-4 rounded-lg border border-slate-700 bg-slate-800/50">
<div className="space-y-4 p-4 rounded-lg border" style={{ borderColor: 'var(--card-border)', backgroundColor: 'var(--secondary)' }}>
<div className="flex items-center justify-between">
<p className="text-sm text-slate-400">
<p className="text-sm" style={{ color: 'var(--text-muted)' }}>
Override theme colors (optional)
</p>
{hasAnyOverrides && (
@@ -138,7 +141,7 @@ export function ColorOverridesPanel({ value, onChange, disabled }: ColorOverride
size="sm"
onClick={handleResetAll}
disabled={disabled}
className="text-slate-400 hover:text-white"
style={{ color: 'var(--text-muted)' }}
>
<RotateCcw className="w-3 h-3 mr-1" />
Reset All
+2 -1
View File
@@ -124,7 +124,8 @@ export function JobActions({ job, onRefresh, showLogs, onToggleLogs }: JobAction
size="sm"
variant="ghost"
onClick={onToggleLogs}
className="text-xs text-slate-400 hover:text-white"
className="text-xs"
style={{ color: 'var(--text-muted)' }}
>
<FileText className="w-3 h-3 mr-1" />
{showLogs ? "Hide" : "Show"} Logs
+9 -5
View File
@@ -60,7 +60,7 @@ function ProgressBar({ job }: { job: Job }) {
const barColor = barColorMap[color] || "bg-blue-400"
return (
<div className="w-full h-1 bg-slate-700/50 rounded-full mt-2 overflow-hidden">
<div className="w-full h-1 rounded-full mt-2 overflow-hidden" style={{ backgroundColor: 'var(--secondary)' }}>
<div
className={`h-full ${barColor} rounded-full transition-all duration-500 ease-out`}
style={{ width: `${progressPercent}%` }}
@@ -190,18 +190,22 @@ export function JobCard({ job, onRefresh }: JobCardProps) {
return (
<div
className={`rounded-lg border p-3 transition-colors border-slate-700 bg-slate-800/30
className={`rounded-lg border p-3 transition-colors
${isComplete ? "border-green-500/30" : ""}
${isFailed ? "border-red-500/30" : ""}`}
style={{
borderColor: isComplete || isFailed ? undefined : 'var(--card-border)',
backgroundColor: 'var(--card)',
}}
>
{/* Header row with title */}
<p className="font-medium text-white truncate">
<p className="font-medium truncate" style={{ color: 'var(--text)' }}>
{job.artist || "Unknown"} - {job.title || "Unknown"}
</p>
{/* Meta row: ID, date, status */}
<p className="text-xs text-slate-500 mt-1">
<span className="text-slate-600">ID:</span> {job.job_id} <span className="text-slate-600">•</span> {createdAt} <span className="text-slate-600">•</span> <StatusIndicator job={job} />
<p className="text-xs mt-1" style={{ color: 'var(--text-muted)' }}>
<span style={{ opacity: 0.7 }}>ID:</span> {job.job_id} <span style={{ opacity: 0.7 }}>•</span> {createdAt} <span style={{ opacity: 0.7 }}>•</span> <StatusIndicator job={job} />
</p>
{/* Progress bar for active jobs */}
+6 -5
View File
@@ -34,7 +34,7 @@ export function JobLogs({ jobId, limit = 50 }: JobLogsProps) {
if (isLoading) {
return (
<div className="flex items-center justify-center py-4 text-slate-400">
<div className="flex items-center justify-center py-4" style={{ color: 'var(--text-muted)' }}>
<Loader2 className="w-4 h-4 animate-spin mr-2" />
Loading logs...
</div>
@@ -52,14 +52,14 @@ export function JobLogs({ jobId, limit = 50 }: JobLogsProps) {
if (logs.length === 0) {
return (
<div className="text-center py-4 text-slate-500 text-sm">
<div className="text-center py-4 text-sm" style={{ color: 'var(--text-muted)' }}>
No logs available
</div>
)
}
return (
<div className="bg-slate-900 rounded border border-slate-700 p-3 max-h-64 overflow-y-auto">
<div className="rounded border p-3 max-h-64 overflow-y-auto" style={{ backgroundColor: 'var(--bg)', borderColor: 'var(--card-border)' }}>
<div className="space-y-1 font-mono text-xs">
{logs.map((log, index) => (
<div
@@ -68,10 +68,11 @@ export function JobLogs({ jobId, limit = 50 }: JobLogsProps) {
log.level === "ERROR" ? "text-red-400" :
log.level === "WARNING" ? "text-yellow-400" :
log.level === "INFO" ? "text-blue-400" :
"text-slate-400"
""
}`}
style={log.level !== "ERROR" && log.level !== "WARNING" && log.level !== "INFO" ? { color: 'var(--text-muted)' } : undefined}
>
<span className="text-slate-600 shrink-0">
<span className="shrink-0" style={{ color: 'var(--text-muted)', opacity: 0.7 }}>
{new Date(log.timestamp).toLocaleTimeString()}
</span>
<span className="shrink-0 font-semibold w-12">
+50 -34
View File
@@ -17,7 +17,7 @@ interface JobSubmissionProps {
}
export function JobSubmission({ onJobCreated }: JobSubmissionProps) {
const [activeTab, setActiveTab] = useState("upload")
const [activeTab, setActiveTab] = useState("search")
const [error, setError] = useState("")
const [isSubmitting, setIsSubmitting] = useState(false)
@@ -147,28 +147,43 @@ export function JobSubmission({ onJobCreated }: JobSubmissionProps) {
return (
<Tabs value={activeTab} onValueChange={setActiveTab}>
<TabsList className="grid w-full grid-cols-3 bg-slate-800 h-auto">
<TabsTrigger value="upload" className="gap-1.5 sm:gap-2 py-3 min-h-[44px] text-xs sm:text-sm data-[state=active]:bg-slate-700">
<TabsList className="grid w-full grid-cols-3 h-auto rounded-lg p-1" style={{ backgroundColor: 'var(--secondary)' }}>
<TabsTrigger
value="search"
className="gap-1.5 sm:gap-2 py-3 min-h-[44px] text-xs sm:text-sm rounded-md data-[state=active]:bg-amber-500 data-[state=active]:text-white data-[state=inactive]:opacity-70"
style={{ color: 'var(--text)' }}
>
<Music className="w-4 h-4 shrink-0" />
<span className="truncate">Search</span>
</TabsTrigger>
<TabsTrigger
value="upload"
className="gap-1.5 sm:gap-2 py-3 min-h-[44px] text-xs sm:text-sm rounded-md data-[state=active]:bg-amber-500 data-[state=active]:text-white data-[state=inactive]:opacity-70"
style={{ color: 'var(--text)' }}
>
<Upload className="w-4 h-4 shrink-0" />
<span className="truncate">Upload</span>
</TabsTrigger>
<TabsTrigger value="url" className="gap-1.5 sm:gap-2 py-3 min-h-[44px] text-xs sm:text-sm data-[state=active]:bg-slate-700">
<TabsTrigger
value="url"
className="gap-1.5 sm:gap-2 py-3 min-h-[44px] text-xs sm:text-sm rounded-md data-[state=active]:bg-amber-500 data-[state=active]:text-white data-[state=inactive]:opacity-70"
style={{ color: 'var(--text)' }}
>
<Youtube className="w-4 h-4 shrink-0" />
<span className="truncate">URL</span>
</TabsTrigger>
<TabsTrigger value="search" className="gap-1.5 sm:gap-2 py-3 min-h-[44px] text-xs sm:text-sm data-[state=active]:bg-slate-700">
<Music className="w-4 h-4 shrink-0" />
<span className="truncate">Search</span>
</TabsTrigger>
</TabsList>
<TabsContent value="upload" className="mt-4">
<form onSubmit={handleUploadSubmit} className="space-y-4">
<div className="space-y-2">
<Label htmlFor="audio-file" className="text-slate-200">Audio File</Label>
<Label htmlFor="audio-file" style={{ color: 'var(--text)' }}>Audio File</Label>
<div
className={`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer
${uploadFile ? "border-amber-500/50 bg-amber-500/5" : "border-slate-700 hover:border-slate-600 bg-slate-800/50"}`}
className="relative border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer"
style={{
borderColor: uploadFile ? 'rgb(245 158 11 / 0.5)' : 'var(--card-border)',
backgroundColor: uploadFile ? 'rgb(245 158 11 / 0.05)' : 'var(--secondary)',
}}
>
<Input
id="audio-file"
@@ -178,16 +193,16 @@ export function JobSubmission({ onJobCreated }: JobSubmissionProps) {
className="absolute inset-0 w-full h-full opacity-0 cursor-pointer"
disabled={isSubmitting}
/>
<Upload className="w-8 h-8 mx-auto mb-2 text-slate-500" />
<Upload className="w-8 h-8 mx-auto mb-2" style={{ color: 'var(--text-muted)' }} />
{uploadFile ? (
<div>
<p className="font-medium text-white">{uploadFile.name}</p>
<p className="text-sm text-slate-400">{(uploadFile.size / 1024 / 1024).toFixed(2)} MB</p>
<p className="font-medium" style={{ color: 'var(--text)' }}>{uploadFile.name}</p>
<p className="text-sm" style={{ color: 'var(--text-muted)' }}>{(uploadFile.size / 1024 / 1024).toFixed(2)} MB</p>
</div>
) : (
<div>
<p className="font-medium text-slate-300 mb-1">Click to upload</p>
<p className="text-sm text-slate-500">MP3, WAV, FLAC, M4A, or OGG</p>
<p className="font-medium mb-1" style={{ color: 'var(--text)' }}>Click to upload</p>
<p className="text-sm" style={{ color: 'var(--text-muted)' }}>MP3, WAV, FLAC, M4A, or OGG</p>
</div>
)}
</div>
@@ -195,31 +210,31 @@ export function JobSubmission({ onJobCreated }: JobSubmissionProps) {
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3 sm:gap-4">
<div className="space-y-2">
<Label htmlFor="upload-artist" className="text-slate-200">Artist</Label>
<Label htmlFor="upload-artist" style={{ color: 'var(--text)' }}>Artist</Label>
<Input
id="upload-artist"
placeholder="Artist name"
value={uploadArtist}
onChange={(e) => setUploadArtist(e.target.value)}
disabled={isSubmitting}
className="bg-slate-800 border-slate-700 text-white placeholder:text-slate-500"
style={{ backgroundColor: 'var(--secondary)', borderColor: 'var(--card-border)', color: 'var(--text)' }}
/>
</div>
<div className="space-y-2">
<Label htmlFor="upload-title" className="text-slate-200">Title</Label>
<Label htmlFor="upload-title" style={{ color: 'var(--text)' }}>Title</Label>
<Input
id="upload-title"
placeholder="Song title"
value={uploadTitle}
onChange={(e) => setUploadTitle(e.target.value)}
disabled={isSubmitting}
className="bg-slate-800 border-slate-700 text-white placeholder:text-slate-500"
style={{ backgroundColor: 'var(--secondary)', borderColor: 'var(--card-border)', color: 'var(--text)' }}
/>
</div>
</div>
{/* Theme Selection */}
<div className="space-y-4 pt-4 border-t border-slate-700">
<div className="space-y-4 pt-4 border-t" style={{ borderColor: 'var(--card-border)' }}>
<ThemeSelector
value={selectedTheme}
onChange={setSelectedTheme}
@@ -256,16 +271,17 @@ export function JobSubmission({ onJobCreated }: JobSubmissionProps) {
<TabsContent value="url" className="mt-4">
<form onSubmit={handleUrlSubmit} className="space-y-4">
<div className="space-y-2">
<Label htmlFor="youtube-url" className="text-slate-200">YouTube URL</Label>
<Label htmlFor="youtube-url" style={{ color: 'var(--text)' }}>YouTube URL</Label>
<div className="relative">
<Youtube className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500" />
<Youtube className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4" style={{ color: 'var(--text-muted)' }} />
<Input
id="youtube-url"
type="url"
placeholder="https://youtube.com/watch?v=..."
value={youtubeUrl}
onChange={(e) => setYoutubeUrl(e.target.value)}
className="pl-10 bg-slate-800 border-slate-700 text-white placeholder:text-slate-500"
className="pl-10"
style={{ backgroundColor: 'var(--secondary)', borderColor: 'var(--card-border)', color: 'var(--text)' }}
disabled={isSubmitting}
/>
</div>
@@ -273,31 +289,31 @@ export function JobSubmission({ onJobCreated }: JobSubmissionProps) {
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3 sm:gap-4">
<div className="space-y-2">
<Label htmlFor="youtube-artist" className="text-slate-200">Artist (optional)</Label>
<Label htmlFor="youtube-artist" style={{ color: 'var(--text)' }}>Artist (optional)</Label>
<Input
id="youtube-artist"
placeholder="Auto-detected"
value={youtubeArtist}
onChange={(e) => setYoutubeArtist(e.target.value)}
disabled={isSubmitting}
className="bg-slate-800 border-slate-700 text-white placeholder:text-slate-500"
style={{ backgroundColor: 'var(--secondary)', borderColor: 'var(--card-border)', color: 'var(--text)' }}
/>
</div>
<div className="space-y-2">
<Label htmlFor="youtube-title" className="text-slate-200">Title (optional)</Label>
<Label htmlFor="youtube-title" style={{ color: 'var(--text)' }}>Title (optional)</Label>
<Input
id="youtube-title"
placeholder="Auto-detected"
value={youtubeTitle}
onChange={(e) => setYoutubeTitle(e.target.value)}
disabled={isSubmitting}
className="bg-slate-800 border-slate-700 text-white placeholder:text-slate-500"
style={{ backgroundColor: 'var(--secondary)', borderColor: 'var(--card-border)', color: 'var(--text)' }}
/>
</div>
</div>
{/* Theme Selection */}
<div className="space-y-4 pt-4 border-t border-slate-700">
<div className="space-y-4 pt-4 border-t" style={{ borderColor: 'var(--card-border)' }}>
<ThemeSelector
value={selectedTheme}
onChange={setSelectedTheme}
@@ -335,31 +351,31 @@ export function JobSubmission({ onJobCreated }: JobSubmissionProps) {
<form onSubmit={handleSearchSubmit} className="space-y-4">
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3 sm:gap-4">
<div className="space-y-2">
<Label htmlFor="search-artist" className="text-slate-200">Artist</Label>
<Label htmlFor="search-artist" style={{ color: 'var(--text)' }}>Artist</Label>
<Input
id="search-artist"
placeholder="Artist name"
value={searchArtist}
onChange={(e) => setSearchArtist(e.target.value)}
disabled={isSubmitting}
className="bg-slate-800 border-slate-700 text-white placeholder:text-slate-500"
style={{ backgroundColor: 'var(--secondary)', borderColor: 'var(--card-border)', color: 'var(--text)' }}
/>
</div>
<div className="space-y-2">
<Label htmlFor="search-title" className="text-slate-200">Title</Label>
<Label htmlFor="search-title" style={{ color: 'var(--text)' }}>Title</Label>
<Input
id="search-title"
placeholder="Song title"
value={searchTitle}
onChange={(e) => setSearchTitle(e.target.value)}
disabled={isSubmitting}
className="bg-slate-800 border-slate-700 text-white placeholder:text-slate-500"
style={{ backgroundColor: 'var(--secondary)', borderColor: 'var(--card-border)', color: 'var(--text)' }}
/>
</div>
</div>
{/* Theme Selection */}
<div className="space-y-4 pt-4 border-t border-slate-700">
<div className="space-y-4 pt-4 border-t" style={{ borderColor: 'var(--card-border)' }}>
<ThemeSelector
value={selectedTheme}
onChange={setSelectedTheme}
+19 -24
View File
@@ -30,8 +30,8 @@ export function OutputLinks({ jobId }: OutputLinksProps) {
if (job.state_data?.youtube_url) {
setYoutubeUrl(job.state_data.youtube_url)
}
if (job.state_data?.dropbox_folder_url) {
setDropboxUrl(job.state_data.dropbox_folder_url)
if (job.state_data?.dropbox_link) {
setDropboxUrl(job.state_data.dropbox_link)
}
} catch (err) {
console.error("Failed to load output links:", err)
@@ -42,20 +42,23 @@ export function OutputLinks({ jobId }: OutputLinksProps) {
if (isLoading) {
return (
<div className="flex items-center gap-2 text-xs text-slate-400">
<div className="flex items-center gap-2 text-xs" style={{ color: 'var(--text-muted)' }}>
<Loader2 className="w-3 h-3 animate-spin" />
Loading downloads...
</div>
)
}
const hasOutputs = youtubeUrl || dropboxUrl || (downloadUrls && Object.keys(downloadUrls).length > 0)
return (
<div className="space-y-2">
{/* Distribution Links */}
{(youtubeUrl || dropboxUrl) && (
{/* Combined Output Links */}
{hasOutputs && (
<div className="space-y-2">
<p className="text-xs text-slate-400 font-medium">Distribution:</p>
<p className="text-xs font-medium" style={{ color: 'var(--text-muted)' }}>Outputs:</p>
<div className="flex flex-wrap gap-2">
{/* Distribution Links */}
{youtubeUrl && (
<a
href={youtubeUrl}
@@ -77,19 +80,11 @@ export function OutputLinks({ jobId }: OutputLinksProps) {
onClick={(e) => e.stopPropagation()}
>
<FolderOpen className="w-3 h-3" />
Open Dropbox Folder
Dropbox Folder
</a>
)}
</div>
</div>
)}
{/* Download Links */}
{downloadUrls && Object.keys(downloadUrls).length > 0 && (
<div className="space-y-2">
<p className="text-xs text-slate-400 font-medium">Downloads:</p>
<div className="flex flex-wrap gap-2">
{downloadUrls.finals?.lossy_720p && (
{/* Download Links */}
{downloadUrls?.finals?.lossy_720p && (
<a
href={api.getDownloadUrl(jobId, "finals", "lossy_720p")}
className="inline-flex items-center gap-1 text-xs px-3 py-1.5 rounded bg-green-600 hover:bg-green-500 text-white"
@@ -99,7 +94,7 @@ export function OutputLinks({ jobId }: OutputLinksProps) {
720p Video
</a>
)}
{downloadUrls.finals?.lossy_4k_mp4 && (
{downloadUrls?.finals?.lossy_4k_mp4 && (
<a
href={api.getDownloadUrl(jobId, "finals", "lossy_4k_mp4")}
className="inline-flex items-center gap-1 text-xs px-3 py-1.5 rounded bg-green-600 hover:bg-green-500 text-white"
@@ -109,20 +104,20 @@ export function OutputLinks({ jobId }: OutputLinksProps) {
4K Video
</a>
)}
{downloadUrls.packages?.cdg_zip && (
{downloadUrls?.packages?.cdg_zip && (
<a
href={api.getDownloadUrl(jobId, "packages", "cdg_zip")}
className="inline-flex items-center gap-1 text-xs px-2 py-1.5 rounded bg-slate-600 hover:bg-slate-500 text-white"
className="inline-flex items-center gap-1 text-xs px-2 py-1.5 rounded bg-gray-700 hover:bg-gray-600 text-white"
onClick={(e) => e.stopPropagation()}
>
<Download className="w-3 h-3" />
CDG+MP3
</a>
)}
{downloadUrls.packages?.txt_zip && (
{downloadUrls?.packages?.txt_zip && (
<a
href={api.getDownloadUrl(jobId, "packages", "txt_zip")}
className="inline-flex items-center gap-1 text-xs px-2 py-1.5 rounded bg-slate-600 hover:bg-slate-500 text-white"
className="inline-flex items-center gap-1 text-xs px-2 py-1.5 rounded bg-gray-700 hover:bg-gray-600 text-white"
onClick={(e) => e.stopPropagation()}
>
<Download className="w-3 h-3" />
@@ -133,8 +128,8 @@ export function OutputLinks({ jobId }: OutputLinksProps) {
</div>
)}
{!downloadUrls && !youtubeUrl && !dropboxUrl && (
<p className="text-xs text-slate-500">No outputs available yet</p>
{!hasOutputs && (
<p className="text-xs" style={{ color: 'var(--text-muted)' }}>No outputs available yet</p>
)}
</div>
)
+28 -13
View File
@@ -6,7 +6,8 @@ import type { VideoThemeSummary } from "@/lib/video-themes"
import { Label } from "@/components/ui/label"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { Skeleton } from "@/components/ui/skeleton"
import { Palette, AlertCircle } from "lucide-react"
import { Button } from "@/components/ui/button"
import { Palette, AlertCircle, Eye, EyeOff } from "lucide-react"
interface ThemeSelectorProps {
value?: string
@@ -18,6 +19,7 @@ export function ThemeSelector({ value, onChange, disabled }: ThemeSelectorProps)
const [themes, setThemes] = useState<VideoThemeSummary[]>([])
const [loading, setLoading] = useState(true)
const [error, setError] = useState<string | null>(null)
const [showPreview, setShowPreview] = useState(false)
useEffect(() => {
async function loadThemes() {
@@ -52,11 +54,11 @@ export function ThemeSelector({ value, onChange, disabled }: ThemeSelectorProps)
if (loading) {
return (
<div className="space-y-2">
<Label className="text-slate-200 flex items-center gap-2">
<Label className="flex items-center gap-2" style={{ color: 'var(--text)' }}>
<Palette className="w-4 h-4" />
Video Theme
</Label>
<Skeleton className="h-10 w-full bg-slate-700" />
<Skeleton className="h-10 w-full" style={{ backgroundColor: 'var(--secondary)' }} />
</div>
)
}
@@ -64,7 +66,7 @@ export function ThemeSelector({ value, onChange, disabled }: ThemeSelectorProps)
if (error || themes.length === 0) {
return (
<div className="space-y-2">
<Label className="text-slate-200 flex items-center gap-2">
<Label className="flex items-center gap-2" style={{ color: 'var(--text)' }}>
<Palette className="w-4 h-4" />
Video Theme
</Label>
@@ -78,7 +80,7 @@ export function ThemeSelector({ value, onChange, disabled }: ThemeSelectorProps)
return (
<div className="space-y-2">
<Label htmlFor="theme-select" className="text-slate-200 flex items-center gap-2">
<Label htmlFor="theme-select" className="flex items-center gap-2" style={{ color: 'var(--text)' }}>
<Palette className="w-4 h-4" />
Video Theme
</Label>
@@ -90,16 +92,16 @@ export function ThemeSelector({ value, onChange, disabled }: ThemeSelectorProps)
>
<SelectTrigger
id="theme-select"
className="bg-slate-800 border-slate-700 text-white"
style={{ backgroundColor: 'var(--secondary)', borderColor: 'var(--card-border)', color: 'var(--text)' }}
>
<SelectValue placeholder="Select a theme..." />
</SelectTrigger>
<SelectContent className="bg-slate-800 border-slate-700">
<SelectContent style={{ backgroundColor: 'var(--card)', borderColor: 'var(--card-border)' }}>
{themes.map((theme) => (
<SelectItem
key={theme.id}
value={theme.id}
className="text-white hover:bg-slate-700 focus:bg-slate-700"
style={{ color: 'var(--text)' }}
>
<div className="flex items-center gap-2">
<span>{theme.name}</span>
@@ -112,13 +114,26 @@ export function ThemeSelector({ value, onChange, disabled }: ThemeSelectorProps)
</SelectContent>
</Select>
{/* Theme description and preview */}
{selectedTheme && (
{/* Theme preview toggle */}
{selectedTheme?.thumbnail_url && (
<div className="mt-2 space-y-2">
<p className="text-sm text-slate-400">{selectedTheme.description}</p>
<Button
type="button"
variant="ghost"
size="sm"
onClick={() => setShowPreview(!showPreview)}
className="px-0"
style={{ color: 'var(--text-muted)' }}
>
{showPreview ? (
<><EyeOff className="w-4 h-4 mr-1.5" />Hide preview</>
) : (
<><Eye className="w-4 h-4 mr-1.5" />Show preview</>
)}
</Button>
{selectedTheme.thumbnail_url && (
<div className="relative w-full aspect-video max-w-xs rounded-lg overflow-hidden border border-slate-700">
{showPreview && (
<div className="relative w-full aspect-video max-w-xs rounded-lg overflow-hidden border" style={{ borderColor: 'var(--card-border)' }}>
<img
src={selectedTheme.thumbnail_url}
alt={`${selectedTheme.name} preview`}
+46
View File
@@ -0,0 +1,46 @@
"use client";
import { useEffect, useState } from "react";
import { api } from "@/lib/api";
export function VersionFooter() {
const [backendVersion, setBackendVersion] = useState<string | null>(null);
// Frontend version is injected at build time from pyproject.toml
const frontendVersion = process.env.NEXT_PUBLIC_APP_VERSION || "dev";
useEffect(() => {
const fetchBackendVersion = async () => {
try {
const info = await api.getBackendInfo();
setBackendVersion(info.version);
} catch (error) {
console.error("Failed to fetch backend version:", error);
setBackendVersion(null);
}
};
fetchBackendVersion();
}, []);
return (
<footer className="border-t mt-12 py-6" style={{ borderColor: 'var(--card-border)' }}>
<div className="px-4 text-center text-sm" style={{ color: 'var(--text-muted)' }}>
<p>
Powered by{" "}
<a href="https://github.com/nomadkaraoke/karaoke-gen" className="text-amber-500 hover:underline">
karaoke-gen
</a>
</p>
<p className="mt-1 text-xs opacity-75">
Frontend: v{frontendVersion}
{backendVersion && (
<>
{" | "}
Backend: v{backendVersion}
</>
)}
</p>
</div>
</footer>
);
}
+21 -2
View File
@@ -384,10 +384,15 @@ export const api = {
},
/**
* Get the base download URL for a file
* Get the download URL for a file, including authentication token
*/
getDownloadUrl(jobId: string, category: string, fileKey: string): string {
return `${API_BASE_URL}/api/jobs/${jobId}/download/${category}/${fileKey}`;
const baseUrl = `${API_BASE_URL}/api/jobs/${jobId}/download/${category}/${fileKey}`;
const token = getAccessToken();
if (token) {
return `${baseUrl}?token=${encodeURIComponent(token)}`;
}
return baseUrl;
},
/**
@@ -517,6 +522,20 @@ export const api = {
const data = await handleResponse<{ description: string | null }>(response);
return data.description;
},
// ==========================================================================
// Version API endpoint
// ==========================================================================
/**
* Get backend service info including version
*/
async getBackendInfo(): Promise<{ service: string; version: string; status: string }> {
const response = await fetch(`${API_BASE_URL}/`, {
headers: getAuthHeaders()
});
return handleResponse(response);
},
};
export { ApiError };
+61 -814
View File
File diff suppressed because it is too large. Load diff
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "my-v0-project",
"version": "0.1.0",
"name": "karaoke-gen-frontend",
"version": "0.76.26",
"private": true,
"scripts": {
"build": "next build",
@@ -82,8 +82,8 @@
"devDependencies": {
"@playwright/test": "^1.57.0",
"@tailwindcss/postcss": "^4.1.9",
"@testing-library/jest-dom": "^6.1.5",
"@testing-library/react": "^14.1.2",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.1",
"@testing-library/user-event": "^14.5.1",
"@types/jest": "^29.5.11",
"@types/node": "^22",
+4 -4
View File
@@ -262,7 +262,7 @@ Multiple GCP VMs run self-hosted GitHub Actions runners to:
### Specs
- **Instances**: 5x e2-standard-4 (4 vCPU, 16GB RAM each)
- **Instances**: 10x e2-standard-4 (4 vCPU, 16GB RAM each)
- **Disk**: 200GB SSD per runner
- **Pre-installed**: Docker, Python 3.13, Node.js 20, Java 21, Poetry, FFmpeg, gcloud CLI
- **Labels**: `self-hosted`, `linux`, `x64`, `gcp`, `large-disk`
@@ -285,7 +285,7 @@ Multiple GCP VMs run self-hosted GitHub Actions runners to:
4. Verify the runners registered:
- Go to https://github.com/nomadkaraoke/karaoke-gen/settings/actions/runners
- You should see `gcp-runner-github-runner-1` through `gcp-runner-github-runner-5`
- You should see `gcp-runner-github-runner-1` through `gcp-runner-github-runner-10`
### Usage in Workflows
@@ -306,7 +306,7 @@ GitHub automatically distributes jobs across available runners.
**Runner not appearing in GitHub:**
```bash
# Check startup logs (replace N with runner number 1-3)
# Check startup logs (replace N with runner number 1-10)
gcloud compute ssh github-runner-N --zone=us-central1-a -- \
"sudo cat /var/log/github-runner-startup.log"
```
@@ -325,7 +325,7 @@ gcloud compute ssh github-runner-N --zone=us-central1-a -- \
**List all runners:**
```bash
for i in 1 2 3 4 5; do
for i in {1..10}; do
echo "=== github-runner-$i ==="
gcloud compute instances describe github-runner-$i --zone=us-central1-a --format='get(status)'
done
+6 -2
View File
@@ -1419,7 +1419,7 @@ echo "Setup complete!"
"""
# GitHub runner VM instances (multiple runners for parallel job execution)
NUM_RUNNERS = 5
NUM_RUNNERS = 10
github_runner_vms = []
for i in range(1, NUM_RUNNERS + 1):
@@ -1447,7 +1447,11 @@ for i in range(1, NUM_RUNNERS + 1):
tags=["github-runner"],
allow_stopping_for_update=True,
# Ensure the secret exists before creating the VM
opts=pulumi.ResourceOptions(depends_on=[github_runner_pat_secret]),
# For existing runners (1-5), ignore startup script changes to avoid replacement
opts=pulumi.ResourceOptions(
depends_on=[github_runner_pat_secret],
ignore_changes=["metadataStartupScript"] if i <= 5 else None,
),
)
github_runner_vms.append(vm)
@@ -11,12 +11,13 @@ class TranscriberConfig:
runpod_api_key: Optional[str] = None
whisper_runpod_id: Optional[str] = None
# Local Whisper configuration
# Local Whisper configuration - reads from environment variables with sensible defaults
# Environment variables: WHISPER_MODEL_SIZE, WHISPER_DEVICE, WHISPER_CACHE_DIR, WHISPER_LANGUAGE
enable_local_whisper: bool = True # Enabled by default as fallback
local_whisper_model_size: str = "medium" # tiny, base, small, medium, large
local_whisper_device: Optional[str] = None # None for auto-detect, or cpu/cuda/mps
local_whisper_cache_dir: Optional[str] = None # Custom model download location
local_whisper_language: Optional[str] = None # None for auto-detect
local_whisper_model_size: str = field(default_factory=lambda: os.getenv("WHISPER_MODEL_SIZE", "medium"))
local_whisper_device: Optional[str] = field(default_factory=lambda: os.getenv("WHISPER_DEVICE"))
local_whisper_cache_dir: Optional[str] = field(default_factory=lambda: os.getenv("WHISPER_CACHE_DIR"))
local_whisper_language: Optional[str] = field(default_factory=lambda: os.getenv("WHISPER_LANGUAGE"))
@dataclass
@@ -0,0 +1,81 @@
"""Tests for core configuration classes."""
import os
import pytest
from unittest.mock import patch
from lyrics_transcriber.core.config import TranscriberConfig
class TestTranscriberConfig:
"""Tests for TranscriberConfig dataclass."""
def test_default_values(self):
"""Test that default values are set correctly when no env vars are present."""
with patch.dict(os.environ, {}, clear=True):
# Remove any existing WHISPER_* env vars
for key in list(os.environ.keys()):
if key.startswith("WHISPER_"):
del os.environ[key]
config = TranscriberConfig()
assert config.enable_local_whisper is True
assert config.local_whisper_model_size == "medium"
assert config.local_whisper_device is None
assert config.local_whisper_cache_dir is None
assert config.local_whisper_language is None
def test_reads_whisper_model_size_from_env(self):
"""Test that WHISPER_MODEL_SIZE env var is respected."""
with patch.dict(os.environ, {"WHISPER_MODEL_SIZE": "large"}, clear=False):
config = TranscriberConfig()
assert config.local_whisper_model_size == "large"
def test_reads_whisper_device_from_env(self):
"""Test that WHISPER_DEVICE env var is respected."""
with patch.dict(os.environ, {"WHISPER_DEVICE": "mps"}, clear=False):
config = TranscriberConfig()
assert config.local_whisper_device == "mps"
def test_reads_whisper_cache_dir_from_env(self):
"""Test that WHISPER_CACHE_DIR env var is respected."""
with patch.dict(os.environ, {"WHISPER_CACHE_DIR": "/custom/cache"}, clear=False):
config = TranscriberConfig()
assert config.local_whisper_cache_dir == "/custom/cache"
def test_reads_whisper_language_from_env(self):
"""Test that WHISPER_LANGUAGE env var is respected."""
with patch.dict(os.environ, {"WHISPER_LANGUAGE": "en"}, clear=False):
config = TranscriberConfig()
assert config.local_whisper_language == "en"
def test_reads_all_whisper_env_vars(self):
"""Test that all WHISPER_* env vars are respected together."""
env_vars = {
"WHISPER_MODEL_SIZE": "large-v3",
"WHISPER_DEVICE": "cuda",
"WHISPER_CACHE_DIR": "/models/whisper",
"WHISPER_LANGUAGE": "es",
}
with patch.dict(os.environ, env_vars, clear=False):
config = TranscriberConfig()
assert config.local_whisper_model_size == "large-v3"
assert config.local_whisper_device == "cuda"
assert config.local_whisper_cache_dir == "/models/whisper"
assert config.local_whisper_language == "es"
def test_explicit_values_override_env_vars(self):
"""Test that explicitly passed values override env vars."""
with patch.dict(os.environ, {"WHISPER_MODEL_SIZE": "large"}, clear=False):
config = TranscriberConfig(local_whisper_model_size="small")
assert config.local_whisper_model_size == "small"
def test_cloud_provider_config(self):
"""Test that cloud provider config fields work correctly."""
config = TranscriberConfig(
audioshake_api_token="test_token",
runpod_api_key="test_key",
whisper_runpod_id="test_id",
)
assert config.audioshake_api_token == "test_token"
assert config.runpod_api_key == "test_key"
assert config.whisper_runpod_id == "test_id"
+1 -1
View File
@@ -1,6 +1,6 @@
[tool.poetry]
name = "karaoke-gen"
version = "0.76.26"
version = "0.76.28"
description = "Generate karaoke videos with synchronized lyrics. Handles the entire process from downloading audio and lyrics to creating the final video with title screens."
authors = ["Andrew Beveridge <andrew@beveridge.uk>"]
license = "MIT"
+1 -1
View File
@@ -203,7 +203,7 @@ class TestLyrics:
with patch('karaoke_gen.lyrics_processor.LyricsTranscriber', mock_transcriber), \
patch('os.path.exists', return_value=False), \
patch('shutil.copy2') as mock_copy2, \
patch('os.getenv', side_effect=lambda key: mock_env.get(key)), \
patch('os.getenv', side_effect=lambda key, default=None: mock_env.get(key, default)), \
patch('karaoke_gen.lyrics_processor.load_dotenv'):
# Call the method on the lyrics_processor