Widget: keep a message sent while offline, and send it when the connection is back

クローズ
#495 コメント 3 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Saifjafri212213 がすでに取り組んでいます。

2026年10月30日 から。

  • #502 @Saifjafri212213 による — オープン

評価

この issue はまだ評価されていません。

説明

hacktoberfest

F-05 task 18. Today a message sent while offline fails with errorNetwork ("Connection error. Please check your network.", packages/widget/src/i18n.ts:53) and the visitor has to press Retry once they're back online.

What to do

  • Before sending (handleSend, packages/widget/src/widget.ts:738), check navigator.onLine. If offline, show the visitor's message as waiting ("Will send when you're back online", a new string in WidgetLocaleStrings with an English default), and don't call the API.
  • Listen for the online event on window and send what's waiting, in order, one at a time. A message that then fails gets the normal error and Retry.
  • Remove the listener in destroy(). Don't keep waiting messages in storage: they're for this page view only.
  • Going offline in the middle of a reply isn't part of this; that already fails with the network error and Retry.

Acceptance criteria

  • Unit tests with navigator.onLine mocked: a message sent offline isn't sent, it's sent once online fires, two waiting messages go in order, and nothing is left listening after destroy()
  • An e2e test using Playwright's context.setOffline(true), then false, checking the reply arrives without a click
  • The waiting state is announced through the existing reply live region, and the axe checks still pass
  • A minor changeset for @chatcops/widget; pnpm test:coverage, pnpm lint and pnpm size pass

Comment here to be assigned.

主要言語
TypeScript
スター
13
フォーク
7
平均マージ
3時間 10分
マージ済み PR(30日)
339

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

codercops/chatcops のほかの issue

codercops/chatcops の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。