Skip to content

Audio player initial impl#1552

Merged
yujonglee merged 4 commits intomainfrom
wav-player
Oct 10, 2025
Merged

Audio player initial impl#1552
yujonglee merged 4 commits intomainfrom
wav-player

Conversation

@yujonglee
Copy link
Contributor

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 10, 2025

📝 Walkthrough

Walkthrough

Added an AudioPlayer component and integrated a show/hide toggle into Sessions. Threads visibility state from Sessions -> OuterHeader -> RecordingButton, wires a toggle handler, and conditionally renders AudioPlayer (Wavesurfer) within the session UI.

Changes

Cohort / File(s) Summary
Sessions integration and layout
apps/desktop2/src/components/main/body/sessions/index.tsx
Added local state showAudioPlayer; passed onToggleAudioPlayer and isAudioPlayerVisible to OuterHeader; conditionally render AudioPlayer; adjusted session layout to include audio area.
Outer header and recording button wiring
apps/desktop2/src/components/main/body/sessions/outer-header/index.tsx, apps/desktop2/src/components/main/body/sessions/outer-header/recording.tsx
Expanded OuterHeader props to accept onToggleAudioPlayer and isAudioPlayerVisible; updated RecordingButton to accept onToggle and isActive; added click handler and active-state styling.
New audio player component
apps/desktop2/src/components/main/body/sessions/player.tsx
Added named export AudioPlayer({ url: string }) using Wavesurfer: waveform container, play/pause control, current time/duration display, and waveform initialization via refs.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant RecordingButton
  participant OuterHeader
  participant Sessions
  participant AudioPlayer
  participant Wavesurfer

  User->>RecordingButton: click toggle
  RecordingButton->>OuterHeader: invoke onToggle()
  OuterHeader->>Sessions: call onToggleAudioPlayer()
  Sessions->>Sessions: toggle showAudioPlayer
  alt showAudioPlayer = true
    Sessions->>AudioPlayer: render with url
    AudioPlayer->>Wavesurfer: init waveform
  else showAudioPlayer = false
    Sessions-->>AudioPlayer: unmount
  end

  User->>AudioPlayer: click play/pause
  AudioPlayer->>Wavesurfer: playPause()
  Wavesurfer-->>AudioPlayer: playback/time updates
  AudioPlayer-->>User: update icon/time
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • duckduckhero

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request lacks an author-provided description, making it impossible to understand the intent or details of the changeset without reviewing the code diffs directly. Please add a brief summary outlining the purpose and key changes of this pull request to aid reviewers in understanding the implementation without inspecting individual files.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title “Audio player initial impl” succinctly captures the primary change by indicating that an initial implementation of an audio player has been added to the codebase, and it clearly reflects the main focus of the changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch wav-player

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
apps/desktop2/src/components/main/body/sessions/outer-header/recording.tsx (1)

11-11: Consider extracting opacity values.

The opacity values (opacity-50, opacity-75, opacity-100) could be extracted to a design system constant if this pattern is used elsewhere.

apps/desktop2/src/components/main/body/sessions/player.tsx (1)

30-51: Consider adding loading state.

The component does not display a loading indicator while the audio is being fetched and decoded. Users may experience a delay before the waveform appears.

You could:

  1. Check if wavesurfer is null or use a ready event from wavesurfer
  2. Display a skeleton or spinner during initial load
  3. Handle potential errors (though per coding guidelines, only if already present)
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9c6381d and 4d0bf9f.

📒 Files selected for processing (4)
  • apps/desktop2/src/components/main/body/sessions/index.tsx (3 hunks)
  • apps/desktop2/src/components/main/body/sessions/outer-header/index.tsx (2 hunks)
  • apps/desktop2/src/components/main/body/sessions/outer-header/recording.tsx (1 hunks)
  • apps/desktop2/src/components/main/body/sessions/player.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

⚙️ CodeRabbit configuration file

