Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(contacts): 空库引导升级为三源起步(邮件 / IM / 系统通讯录导入) (#1073)
Chris Zhang1cae170789e5
diff --git a/apps/desktop/src/renderer/components/settings/contacts/ContactsSection.tsx b/apps/desktop/src/renderer/components/settings/contacts/ContactsSection.tsxindex 444c316f8e..81e877d0e1 100644--- a/apps/desktop/src/renderer/components/settings/contacts/ContactsSection.tsx+++ b/apps/desktop/src/renderer/components/settings/contacts/ContactsSection.tsx@@ -10,7 +10,7 @@import { useCallback, useEffect, useState } from 'react';import { useTranslation } from 'react-i18next';import { useNavigate } from 'react-router-dom';-import { BookUser, Sparkles } from 'lucide-react';+import { BookUser, Mail, MessageCircle, Users } from 'lucide-react';import { cn } from '@/lib/utils';import { toast } from '@/lib/toast';@@ -18,6 +18,7 @@ import { Switch } from '@/components/ui/switch';import { createLogger } from '@/lib/logger';import { contactsService, contactsErrorI18nKey, type ContactsStats } from '@/lib/contactsService';import { ContactsManagerDialog } from './ContactsManagerDialog';+import { ContactsImportDialog } from './ContactsImportDialog';import { prefillContactsAiSessionDraft } from './startContactsAiSession';const log = createLogger('ContactsSection');@@ -30,6 +31,7 @@ export function ContactsSection() {const [togglePending, setTogglePending] = useState(false);const [stats, setStats] = useState<ContactsStats | null>(null);const [managerOpen, setManagerOpen] = useState(false);+ const [importOpen, setImportOpen] = useState(false);const reloadStats = useCallback(async () => {try {@@ -84,6 +86,16 @@ export function ContactsSection() {navigate('/cc-agent/new');}, [navigate, t]);+ /** 按来源预填"从邮件/IM 建库"草稿 — 与 startAiSession 同机制, 只是 prompt 不同 */+ const startSourceSession = useCallback(+ (promptKey: 'settings.contacts.guide.mailPrompt' | 'settings.contacts.guide.imPrompt') => {+ prefillContactsAiSessionDraft(t(promptKey));+ setManagerOpen(false);+ navigate('/cc-agent/new');+ },+ [navigate, t],+ );+const statsLine =stats && (stats.people > 0 || stats.orgs > 0 || stats.groups > 0)? t('settings.contacts.stats', {@@ -158,31 +170,63 @@ export function ContactsSection() {</div></div>- {/* 首次引导: 开启后库还是空的 → 引导用户发起第一个"让 AI 整理"会话 */}+ {/* 首次引导: 开启后库还是空的 → 三源起步(邮件 / IM 走预填草稿的 AI 会话,+ 系统通讯录/vCard 走既有导入弹窗), 让用户第一天就有一个非空的库 */}{enabled && stats && stats.people + stats.orgs === 0 && (<divclassName={cn(- 'flex items-center justify-between gap-3 rounded-xl px-4 py-3',+ 'flex flex-col gap-2.5 rounded-xl px-4 py-3','bg-[var(--settings-input-bg)]',)}><p className="min-w-0 text-12 leading-[1.5] text-[var(--settings-section-desc)]">{t('settings.contacts.guide.hint')}</p>- <button- type="button"- onClick={startAiSession}- className={cn(- 'flex h-[30px] shrink-0 items-center gap-1.5 rounded-lg px-3 text-13 font-medium transition-colors',- 'bg-[var(--accent-cta-bg)] text-[var(--accent-pure-cta-fg)] hover:opacity-90',- )}- >- <Sparkles size={13} />- {t('settings.contacts.guide.cta')}- </button>+ <div className="flex flex-wrap items-center gap-2">+ <button+ type="button"+ onClick={() => startSourceSession('settings.contacts.guide.mailPrompt')}+ className={cn(+ 'flex shrink-0 items-center gap-1.5 rounded-full px-6 py-2.5 text-13 font-medium transition-colors active:scale-[0.98]',+ 'bg-[var(--accent-cta-bg)] text-[var(--accent-pure-cta-fg)] hover:opacity-90',+ )}+ >+ <Mail size={13} />+ {t('settings.contacts.guide.sources.mail')}+ </button>+ <button+ type="button"+ onClick={() => startSourceSession('settings.contacts.guide.imPrompt')}+ className={cn(+ 'flex shrink-0 items-center gap-1.5 rounded-full px-6 py-2.5 text-13 transition-colors active:scale-[0.98]',+ 'text-[var(--settings-section-title)] bg-[var(--settings-theme-card-bg)]',+ 'border border-[var(--settings-theme-card-border)]',+ 'hover:bg-[var(--settings-menu-bg-hover)]',+ )}+ >+ <MessageCircle size={13} />+ {t('settings.contacts.guide.sources.im')}+ </button>+ <button+ type="button"+ onClick={() => setImportOpen(true)}+ className={cn(+ 'flex shrink-0 items-center gap-1.5 rounded-full px-6 py-2.5 text-13 transition-colors active:scale-[0.98]',+ 'text-[var(--settings-section-title)] bg-[var(--settings-theme-card-bg)]',+ 'border border-[var(--settings-theme-card-border)]',+ 'hover:bg-[var(--settings-menu-bg-hover)]',+ )}+ >+ <Users size={13} />+ {t('settings.contacts.guide.sources.import')}+ </button>+ </div></div>)}+ {/* 空库引导里的"导入"直达导入弹窗(与管理浮层里的入口同一组件, 状态各自独立) */}+ <ContactsImportDialog open={importOpen} onOpenChange={setImportOpen} />+{/* "让 AI 整理"引导只在开关开启时提供 — 关着时 cindy_contacts MCP 未注册,引导出的会话拿不到工具, 空跑误导用户 */}<ContactsManagerDialogdiff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 92f99e22bd..0e8a4ebe27 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -3053,9 +3053,16 @@"INTERNAL": "Operation failed. Please try again later."},"guide": {- "hint": "Your contacts are empty. Let AI get you started — collect people from conversations or import from system contacts.",+ "hint": "Your contacts are empty. Start from any source so it knows your people from day one:","cta": "Organize with AI",- "prompt": "Help me organize my smart contacts: review what is there, add people worth keeping (import from system contacts or vCard, or ask me), and confirm-then-merge any duplicates."+ "prompt": "Help me organize my smart contacts: review what is there, add people worth keeping (import from system contacts or vCard, or ask me), and confirm-then-merge any duplicates.",+ "sources": {+ "mail": "From Email",+ "im": "From IM",+ "import": "Import Contacts"+ },+ "mailPrompt": "Help me build my Smart Contacts from email: first check which mail tools I have connected (if none, tell me how to connect one); scan the last 6 months of correspondence and create profiles for real contacts I exchange mail with — confirm high-frequency, clearly-identified people directly, use pending for uncertain ones; skip marketing mail, notification bots, and one-off senders. Report which profiles you created at the end.",+ "imPrompt": "Help me build my Smart Contacts from chat tools: first check which IMs I have connected (Feishu / Slack / WeChat etc.; if none, tell me how to connect one); organize the people I chat with regularly into contacts, use pending for uncertain ones, and skip group bots and one-off conversations. Report which profiles you created at the end."}}},diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex 1d054a730f..d993f90fcb 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -3052,9 +3052,16 @@"INTERNAL": "操作に失敗しました。しばらくしてから再試行してください。"},"guide": {- "hint": "連絡先はまだ空です。AI に手伝ってもらいましょう — 会話に登場した人の整理やシステム連絡先からのインポートができます。",+ "hint": "連絡先はまだ空です。いずれかのソースから始めて、初日からあなたの人脈を把握させましょう:","cta": "AI で整理する",- "prompt": "スマート連絡先の整理を手伝ってください。まず現状を確認し、記録すべき人を追加して(システム連絡先や vCard からのインポート、または私への確認でも構いません)、重複があれば確認のうえ統合してください。"+ "prompt": "スマート連絡先の整理を手伝ってください。まず現状を確認し、記録すべき人を追加して(システム連絡先や vCard からのインポート、または私への確認でも構いません)、重複があれば確認のうえ統合してください。",+ "sources": {+ "mail": "メールから整理",+ "im": "IM から整理",+ "import": "連絡先をインポート"+ },+ "mailPrompt": "メールからスマート連絡先を作成してください:まず接続済みのメールツールを確認し(なければ接続方法を教えてください)、直近 6 か月のやり取りをスキャンして、双方向のやり取りがある実在の連絡先を登録してください——頻度が高く身元が明確な人は確定で、不確かな人は pending で。マーケティングメール、通知ボット、一度きりの送信者はスキップ。最後に作成した項目を報告してください。",+ "imPrompt": "チャットツールからスマート連絡先を作成してください:まず接続済みの IM(Feishu / Slack / WeChat など)を確認し(なければ接続方法を教えてください)、最近よく会話する相手を連絡先に整理してください。不確かな人は pending で、グループボットや一時的な会話はスキップ。最後に作成した項目を報告してください。"}}},diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 834190bb07..6e34d2a1b8 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -3052,9 +3052,16 @@"INTERNAL": "작업에 실패했습니다. 잠시 후 다시 시도하세요."},"guide": {- "hint": "연락처가 아직 비어 있습니다. AI의 도움을 받아 시작하세요 — 대화에 등장한 사람 정리나 시스템 연락처 가져오기가 가능합니다.",+ "hint": "연락처가 아직 비어 있습니다. 어느 소스에서든 시작해 첫날부터 인맥을 파악하게 하세요:","cta": "AI로 정리하기",- "prompt": "스마트 연락처 정리를 도와주세요. 먼저 현재 상태를 확인하고, 기록할 가치가 있는 사람을 추가한 뒤(시스템 연락처/vCard 가져오기 또는 저에게 질문해도 됩니다), 중복이 있으면 확인 후 병합해 주세요."+ "prompt": "스마트 연락처 정리를 도와주세요. 먼저 현재 상태를 확인하고, 기록할 가치가 있는 사람을 추가한 뒤(시스템 연락처/vCard 가져오기 또는 저에게 질문해도 됩니다), 중복이 있으면 확인 후 병합해 주세요.",+ "sources": {+ "mail": "이메일에서 정리",+ "im": "IM에서 정리",+ "import": "연락처 가져오기"+ },+ "mailPrompt": "이메일에서 스마트 연락처를 만들어 주세요: 먼저 연결된 메일 도구를 확인하고(없다면 연결 방법을 알려 주세요), 최근 6개월간의 주고받은 메일을 스캔해 실제로 왕래하는 연락처를 등록해 주세요 — 빈도가 높고 신원이 명확한 사람은 바로 확정, 불확실한 사람은 pending으로. 마케팅 메일, 알림 봇, 일회성 발신자는 건너뜁니다. 마지막에 어떤 프로필을 만들었는지 보고해 주세요.",+ "imPrompt": "채팅 도구에서 스마트 연락처를 만들어 주세요: 먼저 연결된 IM(Feishu / Slack / WeChat 등)을 확인하고(없다면 연결 방법을 알려 주세요), 최근 자주 대화하는 사람들을 연락처로 정리해 주세요. 불확실한 사람은 pending으로, 그룹 봇과 일회성 대화는 건너뜁니다. 마지막에 어떤 프로필을 만들었는지 보고해 주세요."}}},diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 99951446dd..3298aaaba8 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -3052,9 +3052,16 @@"INTERNAL": "操作失败,请稍后重试"},"guide": {- "hint": "通讯录还是空的。让 AI 帮你开始:整理对话里出现过的人、或从系统通讯录导入。",+ "hint": "通讯录还是空的。从任一来源开始,让它第一天就认识你的联系人:","cta": "让 AI 整理通讯录",- "prompt": "帮我整理一下我的智能通讯录:先看看现在有什么,然后把值得记录的人补进去(可以从系统通讯录或 vCard 导入,也可以问我),有重复的帮我确认后合并。"+ "prompt": "帮我整理一下我的智能通讯录:先看看现在有什么,然后把值得记录的人补进去(可以从系统通讯录或 vCard 导入,也可以问我),有重复的帮我确认后合并。",+ "sources": {+ "mail": "从邮件整理",+ "im": "从 IM 整理",+ "import": "导入通讯录"+ },+ "mailPrompt": "帮我从邮件建立智能通讯录:先看看我连接了哪些邮箱工具(没有的话告诉我该怎么连接);扫描最近 6 个月的往来邮件,找出和我有双向往来的真实联系人建档——高频且信息明确的直接确认,拿不准的用 pending;营销邮件、通知机器人、一次性发件人跳过。最后汇报建了哪些档案。",+ "imPrompt": "帮我从 IM 工具建立智能通讯录:先看看我连接了哪些 IM(飞书 / Slack / 微信等,没有的话告诉我该怎么连接);把近期经常和我对话的联系人整理进通讯录,拿不准的用 pending,群机器人和一次性对话跳过。最后汇报建了哪些档案。"}}},