Skip to content

fix: sender component supports custom sending functionality - #375

Merged
gene9831 merged 3 commits into
opentiny:developfrom
xuanlid:feat/sender-submit-custom
Jul 14, 2026
Merged

fix: sender component supports custom sending functionality#375
gene9831 merged 3 commits into
opentiny:developfrom
xuanlid:feat/sender-submit-custom

Conversation

@xuanlid

@xuanlid xuanlid commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

背景

Sender 在上传附件、图片等内容不写入编辑器文本的场景下,即使业务侧已有可提交内容,组件仍会因为编辑器为空而隐藏/禁用提交入口,导致无法提交仅包含外部内容的消息。

变更内容

  • 为 Sender 新增 hasExternalContent prop,用于标识是否存在附件、图片、文件列表等外部可提交内容。
  • 将内容状态拆分为:
    • hasContent:编辑器文本或外部内容任一存在时为 true,用于提交按钮、快捷键提交和 submit() 方法。
    • hasEditorContent:仅表示编辑器内文本内容,用于清空按钮等只作用于编辑器文本的场景。
  • 调整清空按钮显示逻辑:仅有外部内容时不显示默认清空按钮,外部内容由业务侧维护删除入口。
  • 更新 Sender 增强按钮示例,演示上传文件作为外部内容提交、展示和删除。
  • 更新文档,补充 hasExternalContent 的使用说明和 Props 表。
  • 增加测试用例,覆盖“仅外部内容可提交”场景。

测试

  • 新增用例:Props: hasExternalContent - 应该支持仅外部内容提交
image sender

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Sender now supports submitting “external content” (attachments/images) even when editor text is empty via hasExternalContent.
    • Added a UI to preview externally selected files with per-file removal.
  • Bug Fixes
    • Clear behavior now resets external file selections, while clear visibility is tied to editor text.
  • Documentation
    • Documented hasExternalContent behavior in Sender docs.
  • Tests
    • Added Playwright coverage for the new external-content submission and button-visibility logic.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1e7d1117-3944-47e1-a670-ef8a8d70be64

📥 Commits

Reviewing files that changed from the base of the PR and between 1c207f8 and 5a5c591.

📒 Files selected for processing (2)
  • docs/demos/sender/actions-enhanced.vue
  • docs/src/components/sender.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/src/components/sender.md

Walkthrough

Adds a hasExternalContent prop to Sender so external files can count as submit-ready content without editor text. Separates editor-only content for clear-button visibility, and updates docs, tests, and the demo file-list behavior.

Changes

hasExternalContent feature

Layer / File(s) Summary
Sender contracts
packages/components/src/sender/index.type.ts, packages/components/src/sender/types/context.ts
Adds hasExternalContent to SenderProps and hasEditorContent to SenderContext.
Sender content state
packages/components/src/sender/composables/useSenderCore.ts, packages/components/src/sender/index.vue, packages/components/src/sender-actions/clear-button/useClearButtonState.ts
Computes editor-only content separately, treats external content as submit-ready, sets the prop default to false, and bases clear-button visibility on editor-only content.
Sender test harness
packages/test/src/sender/index.vue, packages/test/src/sender/selectors.ts, packages/test/src/sender/helpers/index.ts, packages/test/src/sender/specs/basic.spec.ts
Adds test-app state and toggle UI, selector and helper methods, and a spec covering submit and clear behavior with external content enabled.
Docs and demo updates
docs/src/components/sender.md, docs/demos/sender/actions-enhanced.vue
Documents the new prop behavior and updates the demo to manage selected files, clear them, submit them, and render removable file chips.

Estimated code review effort: 2 (Simple) | ~15 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Demo
  participant Sender
  participant SenderCore
  participant ClearButton
  Demo->>Sender: pass hasExternalContent from selectedFiles
  Sender->>SenderCore: evaluate editor text and external content
  SenderCore->>ClearButton: provide hasEditorContent
  Sender->>Demo: emit submit or clear
  Demo->>Demo: submit or remove selected files
Loading

Poem

A rabbit found some files to share,
No text was needed anywhere.
With chips of files and a tidy hop,
The sender sends and won’t quite stop.
Clear stays true to editor light—
Bun-bun approves this flow tonight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the PR’s main change: enabling Sender to submit content with external attachments/files, though it is broader than the implementation details.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`:
- Around line 18-20: The handleFiles handler in actions-enhanced.vue is
replacing selectedFiles with only the latest UploadButton emission, which drops
previously chosen files. Update handleFiles so it appends the new files to
selectedFiles.value instead of overwriting it, while preserving compatibility
with per-item removal in the demo flow.
🪄 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

Run ID: 53258614-62e4-4731-a6e3-aabbe6aab860

📥 Commits

Reviewing files that changed from the base of the PR and between 6b17156 and e21ceb7.

📒 Files selected for processing (11)
  • docs/demos/sender/actions-enhanced.vue
  • docs/src/components/sender.md
  • packages/components/src/sender-actions/clear-button/useClearButtonState.ts
  • packages/components/src/sender/composables/useSenderCore.ts
  • packages/components/src/sender/index.type.ts
  • packages/components/src/sender/index.vue
  • packages/components/src/sender/types/context.ts
  • packages/test/src/sender/helpers/index.ts
  • packages/test/src/sender/index.vue
  • packages/test/src/sender/selectors.ts
  • packages/test/src/sender/specs/basic.spec.ts

Comment thread docs/demos/sender/actions-enhanced.vue
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

✅ Preview build completed successfully!

Click the image above to preview.
Preview will be automatically removed when this PR is closed.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Comment thread docs/src/components/sender.md Outdated
@gene9831 gene9831 changed the title fix:sender component supports custom sending functionality fix: sender component supports custom sending functionality Jul 14, 2026
SonyLeo
SonyLeo previously approved these changes Jul 14, 2026
@gene9831
gene9831 merged commit 043003f into opentiny:develop Jul 14, 2026
4 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🧹 Preview Cleaned Up

The preview deployment has been removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants