-
Notifications
You must be signed in to change notification settings - Fork 55
browserOS websocket agent - fixes #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
shadowfax92
commented
Oct 22, 2025
- websocket agent: keep only thinking, responses message for conciseness
- update starting messages
- configurable glow update
- fix: glow service
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
This PR refactors WebSocket agent message handling to improve production UX by filtering verbose debugging messages. The changes introduce development mode detection using isDevelopmentMode() to selectively display messages - showing only user-facing content ('thinking', 'tool_use', 'response') in production while preserving full visibility ('init', 'tool_result') in development. The glow animation logic was extracted into a reusable _maybeStartGlow() helper to eliminate code duplication across both WebSocketAgent and TeachWebSocketAgent. Additionally, the visual glow effect is now configurable via constants (GLOW_THICKNESS, GLOW_OPACITY) with increased default intensity for better visibility. These changes integrate with the existing PubSub-based messaging system and GlowAnimationService, maintaining the architecture's separation of concerns while reducing production noise.
Changed Files
| Filename | Score | Overview |
|---|---|---|
| src/content/glow-animation.ts | 5/5 | Introduces configurable constants for glow thickness/opacity and increases default glow intensity via multiplier-based sizing |
| src/lib/agent/TeachWebSocketAgent.ts | 4/5 | Refactors message routing with dev/prod filtering, extracts glow animation helper, and reduces verbose connection messages |
| src/lib/agent/WebSocketAgent.ts | 3/5 | Similar message filtering refactor as TeachWebSocketAgent but with concerning commented-out error publishing that hides timeout/server errors |
Confidence score: 3/5
- This PR introduces potential production issues by hiding critical error messages from users through commented-out error publishing
- Score reflects working message filtering logic but serious concerns about commented error handling in WebSocketAgent.ts (lines 448, 474, 524) that will prevent users from seeing timeout and server connection errors
- Pay close attention to src/lib/agent/WebSocketAgent.ts - the three commented
_publishMessage()calls for errors need to be either restored or replaced with proper error handling; leaving them commented creates a silent failure mode
Sequence Diagram
sequenceDiagram
participant User
participant WebSocketAgent
participant ExecutionContext
participant GlowService
participant WebSocket
participant Server
participant PubSub
User->>WebSocketAgent: "execute(task, metadata)"
WebSocketAgent->>ExecutionContext: "setCurrentTask(task)"
WebSocketAgent->>ExecutionContext: "setExecutionMetrics()"
WebSocketAgent->>GlowService: "_maybeStartGlow()"
GlowService->>ExecutionContext: "getCurrentPage()"
GlowService->>GlowService: "startGlow(tabId)"
WebSocketAgent->>ExecutionContext: "getAgentServerUrl()"
WebSocketAgent->>WebSocket: "new WebSocket(wsUrl)"
WebSocket->>Server: "connect"
Server-->>WebSocket: "connection event + sessionId"
WebSocket-->>WebSocketAgent: "onmessage(connection)"
WebSocketAgent->>WebSocketAgent: "isConnected = true"
WebSocketAgent->>ExecutionContext: "getBrowserContext()"
ExecutionContext-->>WebSocketAgent: "{ tabId, url, title, selectedTabIds }"
WebSocketAgent->>ExecutionContext: "messageManager.addHuman(task)"
WebSocketAgent->>WebSocket: "send(query + context + predefinedPlan)"
WebSocket->>Server: "message"
loop Until Completion
Server-->>WebSocket: "thinking/tool_use/response events"
WebSocket-->>WebSocketAgent: "onmessage(event)"
WebSocketAgent->>WebSocketAgent: "lastEventTime = now"
WebSocketAgent->>GlowService: "_maybeStartGlow()"
WebSocketAgent->>PubSub: "publishMessage(content, 'thinking')"
WebSocketAgent->>WebSocketAgent: "checkIfAborted()"
WebSocketAgent->>WebSocketAgent: "check eventGapTimeout"
end
Server-->>WebSocket: "completion event"
WebSocket-->>WebSocketAgent: "onmessage(completion)"
WebSocketAgent->>WebSocketAgent: "isCompleted = true"
WebSocketAgent->>PubSub: "publishMessage(finalAnswer, 'assistant')"
WebSocketAgent->>ExecutionContext: "messageManager.addAI(finalAnswer)"
WebSocketAgent->>WebSocket: "close()"
WebSocketAgent->>GlowService: "stopGlow(tabId)"
WebSocketAgent->>ExecutionContext: "setExecutionMetrics(endTime)"
WebSocketAgent->>WebSocketAgent: "_cleanup()"
WebSocketAgent-->>User: "Task completed"
Context used:
- Rule from
dashboard- Remove unused/dead code rather than leaving it in the codebase. If functionality might be needed lat... (source) - Rule from
dashboard- Remove excessive Logging.log statements after debugging is complete. Avoid leaving too many debug lo... (source)
3 files reviewed, no comments