10 KiB
Room Code Implementation Summary
Completed Work
✅ Phase 1.1: Enhanced WebSocket Monitor
File: cmd/monitor-ws/main.go
Features Added:
- Binary WebSocket frame detection
- HTTP request/response logging with JSON pretty-printing
- File chooser event handling
- Automatic file upload triggering (with manual fallback)
- Dual logging (console +
image-upload-capture.log)
How to Use:
cd /Users/erikfredericks/dev-ai/HSO/irc-kosmi-relay
./monitor-ws
Then manually upload blurt.jpg in the Kosmi chat interface.
Documentation: See cmd/monitor-ws/README.md
✅ Phase 2: Image Generation
File: bridge/jackbox/roomcode_image.go
Implementation:
- Generates 200x100 pixel PNG images
- Black background (RGB 0,0,0)
- White monospace text (basicfont.Face7x13)
- Centered text
- Returns PNG bytes ready for upload
Test Script: cmd/test-roomcode-image/main.go
Test Results:
✅ Generated roomcode_ABCD.png (429 bytes)
✅ Generated roomcode_XYZ123.png (474 bytes)
✅ Generated roomcode_TEST.png (414 bytes)
✅ Generated roomcode_ROOM42.png (459 bytes)
Sample images created in project root for verification.
✅ Phase 4: IRC Formatting
File: bridge/irc/formatting.go
Implementation:
func FormatRoomCode(roomCode string) string {
return "\x02\x11" + roomCode + "\x0F"
}
IRC Control Codes:
\x02= Bold\x11= Monospace/fixed-width font\x0F= Reset all formatting
Example Output:
- Input:
"ABCD" - Output:
"\x02\x11ABCD\x0F"(renders asABCDin monospace in IRC clients)
✅ Configuration Added
File: matterbridge.toml
# Enable room code image upload for Kosmi chat
# When enabled, generates a PNG image of the room code and attempts to upload it
# Falls back to plain text if upload fails or is not supported
# Note: Requires image upload protocol research to be completed
EnableRoomCodeImage=false
Pending Work (Blocked)
⏳ Phase 1.2: Capture Real Upload
Status: WAITING FOR USER ACTION
Required:
- Run
./monitor-ws - Upload
blurt.jpgin Kosmi chat - Press Ctrl+C when done
- Analyze
image-upload-capture.log
What We're Looking For:
- HTTP endpoint for image upload (POST/PUT)
- Request format (multipart/form-data, JSON, binary)
- Required headers (Authorization, Content-Type)
- Response format (JSON with URL?)
- OR: GraphQL mutation for file upload
⏳ Phase 1.3: Document Findings
Status: BLOCKED (waiting for Phase 1.2)
Will create KOSMI_IMAGE_UPLOAD.md with:
- Upload method (HTTP vs WebSocket)
- Endpoint URL and authentication
- Request/response format
- Go implementation strategy
⏳ Phase 3: Kosmi Upload Client
Status: BLOCKED (waiting for Phase 1.3)
To Implement:
bridge/kosmi/graphql_ws_client.go:UploadImage(imageData []byte, filename string) (string, error)SendMessageWithImage(text string, imageURL string) error
⏳ Phase 5: Integration
Status: BLOCKED (waiting for Phase 3)
To Implement:
- Update
bridge/jackbox/websocket_client.gohandleGameAdded() - Update
gateway/router.gobroadcastJackboxMessage() - Protocol-specific message formatting:
- IRC: Use
FormatRoomCode()for bold+monospace - Kosmi with image: Upload image, send URL
- Kosmi fallback: Plain text (no formatting)
- IRC: Use
⏳ Phase 6: Testing
Status: BLOCKED (waiting for Phase 5)
Test Plan:
- Generate test images (✅ already tested)
- Test Kosmi upload (if protocol discovered)
- Test IRC formatting in real IRC client
- Integration test with both Kosmi and IRC
- Test mute functionality (should suppress both)
Next Steps
Immediate (User Action Required)
- Run the monitor:
./monitor-ws - Upload test image: Use
blurt.jpgin Kosmi chat - Stop monitoring: Press Ctrl+C
- Share log: Provide
image-upload-capture.logcontents
After Upload Capture
- Analyze captured traffic
- Document upload protocol in
KOSMI_IMAGE_UPLOAD.md - Implement upload client
- Integrate into message broadcast
- Test complete flow
Files Created/Modified
New Files
cmd/monitor-ws/main.go(enhanced)cmd/monitor-ws/README.mdbridge/jackbox/roomcode_image.gocmd/test-roomcode-image/main.gobridge/irc/formatting.goROOM_CODE_IMAGE_STATUS.mdROOM_CODE_IMPLEMENTATION_SUMMARY.md(this file)
Modified Files
matterbridge.toml(addedEnableRoomCodeImageconfig)
Generated Test Files
roomcode_ABCD.pngroomcode_XYZ123.pngroomcode_TEST.pngroomcode_ROOM42.png
Architecture Overview
┌─────────────────────────────────────────────────────────────┐
│ Jackbox API Event │
│ (game.added with room_code) │
└────────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ gateway/router.go: broadcastJackboxMessage() │
│ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ For each bridge, format message based on protocol: │ │
│ └──────────────────────────────────────────────────────┘ │
└────────────┬─────────────────────────┬──────────────────────┘
│ │
▼ ▼
┌────────────────┐ ┌────────────────┐
│ IRC Bridge │ │ Kosmi Bridge │
└────────────────┘ └────────────────┘
│ │
▼ ▼
┌────────────────┐ ┌────────────────┐
│ FormatRoomCode │ │ If image enabled│
│ (bold + │ │ ┌─────────────┐│
│ monospace) │ │ │Generate PNG ││
│ │ │ └──────┬──────┘│
│ "\x02\x11CODE │ │ ▼ │
│ \x0F" │ │ ┌─────────────┐│
└────────────────┘ │ │Upload Image ││
│ └──────┬──────┘│
│ ▼ │
│ ┌─────────────┐│
│ │Get URL ││
│ └──────┬──────┘│
│ ▼ │
│ Send URL │
│ (or fallback │
│ to text) │
└────────────────┘
Key Design Decisions
-
Image Generation: Using Go's built-in
imagepackage withbasicfont.Face7x13for simplicity and no external dependencies. -
IRC Formatting: Using standard IRC control codes (
\x02\x11...\x0F) which are widely supported. -
Fallback Strategy: Always have plain text fallback if image upload fails or is disabled.
-
Protocol-Specific Formatting: Messages are formatted differently for each protocol at the router level, ensuring each bridge gets the appropriate format.
-
Configuration: Image upload is disabled by default (
EnableRoomCodeImage=false) until the upload protocol is fully implemented and tested.
Performance Considerations
- Image Generation: < 1ms per image (tested with 4 samples)
- Image Size: ~400-500 bytes per PNG (very small)
- Upload Timeout: Will need to implement timeout (suggested 3000ms max)
- Caching: Could cache generated images if same room code is reused
- Async Upload: Upload should be non-blocking to avoid delaying message broadcast
Testing Status
- ✅ Image generation tested and working
- ✅ IRC formatting implemented (not yet tested in real IRC client)
- ⏳ Kosmi upload pending (protocol research required)
- ⏳ Integration testing pending
- ⏳ Mute functionality testing pending
Documentation
cmd/monitor-ws/README.md- How to run the monitorROOM_CODE_IMAGE_STATUS.md- Current status and blockersROOM_CODE_IMPLEMENTATION_SUMMARY.md- This fileKOSMI_IMAGE_UPLOAD.md- To be created after capture
Questions/Decisions Needed
-
Upload Protocol: Waiting for capture to determine if it's HTTP multipart, GraphQL mutation, or something else.
-
Error Handling: How should we handle upload failures? (Currently: fallback to plain text)
-
Rate Limiting: Should we limit image uploads per time period?
-
Caching: Should we cache generated images for repeated room codes?
-
Image Customization: Should image size/colors be configurable?
Current Blockers Summary
Critical Path:
- User runs monitor → 2. Capture upload → 3. Document protocol → 4. Implement upload → 5. Integrate → 6. Test
Currently At: Step 1 (waiting for user to run monitor)
Can Proceed Independently:
- None (all remaining work depends on upload protocol research)
Completed:
- Image generation ✅
- IRC formatting ✅
- Monitor tool ✅
- Configuration ✅