Skip to content

chore: adjust database custom prompt ui#7902

Merged
LucasXu0 merged 1 commit intoAppFlowy-IO:mainfrom
richardshiue:chore/adjust-database-custom-prompt-ui
May 11, 2025
Merged

chore: adjust database custom prompt ui#7902
LucasXu0 merged 1 commit intoAppFlowy-IO:mainfrom
richardshiue:chore/adjust-database-custom-prompt-ui

Conversation

@richardshiue
Copy link
Collaborator

@richardshiue richardshiue commented May 9, 2025

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

Refactor and improve the custom prompt database selector UI in the AI prompt modal, enhancing user experience and adding more flexible database selection functionality.

Bug Fixes:

  • Fixed issues with database prompt selection and loading
  • Improved error handling for invalid database selections

Enhancements:

  • Redesigned the database selector component to be more flexible and user-friendly
  • Improved the UI for selecting and displaying custom database prompts
  • Added an onboarding state for when no database is selected

Chores:

  • Refactored database selector and prompt selection components
  • Updated dialog and UI styling to be more consistent

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented May 9, 2025

Reviewer's Guide

This pull request refines the user interface for selecting a database for custom AI prompts. It achieves this by introducing a new onboarding flow using the AiPromptOnboarding widget when no database is initially selected in the custom prompts section. The CustomPromptDatabaseSelector widget has been refactored with a childBuilder to allow its button's appearance to be context-dependent (e.g., a prominent "Select Database" button for onboarding versus a subtle "Change" button). State management in AiPromptSelectorCubit was adjusted to support these UI changes, particularly for handling empty custom prompt lists, now relying on the UI to display states like "no results" or the onboarding screen. Error handling for invalid databases now uses an updated dialog style, and a backend change prevents empty content from being treated as a valid prompt.

File-Level Changes

Change Details Files
Introduced Custom Prompt Onboarding UI
  • Added AiPromptOnboarding widget to guide users in selecting a database for custom prompts.
  • Modified AiPromptModal to display the onboarding UI when the custom section is active and no database is selected.
frontend/appflowy_flutter/lib/ai/widgets/ai_prompt_modal/ai_prompt_modal.dart
frontend/appflowy_flutter/lib/ai/widgets/ai_prompt_modal/ai_prompt_onboarding.dart
frontend/appflowy_flutter/lib/ai/widgets/ai_prompt_modal/ai_prompt_database_selector.dart
Enhanced Database Selector Widget and UI
  • Refactored CustomPromptDatabaseSelector to use a childBuilder for its trigger, allowing for dynamic button styles.
  • Introduced AiPromptDatabaseSelectorButton as the new default button, displaying database name and a "Change" option.
  • Enabled auto-focus on the search input within the database selection popover.
  • Removed instructional text from the database selection popover header.
frontend/appflowy_flutter/lib/ai/widgets/ai_prompt_modal/ai_prompt_database_selector.dart
frontend/appflowy_flutter/lib/ai/widgets/ai_prompt_modal/ai_prompt_visible_list.dart
Improved Handling of Custom Prompt States and Errors
  • Updated AiPromptSelectorCubit to prevent automatic switching to "featured" prompts if custom prompts are empty; UI now manages these states.
  • Added a "No results" message in AiPromptVisibleList when no custom prompts are found.
  • Revised error dialog for invalid database selection using the dialog_v2.dart component.
  • Backend: Prevented database rows with empty content fields from being considered valid prompts.
frontend/appflowy_flutter/lib/ai/service/ai_prompt_selector_cubit.dart
frontend/appflowy_flutter/lib/ai/widgets/ai_prompt_modal/ai_prompt_visible_list.dart
frontend/appflowy_flutter/lib/ai/widgets/ai_prompt_modal/ai_prompt_modal.dart
frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs
frontend/appflowy_flutter/lib/workspace/presentation/widgets/dialog_v2.dart
General UI Styling and Minor Adjustments
  • Applied a distinct background color to selected prompt items in the list.
  • Standardized close icon and padding across dialogs.
  • Removed unnecessary disabled state logic from the "Custom" prompt category button.
frontend/appflowy_flutter/lib/ai/widgets/ai_prompt_modal/ai_prompt_visible_list.dart
frontend/appflowy_flutter/lib/workspace/presentation/widgets/dialog_v2.dart
frontend/appflowy_flutter/lib/ai/widgets/ai_prompt_modal/ai_prompt_category_list.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

@github-actions
Copy link

github-actions bot commented May 9, 2025

🥷 Ninja i18n – 🛎️ Translations need to be updated

Project /project.inlang

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

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 @richardshiue - I've reviewed your changes - here's some feedback:

  • The AiPromptDatabaseSelectorButton now fetches ViewPB independently; consider if this data fetching should be managed by AiPromptSelectorCubit to centralize view-related state.
  • Since the backend now skips generating prompts from rows with empty content, ensure the UI clearly communicates to the user if a selected database yields no custom prompts due to this filtering.
  • The AiPromptSelectorCubit's behavior for selectDatabase has changed when custom prompts are empty (no longer defaulting to "Featured"); confirm this new user flow is intended.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue 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.

@richardshiue richardshiue force-pushed the chore/adjust-database-custom-prompt-ui branch from 1030dad to ece4d2c Compare May 9, 2025 11:57
@LucasXu0 LucasXu0 merged commit 30f5692 into AppFlowy-IO:main May 11, 2025
19 checks passed
@richardshiue richardshiue deleted the chore/adjust-database-custom-prompt-ui branch May 12, 2025 01:18
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