feat(ai): AIChat 输入框支持 @ 符号选择专家 Agent#261
Conversation
Code reviewFound 3 issues:
The code uses type assertions to create 通才: "GENERAL" as ParrotAgentType,
灵光: "INSIGHT" as ParrotAgentType,The divinesense/web/src/utils/agentMention.ts Lines 24 to 31 in 2772b17
<kbd>Enter</kbd> 发送 ·
<kbd>{sendShortcut}</kbd> 换行Non-Chinese users will see untranslated text. The code correctly uses divinesense/web/src/components/AIChat/ChatInput.tsx Lines 335 to 340 in 2772b17
`text-${color.primary}-700 dark:text-${color.primary}-200`Template literal class names are not detected by Tailwind v4's JIT compiler, resulting in missing styles. The project explicitly uses explicit values elsewhere to avoid this. divinesense/web/src/components/AIChat/AgentMentionPopover.tsx Lines 320 to 325 in 2772b17 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
Implement UI component for mentioning expert agents (灰灰, 时巧, 通才, 灵光) via @ symbol in chat input. Features include: - AgentMentionPopover component with keyboard navigation (↑↓ + Enter + Esc) - Dynamic agent list from API with filtering support - Theme-colored agent items (slate/cyan/amber/violet) - Portal rendering for proper z-index handling - Integration with ChatInput for @ detection and text insertion Files: - AgentMentionPopover.tsx: Main popover component - ChatInput.tsx: Integration with @ detection logic - useParrotsList.ts: Hook for fetching mentionable agents - agentMention.ts: Utility functions for parsing and insertion - i18n: Added translations for general and insight agents Refs #259 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove invalid ParrotAgentType type assertions (GENERAL, INSIGHT) - Remove support for unimplemented agents (通才, 灵光) with TODO - Replace hardcoded Chinese text with i18n t() calls - Replace dynamic Tailwind classes with static classes for v4 JIT Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add general (通才) mapped to AMAZING type - Add ideation (灵光) with IDEATION type (pending backend support) - Update color themes for both agents - Update MENTIONABLE_NAMES list Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Breaking changes: - Rename AGENT_TYPE_AMAZING to AGENT_TYPE_GENERAL in proto - Update all frontend ParrotAgentType.AMAZING to GENERAL - Update all backend AMAZING references to GENERAL - Remove AGENT_TYPE_CREATIVE (reserved for future use) Agent naming: - memo -> 灰灰 (笔记助手) - schedule -> 时巧 (日程管理) - general -> 通才 (通用助手) - ideation -> 灵光 (创意助手, pending backend support) Cleanup: - Remove deprecated proto/api/v1/*.pb.go files (use proto/gen instead) - Update agent mention mapping to use GENERAL Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add bounds check for selectedIndex in scroll effect to prevent null pointer - Fix race condition in keyboard handler using ref for filteredAgents - Fix event listener cleanup with isMounted flag to prevent memory leak - Add AMAZING to legacy mapping for backward compatibility - Update TODO comment to NOTE for IDEATION placeholder - Fix shouldTriggerMentionPopover logic to return false for invalid positions Refs #259 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4e4f0d9 to
3c85724
Compare
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. Reviewed:
🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
… agents Remove non-mentionable agent mappings (auto, geek, evolution, amazing) from formatAgentMention. Only keep agents that can be @ mentioned: memo, schedule, general, and ideation (placeholder). Refs #259 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Backend: - Add AGENT_TYPE_IDEATION to proto enum (value 5) - Add IDEATION routing and default title mapping - Remove legacy CREATIVE/AMAZING/DEFAULT mappings Frontend: - Add ParrotAgentType.IDEATION enum value - Add IDEATION theme (violet), sound effects, catchphrases, behaviors - Add IDEATION to PARROT_AGENTS metadata - Remove placeholder comment from agentMention.ts - Update AIChatContext with IDEATION default title i18n: - Add chat.default.general and chat.default.ideation keys - Remove deprecated chat.default.amazing key Refs #259 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove GENERAL from EXCLUDED_AGENT_TYPES in useParrotsList - Add IDEATION to AGENT_TYPE_MAP - Update isMentionable to include GENERAL and IDEATION - Remove outdated comment about ideation pending backend support Fixes issue where @ mention popover showed "未找到匹配的专家" Refs #259 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add AGENT_TYPE_IDEATION to agentTypes list - Add IDEATION case to getParrotSelfCognition - Add IDEATION case to getParrotNameByAgentType Fixes issue where @ mention popover showed "未找到匹配的专家" because ListParrots API did not include IDEATION agent. Refs #259 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Limitations are not enumerable as "cannot do" is infinite. Following unified architecture principles, remove this field from all parrot self-cognition definitions. Refs #259 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Clean up legacy naming: - Backend: Update schedule self-cognition to use "时巧 - 日程管理专家" - Frontend: Update AISuggestionCards aria-label and badge text - Proto: Update comment examples to use correct names Legacy names removed: - "金刚" → "时巧" (schedule agent) - "creative", "amazing" → "general", "ideation" (proto comments) Refs #259 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- FavoriteTools now lists actual tool names matching config/parrots/*.yaml - Capabilities use Chinese descriptions matching self_description.capabilities - General agent correctly has empty FavoriteTools (pure LLM, no tools) - Memo emoji changed from 🦜 to 📝 for consistency - Removed deprecated AMAZING/CREATIVE compatibility mapping (data cleared) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Cache chatHandler in AIService with lazy initialization (getChatHandler) - Avoid creating ChatRouter, Orchestrator, etc. on every request - Skip context building for GeekMode and EvolutionMode (direct CLI execution) - Reduces unnecessary initialization logs and improves performance Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The name field should be a programmatic identifier (memo, schedule, etc.), not a display name. Display names are available via SelfCognition.Title. This fixes the "未找到匹配的专家" error in agent mention popover, where frontend filters by English names but API returned Chinese. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
实现 AIChat 输入框的 @ 符号触发专家 Agent 选择弹窗功能,并修复 ParrotSelfCognition 配置问题。
Resolves #259
Changes
新功能
AgentMentionPopover.tsx: 新增专家代理选择弹窗组件
ChatInput.tsx: 集成 @ 检测逻辑
useParrotsList.ts: 新增 Hook,从 API 获取可提及的专家代理列表
agentMention.ts: 新增工具函数
Bug 修复
memo_search,schedule_add)性能优化
重构
Test plan
make check-all通过@灰灰) 和英文名 (@memo) 匹配Screenshot
🤖 Generated with Claude Code