Cowork Handoff Chrome Extension Testing

Documentation for Sessions

Cowork Agent Handoff: Chrome Extension Testing

Session: 75 Handoff ID: handoff-1769778720607-2d8cc30f From: Claude Code (cursor-claude-code-session75) To: Cowork Agent (browser) Priority: High Created: 2026-01-30


Context

Session 75 implemented a Native WebSocket Protocol Adapter (/ws endpoint) to enable Chrome MV3 extensions and VSCode extensions to connect to the MCP Gateway. The Socket.io /mcp-stream endpoint doesn't work with Chrome MV3 service workers due to platform limitations.

What Was Built

  1. Native WebSocket Gateway - apis/backend-ai-api/src/app/mcp-gateway/native-ws.gateway.ts
  2. Chrome Extension Connector - apps/gograb-ai-extension/background/mcp-connector.js (updated to use /ws)
  3. VSCode Extension Connector - apps/vscode-gograb-ai/src/agent-status.ts (updated to use /ws)

Current Status


Tasks for Cowork Agent

Task 1: Verify Backend is Running

Steps:

  1. Open Chrome browser
  2. Navigate to: http://localhost:3001/ai-api/health
  3. Verify response shows "status": "ok"

Expected Result:

{
  "status": "ok",
  "timestamp": "...",
  "service": "backend-ai-api"
}

Task 2: Install Chrome Extension (Unpacked)

Steps:

  1. Open Chrome browser
  2. Navigate to: chrome://extensions/
  3. Enable "Developer mode" (toggle in top-right corner)
  4. Click "Load unpacked" button
  5. Navigate to: /Users/fguijarro/developer/repos/editor2/apps/gograb-ai-extension
  6. Select the folder and click "Select"

Expected Result:

If Errors Occur:


Task 3: Inspect Service Worker Console

Steps:

  1. On chrome://extensions/ page, find the GoGrab AI extension
  2. Click "Service Worker" link (or "Inspect views: service worker")
  3. This opens Chrome DevTools for the background script
  4. Go to Console tab
  5. Look for MCP connection logs

Expected Logs (Success):

[MCP] Initializing connector as chrome-ext-xxxxx
[MCP] Connecting to ws://localhost:3001/ws?agentId=chrome-ext-xxxxx&platform=external&...
[MCP] WebSocket opened
[MCP] Message received: connected
[MCP] Connected and authenticated: {...}

Expected Logs (Failure):

[MCP] WebSocket error: ...
[MCP] WebSocket closed: 1006 ...
[MCP] Reconnecting in 1000ms (attempt 1)

Screenshot the console output regardless of success/failure.


Task 4: Check Extension Badge

Steps:

  1. Look at the extension icon in Chrome toolbar
  2. Check for badge status:
    • No badge = Connected, no pending handoffs
    • Number badge (e.g., "1") = Connected, has pending handoffs
    • "!" badge (red) = Not connected

Expected Result:


Task 5: Verify Agent in MongoDB

Steps:

  1. Open MongoDB Compass
  2. Connect to: gograbspace.dgqjj2t.mongodb.net
  3. Navigate to: ai-mcp-dev database → agents collection
  4. Look for a document with:
    • agentId: starts with chrome-ext-
    • platform: "external"
    • status: "online"
    • workspace: "editor2"

Expected Document:

{
  "agentId": "chrome-ext-xxxxxxxxx",
  "platform": "external",
  "status": "online",
  "workspace": "editor2",
  "connectedAt": "2026-01-30T...",
  "lastHeartbeat": "2026-01-30T...",
  "socketId": "ws-..."
}

Screenshot the agent document if found.


Task 6: Test Extension Popup

Steps:

  1. Click the GoGrab AI extension icon in toolbar
  2. Verify popup opens without errors
  3. Check connection status displayed in popup
  4. If there are pending handoffs, they should be listed

Screenshot the popup showing the status.


Task 7: Test Handoff Notification

Steps:

  1. Keep the extension installed and service worker console open
  2. Create a test handoff via curl (run in terminal):
curl -X POST http://localhost:3001/ai-api/infrastructure/handoffs \
  -H "Content-Type: application/json" \
  -d '{
    "fromAgent": "cowork-test-agent",
    "workspace": "editor2",
    "sessionNumber": 75,
    "toAgentType": "browser",
    "type": "verification",
    "priority": "normal",
    "summary": "Test notification to Chrome extension",
    "tasks": [{"description": "Verify notification received"}]
  }'
  1. Check if:
    • Chrome notification appears
    • Extension badge updates with count
    • Console shows [MCP] Handoff created: {...}

Screenshot any notifications that appear.


Troubleshooting

Extension Won't Load

  1. Check manifest.json exists in apps/gograb-ai-extension/
  2. Verify all required files exist:
    • manifest.json
    • background/service-worker.js
    • background/mcp-connector.js
    • popup/popup.html
    • icons/icon16.png, icon48.png, icon128.png

WebSocket Won't Connect

  1. Verify backend is running: lsof -i :3001
  2. Test endpoint directly:
curl -v --no-buffer \
  -H "Connection: Upgrade" \
  -H "Upgrade: websocket" \
  -H "Sec-WebSocket-Version: 13" \
  -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" \
  "http://localhost:3001/ws?agentId=test&platform=external&workspace=editor2"

Should return HTTP/1.1 101 Switching Protocols

No Heartbeat/Agent Goes Offline


Success Criteria

Mark this handoff as completed when:


Files Reference

File Purpose
apps/gograb-ai-extension/manifest.json Extension manifest
apps/gograb-ai-extension/background/service-worker.js Main service worker
apps/gograb-ai-extension/background/mcp-connector.js WebSocket connection logic
apps/gograb-ai-extension/popup/popup.html Extension popup UI
apis/backend-ai-api/src/app/mcp-gateway/native-ws.gateway.ts Server-side WebSocket handler

Responding to This Handoff

When complete, respond via:

curl -X POST "http://localhost:3001/ai-api/infrastructure/handoffs/handoff-1769778720607-2d8cc30f/respond" \
  -H "Content-Type: application/json" \
  -d '{
    "respondingAgent": "cowork-browser-agent",
    "status": "completed",
    "taskResults": [
      {"taskId": "task-1", "status": "completed", "result": "Backend healthy"},
      {"taskId": "task-2", "status": "completed", "result": "Extension installed"},
      {"taskId": "task-3", "status": "completed", "result": "Connection successful"},
      {"taskId": "task-4", "status": "completed", "result": "Badge shows connected"},
      {"taskId": "task-5", "status": "completed", "result": "Agent visible in MongoDB"},
      {"taskId": "task-6", "status": "completed", "result": "Notification received"}
    ],
    "recommendations": ["Any issues found or suggestions"]
  }'

Handoff created by Claude Code (Session 75) for Cowork Agent testing