**/*.{js,ts,tsx,rs}: 1. Do not add any error handling. Keep the existing one.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".

Files:

  • apps/desktop2/src/components/main/body/sessions/outer-header/recording.tsx
  • apps/desktop2/src/components/main/body/sessions/outer-header/index.tsx
  • apps/desktop2/src/components/main/body/sessions/index.tsx
  • apps/desktop2/src/components/main/body/sessions/player.tsx
🧬 Code graph analysis (3)
apps/desktop2/src/components/main/body/sessions/outer-header/recording.tsx (1)
apps/desktop2/src/components/main/body/sessions/outer-header/types.ts (1)
  • SessionRowProp (3-5)
apps/desktop2/src/components/main/body/sessions/outer-header/index.tsx (1)
apps/desktop2/src/components/main/body/sessions/outer-header/recording.tsx (1)
  • RecordingButton (3-16)
apps/desktop2/src/components/main/body/sessions/index.tsx (2)
apps/desktop2/src/components/main/body/sessions/outer-header/index.tsx (1)
  • OuterHeader (11-54)
apps/desktop2/src/components/main/body/sessions/player.tsx (1)
  • AudioPlayer (5-52)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: ci (windows, windows-latest)
  • GitHub Check: ci (macos, macos-14)
🔇 Additional comments (10)
apps/desktop2/src/components/main/body/sessions/outer-header/recording.tsx (2)

3-7: LGTM!

The function signature correctly extends SessionRowProp with the new toggle props. The prop threading from OuterHeader is wired correctly.


9-14: {"code":"# run_scripts\n#!/bin/bash\ncat apps/desktop2/src/components/main/body/sessions/outer-header/types.ts"}

apps/desktop2/src/components/main/body/sessions/index.tsx (3)

30-30: LGTM!

Simple boolean state for audio player visibility is appropriate for this feature.


54-63: LGTM!

The layout structure and prop threading to OuterHeader are correct. The toggle handler properly flips the showAudioPlayer state.


90-90: Replace hardcoded audio URL Use the audio URL from sessionRow (e.g. sessionRow.audio_url) instead of the Gettysburg link and confirm that the sessions schema provides this field.

apps/desktop2/src/components/main/body/sessions/player.tsx (3)

8-22: LGTM!

The Wavesurfer configuration is appropriate. The options align with the @wavesurfer/react v1.0.11 and wavesurfer.js v7+ API. Based on learnings.


24-26: LGTM!

The useCallback correctly memoizes the play/pause handler with wavesurfer as a dependency. The optional chaining safely handles null/undefined.


54-57: LGTM!

The formatTime helper correctly formats seconds to MM:SS with zero-padding.

apps/desktop2/src/components/main/body/sessions/outer-header/index.tsx (2)

11-17: LGTM!

The function signature correctly adds onToggleAudioPlayer and isAudioPlayerVisible props, which are properly threaded from the Sessions index component.


43-47: LGTM!

The RecordingButton now correctly receives onToggle and isActive props, aligning with its updated signature in recording.tsx.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d0bf9f and e644767.

📒 Files selected for processing (1)
  • apps/desktop2/src/components/main/body/sessions/index.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

⚙️ CodeRabbit configuration file

**/*.{js,ts,tsx,rs}: 1. Do not add any error handling. Keep the existing one.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".

Files:

  • apps/desktop2/src/components/main/body/sessions/index.tsx
🧬 Code graph analysis (1)
apps/desktop2/src/components/main/body/sessions/index.tsx (1)
apps/desktop2/src/components/main/body/sessions/player.tsx (1)
  • AudioPlayer (5-52)
🪛 Biome (2.1.2)
apps/desktop2/src/components/main/body/sessions/index.tsx

