feat(conversation): add onLoad callback for initial conversation list loading#304
Conversation
📦 Package Previewpnpm add https://pkg.pr.new/opentiny/tiny-robot/@opentiny/tiny-robot@556a2aa pnpm add https://pkg.pr.new/opentiny/tiny-robot/@opentiny/tiny-robot-kit@556a2aa pnpm add https://pkg.pr.new/opentiny/tiny-robot/@opentiny/tiny-robot-svgs@556a2aa commit: 556a2aa |
…rsation list loading
WalkthroughAn optional Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/kit/src/vue/conversation/useConversation.ts (1)
116-149:⚠️ Potential issue | 🟡 Minor
onLoadreceives the merged list in the merge branch, not the storage-loaded list.When in-memory conversations already exist (the merge path on Line 134–140), the callback receives
conversations.value(the merged result), not the originallistfrom storage. This contradicts the JSDoc which says "Called when the initial conversation list has been loaded from storage."If the intent is to always pass the conversations as loaded from storage (i.e.,
list), every branch should returnlist. If the intent is to pass the final state after load, the JSDoc/param name should be updated accordingly (e.g., rename to something likeonReady).Option A: Always pass the storage-loaded list
if (!list?.length) { - return [] + return list ?? [] } if (conversations.value.length === 0) { conversations.value = list - return conversations.value + return list } // merge logic … conversations.value = Array.from(merged.values()) - return conversations.value + return list })Option B: Keep current behavior but update docs
Update the JSDoc in
types.ts:/** - * Called when the initial conversation list has been loaded from storage. - * Only fired when storage.loadConversations is available and has completed. + * Called after the initial conversation list has been loaded from storage and merged + * with any in-memory conversations. Receives the final conversation list. + * Only fired when storage.loadConversations is available and has completed. */ - onLoad?: (conversations: ConversationInfo[]) => void + onLoad?: (conversations: ConversationInfo[]) => void
🧹 Nitpick comments (1)
packages/kit/src/vue/conversation/useConversation.ts (1)
147-149:onLoadis silently skipped on storage errors — consider whether this is intentional.If
loadConversations()rejects, the.catchon Line 150 logs the error butonLoadis never invoked. Consumers have no way to know loading finished (with failure). If this is intentional, a brief comment would help; otherwise, consider callingonLoad?.([])in the catch block so consumers always get a signal.
🧹 Preview Cleaned UpThe preview deployment has been removed. |

Summary by CodeRabbit
Release Notes