Skip to content

implement audio URL fetching and configuration updates#72

Merged
spashii merged 1 commit intomainfrom
fix/audio-cors
Mar 19, 2025
Merged

implement audio URL fetching and configuration updates#72
spashii merged 1 commit intomainfrom
fix/audio-cors

Conversation

@spashii
Copy link
Copy Markdown
Member

@spashii spashii commented Mar 19, 2025

  • Add new mcp.json configuration for MCP servers.
  • Refactor audio transcript component to use useConversationChunkContentUrl for fetching audio URLs.
  • Update API functions to support returning direct audio URLs.
  • Enhance server-side conversation content retrieval to optionally return signed URLs.

Summary by CodeRabbit

  • New Features
    • Enhanced conversation audio playback: users now see dynamic loading indicators and clear error notifications when audio content is being fetched.
    • Optimized media streaming for faster, more reliable audio delivery through improved asynchronous retrieval and caching mechanisms.
    • Refined content delivery provides a smoother and more responsive audio experience during conversations.

- Add new mcp.json configuration for MCP servers.
- Refactor audio transcript component to use `useConversationChunkContentUrl` for fetching audio URLs.
- Update API functions to support returning direct audio URLs.
- Enhance server-side conversation content retrieval to optionally return signed URLs.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 19, 2025

Walkthrough

A new configuration file (mcp.json) has been added to define server commands for mcpServers. In the frontend, the conversation audio transcript component has been updated to replace a direct function call with a hook (useConversationChunkContentUrl) for fetching audio URLs asynchronously. The corresponding API function (getConversationChunkContentLink) now supports a boolean parameter to conditionally append a query parameter. Additionally, new caching logic and state handling were introduced in the hook, and the backend API functions have been updated to accept a new return_url parameter for conditional response types.

Changes

File(s) Change Summary
echo/.cursor/mcp.json Added new JSON configuration defining mcpServers with two server setups: playwright (using npx @executeautomation/playwright-mcp-server) and fetch (using uvx mcp-server-fetch).
echo/.../ConversationChunkAudioTranscript.tsx, echo/.../api.ts, echo/.../query.ts Updated conversation audio transcript flow: replaced direct URL fetching with the useConversationChunkContentUrl hook, added loading/error state handling, and updated API function signature to accept a returnUrl parameter.
echo/.../conversation.py Modified API functions to include an optional return_url parameter, allowing functions to return a direct URL (as a string) rather than a redirect response when requested.

Sequence Diagram(s)

sequenceDiagram
    participant C as ConversationChunkAudioTranscript Component
    participant H as useConversationChunkContentUrl Hook
    participant Q as useQuery (react-query)
    participant A as API Function (getConversationChunkContentLink)
    participant S as API Server

    C->>H: Request audio URL for conversation chunk
    H->>Q: Initiate asynchronous query
    Q->>A: Call API to get conversation chunk URL (with returnUrl parameter)
    A->>S: Fetch URL from backend (if applicable)
    S-->>A: Return URL (with ?return_url if needed)
    A-->>Q: Return audio URL
    Q-->>H: Provide query result (loading/error state)
    H-->>C: Component renders audio element based on result
Loading
sequenceDiagram
    participant Client as API Consumer
    participant API as Backend Conversation API

    Client->>API: Request conversation/chunk content (with return_url flag)
    API->>API: Check return_url flag internally
    API-->>Client: Return signed URL as string (or redirect response)
Loading

Poem

In code we dance, we tweak, and play,
A new config file lights the way.
Hooks fetch audio with a graceful spin,
With queries and parameters built to win.
Server and client now sing in tune—
LGTM from the SF lab, over the moon! 🚀

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
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: 0

🧹 Nitpick comments (1)
echo/frontend/src/lib/query.ts (1)

19-19: Unnecessary rename in import - harmless but cleanup would be nice

The static analysis flags a useless rename for the generateProjectLibrary import.

- generateProjectLibrary as generateProjectLibrary,
+ generateProjectLibrary,
🧰 Tools
🪛 Biome (1.9.4)

[error] 19-19: Useless rename.

Safe fix: Remove the renaming.

(lint/complexity/noUselessRename)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ae1068f and a7044c9.

