fix: derive WebSocket URL from API_BASE_URL in conversation screen#130
fix: derive WebSocket URL from API_BASE_URL in conversation screen#130elifouts merged 4 commits intoadd-commentsfrom
Conversation
Co-authored-by: grillinr <169214325+grillinr@users.noreply.github.com>
|
@copilot resolve conflicts please. |
…_URL approach Co-authored-by: elifouts <116454864+elifouts@users.noreply.github.com>
Resolved in 3482dd0. The base branch ( |
elifouts
left a comment
There was a problem hiding this comment.
Looks ok merge to other pr
There was a problem hiding this comment.
Pull request overview
Updates the conversation screen’s WebSocket connection to derive its base URL from the same API_BASE_URL used for HTTP API calls, avoiding hard-coded dev/prod host/protocol selection.
Changes:
- Import
API_BASE_URLinto the conversation screen. - Add a
getWebSocketBaseUrlhelper to converthttp(s)base URLs tows(s). - Build the conversation WebSocket URL using
getWebSocketBaseUrl(API_BASE_URL)instead of hard-coded__DEV__host/protocol logic.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (baseUrl.startsWith("https://")) { | ||
| return `wss://${baseUrl.slice("https://".length)}`; | ||
| } | ||
| if (baseUrl.startsWith("http://")) { | ||
| return `ws://${baseUrl.slice("http://".length)}`; | ||
| } | ||
| return baseUrl; |
There was a problem hiding this comment.
getWebSocketBaseUrl is now duplicated here and in frontend/app/terminal.tsx. To avoid drift (e.g., future protocol/path handling changes), consider extracting this helper into a shared module (e.g., @/services/api or a @/utils/websocket helper) and importing it in both places.
| if (baseUrl.startsWith("https://")) { | |
| return `wss://${baseUrl.slice("https://".length)}`; | |
| } | |
| if (baseUrl.startsWith("http://")) { | |
| return `ws://${baseUrl.slice("http://".length)}`; | |
| } | |
| return baseUrl; | |
| try { | |
| const url = new URL(baseUrl); | |
| if (url.protocol === "https:") { | |
| url.protocol = "wss:"; | |
| } else if (url.protocol === "http:") { | |
| url.protocol = "ws:"; | |
| } | |
| return url.toString(); | |
| } catch { | |
| // Fallback for non-standard or relative URLs: map http/https prefixes to ws/wss. | |
| if (baseUrl.startsWith("https://")) { | |
| return `wss://${baseUrl.slice("https://".length)}`; | |
| } | |
| if (baseUrl.startsWith("http://")) { | |
| return `ws://${baseUrl.slice("http://".length)}`; | |
| } | |
| return baseUrl; | |
| } |
* wip: add messaging * feat: add messages tab * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: derive WebSocket URL from API_BASE_URL in conversation screen (#130) * Initial plan * fix: use API_BASE_URL for WebSocket URL in conversation screen Co-authored-by: grillinr <169214325+grillinr@users.noreply.github.com> * fix: merge reconnection logic from base branch while keeping API_BASE_URL approach Co-authored-by: elifouts <116454864+elifouts@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: grillinr <169214325+grillinr@users.noreply.github.com> Co-authored-by: elifouts <116454864+elifouts@users.noreply.github.com> Co-authored-by: Eli Fouts <eligfouts@gmail.com> * feat: enhance MessageBubble and MessageComposer components - Added authorLabel prop to MessageBubble for displaying message authors. - Improved styling in MessageBubble for better visual consistency. - Updated MessageComposer to include layout animations for dynamic height adjustments. - Refactored input handling in MessageComposer to optimize performance. - Removed unused terminal animation code from MyHeader component. - Added terminal icon mapping in IconSymbol for better icon management. * fix: safe router navigation encoding and /users/search test coverage (#133) * fix: exclude sentinel user from search results and correct stale test expectations (#136) * Initial plan * fix: exclude deleted_user sentinel from search results and update test expectations Co-authored-by: grillinr <169214325+grillinr@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: grillinr <169214325+grillinr@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Nathan Grilliot <grillinr.mail.uc.edu> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: grillinr <169214325+grillinr@users.noreply.github.com> Co-authored-by: elifouts <116454864+elifouts@users.noreply.github.com> Co-authored-by: Eli Fouts <eligfouts@gmail.com>
conversation/[username].tsxto useAPI_BASE_URLinstead of hard-coded host/protocol for WebSocket URLAPI_BASE_URLimport from@/services/apigetWebSocketBaseUrlhelper (matching the pattern interminal.tsx)__DEV__ ? "10.0.2.2:8080" : "devbits.ddns.net"logic withgetWebSocketBaseUrl(API_BASE_URL)add-commentsisActiveflag,reconnectAttempts, andreconnectTimeoutIdstateconnect()function with exponential backoff retry (max 5 attempts)💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.