Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Geschlossen Anfängerfreundlich
#172 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
84/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
frontend, testing

Rechercherichtung

Beginne mit load() in packages/widget/src/storage.ts und prüfe dann, wie init() in packages/widget/src/widget.ts mit einer fehlenden Unterhaltung umgeht. Füge Storage-Tests für ungültige Strukturen und Nachrichten sowie einen Widget-Test für {} hinzu; das Issue listet das erwartete Verhalten und die Befehle auf. Fertig ist die Arbeit, wenn ungültige Daten entfernt werden, gültige Nachrichten erhalten bleiben, das Widget mit seiner Willkommensnachricht startet und der angeforderte Build, Typecheck, die Tests und der Changeset abgeschlossen sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
TypeScript
Sterne
13
Forks
7
Ø Merge
4 Std. 11 Min.
Gemergte PRs (30 T.)
122

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus codercops/chatcops

Alle Issues in codercops/chatcops

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.