Skip to content

[codex] Handle webchat reconnect catch-up#50

Merged
rockwellll merged 1 commit into
mainfrom
socket-reconnection
Jun 2, 2026
Merged

[codex] Handle webchat reconnect catch-up#50
rockwellll merged 1 commit into
mainfrom
socket-reconnection

Conversation

@rockwellll
Copy link
Copy Markdown
Collaborator

@rockwellll rockwellll commented Jun 2, 2026

Summary

  • Reconnect the shared ActionCable socket after close or error, with debounced retry and active channel resubscription.
  • Wait for WebchatChannel subscription confirmation before running webchat catch-up.
  • Add a webchat messages catch-up request using after_id and insert recovered messages by timestamp so missed messages land before newer realtime messages.
  • Rebuild lib and dist outputs.

Server dependency

Why

When a deploy replaces the Docker image, the WebSocket can drop while the page is still open. The SDK now restores the subscription and asks the server for messages created after the last rendered persisted message, closing the small window where a message could otherwise be missed.

Validation

  • yarn test
  • yarn build
  • git diff --check

Note

Medium Risk
Changes live messaging, reconnect, and message ordering; behavior depends on the new backend catch-up API and must stay aligned with realtime delivery.

Overview
Adds webchat reconnect recovery so an open widget can survive ActionCable drops (for example during deploys) without missing messages.

The shared ApplicationChannel now replaces dead sockets, debounces reconnects, replays message handlers, and resubscribes active channels after open. It also exposes onDisconnect and onSubscriptionConfirmed hooks for control frames.

WebchatChannel tracks subscription intent, resubscribe only when still subscribed, and runs onReconnect callbacks only after a matching confirm_subscription for this webchat/session/conversation.

WebchatMessagesAPI.catchUp fetches messages with after_id and session. WebchatController snapshots the last rendered message id on disconnect, calls catch-up after reconnect confirmation, and inserts recovered messages by created_at so backfill sits before newer realtime bubbles. lib/dist outputs are rebuilt.

Depends on the server catch-up endpoint in hellotext PR 4757.

Reviewed by Cursor Bugbot for commit 8cfd2cf. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8cfd2cf0c3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/controllers/webchat_controller.js
Comment thread src/controllers/webchat_controller.js
@rockwellll rockwellll merged commit da78979 into main Jun 2, 2026
3 checks passed
@rockwellll rockwellll deleted the socket-reconnection branch June 2, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant