Implement Audio Sharing for Selected Text#992
Conversation
|
Warning Review limit reached
More reviews will be available in 48 minutes and 5 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR introduces a new ShareSelector modal that lets users share selected verses as text or export them as trimmed audio. The modal replaces the previous VerseOnImage modal in the type registry, integrates with TextSelectionToolbar to trigger on verse selection, and wires into the layout for dispatch and rendering. ChangesAudio and text sharing modal
Sequence Diagram(s)sequenceDiagram
participant User
participant ShareSelector
participant TextShare as shareText
participant AudioContext
participant Mediabunny
participant Navigator as navigator.share
participant Fallback as Download link
rect rgba(200, 150, 255, 0.5)
User->>ShareSelector: Click Share Text
ShareSelector->>ShareSelector: Build reference & message
ShareSelector->>TextShare: shareText(filename, message)
ShareSelector->>ShareSelector: logShareContent()
end
rect rgba(150, 200, 255, 0.5)
User->>ShareSelector: Click Share Audio
ShareSelector->>ShareSelector: pickSupportedAudioConfig()
ShareSelector->>AudioContext: Decode chapter audio
ShareSelector->>AudioContext: Extract & trim verse segments
AudioContext->>Mediabunny: Encode trimmed audio
Mediabunny->>ShareSelector: Return encoded blob
ShareSelector->>Navigator: navigator.share({ files: [File] })
alt Share succeeded
Navigator->>User: Share dialog
else Share unsupported
ShareSelector->>Fallback: Create download link
Fallback->>User: Trigger download
end
ShareSelector->>AudioContext: Close context
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Currently it downloads rather than sharing the audio.
Audio will be downloaded if sharing fails, which occurs on most browsers.
e5d1011 to
5ab1d1e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/lib/components/ShareSelector.svelte (1)
27-40: ⚡ Quick winExtract shared text-share composition into one helper.
Lines 27-40 duplicate the same “selected verses → message →
shareText+logShareContent” logic now also present insrc/lib/components/TextSelectionToolbar.svelte(Lines 138-150). Centralizing this avoids drift in filename/message/analytics behavior.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/components/ShareSelector.svelte` around lines 27 - 40, Extract the repeated "selected verses → message → shareText + logShareContent" logic into a single helper (e.g., export a function like composeAndShareSelectedText or shareSelectedVerses) and replace the duplicate blocks in shareSelectedText (in ShareSelector.svelte) and the corresponding handler in TextSelectionToolbar.svelte to call that helper; the helper should accept the selectedVerses object (or its derived book, collection, text, and reference), scriptureConfig.name, and internally build the filename, message body, call shareText(scriptureName, message, filename) and then call logShareContent('Text', bookCol, bookAbbrev, reference) so both components share identical filename/message/analytics behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/components/ShareSelector.svelte`:
- Around line 124-129: In shareAudio() in ShareSelector.svelte, modify the catch
after navigator.share(...) to detect a user-cancelled share (error.name ===
'AbortError' or error is a DOMException with name 'AbortError') and return early
so the download fallback is not triggered; only for other errors should the code
continue to createObjectURL(file) and trigger the anchor download. Ensure you
check error?.name and only fall through on non-AbortError cases.
---
Nitpick comments:
In `@src/lib/components/ShareSelector.svelte`:
- Around line 27-40: Extract the repeated "selected verses → message → shareText
+ logShareContent" logic into a single helper (e.g., export a function like
composeAndShareSelectedText or shareSelectedVerses) and replace the duplicate
blocks in shareSelectedText (in ShareSelector.svelte) and the corresponding
handler in TextSelectionToolbar.svelte to call that helper; the helper should
accept the selectedVerses object (or its derived book, collection, text, and
reference), scriptureConfig.name, and internally build the filename, message
body, call shareText(scriptureName, message, filename) and then call
logShareContent('Text', bookCol, bookAbbrev, reference) so both components share
identical filename/message/analytics behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 132775a3-fce6-4d3e-9c2d-793176254d92
📒 Files selected for processing (5)
src/lib/components/ShareSelector.sveltesrc/lib/components/TextSelectionToolbar.sveltesrc/lib/components/VerseOnImage.sveltesrc/lib/data/stores/view.tssrc/routes/+layout.svelte
Implementing #377. If there is audio timing data, this causes the share button when text is selected to open a modal that gives the user a choice between sharing text and sharing audio.
Summary by CodeRabbit
New Features
Improvements