📒 Files selected for processing (5)
  • echo/.cursor/mcp.json (1 hunks)
  • echo/frontend/src/components/conversation/ConversationChunkAudioTranscript.tsx (3 hunks)
  • echo/frontend/src/lib/api.ts (1 hunks)
  • echo/frontend/src/lib/query.ts (2 hunks)
  • echo/server/dembrane/api/conversation.py (4 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
echo/frontend/src/lib/query.ts (1)
echo/frontend/src/lib/api.ts (2) (2)
  • getConversationChunkContentLink (422-427)
  • apiNoAuth (17-17)
echo/frontend/src/components/conversation/ConversationChunkAudioTranscript.tsx (1)
echo/frontend/src/lib/query.ts (1) (1)
  • useConversationChunkContentUrl (1747-1766)
🪛 Biome (1.9.4)
echo/frontend/src/lib/query.ts

[error] 19-19: Useless rename.

Safe fix: Remove the renaming.

(lint/complexity/noUselessRename)

🔇 Additional comments (12)
echo/frontend/src/lib/query.ts (2)

1747-1766: Slick new hook for fetching audio URLs - LGTM

This well-crafted hook leverages React Query for caching and async state management. Smart move setting the stale/gc times to optimize network requests (30m/1h) - ideal for audio resources that rarely change.

+ export const useConversationChunkContentUrl = (
+   conversationId: string,
+   chunkId: string,
+   enabled: boolean = true,
+ ) => {
+   return useQuery({
+     queryKey: ["conversation", conversationId, "chunk", chunkId, "audio-url"],
+     queryFn: async () => {
+       const url = getConversationChunkContentLink(
+         conversationId,
+         chunkId,
+         true,
+       );
+       return apiNoAuth.get<unknown, string>(url);
+     },
+     enabled,
+     staleTime: 1000 * 60 * 30, // 30 minutes
+     gcTime: 1000 * 60 * 60, // 1 hour
+   });
+ };

15-15: Smart import of apiNoAuth

Solid choice using the non-authenticated API client for audio URL fetching.

echo/.cursor/mcp.json (1)

1-17: Server config for MCP - LGTM

Clean JSON structure for mcpServers. Nice setup with two distinct server configurations:

  1. playwright - with an npx execution path
  2. fetch - using uvx command

This facilitates the audio URL fetching capabilities in the PR.

echo/frontend/src/lib/api.ts (1)

422-427: Slick URL param enhancement - LGTM

The addition of the returnUrl parameter is a clean optimization. When true, appends ?return_url=true which allows the backend to return a direct URL instead of redirecting. This enables the frontend to fetch and cache audio URLs, drastically improving UX.

- export const getConversationChunkContentLink = (
-   conversationId: string,
-   chunkId: string
- ) =>
-  `${apiCommonConfig.baseURL}/conversations/${conversationId}/chunks/${chunkId}/content`;

+ export const getConversationChunkContentLink = (
+   conversationId: string,
+   chunkId: string,
+   returnUrl: boolean = false,
+ ) =>
+   `${apiCommonConfig.baseURL}/conversations/${conversationId}/chunks/${chunkId}/content${returnUrl ? "?return_url=true" : ""}`;
echo/frontend/src/components/conversation/ConversationChunkAudioTranscript.tsx (4)

5-5: Solid hook import - LGTM

Importing the new useConversationChunkContentUrl hook - excellent choice for handling asynchronous audio URL fetching.


2-2: Smart UI component imports for loading states

Adding Skeleton and other components from Mantine to handle loading and error states - this is the way.


14-19: Slick async URL fetching implementation - LGTM

Replaced direct URL construction with the new hook, conditionally fetching only when showAudioPlayer is true. This optimizes performance by avoiding unnecessary network requests.


33-46: Epic loading/error states for audio player - LGTM

This conditional rendering is 🔥:

  1. Shows a skeleton during loading
  2. Displays error message when fetch fails
  3. Renders audio player with correct URL when successful
  4. Sets preload="none" to avoid automatic audio downloading

Beautiful async state handling that significantly improves UX.

echo/server/dembrane/api/conversation.py (4)

143-144: LGTM! Clean signature update to support direct URL returns.

Nice backward-compatible change with the default False parameter and proper return type update. The typing is correctly updated to include the new str return type alongside the existing response types.


193-196: LGTM! Elegant implementation of the URL return feature.

Clean conditional logic with a clear explainer comment. The placement just before the original redirect is perfect. This is exactly what we need to support the direct audio URL returns mentioned in the PR objectives.


254-255: LGTM! Consistent signature update for the chunk content endpoint.

The parameter and return type changes mirror those in the conversation content endpoint, maintaining consistency throughout the API. Good job ensuring backward compatibility with the default value.


288-293: LGTM! Well-implemented URL return logic with clear comments.

The conditional block follows the same pattern as in the conversation content endpoint. The additional comment about redirecting as before adds clarity. This completes the implementation for the audio URL fetching enhancement mentioned in the PR objectives.

@spashii
Copy link
Copy Markdown
Member Author

spashii commented Mar 19, 2025

@coderabbitai can you please fix the nitpick comment about the Unnecessary rename in import -

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 19, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Get the PR comments to find the nitpick about import renaming
gh pr view 72 --json comments --jq '.comments[] | select(.author.login == "coderabbitai") | .body'

Length of output: 14386


🏁 Script executed:

#!/bin/bash
# Get the reviews to find the nitpick about import renaming
gh pr view 72 --json reviews --jq '.reviews[] | select(.author.login == "coderabbitai") | .body'

Length of output: 7165


🏁 Script executed:

#!/bin/bash
# Get the content of the query.ts file
cat echo/frontend/src/lib/query.ts

Length of output: 47882


@spashii Yo! Just found that redundant import. Biome is straight up flagging that useless rename on line 19 in query.ts. Legit easy fix:

- generateProjectLibrary as generateProjectLibrary,
+ generateProjectLibrary,

No functionality change, just cleaning up some noise to keep the codebase fire. LGTM!

@spashii spashii merged commit 388fb42 into main Mar 19, 2025
5 checks passed
@spashii spashii deleted the fix/audio-cors branch March 19, 2025 10:14
spashii added a commit that referenced this pull request Nov 18, 2025
- Add new mcp.json configuration for MCP servers.
- Refactor audio transcript component to use `useConversationChunkContentUrl` for fetching audio URLs.
- Update API functions to support returning direct audio URLs.
- Enhance server-side conversation content retrieval to optionally return signed URLs.
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