Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Ignore a saved conversation that doesn't have the expected shape

クローズ 初心者向け
#172 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
frontend, testing

調査の方向性

packages/widget/src/storage.ts の load() から始め、packages/widget/src/widget.ts の init() が会話がない場合にどう処理するかを確認してください。不正な形式やメッセージを対象にしたストレージのテストと、{} を対象にしたウィジェットのテストを追加してください。issue には期待される動作とコマンドが記載されています。不正なデータが削除され、有効なメッセージが保持され、ウィジェットがウェルカムメッセージとともに起動し、要求された build、typecheck、テスト、changeset が完了すれば作業完了です。

索引モデルが issue の本文から書いたものです。

説明

bug good first issue hacktoberfest widget

The widget restores the last conversation from localStorage (the chatcops_conversation key, or chatcops_conversation_<siteId>). ConversationStorage.load() returns whatever JSON.parse gives, cast to StoredConversation (packages/widget/src/storage.ts, line 27), and init() uses it as it is (packages/widget/src/widget.ts, lines 185 to 191). When the key holds valid JSON of another shape, for example left by an older version or by another script on the same site, things break. Checked in Chrome with the widget built from dev:

  • {} or []: init() throws a TypeError (messages is not iterable). The chat still opens, but without the welcome message, and with ChatCops.init() the error reaches the page's own code.
  • {"id":"x","messages":[{"foo":1}],"updatedAt":1}: no error, but the chat shows an empty message bubble.

What to do
Check the shape in load(). Return the conversation only when it has a string id and a messages array, and drop messages that don't have a role of user or assistant and string content. Anything else counts as no saved conversation: remove the key and start fresh.

Where to look

  • packages/widget/src/storage.ts (load, lines 23 to 31)
  • packages/widget/src/widget.ts (lines 184 to 193)
  • packages/widget/tests/storage.test.ts and widget.test.ts

Acceptance criteria

  • load() returns null and removes the key when the stored value isn't an object with a string id and a messages array
  • Messages without a user or assistant role or without string content are dropped
  • With {} or [] stored, the widget starts with its welcome message and no error
  • Tests in storage.test.ts for each case, and one in widget.test.ts that init() doesn't throw with {} stored
  • Changeset for @chatcops/widget (patch)
  • pnpm -r build, pnpm -r typecheck and pnpm test pass

Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off dev, and open your PR against dev with Closes #172. Setup notes (pnpm, build before test) are in CONTRIBUTING.md.

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

環境構築

はじめの一歩

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

codercops/chatcops のほかの issue

codercops/chatcops の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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