[PR #7708] [MERGED] fix: replace the selected text with ai response in the same line #8055

Closed
opened 2026-03-23 23:22:24 +00:00 by mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/AppFlowy-IO/AppFlowy/pull/7708
Author: @LucasXu0
Created: 4/8/2025
Status: Merged
Merged: 4/9/2025
Merged by: @LucasXu0

Base: mainHead: ai_writer_improvement


📝 Commits (4)

  • 18da4f5 fix: replace the selected text with ai response in the same line
  • d471d54 fix: replace the selected text with ai response in the multiple lines
  • dba8235 fix: integrate the replace function in the ai writer cubit
  • 5b6af79 fix: unit test and integration test

📊 Changes

8 files changed (+773 additions, -16 deletions)

View changed files

📝 frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/operations/ai_writer_cubit.dart (+52 -10)
📝 frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/operations/ai_writer_node_extension.dart (+20 -1)
📝 frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/base/markdown_text_robot.dart (+187 -1)
📝 frontend/appflowy_flutter/lib/shared/markdown_to_document.dart (+2 -0)
📝 frontend/appflowy_flutter/pubspec.lock (+2 -2)
📝 frontend/appflowy_flutter/pubspec.yaml (+1 -1)
📝 frontend/appflowy_flutter/test/bloc_test/ai_writer_test/ai_writer_bloc_test.dart (+1 -1)
📝 frontend/appflowy_flutter/test/unit_test/document/text_robot/markdown_text_robot_test.dart (+508 -0)

📄 Description

Feature Preview

  • replace the selected text with ai response in the same line
  • replace the selected text with ai response in the multiple lines
  • only pass the selected content to ai writer

PR Checklist

  • My code adheres to AppFlowy's Conventions
  • I've listed at least one issue that this PR fixes in the description above.
  • I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes.
  • All existing tests are passing.

Summary by Sourcery

Implement functionality to replace selected text with AI-generated markdown response within the same line or across multiple lines in the document editor

New Features:

  • Add a new method to replace selected text with AI-generated markdown response, supporting both single-line and multi-line text replacements

Enhancements:

  • Extend the MarkdownTextRobot class to support text replacement with markdown formatting
  • Improve AI writer functionality to handle text selection replacement

Tests:

  • Add comprehensive unit tests for replacing text in different selection scenarios (start, middle, and end of a paragraph)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/AppFlowy-IO/AppFlowy/pull/7708 **Author:** [@LucasXu0](https://github.com/LucasXu0) **Created:** 4/8/2025 **Status:** ✅ Merged **Merged:** 4/9/2025 **Merged by:** [@LucasXu0](https://github.com/LucasXu0) **Base:** `main` ← **Head:** `ai_writer_improvement` --- ### 📝 Commits (4) - [`18da4f5`](https://github.com/AppFlowy-IO/AppFlowy/commit/18da4f5d2f5e714904f658803a287d2de7c2a743) fix: replace the selected text with ai response in the same line - [`d471d54`](https://github.com/AppFlowy-IO/AppFlowy/commit/d471d54252c59c83ef774a22471eb6696f3a07bc) fix: replace the selected text with ai response in the multiple lines - [`dba8235`](https://github.com/AppFlowy-IO/AppFlowy/commit/dba8235440bb26abd9016458c1a61d20d8c4994e) fix: integrate the replace function in the ai writer cubit - [`5b6af79`](https://github.com/AppFlowy-IO/AppFlowy/commit/5b6af79dbdf01c109018168a16ae212f39007fe5) fix: unit test and integration test ### 📊 Changes **8 files changed** (+773 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/operations/ai_writer_cubit.dart` (+52 -10) 📝 `frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/operations/ai_writer_node_extension.dart` (+20 -1) 📝 `frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/base/markdown_text_robot.dart` (+187 -1) 📝 `frontend/appflowy_flutter/lib/shared/markdown_to_document.dart` (+2 -0) 📝 `frontend/appflowy_flutter/pubspec.lock` (+2 -2) 📝 `frontend/appflowy_flutter/pubspec.yaml` (+1 -1) 📝 `frontend/appflowy_flutter/test/bloc_test/ai_writer_test/ai_writer_bloc_test.dart` (+1 -1) 📝 `frontend/appflowy_flutter/test/unit_test/document/text_robot/markdown_text_robot_test.dart` (+508 -0) </details> ### 📄 Description <!--- Thank you for submitting a pull request to AppFlowy. The team will dedicate their best efforts to reviewing and approving your pull request. If you have any questions about the project or feedback for us, please join our [Discord](https://discord.gg/wdjWUXXhtw). --> <!--- If your pull request adds a new feature, please drag and drop a video into this section to showcase what you've done! If not, you may delete this section. --> ### Feature Preview - [x] replace the selected text with ai response in the same line - [x] replace the selected text with ai response in the multiple lines - [x] only pass the selected content to ai writer <!--- List at least one issue here that this PR addresses. If it fixes the issue, please use the [fixes](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests) keyword to close the issue. For example: fixes https://github.com/AppFlowy-IO/AppFlowy/pull/2106 --> --- <!--- Before you mark this PR ready for review, run through this checklist! --> #### PR Checklist - [x] My code adheres to [AppFlowy's Conventions](https://docs.appflowy.io/docs/documentation/software-contributions/conventions) - [x] I've listed at least one issue that this PR fixes in the description above. - [x] I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes. - [x] All existing tests are passing. ## Summary by Sourcery Implement functionality to replace selected text with AI-generated markdown response within the same line or across multiple lines in the document editor New Features: - Add a new method to replace selected text with AI-generated markdown response, supporting both single-line and multi-line text replacements Enhancements: - Extend the MarkdownTextRobot class to support text replacement with markdown formatting - Improve AI writer functionality to handle text selection replacement Tests: - Add comprehensive unit tests for replacing text in different selection scenarios (start, middle, and end of a paragraph) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
mirror 2026-03-23 23:22:24 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AppFlowy-IO/AppFlowy#8055
No description provided.