Conversation
## Summary Adds user-facing access to team chat rooms with REST API endpoints and a real-time CLI viewer with type-to-send support. Users can now view chat room messages and post to them directly. ## Changes - Add `GET /api/chatroom/:teamId` and `POST /api/chatroom/:teamId` API endpoints for querying and posting chat room messages - Create `chatroom-viewer.tsx` — Ink-based real-time TUI that polls the API and displays messages with type-to-send support - Add `tinyclaw chatroom <team_id>` CLI command to launch the viewer - Add `getChatMessages()` query function to `db.ts` for fetching chat room messages - Mount chatroom routes in the API server - Update documentation with chat room viewing and API endpoint info All changes relate to chat room viewing only — no changes to the chat room implementation itself (agents still post via `[#team_id: message]`). Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Greptile SummaryThis PR adds user-facing access to the team chat room system through REST API endpoints ( Key findings:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant TUI as chatroom-viewer (TUI)
participant API as API Server /api/chatroom/:teamId
participant DB as chat_messages (SQLite)
participant QP as queue-processor
participant Agent as Agent(s)
Note over TUI,API: Poll for new messages (every 1s)
TUI->>API: GET /api/chatroom/:teamId?since=lastId
API->>DB: getChatMessages(teamId, limit, sinceId)
DB-->>API: ChatMessageRow[]
API-->>TUI: JSON array of messages
Note over TUI,Agent: User posts a message
User->>TUI: types message + Enter
TUI->>API: POST /api/chatroom/:teamId {message}
API->>DB: insertChatMessage(teamId, "user", message)
API->>QP: postToChatRoom → enqueueMessage for each agent
API-->>TUI: {ok: true}
Note over QP,Agent: Agent processing (batch claim)
QP->>DB: claimAllPendingMessages(agentId)
DB-->>QP: [primaryMsg, ...chatRoomMsgs]
QP->>Agent: invokeAgent(primaryMsg + batched context)
Agent-->>QP: response (may contain [#team_id: ...] tags)
QP->>QP: extractChatRoomMessages(response)
QP->>DB: insertChatMessage + enqueue for teammates
QP->>DB: completeMessage(primary + additionalMsgs)
|
| d.prepare(` | ||
| UPDATE messages SET status = 'processing', claimed_by = ?, updated_at = ? | ||
| WHERE id IN (${ids.map(() => '?').join(',')}) | ||
| `).run(agentId, now, ...ids); |
There was a problem hiding this comment.
Dynamic SQL IN clause can exceed SQLite's variable limit
The prepared statement builds WHERE id IN (${ids.map(() => '?').join(',')}) with one bind parameter per message. SQLite's default SQLITE_MAX_VARIABLE_NUMBER is 999. If more than ~997 messages are pending for a single agent (the first two parameters in .run() are agentId and now), the statement will throw SQLITE_ERROR: too many SQL variables.
While unlikely under normal load, a backlog after a crash/recovery cycle could trigger this. Consider chunking the UPDATE into batches of 900 or using a temporary table approach.
Replace regex-based tag parsing with a bracket-depth counter that correctly handles nested brackets in message bodies. Previously, `[@coder: fix arr[0]]` would truncate at the first `]`. Affects all three tag extraction sites: - extractTeammateMentions ([@agent: ...] tags) - extractChatRoomMessages ([#team: ...] tags) - completeConversation (tag-to-readable conversion) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1. Batched messages can be stranded in
|
Summary
Adds user-facing access to team chat rooms with REST API endpoints and a real-time CLI viewer with type-to-send support. Users can now view chat room messages and post to them directly.
Changes
GET /api/chatroom/:teamIdto query messages,POST /api/chatroom/:teamIdto post messagestinyclaw chatroom <team_id>command with message polling and type-to-sendgetChatMessages()query function to fetch chat room messagesAll changes relate to chat room viewing/posting from the user's perspective — the agent-side chat room implementation (via
[#team_id: message]tags) remains unchanged.Type of Change
Testing
Checklist