Skip to content

feat: Explore + AI Agent + Map Picker + Chat Persistence (Phase A-D)#181

Open
Shangjin-Xiao wants to merge 69 commits intomainfrom
feature/explore-ai-map-refactoring
Open

feat: Explore + AI Agent + Map Picker + Chat Persistence (Phase A-D)#181
Shangjin-Xiao wants to merge 69 commits intomainfrom
feature/explore-ai-map-refactoring

Conversation

@Shangjin-Xiao
Copy link
Copy Markdown
Owner

@Shangjin-Xiao Shangjin-Xiao commented Apr 3, 2026

概述

完成 4 份计划文档的 SOTA 级重构,涵盖 Phase A(基建层)到 Phase D(统一壳层)。

Phase A — 基建层

  • Schema v20 合并迁移:poi_name + chat_sessions + chat_messages
  • ChatMessage / ChatSession 模型(toMap/fromMap/copyWith)
  • Quote.poiName 字段 + 三级显示优先级
  • ChatSessionService 持久化服务
  • PlaceSearchService(Nominatim,免费无 Key)
  • AIRequestHelper.createMessagesWithHistory(token 预算截断)
  • AIService.streamAskQuestion 支持历史上下文

Phase B — 页面层

  • NoteQAChatPage 重写:持久化会话 + 多轮对话
  • MapLocationPickerPage:flutter_map + OSM + POI 搜索
  • 编辑器长按位置按钮 → 地图选点
  • quote_item_widget poiName 显示优先级

Phase C — Agent 框架

  • AgentTool 接口 + ToolCall / ToolResult / AgentResponse 模型
  • 4 个工具:NoteSearchTool / NoteStatsTool / WebSearchTool(Bing 抓取)/ NoteEditTool
  • AgentService:工具循环 + 重复检测 + 最大轮数 + 解析失败 repair
  • AgentChatPage 工具状态展示

Phase D — 统一壳层

  • ExplorePage:数据概览 + AI 入口 + 地图入口 + 收藏笔记
  • 底部导航第三 tab 替换为 Explore

技术决策

  • 所有外部服务 免费无 API Key(Nominatim、Bing HTTP 抓取)
  • Schema v20 合并 poiName + chat 表,与 feature/recycle-bin-v20 分支独立
  • _removeTagIdsColumnSafely 已同步 poi_name 防数据丢失
  • 新增依赖:flutter_map, latlong2, flutter_map_marker_cluster, gpt_markdown

验证

  • flutter analyze --no-fatal-infos: 0 error, 0 warning
  • dart format: 全部通过

Open with Devin

Summary by CodeRabbit

发布说明

  • 新功能

    • 新增地图位置选择器,支持长按编辑位置时打开地图选择精确位置。
    • 新增"探索"页面,展示笔记统计数据、收藏笔记列表和AI助手、地图回忆入口。
    • 新增AI助手页面,支持笔记问答和智能Agent模式。
    • 新增地图回忆页面,以聚类地图视图浏览所有地理标记笔记。
    • 新增聊天历史管理,支持多会话切换和删除。
    • 新增兴趣点(POI)名称标签,优先显示位置。
    • 新增Agent工具系统,支持笔记搜索、编辑、统计和网络搜索。
  • 改进

    • 优化删除笔记提示,显示关联聊天会话数量。
    • 调整位置显示优先级:POI名称 > 地址 > 坐标。
  • 本地化

    • 新增英文、中文、日语等多语言支持。

Phase A — 基建层:
- Schema v20: poi_name + chat_sessions + chat_messages tables
- ChatMessage/ChatSession models with toMap/fromMap/copyWith
- Quote.poiName field with three-level display priority
- ChatSessionService for chat persistence
- PlaceSearchService (Nominatim, free, no API key)
- AIRequestHelper.createMessagesWithHistory (token budget)
- AIService.streamAskQuestion with history support

Phase B — 页面层:
- NoteQAChatPage rewrite: persistent sessions, multi-turn context
- MapLocationPickerPage: flutter_map + OSM + POI search
- Editor long-press location button → map picker
- quote_item_widget poiName display priority

