Skip to content

Assistant ActionCable / Que ops checks ​

Use these on API and Que hosts when the SPA is stuck on Thinking… after send.

What the SPA does (production AppLayout) ​

  1. Sets status Thinking…
  2. Ensures conversation exists
  3. Opens wss://api.uptinio.com/cable?token=<user_authentication_token>
  4. Subscribes to AssistantConversationChannel with { conversation_uuid }
  5. Awaits subscription confirmation forever (no timeout in current SPA)
  6. POST .../messages → 202 { run_uuid }
  7. Sets status Queued… and awaits done / error / needs_* forever

If step 3–5 fails, the UI never POSTs (or never leaves Thinking). If Que fails after a successful subscribe, it can hang on Queued/streaming.

1. Host nginx /cable upgrade (most likely) ​

bash
# From laptop — broken today returns plain "Page not found"
curl --http1.1 -sS -i \
  -H 'Upgrade: websocket' \
  -H 'Connection: Upgrade' \
  -H 'Sec-WebSocket-Version: 13' \
  -H 'Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==' \
  -H 'Origin: https://www.uptinio.com' \
  'https://api.uptinio.com/cable?token=test' | head -30

# On API host — confirm location exists
sudo nginx -T 2>/dev/null | grep -nA20 'location /cable'
# Apply docs/nginx-host-cable.conf then:
sudo nginx -t && sudo systemctl reload nginx

Healthy: 101 Switching Protocols (or connection auth rejection after upgrade).
Broken: 404 + text/plain + Page not found.

2. Solid Cable / Postgres (no Redis) ​

ActionCable uses Solid Cable on the primary Postgres database (solid_cable_messages). Que workers and web processes share that DB, so Que→browser broadcasts work without Redis.

REDIS_URL is not required for live ActionCable. Do not set or depend on it for cable.

bash
# Confirm migration applied (web or Que task)
bundle exec rails runner '
  puts ActiveRecord::Base.connection.table_exists?(:solid_cable_messages)
  puts ActionCable.server.config.cable["adapter"]
'
# Expect: true / solid_cable

Host nginx /cable WebSocket upgrade (section 1) is still required.

3. Que worker picking up AssistantChatJob ​

bash
# Inside Rails app (web or console task)
cd /home/rails/app   # or app root
bundle exec rails runner '
  rows = ActiveRecord::Base.connection.exec_query(
    "SELECT job_class, queue, error_count, run_at, finished_at FROM que_jobs ORDER BY id DESC LIMIT 20"
  )
  rows.each { |r| puts r.inspect }
'

bundle exec rails runner '
  puts "AssistantChatJob loadable: #{AssistantChatJob.name}"
  puts "Pending assistant runs: #{AssistantRun.active.count}"
  AssistantRun.order(id: :desc).limit(5).each { |r|
    puts [r.uuid, r.status, r.kind, r.error, r.created_at].inspect
  }
'

Confirm a que process is listening on queue default (AssistantChatJob sets self.queue = "default" and enqueues with job_options: { queue: "default" }).

bash
ps aux | grep -E '[q]ue '
# docker: que_default service (`que -q default --poll-interval 1 ...`)
# ECS: que-default service must be running (regional que-us/eu only handle monitors)

4. Rails broadcast smoke test ​

With a real conversation UUID and a browser subscribed (or a second rails runner subscriber):

bash
bundle exec rails runner '
  uuid = ARGV[0] or abort("pass conversation uuid")
  ActionCable.server.broadcast(
    AssistantRunBroadcaster.stream_name_for(uuid),
    { "type" => "status", "content" => "ops ping", "run_uuid" => "ASRTEST",
      "conversation_uuid" => uuid, "run_status" => "running" }
  )
  puts "broadcast ok -> assistant_conversation_#{uuid}"
' ASC_YOUR_CONVERSATION_UUID

5. Polling fallback API ​

GET /api/v1/assistant/runs/:run_uuid returns run status + conversation messages when terminal/waiting_human. Use after a client-side timeout if cable is silent.

Stream name contract ​

SideValue
ChannelAssistantConversationChannel
Params{ conversation_uuid: "ASC..." }
ActionCable streamassistant_conversation_<ASC...>
Eventsstatus / delta / tool / done (+ error, needs_*); include run_uuid, conversation_uuid, run_status
Solid Cable pollpolling_interval: 0.05.seconds in config/cable.yml (token deltas)