feat(sender):content source registration mechanism - #382
Conversation
WalkthroughAdds attachment registration and external payload submission to Sender. It exposes related APIs and types, documents usage, adds an attachment demo, simplifies an existing demo, and expands Sender tests for attachment lifecycle and submit metadata. ChangesAttachments submission flow
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant TrAttachments
participant Sender
participant useSenderContentRegistry
TrAttachments->>Sender: register content source
Sender->>useSenderContentRegistry: store registration
Sender->>useSenderContentRegistry: collectExternalPayloads()
useSenderContentRegistry-->>Sender: externalPayloads
Sender-->>TrAttachments: submit(text, data, meta)
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/demos/sender/actions-enhanced.vue`:
- Line 11: The feedback timers in docs/demos/sender/actions-enhanced.vue must
share one handle so newer messages are not cleared by older callbacks. In the
submit-message logic at lines 11-11, cancel the existing timer before scheduling
the new clear timeout; in the file-selection feedback at lines 16-16, use that
same timer handle.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e02e4910-d554-42c2-b391-156abd28121c
📒 Files selected for processing (19)
docs/demos/sender/actions-enhanced.vuedocs/demos/sender/attachments-in-sender.vuedocs/src/components/attachments.mddocs/src/components/sender.mdpackages/components/src/attachments/context.tspackages/components/src/attachments/index.tspackages/components/src/attachments/index.type.tspackages/components/src/attachments/index.vuepackages/components/src/index.tspackages/components/src/sender/composables/index.tspackages/components/src/sender/composables/useSenderContentRegistry.tspackages/components/src/sender/composables/useSenderCore.tspackages/components/src/sender/index.tspackages/components/src/sender/index.type.tspackages/components/src/sender/types/submit-meta.tspackages/test/src/sender/helpers/index.tspackages/test/src/sender/index.vuepackages/test/src/sender/selectors.tspackages/test/src/sender/specs/basic.spec.ts
📦 Package Previewpnpm add https://pkg.pr.new/@opentiny/tiny-robot@e84f845 pnpm add https://pkg.pr.new/@opentiny/tiny-robot-kit@e84f845 pnpm add https://pkg.pr.new/@opentiny/tiny-robot-svgs@e84f845 commit: e84f845 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/test/src/sender/specs/attachments.spec.ts (1)
16-35: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover status changes after source registration.
The test sets the status before
toggleAttachmentsSource, so it only verifies the initial mount state. It does not verify that a mountedTrAttachmentsupdates Sender submit state when an attachment changes fromsuccesstouploadingorerror.Mount the source with a successful item first, then change its status and assert the submit state and metadata.
Suggested test adjustment
+ await helper.setSenderAttachmentStatus('success') await helper.toggleAttachmentsSource() + await helper.expectSubmitButtonVisible(true) + await helper.setSenderAttachmentStatus(status) await helper.expectSubmitButtonVisible(false)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/test/src/sender/specs/attachments.spec.ts` around lines 16 - 35, Update the test around setSenderAttachmentStatus, toggleAttachmentsSource, and submit assertions so the attachment source is registered while the item is successful, then transition it to uploading and error afterward. For each transition, assert the submit button is hidden and the submitted detail retains the text while exposing the expected attachment metadata behavior, verifying mounted TrAttachments reacts to status changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/test/src/sender/specs/attachments.spec.ts`:
- Around line 16-35: Update the test around setSenderAttachmentStatus,
toggleAttachmentsSource, and submit assertions so the attachment source is
registered while the item is successful, then transition it to uploading and
error afterward. For each transition, assert the submit button is hidden and the
submitted detail retains the text while exposing the expected attachment
metadata behavior, verifying mounted TrAttachments reacts to status changes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 5ef2f23f-ab36-41df-9193-99734e545f62
📒 Files selected for processing (5)
docs/demos/sender/actions-enhanced.vuepackages/components/src/attachments/index.vuepackages/test/src/sender/helpers/index.tspackages/test/src/sender/index.vuepackages/test/src/sender/specs/attachments.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/test/src/sender/helpers/index.ts
- packages/components/src/attachments/index.vue

变更说明
为
Sender增加内容注册机制,使TrAttachments可以作为 Sender 的外部提交内容参与可提交状态判断,并在提交时通过meta.externalPayloads返回附件数据。主要改动
useSenderContentRegistry,用于管理已注册的外部内容,并在提交时收集 payload。TrAttachments新增contentSourceId,当上层容器提供附件注册上下文时,会自动注册当前附件列表。Sender内置附件注册 provider,支持在 Sender 内直接使用TrAttachments完成附件提交。submit事件新增可选第三个参数SenderSubmitMeta;无外部 payload 时仍保持原有两个参数,兼容旧用法。hasExternalContent保持兼容可用,但仅用于控制提交状态,不会生成externalPayloads。attachments-in-senderdemo,展示 Sender 内附件列表和附件随消息提交。actions-enhanceddemo,避免继续用增强按钮示例承载附件提交语义。contentSourceId、hasExternalContent兼容说明。contentSourceId变化等场景。测试
packages/test/src/sender/specs/basic.spec.ts中的 Sender 附件提交相关用例。pnpm type-check。Summary by CodeRabbit
New Features
Documentation
Bug Fixes