Chat Widget Testbook
Validates the nimschatwidget integration on the issue detail page.
Prerequisites
- nimsforestissue running with NATS connected
- Forest pipeline running (river → tree → nim → agentclaudecode → songbird)
- Admin session (logged in at /login)
1. Verify deployment
# Songbird is catching and publishing to river
ssh root@46.225.164.179 "docker logs nimsforestissue 2>&1 | grep 'Chat widget'"
# Expected: Chat widget enabled (publishing to river.chat.widget)
2. Widget endpoint auth
# Without auth → 401
curl -s -o /dev/null -w "%{http_code}" https://issues.nimsforest.nimsforest.com/admin/chat/widget
# Expected: 401
# With auth → 200 + JS content
curl -s -H "Cookie: nimsforestissue_session=<admin_token>" https://issues.nimsforest.nimsforest.com/admin/chat/widget | head -c 50
# Expected: (function() {
3. Nims list endpoint
curl -s -H "Cookie: nimsforestissue_session=<admin_token>" https://issues.nimsforest.nimsforest.com/admin/chat/nims | python3 -m json.tool | head -10
# Expected: JSON array of {name, role} objects starting with neo
4. SSE events endpoint
# Opens SSE stream (will hang waiting for events, Ctrl+C to stop)
curl -s -N -H "Cookie: nimsforestissue_session=<admin_token>" "https://issues.nimsforest.nimsforest.com/admin/chat/events?session=test-1"
# Expected: connection stays open, receives data: lines when nim responds
5. Send endpoint
curl -s -X POST -H "Content-Type: application/json" \
-H "Cookie: nimsforestissue_session=<admin_token>" \
-d '{"session_id":"test-1","target_nim":"nimble","text":"hello","context":"Test context"}' \
https://issues.nimsforest.nimsforest.com/admin/chat/send
# Expected: {"status":"ok"}
6. Browser validation
- Open https://issues.nimsforest.nimsforest.com/login
- Log in with admin token
- Navigate to any issue detail: /admin/issues/{id}
- Verify: green floating chat button visible in bottom-right corner
- Click the chat button
- Verify: slide panel opens from right side with nim selector dropdown
- Verify: dropdown lists all nims (neo, nimble, napoleon, etc.)
- Select a nim (e.g. neo)
- Type a message and press Enter
- Verify: user message appears as green bubble on right
- Verify: typing indicator appears (3 bouncing dots)
- Verify: nim response arrives as white bubble on left with nim name
- Click the X button to close panel
- Verify: panel slides closed
7. Context verification
- Open an issue detail page with a known description
- Open browser DevTools → Network tab
- Open chat widget and send a message
- Inspect the POST to /admin/chat/send
- Verify: request body contains
context field with issue title, status, priority, and description
- Verify: the nim's response acknowledges the issue context
8. SSE reconnect
- Open chat widget on an issue page
- Kill the nimsforestissue container:
docker restart nimsforestissue
- Verify: SSE reconnects after ~3 seconds (check Network tab)
- Send a new message
- Verify: message sends and response arrives normally
9. Mobile layout
- Open issue detail on mobile (or resize browser to < 768px)
- Verify: chat button is smaller (48px) and positioned 16px from edges
- Click to open
- Verify: panel is full-width overlay instead of 400px side panel
10. Chat disabled (no NATS)
If NATS is not configured, the chat widget should not appear. Verify by checking logs — if "Wind connected" is absent, no chat button should render on issue detail pages.