[error] 84-84: expected ) but instead found {

Remove {

(parse)

🪛 GitHub Actions: .github/workflows/desktop2_ci.yaml
apps/desktop2/src/components/main/body/sessions/index.tsx

[error] 84-84: apps/desktop2 typecheck: TS1005: ')' expected at src/components/main/body/sessions/index.tsx(84,7).

🪛 GitHub Actions: .github/workflows/fmt.yaml
apps/desktop2/src/components/main/body/sessions/index.tsx

[error] 84-84: dprint formatting error while running 'dprint check --config 'dprint.json'': Expected ',' but found '{' at line 84.

@yujonglee yujonglee merged commit 302bc5f into main Oct 10, 2025
13 of 14 checks passed
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/desktop2/src/components/main/body/sessions/index.tsx (1)

56-61: Use functional update for more reliable state toggling.

The inline toggle callback reads showAudioPlayer from closure, which could lead to stale state issues if the callback is invoked multiple times rapidly or asynchronously. Using the functional update form ensures the toggle always operates on the latest state.

Apply this diff to use the functional update form:

         <OuterHeader
           sessionRow={sessionRow}
           sessionId={sessionId}
-          onToggleAudioPlayer={() => setShowAudioPlayer(!showAudioPlayer)}
+          onToggleAudioPlayer={() => setShowAudioPlayer(prev => !prev)}
           isAudioPlayerVisible={showAudioPlayer}
         />
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d0bf9f and 38a7494.

📒 Files selected for processing (1)
  • apps/desktop2/src/components/main/body/sessions/index.tsx (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

⚙️ CodeRabbit configuration file

**/*.{js,ts,tsx,rs}: 1. Do not add any error handling. Keep the existing one.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".

Files:

  • apps/desktop2/src/components/main/body/sessions/index.tsx
🧬 Code graph analysis (1)
apps/desktop2/src/components/main/body/sessions/index.tsx (2)
apps/desktop2/src/components/main/body/sessions/outer-header/index.tsx (1)
  • OuterHeader (11-54)
apps/desktop2/src/components/main/body/sessions/player.tsx (1)
  • AudioPlayer (5-52)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: ci (macos, macos-14)
  • GitHub Check: ci (windows, windows-latest)
🔇 Additional comments (2)
apps/desktop2/src/components/main/body/sessions/index.tsx (2)

2-2: LGTM!

The imports are appropriate and properly utilized in the component.

Also applies to: 10-10


30-30: LGTM!

The state initialization is appropriate for controlling the audio player visibility.

},
}}
/>
{showAudioPlayer && <AudioPlayer url="https://www2.cs.uic.edu/~i101/SoundFiles/gettysburg10.wav" />}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Replace hardcoded URL with dynamic session audio URL.

The audio player uses a hardcoded URL instead of dynamically loading the audio file associated with the current session. This will prevent the player from working with actual session recordings. Ensure the sessionRow contains an audio file URL property (e.g., audio_url, recording_url, or similar) and use it here.

Expected pattern:

-      {showAudioPlayer && <AudioPlayer url="https://www2.cs.uic.edu/~i101/SoundFiles/gettysburg10.wav" />}
+      {showAudioPlayer && sessionRow.audio_url && <AudioPlayer url={sessionRow.audio_url} />}

Note: Adjust the property name based on your actual schema.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{showAudioPlayer && <AudioPlayer url="https://www2.cs.uic.edu/~i101/SoundFiles/gettysburg10.wav" />}
{showAudioPlayer && sessionRow.audio_url && <AudioPlayer url={sessionRow.audio_url} />}
🤖 Prompt for AI Agents
In apps/desktop2/src/components/main/body/sessions/index.tsx around line 88, the
AudioPlayer is using a hardcoded WAV URL; replace it with the current session's
audio property (e.g., sessionRow.audio_url or sessionRow.recording_url) so the
player loads the correct recording. Pass that property into the AudioPlayer's
url prop, and add a null/empty check (only render AudioPlayer if showAudioPlayer
&& sessionRow?.audio_url) or fallback to sessionRow.recording_url if your schema
uses that name. Ensure you pick the correct property name from the sessionRow
shape and update the prop usage accordingly.

@yujonglee yujonglee deleted the wav-player branch October 10, 2025 09:09
This was referenced Oct 13, 2025
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.

1 participant