Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Cerrado Apto para principiantes
#172 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
84/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
typescript
Área
frontend, testing

Línea de trabajo

Empieza con load() en packages/widget/src/storage.ts y luego comprueba cómo init() en packages/widget/src/widget.ts gestiona la ausencia de una conversación. Añade pruebas de almacenamiento para estructuras y mensajes no válidos, y una prueba del widget para {}; el issue enumera el comportamiento esperado y los comandos. El trabajo estará terminado cuando se eliminen los datos no válidos, se conserven los mensajes válidos, el widget se inicie con su mensaje de bienvenida y se completen el build, el typecheck, las pruebas y el changeset solicitados.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
13
Forks
7
Merge medio
4 h 11 min
PR fusionados (30 d)
122

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de codercops/chatcops

Todos los issues de codercops/chatcops

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.