Skip to content

Conversation

@asjqkkkk
Copy link
Collaborator

@asjqkkkk asjqkkkk commented Jun 3, 2025

  • at menu
    • person list
    • page list
    • date and reminder
    • backend support
      • get person list
      • at a person with notification
      • get single person info with document id
  • "mention a person" node in editor
  • invite a person as ... menu
    • backend support
      • invite a person as ...
  • person profile card
  • more option menu in "person profile card "
    • backend support
  • integrate test code

Feature Preview


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

Revamp the inline “@” mention menu to support person, page, date, and reminder mentions with a unified new menu service and modular callbacks. Extract insertion logic into EditorState extension methods and streamline the inline menu’s positioning and rendering. Introduce a dedicated MentionMenuService with Bloc-driven lists for people, pages, and date/reminder items, including a persistent “send notification” toggle and mock data providers for person mentions. Enhance AFMenu, AFMenuSection, and item widgets to allow customizable builders, trailing widgets, and background color hooks.

New Features:

  • Add person mention support with live avatar, name, and optional notification toggle
  • Implement a dedicated MentionMenuService replacing InlineActionsMenu on desktop with Bloc-managed sections for people, pages, and date/reminder items
  • Persist and toggle “send notification” setting for person mentions in key–value storage

Enhancements:

  • Refactor page, link, date, and reminder insertion into EditorState extension methods
  • Improve inline menu positioning by extracting offset calculation and alignment logic
  • Extend AFMenu, AFMenuSection, AFMenuItem, and AFTextMenuItem to accept custom builders, titleTrailing widgets, and background color hooks
  • Add visibility_detector for scrolling and item visibility tracking

Chores:

  • Add visibility_detector dependency
  • Extend KeyValueStorage to support bool values for persisting settings

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jun 3, 2025

Reviewer's Guide

This PR overhauls the “@” mention menu by refactoring inline action handlers into reusable EditorState extensions, consolidating menu positioning, enhancing UI components, adding persistent toggle state, and introducing full person-mention support with dedicated BLoCs and UI widgets.

Sequence Diagram for Mentioning a Person

sequenceDiagram
    actor User
    participant Editor
    participant CommandHandler as inlineActionsCommandHandler
    participant MenuService as MentionMenuService
    participant MentionUI as MentionMenu (UI)
    participant MentionBLoC as MentionBloc
    participant EditorExt as EditorState Extensions

    User->>Editor: Types "@"
    Editor->>CommandHandler: Triggers with "@"
    CommandHandler->>MenuService: new MentionMenuService(...)
    MenuService->>MenuService: show()
    MenuService->>MentionUI: Creates and displays
    User->>MentionUI: Types person's name (e.g., "And")
    MentionUI->>MentionBLoC: add(MentionEvent.query("And"))
    MentionBLoC->>MentionBLoC: Filters/fetches persons
    MentionBLoC-->>MentionUI: Updates state with filtered persons
    MentionUI-->>User: Shows filtered list (e.g., Andrew C., Andrew T.)
    User->>MentionUI: Selects "Andrew C."
    MentionUI->>EditorExt: insertPerson(Person("Andrew C."), ...)
    activate EditorExt
    EditorExt->>EditorExt: buildMentionPersonAttributes(...)
    EditorExt->>Editor: apply(transaction with mention)
    deactivate EditorExt
    Editor-->>User: Displays "@Andrew C."
Loading

File-Level Changes

Change Details Files
Refactor inline action handling into EditorState extensions
  • Removed private methods (_onInsertPageRef, _onInsertLinkRef, _insertReminderReference, _insertDateReference, _onSelected)
  • Extracted logic into EditorState extension methods: insertPage, insertPageLinkRef, insertDateReference, insertReminderReference, insertChildPage, insertPerson
inline_page_reference.dart
reminder_reference.dart
date_reference.dart
child_page.dart
Centralize and simplify inline menu positioning
  • Replaced ad-hoc offset/alignment calculations with calculateSelectionMenuOffset
  • Introduced _offset and _alignment fields and updated kInlineMenuHeight/Width
inline_actions_menu.dart
inline_actions_handler.dart
Add persistent toggle and boolean KV support
  • Extended KeyValueStorage with setBool/getBool
  • Added atMenuSendNotification key
  • Initialized toggle from KV and updated storage on change
kv.dart
kv_keys.dart
mention_bloc.dart
Enhance AFMenu UI for flexibility
  • Added titleTrailing in AFMenuSection
  • Added builder callback in AFMenu
  • Enabled custom backgroundColor in AFMenuItem/AFTextMenuItem
section.dart
menu.dart
menu_item.dart
text_menu_item.dart
Implement new person-mention feature
  • Created MentionBloc and PersonBloc with mock repositories
  • Built MentionMenuService for desktop and wired into inline_actions_command
  • Added UI widgets: MentionMenu, PersonList, PageList, DateReminderList, shortcuts, scroller, visibility detector, more results controls
features/mension_person/**
mention_block.dart
inline_actions_command.dart

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @asjqkkkk - I've reviewed your changes - here's some feedback:

  • Extract the duplicated overlay positioning logic in InlineActionsMenu and MentionMenuService into a shared helper or base class to reduce code duplication.
  • Consolidate the various EditorState extension methods into a single extension file or folder to improve discoverability and maintainability.
Here's what I looked at during the review
  • 🟡 General issues: 4 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@asjqkkkk asjqkkkk force-pushed the feat/desktop/mention branch from 69585b6 to 1302af0 Compare June 3, 2025 12:48
@LucasXu0 LucasXu0 added the v0.9.5 label Jun 5, 2025
});

final String email;
final PersonRole role;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I added the ShareRole before, we can reuse it and rename it to WorkspaceUserRole.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

should we add "contact" to ShareRole?

Comment on lines +31 to +33
itemMap.addToPerson(
MentionMenuItem(id: id, onExecute: () => invitePerson(context)),
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it intentional to call this function in the build function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, it's used to implement the feature: selecte items by arrow key

import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:visibility_detector/visibility_detector.dart';

class MentionMenuItenVisibilityDetector extends StatelessWidget {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the purpose of this widget?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is for implementing selecting items using arrow keys

@asjqkkkk asjqkkkk force-pushed the feat/desktop/mention branch from 91f5df8 to 4faafd3 Compare June 17, 2025 06:12
@github-actions
Copy link

github-actions bot commented Jun 23, 2025

🥷 Ninja i18n – 🛎️ Translations need to be updated

Project /project.inlang

lint rule new reports level link
Missing translation 1500 warning contribute (via Fink 🐦)

@asjqkkkk asjqkkkk force-pushed the feat/desktop/mention branch 2 times, most recently from b76e3a0 to 666fa88 Compare June 23, 2025 07:33
@asjqkkkk asjqkkkk force-pushed the feat/desktop/mention branch from 666fa88 to ce2c65f Compare June 23, 2025 08:03
@asjqkkkk asjqkkkk force-pushed the feat/desktop/mention branch from d9296c3 to ab2d2e4 Compare June 26, 2025 14:25
@asjqkkkk asjqkkkk closed this Jun 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants