Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

feat(bots): D12 show and edit what the teammate knows about its owner on the desktop memory page

nanaaa038d49f740
diff --git a/apps/desktop/src/renderer/features/bots/BotMemorySettings.tsx b/apps/desktop/src/renderer/features/bots/BotMemorySettings.tsx
index e3e85f2072..7257ff714a 100644
--- a/apps/desktop/src/renderer/features/bots/BotMemorySettings.tsx
+++ b/apps/desktop/src/renderer/features/bots/BotMemorySettings.tsx
@@ -26,6 +26,14 @@ const SAVE_DEBOUNCE_MS = 800;
type View =
{ kind: 'list' } | { kind: 'detail'; filename: string } | { kind: 'edit'; filename: string };
+export interface AboutMeField {
+ value: string;
+ readOnly?: boolean;
+ onChange: (next: string) => void;
+ onBlur: () => void;
+ /** IME composition handlers of the settings autosave. */
+ composition?: { onCompositionStart: () => void; onCompositionEnd: () => void };
+}
type SaveState = 'idle' | 'saving' | 'saved' | 'error' | 'conflict';
/** The teammate's computer serves the memory; the pages never assume it is this one. */
@@ -74,6 +82,7 @@ export function BotMemorySettings({
botName,
memoryEnabled,
onMemoryEnabledChange,
+ aboutMe,
backRef,
leaveRef,
}: {
@@ -81,6 +90,8 @@ export function BotMemorySettings({
botName: string;
memoryEnabled: boolean;
onMemoryEnabledChange: (enabled: boolean) => void;
+ /** What the teammate knows about its owner (`userContextSource`): saved with the rest of the settings. */
+ aboutMe: AboutMeField;
backRef: MutableRefObject<(() => Promise<boolean>) | null>;
leaveRef: MutableRefObject<(() => Promise<boolean>) | null>;
}) {
@@ -119,6 +130,7 @@ export function BotMemorySettings({
botId={botId}
memoryEnabled={memoryEnabled}
onMemoryEnabledChange={onMemoryEnabledChange}
+ aboutMe={aboutMe}
onOpen={openDetail}
/>
);
@@ -156,11 +168,13 @@ function MemoryList({
botId,
memoryEnabled,
onMemoryEnabledChange,
+ aboutMe,
onOpen,
}: {
botId: string;
memoryEnabled: boolean;
onMemoryEnabledChange: (enabled: boolean) => void;
+ aboutMe: AboutMeField;
onOpen: (filename: string) => void;
}) {
const { t } = useBotTranslation();
@@ -218,6 +232,21 @@ function MemoryList({
aria-label={t('bots.memory.enabled')}
/>
</div>
+ <section aria-label={t('bots.memory.aboutMe')}>
+ <h3 className="px-1 pb-2 text-12 font-medium text-[var(--text-secondary)]">
+ {t('bots.memory.aboutMe')}
+ </h3>
+ <Textarea
+ aria-label={t('bots.memory.aboutMe')}
+ readOnly={aboutMe.readOnly}
+ value={aboutMe.value}
+ onChange={aboutMe.onChange}
+ onBlur={aboutMe.onBlur}
+ {...aboutMe.composition}
+ rows={4}
+ className="min-h-24 resize-none p-3 leading-6 [field-sizing:content]"
+ />
+ </section>
{failed ? (
<div
className="flex flex-col items-center gap-3 py-10 text-13 text-[var(--text-secondary)]"
diff --git a/apps/desktop/src/renderer/features/bots/BotsHomeView.tsx b/apps/desktop/src/renderer/features/bots/BotsHomeView.tsx
index 7d1622469e..46100e9cc1 100644
--- a/apps/desktop/src/renderer/features/bots/BotsHomeView.tsx
+++ b/apps/desktop/src/renderer/features/bots/BotsHomeView.tsx
@@ -763,6 +763,16 @@ export function BotSettings({
botName={name}
memoryEnabled={capabilities.memory}
onMemoryEnabledChange={(enabled) => updateCapability('memory', enabled)}
+ aboutMe={{
+ value: userContextSource,
+ readOnly: !!invitationPending,
+ onChange: (next) => {
+ setUserContextSource(next);
+ autosave.onEdit('text');
+ },
+ onBlur: () => void autosave.flush(),
+ composition: autosave.composition,
+ }}
backRef={memoryBackRef}
leaveRef={memoryLeaveRef}
/>
diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botMemorySettings.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/botMemorySettings.test.tsx
index f146cb1da7..bbc84420f0 100644
--- a/apps/desktop/src/renderer/features/bots/__tests__/botMemorySettings.test.tsx
+++ b/apps/desktop/src/renderer/features/bots/__tests__/botMemorySettings.test.tsx
@@ -60,6 +60,7 @@ function renderMemory(memoryEnabled = true) {
botName="Cindy"
memoryEnabled={memoryEnabled}
onMemoryEnabledChange={onMemoryEnabledChange}
+ aboutMe={{ value: '', onChange: vi.fn(), onBlur: vi.fn() }}
backRef={backRef}
leaveRef={leaveRef}
/>,
diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botSettings.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/botSettings.test.tsx
index 82dea4c6a4..6be74c3af8 100644
--- a/apps/desktop/src/renderer/features/bots/__tests__/botSettings.test.tsx
+++ b/apps/desktop/src/renderer/features/bots/__tests__/botSettings.test.tsx
@@ -769,6 +769,22 @@ describe('Bot settings unified autosave', () => {
capabilities: expect.objectContaining({ memory: true }),
});
});
+
+ it('edits what the teammate knows about its owner on the memory page and saves it as userContextSource', async () => {
+ vi.useFakeTimers();
+ Object.assign(window.electronAPI, {
+ localDb: { ...window.electronAPI.localDb, bots: { memory: { list: vi.fn(async () => []) } } },
+ });
+ renderSettings();
+ fireEvent.click(screen.getByRole('button', { name: 'bots.memory.title' }));
+ fireEvent.change(screen.getByRole('textbox', { name: 'bots.memory.aboutMe' }), {
+ target: { value: 'Prefers tea' },
+ });
+ await act(async () => {
+ await vi.advanceTimersByTimeAsync(3000);
+ });
+ expect(mocks.updateBotProfile.mock.calls[0]?.[1]).toEqual({ userContextSource: 'Prefers tea' });
+ });
});
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index d012b1b372..118f7c877e 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -9226,6 +9226,7 @@
"title": "Memory",
"enabled": "Use memory",
"disabledHint": "Off. Memories aren't read or saved.",
+ "aboutMe": "What you know about me",
"search": "Search memories",
"empty": "No memories yet",
"noResults": "No matching memories",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index c2d706c410..e2c5c11029 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -9192,6 +9192,7 @@
"title": "メモリ",
"enabled": "メモリを使う",
"disabledHint": "オフです。メモリの読み取りも保存もしません",
+ "aboutMe": "私についての記憶",
"search": "メモリを検索",
"empty": "まだメモリはありません",
"noResults": "一致するメモリはありません",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index eaa24ffb1c..9ece9503bd 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -9192,6 +9192,7 @@
"title": "메모리",
"enabled": "메모리 사용",
"disabledHint": "꺼져 있어 메모리를 읽거나 저장하지 않습니다",
+ "aboutMe": "나에 관한 기억",
"search": "메모리 검색",
"empty": "아직 메모리가 없습니다",
"noResults": "일치하는 메모리가 없습니다",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 0fa5e3a355..b9ece5b5e7 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -9192,6 +9192,7 @@
"title": "记忆",
"enabled": "开启记忆",
"disabledHint": "已关闭,不会读取或保存记忆",
+ "aboutMe": "关于我的记忆",
"search": "搜索记忆",
"empty": "还没有记忆",
"noResults": "没有找到相关记忆",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index dac150b343..d55411ba8f 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -9192,6 +9192,7 @@
"title": "記憶",
"enabled": "開啟記憶",
"disabledHint": "已關閉,不會讀取或儲存記憶",
+ "aboutMe": "關於我的記憶",
"search": "搜尋記憶",
"empty": "還沒有記憶",
"noResults": "找不到相關記憶",
diff --git a/docs/product-rules/cindy-bots-runtime.md b/docs/product-rules/cindy-bots-runtime.md
index a21679b956..eefe1be672 100644
--- a/docs/product-rules/cindy-bots-runtime.md
+++ b/docs/product-rules/cindy-bots-runtime.md
@@ -485,7 +485,8 @@ Mobile 使用电脑端已连接的模型目录;目录为空时保持创建禁
保存 Skill 后请求主任务在安全轮次边界刷新,不打断运行中的工作或授权卡;同一个聊天继续使用新技能。
主任务、私聊话题和 IM 专线在下一次发送前比较共享记忆目录与自有 Skill 更新版本,变化时沿用安全刷新,
因此在一个话题学到的内容也能进入已有的其他聊天;不把每个话题的完整消息历史合并进主聊天。
- 桌面伙伴设置的「记忆」页承载这一承诺:同页开关记忆(关闭后已存记忆仍可查看、删除);
+ 桌面伙伴设置的「记忆」页承载这一承诺:同页开关记忆(关闭后已存记忆仍可查看、删除);开关下方有与手机同义的
+ 「关于我的记忆」文本框(`userContextSource`),本机与远程设置目标都随设置自动保存;
按关于你 / 你的要求 / 项目 / 参考分组列出标题与正文开头,搜索复用记忆检索,内部 `digest` 不展示;
详情显示全文,编辑自动保存,单条标题与正文沿用存储上限。改正文时摘要按正文首句确定性刷新,
不调用模型。保存与删除前核对打开时的更新时间,伙伴期间改过则不覆盖,由用户选择最新内容或