Slice 2: Guest Chat (Extends Slice 1)
Blocked
Task
High
Description
## Overview
Add guest-side chat capability. After this task, guests can participate in chat during remote support sessions. Depends on Slice 1 being complete.
## Verification (How to test after deployment)
1. Create remote support session as operator
2. Open guest link in incognito/different browser
3. Both operator and guest see chat panel
4. Operator sends message → guest sees it in real-time
5. Guest sends message → operator sees it in real-time
6. Guest can optionally enter name (stored in localStorage)
## Implementation Scope
### 1. Guest API Endpoints
```ruby
# routes.rb - under guest namespace
scope '/support/guest/:token' do
get 'messages', to: 'remote_support_guest#messages'
post 'messages', to: 'remote_support_guest#create_message'
end
```
- `GET /support/guest/:token/messages` - fetch history
- `POST /support/guest/:token/messages` - send message (body: { content, guest_name })
### 2. ActionCable Guest Authentication
Modify `ApplicationCable::Connection` to support guest tokens:
```ruby
def connect
self.current_user = find_verified_user || find_verified_guest
end
def find_verified_guest
token = request.params[:guest_token]
return nil if token.blank?
session = SupportSession.find_by(guest_link_token: token)
return nil unless session&.can_join?
GuestIdentity.new(session: session, name: request.params[:guest_name])
end
```
Create `GuestIdentity` value object for connection identification.
### 3. Update Channel for Guests
Modify `SupportSessionChatChannel`:
- Accept subscription from either authenticated user or guest token
- Reject if session ended/invalid
### 4. Guest UI Integration
Modify `GuestKiosk.jsx`:
- Import `SessionChatPanel`
- Add collapsible chat to layout
- Chat toggle button in footer
- Store guest_name in localStorage
- Subscribe via ActionCable with token
### 5. Translations
Add to `app/javascript/i18n/guest/translations.js`:
```js
guest: {
chat: {
title: 'Чат',
placeholder: 'Введите сообщение...',
send: 'Отправить',
empty: 'Нет сообщений',
name_prompt: 'Ваше имя (необязательно)',
connection_error: 'Ошибка подключения к чату'
}
}
```
Add translations for all 6 languages.
### 6. Frontend ActionCable Consumer
Create guest-compatible ActionCable consumer:
```js
// app/javascript/services/support_session_chat_consumer.js
import { createConsumer } from '@rails/actioncable'
export function createGuestChatConsumer(token, guestName) {
return createConsumer(`/cable?guest_token=${token}&guest_name=${encodeURIComponent(guestName)}`)
}
```
## Files to Create
- `app/javascript/services/support_session_chat_consumer.js`
- `app/models/guest_identity.rb` (value object)
- `spec/requests/remote_support_guest_chat_spec.rb`
- `spec/channels/support_session_chat_channel_guest_spec.rb`
## Files to Modify
- `config/routes.rb`
- `app/controllers/remote_support_guest_controller.rb`
- `app/channels/application_cable/connection.rb`
- `app/channels/support_session_chat_channel.rb`
- `app/javascript/components/remote_support/GuestKiosk.jsx`
- `app/javascript/components/remote_support/SessionChatPanel.jsx` (guest mode)
- `app/javascript/i18n/guest/translations.js`
Working Memory
{
"blocked_reason": "Waiting for dependencies: 109"
}
Ticket Stats
Status:
Blocked
Priority:
High
Type:
Task
Comments
0 commentsAdd a Comment
No Subtasks Yet
Break down this ticket into smaller, manageable subtasks