Phase C — Agent 框架:
- AgentTool interface + ToolCall/ToolResult/AgentResponse models
- 4 tools: NoteSearch, NoteStats, WebSearch (Bing scraping), NoteEdit
- AgentService: tool loop with dedup detection, max rounds, repair retry
- AgentChatPage with tool status indicators

Phase D — 统一壳层:
- ExplorePage: data overview + AI entry + map entry + favorites
- Home navigation: third tab → Explore (replaces old AI features)

New dependencies: flutter_map, latlong2, flutter_map_marker_cluster, gpt_markdown
All external services are FREE with NO API KEY required.

Amp-Thread-ID: https://ampcode.com/threads/T-019d3ee5-3f47-756d-a080-9338e46466ff
Co-authored-by: Amp <amp@ampcode.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 3, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

本PR引入了AI助手、聊天会话管理、地图位置选择器、笔记地图库、Agent工具系统以及相关的数据库迁移,覆盖新增服务、页面、数据模型、本地化字符串和单元测试。

Changes

Cohort / File(s) Summary
数据库架构与迁移
lib/services/database_schema_manager.dart
版本升级至v20,新增chat_sessionschat_messages表,添加poi_name字段支持,包含外键约束和索引优化。
数据模型
lib/models/chat_message.dart, lib/models/chat_session.dart, lib/models/quote_model.dart, lib/models/ai_skill.dart
扩展ChatMessage和ChatSession以支持持久化和JSON序列化;Quote新增poiName字段;新增AISkill模型用于OpenAI工具定义。
AI与Agent服务
lib/services/agent_service.dart, lib/services/agent_tool.dart, lib/services/agent_tools/*
实现Agent服务、工具调用循环和四种工具(笔记搜索、统计、编辑、网络搜索)的完整工具系统。
聊天与位置服务
lib/services/chat_session_service.dart, lib/services/place_search_service.dart, lib/services/ai_service.dart
新增ChatSessionService用于会话持久化,NominatimPlaceSearchService用于POI搜索,AIService扩展历史消息支持。
核心应用配置
lib/main.dart, pubspec.yaml
注册新服务到Provider,依赖注入AgentService,添加flutter_map、openai_dart等依赖。
地图与位置选择UI
lib/pages/map_location_picker_page.dart, lib/pages/map_memory_page.dart
新增地图位置选择器页面和笔记地图库查看页面,支持点击确认、聚类显示。
AI助手与Explore页面
lib/pages/ai_assistant_page.dart, lib/pages/explore_page.dart, lib/pages/ai_features_page.dart, lib/pages/ai_features_wrapper_page.dart
重构AIFeaturesPage为ExplorePage展示数据统计和入口卡片,新增AIAssistantPage统一处理笔记和Agent两种聊天模式。
笔记编辑器位置与UI
lib/pages/note_editor/editor_location_dialogs.dart, lib/pages/note_editor/editor_metadata_location_section.dart, lib/pages/note_editor/editor_ai_features.dart, lib/pages/note_editor/editor_save_and_draft.dart, lib/pages/note_full_editor_page.dart
新增长按打开地图选择器,支持POI名称显示与清除,集成AI助手替代Q&A页面。
主页与导航
lib/pages/home_page.dart, lib/pages/note_qa_chat_page.dart
移除NoteQAChatPage,主页改为使用AIAssistantPage,更新导航到Explore;添加删除笔记时检查关联聊天会话。
小部件与UI组件
lib/widgets/quote_item_widget.dart, lib/widgets/add_note_dialog.dart, lib/widgets/add_note_ai_menu.dart, lib/widgets/ask_note_widgets.dart, lib/widgets/session_history_sheet.dart, lib/widgets/ai/smart_result_card.dart
更新引用显示优先显示POI名称,新增会话历史底部表单,新增SmartResultCard用于渲染AI结果。
智能推送优化
lib/services/smart_push/smart_push_content.dart, lib/services/smart_push/smart_push_execution.dart, lib/services/smart_push_analytics.dart, lib/services/smart_push_service.dart
调整内容池逻辑,增加每日推送和"此刻"推送追踪,调整sameTimeOfDay权重。
AI相关工具函数
lib/utils/ai_request_helper.dart
新增createMessagesWithHistory方法支持历史消息上下文选择与预算管理。
本地化文件
lib/l10n/app_*.arb (en, zh, de, es, fr, ja, ko)
新增聊天管理、地图选择器、AI助手、Agent工具调用等相关UI字符串。
规划文档
docs/plans/2026-03-26-*, docs/plans/2026-03-30-*, docs/plans/2026-04-04-*, docs/plans/PROGRESS.md
补充设计文档、实施计划、进度追踪,记录代码审查后的最终变更。
单元测试
test/unit/services/*_test.dart, test/unit/models/*_test.dart
新增ChatSessionService、AgentService、NoteSearchTool、PlaceSearchService、AISkill等模块的单元测试。

Sequence Diagram(s)

sequenceDiagram
    actor User as 用户
    participant Explorer as ExplorePage
    participant AIAssistant as AIAssistantPage
    participant Agent as AgentService
    participant Tools as AgentTools
    participant LLM as OpenAI API

    User->>Explorer: 点击"AI助手"
    Explorer->>AIAssistant: 导航(note=null)
    AIAssistant->>AIAssistant: 初始化Agent模式
    User->>AIAssistant: 输入问题
    AIAssistant->>Agent: runAgent(userMessage, history)
    Agent->>LLM: 请求completion(messages, tools)
    LLM-->>Agent: assistant + toolCalls
    Agent->>Tools: 执行工具调用
    Tools->>Tools: 笔记搜索/统计/网络搜索
    Tools-->>Agent: ToolResult
    Agent->>LLM: 追加结果继续推理
    LLM-->>Agent: final content
    Agent-->>AIAssistant: AgentResponse
    AIAssistant->>AIAssistant: 渲染AI回复
    AIAssistant-->>User: 显示结果
Loading
sequenceDiagram
    actor User as 用户
    participant NoteEditor as 笔记编辑器
    participant MapPicker as MapLocationPickerPage
    participant Location as LocationService
    participant Geocoding as LocalGeocodingService
    participant Map as FlutterMap

    User->>NoteEditor: 长按位置芯片
    NoteEditor->>MapPicker: 导航(initialLat?, initialLon?)
    MapPicker->>Location: getCurrentLocation()
    Location-->>MapPicker: Position
    MapPicker->>Map: 更新中心点
    User->>MapPicker: 点击地图选择位置
    MapPicker->>Geocoding: getAddressFromCoordinates(lat, lon)
    Geocoding-->>MapPicker: AddressModel(street, district, city...)
    MapPicker->>MapPicker: 提取POI名称
    MapPicker-->>NoteEditor: MapPickerResult(lat, lon, location, poiName)
    NoteEditor->>NoteEditor: 更新_poiName、_latitude、_longitude
    NoteEditor->>NoteEditor: 刷新位置显示文本
Loading
sequenceDiagram
    participant MapMemory as MapMemoryPage
    participant Database as DatabaseService
    participant FlutterMap as FlutterMap
    participant Cluster as MarkerCluster
    participant BottomSheet as 底部表单
    participant Editor as NoteFullEditorPage

    MapMemory->>Database: 查询所有含坐标笔记
    Database-->>MapMemory: List[Quote]
    MapMemory->>MapMemory: 计算地图中心
    MapMemory->>FlutterMap: 初始化地图视图
    MapMemory->>Cluster: 添加聚类标记层
    User->>Cluster: 点击标记
    Cluster->>BottomSheet: 显示笔记详情
    User->>BottomSheet: 点击"AI问答"
    BottomSheet->>Editor: 导航AIAssistantPage(quote)
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

该PR涉及广泛的功能整合,包括:新的Agent服务与多工具系统(涉及复杂的循环控制、状态管理、错误处理);数据库架构重设(v19→v20迁移、新表添加、外键设置);多个数据模型的序列化/反序列化逻辑修改;聊天会话的完整生命周期管理;地图组件集成;跨页面导航重构;大量本地化字符串同步。异质性高,涉及数据层、服务层、UI层和测试层的多个不同关注点。

Possibly related PRs

  • PR #143:法语本地化文件同步,添加相同的聊天/地图/AI功能相关字符串。
  • PR #140:韩文本地化文件扩展,与本PR新增的国际化字符串组集一致。
  • PR #81:LocationService地址格式化与CSV解析逻辑修改,直接影响本PR中POI名称显示与位置文本优先级的实现。

Suggested labels

codex, infrastructure, data-model, ai-features, localization, database-migration, ui-refactor


🐰 聊天与Agent的奇幻之旅

地图上的足迹闪闪亮,
聊天会话成群结伴翔,
Agent工具化繁为简,
POI名字记住了方向,
智能推送叮咚响,
一次审查,万般思量! ✨🗺️💬

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/explore-ai-map-refactoring

devin-ai-integration[bot]

This comment was marked as resolved.

…very

Root cause: ChatSessionService methods could run before main.dart injects database, causing early chat operations to return/drop persistence.

Solution: gate all DB operations via a one-shot readiness completer with timeout-backed wait; add startup-race regression tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
devin-ai-integration[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
coderabbitai[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
docs/plans/2026-04-04-unified-ai-and-map-memory-design.md (1)

3-3: 建议修正文案语法,避免“记录了关于”表达不顺。

Line 3 的“本文档记录了关于 ...”建议改为“本文档记录 ...”或“本文档围绕 ...”。这是用户可见文案质量问题。

✏️ 建议修改
-> 本文档记录了关于 Explore 中枢页、统一 AI 容器(单笔记模式 vs Agent模式)、AI Skills 技能系统以及地图回忆的最终产品交互设计。
+> 本文档记录 Explore 中枢页、统一 AI 容器(单笔记模式 vs Agent 模式)、AI Skills 技能系统以及地图回忆的最终产品交互设计。
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/plans/2026-04-04-unified-ai-and-map-memory-design.md` at line 3, The
sentence "本文档记录了关于 Explore 中枢页、统一 AI 容器(单笔记模式 vs Agent模式)、AI Skills
技能系统以及地图回忆的最终产品交互设计。" uses the awkward phrase "记录了关于"; replace it with a
smoother phrasing such as "本文档记录 Explore 中枢页、统一 AI 容器(单笔记模式 vs Agent 模式)、AI
Skills 技能系统以及地图回忆的最终产品交互设计。" or "本文档围绕 Explore 中枢页、统一 AI 容器(单笔记模式 vs Agent
模式)、AI Skills 技能系统以及地图回忆的最终产品交互设计展开。" Update the exact sentence to one of these
alternatives (ensure consistent spacing around "vs" and "模式") wherever the
original sentence appears.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/plans/2026-04-04-unified-ai-and-map-memory-design.md`:
- Around line 49-50: The design text currently states "程序发送所有笔记" which risks
privacy and cost; change the design to default to a retrieval-based pipeline
instead of sending all notes by specifying "跨笔记检索" uses top-k retrieval with
snippet/summary extraction (e.g., top-k 摘要/片段) and explicitly document a
sensitive-field redaction/PII masking step before any content is sent to the
LLM, as well as an opt-in full-upload flow; update the sections labeled "跨笔记检索"
and "网络访问" to reflect these changes and mention configurable k and a
redact-sensitive-fields function/policy for minimization.
- Line 70:
在“初始视角与空状态”块(即描述“进入后默认呈现全局总览视角...定位到当前位置附近”的地图空状态)补充定位权限被拒绝或系统定位关闭时的兜底策略:明确说明应切换到默认城市视角或全局世界视角作为
fallback,并在地图顶部增加一个显眼的权限引导气泡/按钮(示例文案:提示需打开定位权限并提供“重新尝试定位”与“使用默认视角”两种操作),同时说明交互流程与文案优先级以避免白屏或页面失败感知。
- Around line 57-60: Update the design text for "升级为 Agent 模式" / "保留上下文 (不中断对话)"
to include an explicit privacy safeguard: require a second confirmation prompt
before the first external-tool/network call that clearly states "将发送上下文范围" with
a visible summary of which notes/chats will be shared, add an option in the
initial upgrade flow to "一键清除上下文再升级" so users can remove bound notes before
enabling Agent 模式, and document that the first external-tool activation must
show the scope and require explicit consent (and record the user's choice).

---

Nitpick comments:
In `@docs/plans/2026-04-04-unified-ai-and-map-memory-design.md`:
- Line 3: The sentence "本文档记录了关于 Explore 中枢页、统一 AI 容器(单笔记模式 vs Agent模式)、AI
Skills 技能系统以及地图回忆的最终产品交互设计。" uses the awkward phrase "记录了关于"; replace it with a
smoother phrasing such as "本文档记录 Explore 中枢页、统一 AI 容器(单笔记模式 vs Agent 模式)、AI
Skills 技能系统以及地图回忆的最终产品交互设计。" or "本文档围绕 Explore 中枢页、统一 AI 容器(单笔记模式 vs Agent
模式)、AI Skills 技能系统以及地图回忆的最终产品交互设计展开。" Update the exact sentence to one of these
alternatives (ensure consistent spacing around "vs" and "模式") wherever the
original sentence appears.
🪄 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: be7d0edc-a714-4271-bfec-d954c9f28837

📥 Commits

Reviewing files that changed from the base of the PR and between fbb6ba2 and 38eea99.

📒 Files selected for processing (2)
  • docs/plans/2026-04-04-unified-ai-and-map-memory-design.md
  • docs/plans/2026-04-04-unified-ai-and-map-memory-implementation.md
✅ Files skipped from review due to trivial changes (1)
  • docs/plans/2026-04-04-unified-ai-and-map-memory-implementation.md

Comment on lines +49 to +50
- **跨笔记检索**:基于用户描述搜索过往笔记(含周期洞察:程序发送所有笔记,或 Agent 自主搜索重新查看某条)。
- **网络访问**:联网搜索、直接读取网页内容。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

全量笔记直传给 LLM 的策略缺少数据最小化约束。

Line 49-50 写到“程序发送所有笔记”,这会显著放大隐私与成本风险。建议在设计上明确默认走检索召回(top-k 摘要/片段)而不是全量直传,并加入敏感字段脱敏策略。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/plans/2026-04-04-unified-ai-and-map-memory-design.md` around lines 49 -
50, The design text currently states "程序发送所有笔记" which risks privacy and cost;
change the design to default to a retrieval-based pipeline instead of sending
all notes by specifying "跨笔记检索" uses top-k retrieval with snippet/summary
extraction (e.g., top-k 摘要/片段) and explicitly document a sensitive-field
redaction/PII masking step before any content is sent to the LLM, as well as an
opt-in full-upload flow; update the sections labeled "跨笔记检索" and "网络访问" to
reflect these changes and mention configurable k and a redact-sensitive-fields
function/policy for minimization.

Comment on lines +57 to +60
- **升级为 Agent 模式**:在“单笔记模式”下,可一键开启“Agent 模式”开关。
- **弹窗确认**:首次开启时弹出安全确认框:“开启 Agent 模式后,AI 将具备调用外部工具(如联网、全库搜索)的能力”,并提供“不再提醒”勾选项。
- **保留上下文 (不中断对话)**:切换为 Agent 模式后,**当前绑定的笔记不会被解除**,依然作为强大的上下文存在。不仅不会重新开启对话,之前的聊天记录也完全保留。
- **降级为单笔记模式**:若在无笔记绑定的 Agent 模式下想切回单笔记模式,系统会提示“请先从记录页选择一条具体笔记进入”。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

模式升级后保留完整上下文存在权限边界穿透风险。

Line 57-60 规定从单笔记模式升级到 Agent 模式后保留完整历史;若随后触发联网/外部工具,历史中原本“沙盒”内容会被带出。建议补充:首次外部工具调用前二次确认 + 可见的“将发送上下文范围”提示 + 一键清除上下文再升级。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/plans/2026-04-04-unified-ai-and-map-memory-design.md` around lines 57 -
60, Update the design text for "升级为 Agent 模式" / "保留上下文 (不中断对话)" to include an
explicit privacy safeguard: require a second confirmation prompt before the
first external-tool/network call that clearly states "将发送上下文范围" with a visible
summary of which notes/chats will be shared, add an option in the initial
upgrade flow to "一键清除上下文再升级" so users can remove bound notes before enabling
Agent 模式, and document that the first external-tool activation must show the
scope and require explicit consent (and record the user's choice).

Comment thread docs/plans/2026-04-04-unified-ai-and-map-memory-design.md
devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
docs/plans/2026-04-04-unified-ai-and-map-memory-implementation.md (1)

112-112: 可选:考虑更强的形容词。

静态分析工具建议 "deep logic review" 中的 "deep" 可以用更具体的词替换,例如 "thorough"(彻底的)或 "comprehensive"(全面的)来加强表达。不过当前用词在上下文中也完全可接受。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/plans/2026-04-04-unified-ai-and-map-memory-implementation.md` at line
112, Replace the vague adjective "deep" in the sentence "Dispatch to Copilot
(`GPT-5.3-codex exhigh`) for a deep logic review of the Agent Loop and UI
components." with a stronger, more specific term such as "thorough" or
"comprehensive" (e.g., "...for a thorough logic review..." or "...for a
comprehensive logic review...") to improve clarity and emphasis.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/plans/2026-04-04-unified-ai-and-map-memory-implementation.md`:
- Around line 37-38: The plan's "Dispatcher Action" that uses run_shell_command
to auto-clone external repos (e.g., opencode) is unsafe; change it to require
manual cloning or add pre-clone safety controls: remove or disable any automated
run_shell_command calls, and instead document that contributors must manually
clone trusted sources and inspect code before use; if automation is required for
reproducibility, implement explicit safeguards in the dispatcher (validate
repository URL, restrict to an allowlist, verify commit hashes/signatures,
perform static analysis/SCA scanning, and run the clone inside a sandboxed
environment) and surface a human confirmation step before executing Agent Loop
exploration in Phase 1 Dart implementation.
- Around line 3-10: The doc currently mandates agents run in "YOLO mode" and "do
NOT stop to ask the user for permission", which poses safety and governance
risks; update the "SPECIAL INSTRUCTION FOR THE EXECUTING AGENT" section to
require explicit human confirmation checkpoints for high-risk actions (e.g.,
"submit code", "clone external repos", "delete files", "modify critical
branches") while retaining automated dispatching for low-risk tasks;
specifically, add a clear gating rule and checklist that the Dispatcher (调度员)
must follow (e.g., confirmation prompt, approver identity, and audit log) and
annotate the "YOLO mode" and "Dispatcher" directives to state they are suspended
when a checkpoint is triggered so the agent will pause and request human
approval before proceeding.
- Around line 66-70: 更新计划文档中的实现摘要以反映当前实际结果:替换第 1 点(创建 AIAssistantPage
并移除旧页面)为说明当前保留并分别增强了 NoteQAChatPage 和 AgentChatPage 的事实,并在文末加入明确的后续工作项(例如“后续
PR:将 NoteQAChatPage 与 AgentChatPage 合并为 AIAssistantPage 的重构任务”),同时在文档中引用
AIAssistantPage、NoteQAChatPage 和 AgentChatPage
以便读者知道哪些组件已保留、哪些为新增或增强,并注明对应的阶段(Phase B/Phase C)。

---

Nitpick comments:
In `@docs/plans/2026-04-04-unified-ai-and-map-memory-implementation.md`:
- Line 112: Replace the vague adjective "deep" in the sentence "Dispatch to
Copilot (`GPT-5.3-codex exhigh`) for a deep logic review of the Agent Loop and
UI components." with a stronger, more specific term such as "thorough" or
"comprehensive" (e.g., "...for a thorough logic review..." or "...for a
comprehensive logic review...") to improve clarity and emphasis.
🪄 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: 11cb9bab-5ae7-44f7-8f27-a41718bc1a2d

📥 Commits

Reviewing files that changed from the base of the PR and between 38eea99 and 7af8607.

📒 Files selected for processing (1)
  • docs/plans/2026-04-04-unified-ai-and-map-memory-implementation.md

Comment thread docs/plans/2026-04-04-unified-ai-and-map-memory-implementation.md Outdated
Comment on lines +37 to +38
**Dispatcher Action:** Use `run_shell_command` to clone repositories like `opencode` or browse local Gemini CLI source code to study how they implement the `Agent Loop` (while/for loops for tool execution).
- Note: Apply the learned best practices to the Dart implementation in Phase 1.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

克隆外部仓库存在安全隐患。

指示使用 run_shell_command 自动克隆外部仓库(如 opencode)可能带来安全风险:

  • 未知仓库内容可能包含恶意代码
  • 自动执行可能触发供应链攻击

建议改为手动审查并克隆可信源,或至少在克隆前添加安全检查步骤。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/plans/2026-04-04-unified-ai-and-map-memory-implementation.md` around
lines 37 - 38, The plan's "Dispatcher Action" that uses run_shell_command to
auto-clone external repos (e.g., opencode) is unsafe; change it to require
manual cloning or add pre-clone safety controls: remove or disable any automated
run_shell_command calls, and instead document that contributors must manually
clone trusted sources and inspect code before use; if automation is required for
reproducibility, implement explicit safeguards in the dispatcher (validate
repository URL, restrict to an allowlist, verify commit hashes/signatures,
perform static analysis/SCA scanning, and run the clone inside a sandboxed
environment) and surface a human confirmation step before executing Agent Loop
exploration in Phase 1 Dart implementation.

Comment on lines +66 to +70
1. Create `lib/pages/ai_assistant_page.dart` to replace both `agent_chat_page.dart` and `note_qa_chat_page.dart`.
2. Implement the floating context chip when entering from a specific note.
3. Implement the dynamic greeting when entering from the Explore page.
4. Add the "New Chat" button in the AppBar.
5. Commit the code and remove old pages.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

计划与实际实现不一致。

此任务指示创建统一的 AIAssistantPage 来替换 agent_chat_page.dartnote_qa_chat_page.dart,并移除旧页面。但根据 PR 摘要:

  • Phase B 重写了 NoteQAChatPage(保留并增强)
  • Phase C 添加了 AgentChatPage(新增功能)

两个页面均被保留并更新,而非按计划统一为单一页面。建议更新此文档以反映实际的实现路径,或在后续 PR 中完成统一重构。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/plans/2026-04-04-unified-ai-and-map-memory-implementation.md` around
lines 66 - 70, 更新计划文档中的实现摘要以反映当前实际结果:替换第 1 点(创建 AIAssistantPage
并移除旧页面)为说明当前保留并分别增强了 NoteQAChatPage 和 AgentChatPage 的事实,并在文末加入明确的后续工作项(例如“后续
PR:将 NoteQAChatPage 与 AgentChatPage 合并为 AIAssistantPage 的重构任务”),同时在文档中引用
AIAssistantPage、NoteQAChatPage 和 AgentChatPage
以便读者知道哪些组件已保留、哪些为新增或增强,并注明对应的阶段(Phase B/Phase C)。

coderabbitai[bot]

This comment was marked as resolved.

@Shangjin-Xiao Shangjin-Xiao force-pushed the feature/explore-ai-map-refactoring branch from d633797 to 6c124b9 Compare April 4, 2026 06:59
Shangjin-Xiao and others added 2 commits April 4, 2026 07:39
- 此时此刻(sameTimeOfDay)改为兜底推送:仅在当日无推送且7天内无其他用户笔记时触发
- 每日一言(dailyQuote)每天最多推送1条,优先级低于用户笔记但高于此时此刻
- 新增 _todayPushedDateKey 和 _todayDailyQuotePushedKey 追踪今日推送状态
- 调整优先级:那年今日(100) > 同地点(25-75) > 往月今日(70) > 上周今日(55) > 同天气(40) > 每日一言(30) > 此时此刻(20)
- 更新疲劳成本配置:此时此刻成本上调至3.0

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 3 new potential issues.

View 56 additional findings in Devin Review.

Open in Devin Review

Comment thread lib/pages/ai_assistant_page.dart Outdated
Comment on lines +98 to +104
groupKey = '📅 Today';
} else if (dayDiff == 1) {
groupKey = '📅 Yesterday';
} else if (dayDiff < 7) {
groupKey = '📅 This Week';
} else {
groupKey = '📅 Earlier';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 Hardcoded English group labels in SessionHistorySheet violate i18n rule

The session history grouping uses hardcoded English strings '📅 Today', '📅 Yesterday', '📅 This Week', '📅 Earlier' (lines 98-104, 175) as both internal keys and displayed text. These are rendered directly in the UI as group headers (line 197), violating the mandatory AGENTS.md rule against hardcoded user-visible text.

Prompt for agents
In session_history_sheet.dart, the date group keys ('📅 Today', '📅 Yesterday', etc.) at lines 98-104 are used both as map keys and as displayed text in the UI (line 197). Split these: use locale-independent internal keys (e.g. 'today', 'yesterday', 'this_week', 'earlier') for the map, and use AppLocalizations for the displayed group header text. Add the corresponding l10n keys to app_zh.arb and app_en.arb.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Padding(
padding: const EdgeInsets.all(12),
child: Text(
'可用命令',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 Hardcoded Chinese text '可用命令' in SlashCommandsMenu violates i18n rule

The slash commands menu at slash_commands_menu.dart:118 uses the hardcoded Chinese string '可用命令' as a UI label, and line 363 uses '输入 / 查看命令' as a hint text. Both violate the mandatory AGENTS.md rule: "禁止 UI 层硬编码任何用户可见文本(含中文)".

Prompt for agents
In slash_commands_menu.dart, line 118 hardcodes '可用命令' and line 363 hardcodes '输入 / 查看命令'. Both are user-visible text that must be internationalized. Add corresponding l10n keys to app_zh.arb and app_en.arb, run flutter gen-l10n, and pass AppLocalizations into SlashCommandsMenu (either via context or constructor parameter) to use the localized strings.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
问题:其他 AI 代理破坏了以下功能:
1. 工具调用从内联消息退化为输入框内面板
2. 输入框使用 AnimatedContainer+keyboardHeight 导致跳动
3. 流式传输被 150ms 防抖破坏
4. 添加大量不需要的代码(~600行)

修复:
- 恢复到 b6f268b 基线版本的 ai_assistant_page.dart
- 保持 AgentService 持久 broadcast StreamController 改进
- 工具调用内联显示: tool_progress 消息插入 _messages 列表
- 输入框: SafeArea 包裹,不手动处理键盘高度
- 流式传输: 直接 setState 无防抖
- 更新 .squad/decisions.md 记录正确架构决策,防止后续破坏

Amp-Thread-ID: https://ampcode.com/threads/T-019d7bc0-d519-716d-b431-885a95d6c35b
Co-authored-by: Amp <amp@ampcode.com>
devin-ai-integration[bot]

This comment was marked as resolved.

1. 输入框一体化:TextField + 按钮行融为一体,无分割线
   - 文本框无边框(InputBorder.none),按钮行在底部
   - 整体圆角24,紧凑padding

2. 模式切换:PopupMenuButton → 直接点击切换
   - Agent/Chat 直接 tap toggle,不弹菜单
   - 使用英文 'Agent'/'Chat',简洁

3. 工具调用面板:默认折叠,用户展开后不自动折叠
   - initState: _isExpanded = false
   - didUpdateWidget: 不再自动展开/折叠
   - 移除 _userManuallyToggled(简化逻辑)

Amp-Thread-ID: https://ampcode.com/threads/T-019d7bc0-d519-716d-b431-885a95d6c35b
Co-authored-by: Amp <amp@ampcode.com>
devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 53 additional findings in Devin Review.

Open in Devin Review

final buffer = StringBuffer();
try {
await for (final chunk in aiService.streamGeneralConversation(
'请基于已有概览数据生成一段简短总结,突出记录特点与建议,100字以内。',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Hardcoded Chinese string in explore_page.dart violates i18n rules

In explore_page.dart:139, the string '请基于已有概览数据生成一段简短总结,突出记录特点与建议,100字以内。' is a user-facing prompt passed to the AI service. While it's a system prompt rather than UI text, it's hardcoded Chinese which violates the AGENTS.md i18n rules. The same file also has 'AI Chat' hardcoded at ai_assistant_page_session.dart:113 in _createNewSession.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

…t buttons, tool progress hanging, and ddgs search formatting
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.

1 participant