Ignore a saved conversation that doesn't have the expected shape
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
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
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 aTypeError(messages is not iterable). The chat still opens, but without the welcome message, and withChatCops.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.tsandwidget.test.ts
Acceptance criteria
-
load()returnsnulland removes the key when the stored value isn't an object with a stringidand amessagesarray - Messages without a
userorassistantrole or without stringcontentare dropped - With
{}or[]stored, the widget starts with its welcome message and no error - Tests in
storage.test.tsfor each case, and one inwidget.test.tsthatinit()doesn't throw with{}stored - Changeset for
@chatcops/widget(patch) -
pnpm -r build,pnpm -r typecheckandpnpm testpass
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
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus codercops/chatcops
-
enhancement hacktoberfest help wanted server
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 1 Tag
-
Document the pre-chat formEvtl. vergeben @masyarakatai hat das vor 5 Tagen übernommen. Offendocumentation good first issue hacktoberfest widget
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
codercops/chatcops#70 · 3 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement hacktoberfest help wanted server
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
Maintainer antworten meist innerhalb von 1 Tag
-
Create @chatcops/store-redis for Upstash and other Redis clientsEvtl. vergeben @bhushan4work hat das vor 1 Tag übernommen. Offenenhancement hacktoberfest help wanted server
codercops/chatcops#248 · 2 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Create @chatcops/store-sqlite, a store for single-server setupsEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offenenhancement hacktoberfest help wanted server
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in codercops/chatcops
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
paperclipai/paperclip#17151 ·
Maintainer antworten meist innerhalb von 1 Tag
-
needs-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
AgoraIO-Extensions/agent-infra#3159 ·
Maintainer antworten meist innerhalb von 1 Tag
-
blocklist addition
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 66/100
MetaMask/eth-phishing-detect#304596 ·
Maintainer antworten meist innerhalb von 1 Tag
-
friction
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
kentcdodds/kody#4142 ·
-
[Bug] Statistics | Task statistics are always empty on MikroORM with MySQL or SQLiteEvtl. vergeben @NdekoCode hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
ever-co/ever-gauzy#11214 ·
Maintainer antworten meist innerhalb von 1 Tag