fix(stories): preview 404 — route through job-less /generate - #176
Conversation
…view-segment/__stories__)
The Stories Editor preview POSTed to a relative /api/dub/preview-segment/__stories__
URL: that dub route requires a real dub job ("__stories__" -> 404) and the bare
relative path skipped the API base + PIN header entirely. Route through the
standalone /generate endpoint via the shared api client (generateSpeech), which
is same-origin and PIN-aware. Per-line and marker-chained preview now work.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesSpeech Preview API Migration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Filename | Overview |
|---|---|
| frontend/src/components/StoriesEditor.jsx | Replaces 404-producing bare relative fetch with generateSpeech (PIN-aware, correct base URL); the post-call res.ok guard is now dead code since apiFetch throws on non-ok responses. |
Reviews (1): Last reviewed commit: "fix(stories): preview via job-less /gene..." | Re-trigger Greptile
| fd.append('speed', '1.0'); | ||
| if (profileId) fd.append('profile_id', profileId); | ||
| const res = await generateSpeech(fd); | ||
| if (!res.ok) throw new Error(`Preview HTTP ${res.status}`); |
There was a problem hiding this comment.
apiFetch (called by generateSpeech) always throws an ApiError before returning on any non-2xx response — it never resolves with an error Response. So !res.ok is unreachable: every failure surfaces as a thrown ApiError, which is correctly caught in the parent try/catch in previewTrack. The Preview HTTP ${res.status} string is therefore never shown to the user; the actual message the catch block receives is the ApiError message from apiFetch.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
…istence, reorder, i18n (#177) * docs(spec): Stories Editor pro-studio design (line cards, auto-cast, pro output, projects) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(stories): Phase 1 — real audiobook output, cast, persistence, reorder, i18n First phase of the pro-studio Stories Editor (spec: docs/superpowers/specs/2026-05-30-stories-editor-studio-design.md). Makes the editor actually produce audiobooks and remember your work: - Persistence: storiesSlice (tracks + cast) via zustand persist -> localStorage; transient fields (generating/audioUrl) stripped on persist; id counter reseeds from persisted tracks. Dropped the hardcoded sample seed -> clean empty state. - Cast: editable CastMember[] (name, color, voice) with a Cast panel; each line picks a character and inherits its voice (per-line override still available). - Real Generate: exportStoryAudio() stitches every line + [pause] gaps into one WAV via the Web Audio API (job-less /generate per chunk) with a % progress indicator and download. Per-line preview already shipped (#176). - Reorder: native HTML5 drag-and-drop (pure reorder() helper). - i18n: all Stories strings via t('stories.*') (en + zh-CN). - Tests: storiesSlice reducers, storyCast resolution, storyExport WAV/concat/ silence, storyReorder. 18 new unit tests. No DB/alembic; localStorage only. Same-origin + PIN-safe synth (apiFetch). No new deps. Cross-platform-identical default behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Stories Editor's per-line Preview failed with
Preview HTTP 404(seen live in dev:Failed to load resource: 404 (__stories__)).Cause: it POSTed to a bare relative
/api/dub/preview-segment/__stories__— that dub route requires a real dub job (__stories__→ 404), and the relative URL also skipped the API base + PIN header.Fix: route preview through the standalone job-less
/generateendpoint via the sharedgenerateSpeechclient (same-origin + PIN-aware). Both the simple and[pause]/[voice:]marker-chained preview paths now work.Verify: typecheck ✓, build ✓, vitest 107/107. This is Task 1 of
docs/superpowers/plans/2026-05-30-stories-editor.md; the rest of the "full polish" plan (export, persistence, cast, drag-reorder, i18n) is still available to execute.🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes