Ignore a saved conversation that doesn't have the expected shape
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 84/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
Hướng nghiên cứu
Bắt đầu với load() trong packages/widget/src/storage.ts, sau đó kiểm tra cách init() trong packages/widget/src/widget.ts xử lý khi không có cuộc hội thoại. Thêm các kiểm thử storage cho cấu trúc và thông điệp không hợp lệ, cùng một kiểm thử widget cho {}; issue liệt kê hành vi mong đợi và các lệnh. Công việc hoàn tất khi dữ liệu không hợp lệ bị xóa, các thông điệp hợp lệ được giữ lại, widget khởi chạy với thông điệp chào mừng và build, typecheck, các kiểm thử cùng changeset được yêu cầu đã hoàn thành.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 13
- Fork
- 7
- Merge trung bình
- 4 giờ 11 phút
- Pull request đã merge (30 ngày)
- 122
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của codercops/chatcops
-
enhancement hacktoberfest help wanted server
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Document the pre-chat formCó thể đã có người làm @masyarakatai đã nhận 4 ngày trước. Đang mởdocumentation good first issue hacktoberfest widget
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
codercops/chatcops#70 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement hacktoberfest help wanted server
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Create @chatcops/store-redis for Upstash and other Redis clientsCó thể đã có người làm @bhushan4work đã nhận hôm nay. Đang mởenhancement hacktoberfest help wanted server
codercops/chatcops#248 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement hacktoberfest help wanted server
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của codercops/chatcops
Issue tương tự
-
Area/Cloud Needs Triage Type/Bug
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 86/100
wso2/product-integrator#2847 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
bluesky-social/social-app#12118 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
heygen-com/hyperframes#6021 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Edit: Tele Posadas HDĐang mởcheck:passed streams:edit
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày