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。

fix(bots): D2 list the official X account on a remote teammate's messaging page like the local one

nana0e4a3e812c6c
diff --git a/apps/desktop/src/main/hook-control/ipc.ts b/apps/desktop/src/main/hook-control/ipc.ts
index e3434cf888..06ddc2f3d3 100644
--- a/apps/desktop/src/main/hook-control/ipc.ts
+++ b/apps/desktop/src/main/hook-control/ipc.ts
@@ -790,11 +790,12 @@ export async function changeXCompanionBinding(botId: string | null, expectedBotI
}
/** What a teammate's settings page may show of the official X account: no URLs, accounts or tokens. */
-export function readXCompanionSummary(): { available: boolean; enabled: boolean; connected: boolean; companionBotId: string | null } {
- if (!hookControlAvailable()) return { available: false, enabled: false, connected: false, companionBotId: null };
- const x = ensureInstances().manager.snapshot().x;
+export function readXCompanionSummary(): { available: boolean; visible: boolean; enabled: boolean; connected: boolean; companionBotId: string | null } {
+ const x = hookControlAvailable() ? ensureInstances().manager.snapshot().x : disabledHookView().x;
return {
available: x.available,
+ // The same rule that decides whether this computer's own settings list the X card.
+ visible: x.url.length > 0 || x.capabilityPending || x.available || x.enabled,
enabled: x.enabled,
connected: x.binding?.state === 'confirmed',
companionBotId: x.companionBotId ?? null,
diff --git a/apps/desktop/src/main/localDb/ipc/botRemoteSettingsOps.ts b/apps/desktop/src/main/localDb/ipc/botRemoteSettingsOps.ts
index 0d139ab826..d5892c2ef8 100644
--- a/apps/desktop/src/main/localDb/ipc/botRemoteSettingsOps.ts
+++ b/apps/desktop/src/main/localDb/ipc/botRemoteSettingsOps.ts
@@ -77,7 +77,7 @@ export interface BotSettingsOpsDeps {
cancelAuthorization(): void;
} | null>;
x: {
- summary(): Promise<{ available: boolean; enabled: boolean; connected: boolean; companionBotId: string | null }>;
+ summary(): Promise<{ available: boolean; visible?: boolean; enabled: boolean; connected: boolean; companionBotId: string | null }>;
setCompanion(botId: string | null, expectedBotId: string | null): Promise<unknown>;
};
};
diff --git a/apps/desktop/src/renderer/features/bots/RemoteOfficialXCard.tsx b/apps/desktop/src/renderer/features/bots/RemoteOfficialXCard.tsx
index 30f095dd69..f9189feeb7 100644
--- a/apps/desktop/src/renderer/features/bots/RemoteOfficialXCard.tsx
+++ b/apps/desktop/src/renderer/features/bots/RemoteOfficialXCard.tsx
@@ -60,8 +60,9 @@ export function RemoteOfficialXCard({ bot, api, deviceName }: { bot: Pick<BotPro
</div>
);
}
- // An older computer, or one without the official X service, simply has nothing to show.
- if (!state || !state.available) return null;
+ // Listed whenever the teammate's own settings list it (also set up there but not usable yet); an
+ // older computer does not say, and then it is listed only once usable.
+ if (!state || !(state.available || state.visible)) return null;
const ready = state.enabled && state.connected;
return (
<section
diff --git a/apps/desktop/src/renderer/features/bots/__tests__/remoteOfficialXCard.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/remoteOfficialXCard.test.tsx
new file mode 100644
index 0000000000..dacdc6da76
--- /dev/null
+++ b/apps/desktop/src/renderer/features/bots/__tests__/remoteOfficialXCard.test.tsx
@@ -0,0 +1,33 @@
+// @vitest-environment jsdom
+import { cleanup, render, screen, waitFor } from '@testing-library/react';
+import { afterEach, expect, it, vi } from 'vitest';
+import { RemoteOfficialXCard } from '../RemoteOfficialXCard';
+
+vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));
+vi.mock('@/components/ui/confirm-dialog-provider', () => ({ useConfirmDialog: () => ({ confirm: vi.fn() }) }));
+vi.mock('@/lib/toast', () => ({ toast: { error: vi.fn() } }));
+
+afterEach(cleanup);
+
+const bot = { id: 'bot-1', name: 'Mia' };
+const render_ = (summary: Record<string, unknown>) => {
+ const api = { get: vi.fn(async () => ({ enabled: false, connected: false, companionBotId: null, ...summary })), setCompanion: vi.fn() };
+ render(<RemoteOfficialXCard bot={bot} api={api as never} deviceName="Desk" />);
+ return api;
+};
+
+it('lists the X account when the other computer lists it, even before it is usable there', async () => {
+ const api = render_({ available: false, visible: true });
+ expect(await screen.findByLabelText('settings.tina.prefs.providerX')).toBeTruthy();
+ expect(screen.getByText('bots.remoteSettings.finishOnHost')).toBeTruthy();
+ expect(api.get).toHaveBeenCalledOnce();
+});
+
+it('shows a usable account from a computer that does not say whether it lists it, and nothing otherwise', async () => {
+ render_({ available: true });
+ expect(await screen.findByLabelText('settings.tina.prefs.providerX')).toBeTruthy();
+ cleanup();
+ const api = render_({ available: false });
+ await waitFor(() => expect(api.get).toHaveBeenCalled());
+ await waitFor(() => expect(screen.queryByLabelText('settings.tina.prefs.providerX')).toBeNull());
+});
diff --git a/apps/desktop/src/renderer/features/bots/botSettingsTarget.ts b/apps/desktop/src/renderer/features/bots/botSettingsTarget.ts
index 288f034543..e637f27b82 100644
--- a/apps/desktop/src/renderer/features/bots/botSettingsTarget.ts
+++ b/apps/desktop/src/renderer/features/bots/botSettingsTarget.ts
@@ -69,7 +69,7 @@ export interface BotSettingsTarget {
wechat: WechatApi | null;
/** The official X account of the teammate's computer (remote only). */
x: {
- get(): Promise<{ available: boolean; enabled: boolean; connected: boolean; companionBotId: string | null }>;
+ get(): Promise<{ available: boolean; /** Absent on older computers. */ visible?: boolean; enabled: boolean; connected: boolean; companionBotId: string | null }>;
setCompanion(assign: boolean, expectedBotId: string | null): Promise<{ companionBotId: string | null }>;
} | null;
};
diff --git a/docs/product-rules/cindy-bots-runtime.md b/docs/product-rules/cindy-bots-runtime.md
index 9975c59161..a21679b956 100644
--- a/docs/product-rules/cindy-bots-runtime.md
+++ b/docs/product-rules/cindy-bots-runtime.md
@@ -1165,7 +1165,7 @@ Desktop 的 Bot Market 随安装包提供预制原生包入口,复用同一 im
- 本机伙伴的「消息平台」复用设置页已有的官方 `@askmycindy` 连接,可将当前账号在该电脑上的 X 提问交给一位伙伴;绑定与 X OAuth 授权、启停相互独立。取消伙伴绑定保留 X 账号授权,后续回到普通 X 任务。
- 每条服务端 X 路由建立伙伴 `role=channel` 专线,使用同一身份、能力、记忆、工作目录与模型配置,不接续伙伴私聊的模型历史。公开回帖风险在绑定确认和卡片中明确展示。
- 伙伴选择按账号保存;更换使用当前绑定做比较,避免迟到确认覆盖新选择。停用、删除或已交出主力电脑的伙伴不可接收新 X 提问;解除绑定后已排队的旧专线请求拒绝执行,不转给另一位伙伴。
-- 复用官方 X 的认证、收发与媒体回帖,不接入 X Manager 搜索/发帖插件,不新增 X 私信机器人或个人 API 凭证入口。消息平台设置(2026-10-22 起)在桌面远程控制时同样可管理,由伙伴所在电脑执行,凭证不离开那台电脑;官方 X 的绑定 / 解绑可从远程设置完成,X 登录授权仍在那台电脑上进行。Mobile 沿用现有入口边界。
+- 复用官方 X 的认证、收发与媒体回帖,不接入 X Manager 搜索/发帖插件,不新增 X 私信机器人或个人 API 凭证入口。消息平台设置(2026-10-22 起)在桌面远程控制时同样可管理,由伙伴所在电脑执行,凭证不离开那台电脑;官方 X 的绑定 / 解绑可从远程设置完成,X 登录授权仍在那台电脑上进行。远程页的 X 区块与那台电脑自己的设置同一条件显示(配置了服务地址、正在协商、可用或已开启任一成立,由 `channels.x.get` 的 `visible` 带回;还不可用时只写「到那台电脑上完成」),旧电脑没有 `visible` 时仍只在可用后显示。Mobile 沿用现有入口边界。
### 请求原话与 Agent 补充(2026-10-20)