Open
Conversation
Add a new backend mode for connecting to LM Studio's OpenAI-compatible API (HTTP+SSE), in addition to the existing OpenClaw WebSocket mode. - New lib/lmStudio.ts: HTTP+SSE streaming client with support for text, reasoning/thinking blocks, and tool call streaming - SetupDialog now has a segmented control to switch between OpenClaw and LM Studio modes, each with appropriate configuration fields - LM Studio mode includes model fetching from /v1/models and a model selector dropdown - Full conversation history sent with each request (client-side session) - Backend mode persisted in localStorage for auto-reconnect - Header status indicator shows "LM Studio" when in that mode https://claude.ai/code/session_01JV6o5twKqGVp6RBQ3ifxGp
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Hey - I've found 2 security issues, and left some high level feedback:
Security issues:
- Insecure WebSocket Detected. WebSocket Secure (wss) should be used for all WebSocket connections. (link)
- Insecure WebSocket Detected. WebSocket Secure (wss) should be used for all WebSocket connections. (link)
General comments:
- There are duplicated helpers like
getTextFromContentin bothapp/page.tsxandlib/lmStudio.ts; consider extracting shared message/content utilities into a common module to avoid divergence and keep behavior consistent across backends. - In the initial auto-connect
useEffect,savedMode === "demo"falls through to the OpenClaw branch; if you intend to persist demo mode, it may be clearer and safer to handle thedemovalue explicitly (e.g., setbackendMode/isDemoModeand skip any OpenClaw auto-connect logic). - In
handleDisconnect, you clear OpenClaw-specific keys andmobileclaw-modebut leavelmstudio-*keys; if a user disconnects from LM Studio and later reconnects, this stale state may be surprising—consider either clearing LM Studio keys as well or making the retention behavior explicit in the reconnection logic.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- There are duplicated helpers like `getTextFromContent` in both `app/page.tsx` and `lib/lmStudio.ts`; consider extracting shared message/content utilities into a common module to avoid divergence and keep behavior consistent across backends.
- In the initial auto-connect `useEffect`, `savedMode === "demo"` falls through to the OpenClaw branch; if you intend to persist demo mode, it may be clearer and safer to handle the `demo` value explicitly (e.g., set `backendMode`/`isDemoMode` and skip any OpenClaw auto-connect logic).
- In `handleDisconnect`, you clear OpenClaw-specific keys and `mobileclaw-mode` but leave `lmstudio-*` keys; if a user disconnects from LM Studio and later reconnects, this stale state may be surprising—consider either clearing LM Studio keys as well or making the retention behavior explicit in the reconnection logic.
## Individual Comments
### Comment 1
<location> `app/page.tsx:2320` </location>
<code_context>
if (!config.url.startsWith("ws://") && !config.url.startsWith("wss://")) {
</code_context>
<issue_to_address>
**security (javascript.lang.security.detect-insecure-websocket):** Insecure WebSocket Detected. WebSocket Secure (wss) should be used for all WebSocket connections.
*Source: opengrep*
</issue_to_address>
### Comment 2
<location> `app/page.tsx:2321` </location>
<code_context>
wsUrl = config.url.replace(/^http:\/\//, "ws://").replace(/^https:\/\//, "wss://");
</code_context>
<issue_to_address>
**security (javascript.lang.security.detect-insecure-websocket):** Insecure WebSocket Detected. WebSocket Secure (wss) should be used for all WebSocket connections.
*Source: opengrep*
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| lmStudioHandlerRef.current = null; | ||
| setOpenclawUrl(config.url); | ||
| let wsUrl = config.url; | ||
| if (!config.url.startsWith("ws://") && !config.url.startsWith("wss://")) { |
There was a problem hiding this comment.
security (javascript.lang.security.detect-insecure-websocket): Insecure WebSocket Detected. WebSocket Secure (wss) should be used for all WebSocket connections.
Source: opengrep
| setOpenclawUrl(config.url); | ||
| let wsUrl = config.url; | ||
| if (!config.url.startsWith("ws://") && !config.url.startsWith("wss://")) { | ||
| wsUrl = config.url.replace(/^http:\/\//, "ws://").replace(/^https:\/\//, "wss://"); |
There was a problem hiding this comment.
security (javascript.lang.security.detect-insecure-websocket): Insecure WebSocket Detected. WebSocket Secure (wss) should be used for all WebSocket connections.
Source: opengrep
…support-dOooD # Conflicts: # app/page.tsx
GLM models output thinking content immediately without an explicit <think> opening tag, only using </think> to end thinking blocks. Detect GLM from model name to start in thinking mode, add fallback </think> detection in text mode for other models, and reset thinking state after tool execution for subsequent agentic rounds. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for LM Studio as an alternative backend to the existing OpenClaw WebSocket connection. Users can now choose between OpenClaw, LM Studio, or Demo mode when connecting, with each backend having its own configuration and connection handling.
Key Changes
New LM Studio backend module (
lib/lmStudio.ts):Updated connection setup dialog:
Backend mode management:
BackendModetype: "openclaw" | "lmstudio" | "demo"ConnectionConfiginterface to unify connection parameters across backendslmStudioHandlerRef,lmStudioConfigRef)Message routing:
UI indicators:
Pull-to-refresh behavior:
Implementation Details
AbortControllerfor cancellation supportopenclaw-*andlmstudio-*https://claude.ai/code/session_01JV6o5twKqGVp6RBQ3ifxGp