Skip to content

feat: AI relate implements#1968

Open
boyan01 wants to merge 52 commits into
mainfrom
feat/ai
Open

feat: AI relate implements#1968
boyan01 wants to merge 52 commits into
mainfrom
feat/ai

Conversation

@boyan01
Copy link
Copy Markdown
Collaborator

@boyan01 boyan01 commented May 7, 2026

No description provided.

boyan01 added 30 commits April 17, 2026 17:08
boyan01 added 21 commits April 28, 2026 20:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces an AI assistant feature set into the app, including provider configuration, prompt templating, AI chat threads stored in a dedicated Drift database, and tooling such as unread-message summarization, message-level AI actions, OCR for attached images, and a local MCP server bridge.

Changes:

  • Added AI chat infrastructure (new AiDatabase, DAOs, controller/prompt builder, metadata, thread model) plus unit tests.
  • Integrated AI entry points into chat UI (inline message actions, AI side page routing, attachments to AI, unread summary actions).
  • Added settings support for AI providers, prompt template overrides, and MCP server enablement/token management; updated dependencies accordingly.

Reviewed changes

Copilot reviewed 76 out of 80 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
test/utils/device_transfer_test.dart Updates test database construction to include AiDatabase.
test/db/property_storage_test.dart Adds tests for AI prompt template overrides and translator-provider model selection.
test/ai/ai_provider_requester_test.dart Adds tests for prompt-role mapping and cancellation behavior.
test/ai/ai_prompt_template_test.dart Adds tests for prompt template rendering and legacy aliases.
test/ai/ai_conversation_context_test.dart Adds coverage for conversation context, tool-result encoding, attachments/transcripts/OCR prompt context.
test/ai/ai_chat_thread_test.dart Tests AI thread scoping, metadata updates, and prompt history behavior.
test/ai/ai_chat_metadata_test.dart Tests AI message metadata merging and attachment storage.
pubspec.yaml Adds AI/MCP/OCR dependencies, switches some deps to git, and adds dependency overrides.
macos/Runner.xcodeproj/project.pbxproj Updates macOS project settings/framework entries related to plugin linkage.
macos/Podfile.lock Updates macOS CocoaPods lockfile for changed plugins/deps.
lib/workers/message_worker_isolate.dart Ensures message worker isolate opens AiDatabase.
lib/workers/device_transfer.dart Ensures device transfer isolate opens AiDatabase.
lib/widgets/message/message.dart Adds inline AI UI, AI context attachment routing, unread-summary button, and AI menu actions.
lib/widgets/message/message_day_time.dart Adds MessageDayTimeItem and adjusts viewport tracking to support non-message list items.
lib/widgets/message/message_datetime_and_status.dart Extracts MessageMetaRow for reuse and clearer composition.
lib/widgets/message/message_ai_assist.dart Implements message-level AI actions (translate/explain/suggest replies) with inline result UI.
lib/widgets/message/item/post_message.dart Adds markdown cache keys for post rendering to improve stability/perf.
lib/widgets/menu.dart Adds useActionButton option to support non-ActionButton menu triggers.
lib/widgets/brightness_observer.dart Adds AI-specific color scheme to theme data and lerp/equality wiring.
lib/widgets/app_bar.dart Adds leadingWidth to MixinAppBar for layout control.
lib/widgets/ai/ai_context_attachment_bar.dart Adds UI for displaying/removing AI context attachments (message chips).
lib/utils/uri_utils.dart Adds message_id URI parameter handling with validation to support deep-linking to a message.
lib/utils/property/setting_property.dart Adds persistent settings for AI providers, prompt template overrides, and MCP server/token flags.
lib/utils/mixin_api_client.dart Adjusts Client configuration (httpLogLevel handling).
lib/utils/mcp/mixin_mcp_bridge.dart Adds an MCP bridge for UI operations (open/reveal message, draft ops, circle ops, attach messages).
lib/ui/setting/setting_page.dart Adds navigation entry for AI settings.
lib/ui/setting/ai_prompt_settings_page.dart Adds UI for viewing/editing AI prompt templates and inserting variables.
lib/ui/setting/ai_mcp_settings_page.dart Adds UI for enabling MCP server, copying endpoint/token, and viewing tool availability.
lib/ui/provider/responsive_navigator_provider.dart Registers AI settings page route.
lib/ui/provider/database_provider.dart Ensures main isolate database includes AiDatabase and passes identity number.
lib/ui/provider/ai_input_mode_provider.dart Adds state for AI input mode (provider/model selection).
lib/ui/provider/ai_context_attachment_provider.dart Adds provider for managing attached message context per conversation.
lib/ui/provider/ai_assistant_thread_provider.dart Adds provider for AI thread selection state (latest/new/existing).
lib/ui/home/home.dart Starts/stops local MCP server based on settings and binds bridge root context.
lib/ui/home/conversation/menu_wrapper.dart Adds context menu action to summarize unread messages with AI.
lib/ui/home/chat/selection_bottom_bar.dart Adds “Attach to AI” action for multi-selected messages and supports icon-based buttons.
lib/ui/home/chat/chat_side_route_names.dart Introduces route name constant for the AI assistant side page.
lib/ui/home/chat/chat_page.dart Adds AI assistant side routes and dynamically adjusts side-page width for AI pages.
lib/ui/home/chat/chat_bar.dart Adds AI assistant toggle button when a model is available.
lib/ui/home/chat_slide_page/ai_assistant/unread_summary.dart Implements unread summary flow (thread creation + prompt seeding + navigation).
lib/ui/home/chat_slide_page/ai_assistant/message_list.dart Adds AI assistant message list with pagination and day-time headers.
lib/ui/home/chat_slide_page/ai_assistant/helpers.dart Adds helpers for provider/model resolution and language tag selection.
lib/ui/home/chat_slide_page/ai_assistant/constants.dart Adds constants for AI assistant UI strings and pagination behavior.
lib/ui/home/chat_slide_page/ai_assistant/composer.dart Adds AI assistant composer UI with provider/model selectors and attachments bar.
lib/db/moor/mixin.drift Formatting adjustment to keep schema file consistent.
lib/db/moor/ai.drift Adds AI database schema (threads, messages, OCR results) and indexes.
lib/db/database.dart Extends Database wrapper to include AiDatabase and AI DAOs; disposes it.
lib/db/dao/pin_message_dao.dart Adds cursor-based pin-message pagination/query helpers.
lib/db/dao/message_dao.dart Adds new range-based message queries and quote-link lookup for AI context building.
lib/db/dao/ai_image_ocr_dao.g.dart Generated Drift mixin for OCR DAO.
lib/db/dao/ai_image_ocr_dao.dart Adds DAO for reading/upserting OCR results.
lib/db/dao/ai_chat_message_dao.g.dart Generated Drift mixin for AI chat DAO.
lib/db/dao/ai_chat_message_dao.dart Adds AI thread/message DAO operations (watch, paginate, stats, metadata updates, stale pending resolution).
lib/db/ai_database.dart Adds dedicated AI Drift database with migration strategy and connection helper.
lib/constants/brightness_theme_data.dart Populates AI color scheme for light/dark themes.
lib/ai/tools/ai_image_ocr_service.dart Adds OCR service with caching and Darwin Vision fast-path for image attachments.
lib/ai/model/ai_provider_type.dart Adds AI provider type enum (OpenAI-compatible, Anthropic, Gemini).
lib/ai/model/ai_provider_config.dart Adds provider config model with JSON serialization and model normalization.
lib/ai/model/ai_prompt_message.dart Adds prompt message model + role mapping to Genkit.
lib/ai/model/ai_mode_state.dart Adds state model for AI mode selection.
lib/ai/model/ai_chat_metadata.dart Adds metadata encoding/merging helpers for AI tool events, response metadata, attachments.
lib/ai/ai_thread_target.dart Adds thread-target abstraction (existing vs new).
lib/ai/ai_provider_requester.dart Adds Genkit-based provider requester with streaming and proxy support.
lib/ai/ai_message_context.dart Adds message context extraction/formatting for prompts (including quotes/transcripts).
lib/ai/ai_chat_prompt_builder.dart Builds chat/assist prompts with recent context, attachments, transcript/OCR, and history.
lib/ai/ai_chat_controller.dart Orchestrates AI requests, persistence, streaming updates, tool events, and cancellation.
devtools_options.yaml Adds DevTools options placeholder file.
AGENTS.md Documents project structure, commands, conventions (including localization and generated file guidance).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +677 to +684
final hasEnabledAiProvider = context
.database
.settingProperties
.aiProviders
.any((p) => p.enabled);
final aiText = hasEnabledAiProvider
? messageAiText(message)
: null;
Comment on lines +705 to +708
MenuAction(
image: MenuImage.icon(Icons.translate),
title: 'Translate',
callback: () => unawaited(
Comment on lines +141 to +147
const _Item(
leadingAssetName:
Resources.assetsImagesIcAppearanceSvg,
pageName:
ResponsiveNavigatorStateNotifier.aiSettingsPage,
title: 'AI Settings',
),
Comment on lines +28 to +33
return Scaffold(
backgroundColor: context.theme.background,
appBar: const MixinAppBar(title: Text('AI Prompt Templates')),
body: Align(
alignment: Alignment.topCenter,
child: ConstrainedBox(
Comment on lines +36 to +41
return Scaffold(
backgroundColor: context.theme.background,
appBar: const MixinAppBar(title: Text('Local MCP Server')),
body: Align(
alignment: Alignment.topCenter,
child: ConstrainedBox(
Comment thread pubspec.yaml
Comment on lines +244 to +247
dependency_overrides:
code_assets: ^1.0.0
hooks: ^1.0.0

Comment on lines +9 to +10
// ignore: implementation_imports
import 'package:platform_ocr/src/darwin/bindings.g.dart' as darwin;
Comment on lines +18 to +28
static final MixinMcpBridge instance = MixinMcpBridge._();

BuildContext? _rootContext;
String? _inputConversationId;
TextEditingController? _inputController;

String? get activeInputConversationId => _inputConversationId;

set rootContext(BuildContext context) {
_rootContext = context;
}
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.

2 participants