implement audio URL fetching and configuration updates#72
Conversation
- 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.
WalkthroughA new configuration file ( Changes
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
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)
Poem
Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
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 niceThe 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
📒 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 - LGTMThis 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 apiNoAuthSolid choice using the non-authenticated API client for audio URL fetching.
echo/.cursor/mcp.json (1)
1-17: Server config for MCP - LGTMClean JSON structure for mcpServers. Nice setup with two distinct server configurations:
playwright- with an npx execution pathfetch- using uvx commandThis facilitates the audio URL fetching capabilities in the PR.
echo/frontend/src/lib/api.ts (1)
422-427: Slick URL param enhancement - LGTMThe addition of the
returnUrlparameter is a clean optimization. When true, appends?return_url=truewhich 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 - LGTMImporting the new
useConversationChunkContentUrlhook - excellent choice for handling asynchronous audio URL fetching.
2-2: Smart UI component imports for loading statesAdding Skeleton and other components from Mantine to handle loading and error states - this is the way.
14-19: Slick async URL fetching implementation - LGTMReplaced direct URL construction with the new hook, conditionally fetching only when
showAudioPlayeris true. This optimizes performance by avoiding unnecessary network requests.
33-46: Epic loading/error states for audio player - LGTMThis conditional rendering is 🔥:
- Shows a skeleton during loading
- Displays error message when fetch fails
- Renders audio player with correct URL when successful
- 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
Falseparameter and proper return type update. The typing is correctly updated to include the newstrreturn 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.
|
@coderabbitai can you please fix the nitpick comment about the Unnecessary rename in import - |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 14386 🏁 Script executed: Length of output: 7165 🏁 Script executed: 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! |
- 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.
useConversationChunkContentUrlfor fetching audio URLs.Summary by CodeRabbit