Skip to content

Conversation

@shadowfax92
Copy link
Contributor

  • websocket agent: keep only thinking, responses message for conciseness
  • update starting messages
  • configurable glow update
  • fix: glow service

@shadowfax92 shadowfax92 merged commit 3c4dbe4 into main Oct 22, 2025
1 check passed
@github-actions github-actions bot locked and limited conversation to collaborators Oct 22, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a 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"
Loading

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

Edit Code Review Agent Settings | Greptile

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants