Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(bots): 在主界面查看消息平台隐藏任务详情
xuzini-xznc5c532e8dab5
diff --git a/apps/desktop/scripts/fixtures/wechat-companion/ui-page.mjs b/apps/desktop/scripts/fixtures/wechat-companion/ui-page.mjsindex a9e68eb67a..b322c2fd21 100644--- a/apps/desktop/scripts/fixtures/wechat-companion/ui-page.mjs+++ b/apps/desktop/scripts/fixtures/wechat-companion/ui-page.mjs@@ -3,14 +3,20 @@ export default {entry: './wechat-companion-fixture.tsx',viewport: { width: 620, height: 900 },real: 'BotChannelsPage, WechatBotSection, useWechatBot, existing connection accordion and translations',- notCovered: 'Real account login, Tencent scan authorization, persisted binding and message delivery',+ notCovered: 'Real account login, Tencent scan authorization, persisted binding, message delivery, full-app history navigation and live agent execution',cases: {default: { about: 'New WeChat connection for a teammate', data: {} },existing: { about: 'Reuse the already authorized personal WeChat connection', data: { bound: true } },assigned: { about: 'Connected teammate and remove-link action', data: { bound: true, companionBotId: 'fixture-cindy' } },other: { about: 'Another teammate owns this connection', data: { bound: true, companionBotId: 'fixture-other' } },+ 'feishu-hidden-tasks': { about: 'Clickable hidden IM records and independent restart action', data: { hiddenIm: true } },+ 'feishu-hidden-tasks-narrow': { about: 'Hidden IM records in a narrow window', data: { hiddenIm: true }, viewport: { width: 360, height: 900 } },},- async check(page) {- await page.locator('#companion-im-wechat-trigger').click();+ async check(page, ui) {+ if (ui.data.hiddenIm) {+ await page.locator('button').filter({ hasText: '8c9b5c' }).focus();+ } else {+ await page.locator('#companion-im-wechat-trigger').click();+ }},};diff --git a/apps/desktop/scripts/fixtures/wechat-companion/wechat-companion-fixture.tsx b/apps/desktop/scripts/fixtures/wechat-companion/wechat-companion-fixture.tsxindex 12fbc82906..ab8f2a09c0 100644--- a/apps/desktop/scripts/fixtures/wechat-companion/wechat-companion-fixture.tsx+++ b/apps/desktop/scripts/fixtures/wechat-companion/wechat-companion-fixture.tsx@@ -3,9 +3,21 @@ import type { BotProfile } from '../../../src/renderer/features/bots/botStore';import { mountPage, subscription, forbid } from '../../ui-page/harness';mountPage({+ route: '/bots/fixture-cindy?settings=1&settingsPage=channels',host: (ctx) => ({botImConnection: {- list: async () => ({ connections: [] }),+ list: async () => ({ connections: ctx.data.hiddenIm ? [{+ id: 'fixture-feishu', botId: 'fixture-cindy', channel: 'feishu', createdAt: 1,+ botContextId: 'cli_aa53dc2c', status: { kind: 'connected', appId: 'cli_aa53dc2c' },+ identity: { ownerUserId: 'owner' },+ }] : [] }),+ listLanes: async () => ({ connectionId: 'fixture-feishu', lanes: [+ { sessionId: 'fixture-main', kind: 'owner-dm', name: null, chatId: null, threadId: null,+ state: 'idle', lastActivityAt: Date.now() - 3600000, contextMessageCount: 0 },+ { sessionId: 'fixture-topic', kind: 'topic', name: '拉拉, 徐紫旎, 姚刘浏', chatId: 'group', threadId: '8c9b5c',+ state: 'running', lastActivityAt: Date.now() - 300000, contextMessageCount: 11 },+ ] }),+ resetLane: forbid('botImConnection.resetLane'),onChanged: subscription('connections'),},maker: {diff --git a/apps/desktop/src/renderer/features/bots/BotChannelsPage.tsx b/apps/desktop/src/renderer/features/bots/BotChannelsPage.tsxindex b94301b685..d43eb1367b 100644--- a/apps/desktop/src/renderer/features/bots/BotChannelsPage.tsx+++ b/apps/desktop/src/renderer/features/bots/BotChannelsPage.tsx@@ -11,7 +11,8 @@import { HookConnectionsSection } from '@/components/settings/HookConnectionsSection';import { useCallback, useEffect, useRef, useState, type FormEvent } from 'react';import * as Dialog from '@radix-ui/react-dialog';-import { Briefcase, Gamepad2, MessageSquare, Plus, Send, Zap, type LucideIcon } from 'lucide-react';+import { Briefcase, ChevronRight, Gamepad2, MessageSquare, Plus, Send, Zap, type LucideIcon } from 'lucide-react';+import { useNavigate } from 'react-router-dom';import { AttentionDot } from '@/components/sidebar/AttentionDot';import { Button } from '@/components/ui/button';@@ -214,7 +215,7 @@ export function BotChannelsPage({ bot }: { bot: BotProfile }) {<ConnectionGroups connectionId={view.id} botName={bot.name} />) : null}{view.botContextId && botImConnectionLanesSupported() ? (- <ConnectionLanes connectionId={view.id} botName={bot.name} />+ <ConnectionLanes connectionId={view.id} botId={bot.id} botName={bot.name} />) : null}</li>);@@ -355,10 +356,11 @@ const LANE_KIND_KEY: Record<BotImConnectionLane['kind'], string> = {/*** 一条连接的「隐藏任务」小节: 主人私聊(伙伴主任务)、每个群 / 话题与其他人的私聊各一行,* 显示状态、最近活动和当前上下文里的消息数; 卡住时可以让某一条重新开始(同一条任务,- * 记录保留, 下一条消息换干净的上下文)。隐藏任务没有自己的任务页, 所以这里不提供打开。+ * 记录保留, 下一条消息换干净的上下文)。点击记录复用主界面的只读历史页, 不取消隐藏。*/-function ConnectionLanes({ connectionId, botName }: { connectionId: string; botName: string }) {+function ConnectionLanes({ connectionId, botId, botName }: { connectionId: string; botId: string; botName: string }) {const { t } = useBotTranslation();+ const navigate = useNavigate();const { confirm } = useConfirmDialog();const [lanes, setLanes] = useState<BotImConnectionLane[] | null>(null);const [loadFailed, setLoadFailed] = useState(false);@@ -468,19 +470,26 @@ function ConnectionLanes({ connectionId, botName }: { connectionId: string; botN].filter((part): part is string => !!part);return (<div key={lane.sessionId} className="flex items-center gap-3">- <div className="min-w-0 flex-1">- <div className="flex min-w-0 items-center gap-1.5">- <span className="min-w-0 truncate text-12 text-[var(--text-primary)]" title={name}>- {name}+ <button+ type="button"+ onClick={() => navigate(`/bots/${encodeURIComponent(botId)}/history/${encodeURIComponent(lane.sessionId)}`)}+ className="flex min-h-9 min-w-0 flex-1 items-center gap-2 rounded-lg px-2 py-1 text-left outline-none hover:bg-[var(--surface-hover)] focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"+ >+ <span className="min-w-0 flex-1">+ <span className="flex min-w-0 items-center gap-1.5">+ <span className="min-w-0 truncate text-12 text-[var(--text-primary)]" title={name}>+ {name}+ </span>+ {lane.state === 'running' ? (+ <Spinner size={12} aria-hidden className="shrink-0 text-[var(--text-tertiary)]" />+ ) : lane.state === 'failed' ? (+ <AttentionDot tone="error" />+ ) : null}</span>- {lane.state === 'running' ? (- <Spinner size={12} aria-hidden className="shrink-0 text-[var(--text-tertiary)]" />- ) : lane.state === 'failed' ? (- <AttentionDot tone="error" />- ) : null}- </div>- <div className="text-11 leading-[1.5] text-[var(--text-tertiary)]">{meta.join(' · ')}</div>- </div>+ <span className="block text-11 leading-[1.5] text-[var(--text-tertiary)]">{meta.join(' · ')}</span>+ </span>+ <ChevronRight size={14} aria-hidden className="shrink-0 text-[var(--text-tertiary)]" />+ </button><Buttontype="button"variant="secondary"diff --git a/apps/desktop/src/renderer/features/bots/BotHistorySessionView.tsx b/apps/desktop/src/renderer/features/bots/BotHistorySessionView.tsxindex 2791485496..aeb24d0b18 100644--- a/apps/desktop/src/renderer/features/bots/BotHistorySessionView.tsx+++ b/apps/desktop/src/renderer/features/bots/BotHistorySessionView.tsx@@ -21,7 +21,7 @@ function readBotChatIdentity(bot: unknown, botId: string): BotChatIdentity | nul};}-/** Historical Bot transcripts are reviewable but never writable from the history route. */+/** History and hidden IM transcripts share the main-window read-only task view. */export function BotHistorySessionView() {const { botId, sessionId, deviceId } = useParams();return <BotHistorySessionGateView key={JSON.stringify([deviceId, botId, sessionId])} />;@@ -60,7 +60,8 @@ function BotHistorySessionGateView() {const personalLink = (bot: unknown) => {const rows = (bot as { sessions?: Array<{ id: string; role?: string; status?: string }> } | null)?.sessions;return rows?.some(row => row.id === sessionId && row.status !== 'deleted'- && (row.role === 'history' || row.role === 'canonical')) ?? false;+ && (row.role === 'history' || row.role === 'canonical'+ || (!deviceId && row.role === 'channel'))) ?? false;};const history = deviceId? profile.then(bot => personalLink(bot) ? [{ id: sessionId }] : [])diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botChannelsPage.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/botChannelsPage.test.tsxindex c47421d037..959d3b2363 100644--- a/apps/desktop/src/renderer/features/bots/__tests__/botChannelsPage.test.tsx+++ b/apps/desktop/src/renderer/features/bots/__tests__/botChannelsPage.test.tsx@@ -11,8 +11,11 @@ import type { BotProfile } from '../botStore';const mocks = vi.hoisted(() => ({confirm: vi.fn(async () => true),+ navigate: vi.fn(),}));+vi.mock('react-router-dom', () => ({ useNavigate: () => mocks.navigate }));+vi.mock('react-i18next', () => ({useTranslation: () => ({t: (key: string, opts?: Record<string, unknown>) =>@@ -85,6 +88,7 @@ let lanesApi: {} = {};beforeEach(() => {+ mocks.navigate.mockClear();mocks.confirm.mockReset();mocks.confirm.mockResolvedValue(true);groupsApi = {};@@ -93,6 +97,28 @@ beforeEach(() => {afterEach(cleanup);describe('BotChannelsPage', () => {+ // 测试价值: 真实列表点击应打开主界面只读详情, 旧覆盖只有重启; 最小输入为一条渠道记录。+ // unit: 校验路由与副作用, 不需真实飞书连接。+ it('opens each IM record in the existing history page without restarting it', async () => {+ const lanes = ['owner-dm', 'group', 'topic', 'guest-dm'].map((kind) => ({+ sessionId: `s/${kind}`, kind, chatId: '-1001', threadId: 'thread-1', name: kind,+ state: 'idle', lastActivityAt: null, contextMessageCount: 0,+ }));+ lanesApi = {+ listLanes: vi.fn(async () => ({ connectionId: 'a1b2c3d4e5f6', lanes })),+ resetLane: vi.fn(),+ };+ installApi({ connections: [connection({ channel: 'feishu', botId: 'bot/1' })] });+ render(<BotChannelsPage bot={{ ...mia, id: 'bot/1' }} />);+ for (const lane of lanes) {+ const name = lane.kind === 'owner-dm' ? 'bots.channels.lanes.ownerName' : lane.name;+ fireEvent.click(await screen.findByRole('button', { name: new RegExp(`^${name}`) }));+ expect(mocks.navigate).toHaveBeenLastCalledWith(`/bots/bot%2F1/history/${encodeURIComponent(lane.sessionId)}`);+ }+ expect(lanesApi.resetLane).not.toHaveBeenCalled();+ expect(mocks.confirm).not.toHaveBeenCalled();+ });+it('lets the owner switch a known group to always-on per connection, and hides the section without groups', async () => {let activation: 'mention' | 'always' = 'mention';const groups = () => ({@@ -147,6 +173,7 @@ describe('BotChannelsPage', () => {);expect(await screen.findByRole('status')).toBeTruthy();expect(lanesApi.resetLane).toHaveBeenCalledTimes(1);+ expect(mocks.navigate).not.toHaveBeenCalled();});it('does not start a hidden task over when the owner cancels', async () => {diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botIslandVisibility.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/botIslandVisibility.test.tsxindex 24c833547d..f042310b9b 100644--- a/apps/desktop/src/renderer/features/bots/__tests__/botIslandVisibility.test.tsx+++ b/apps/desktop/src/renderer/features/bots/__tests__/botIslandVisibility.test.tsx@@ -20,7 +20,7 @@ vi.mock('@/hooks/useAgentIslandSettings', () => ({// The private-chat topic host belongs to the chat surface these tests isolate.vi.mock('../BotDmThreadHost', () => ({ BotDmThreadHost: ({ children }: { children: import('react').ReactNode }) => <>{children}</> }));vi.mock('@/features/cc-agent/CCAgentSessionView', () => ({- CCAgentSessionView: () => <div data-testid="chat" />,+ CCAgentSessionView: ({ readOnly }: { readOnly?: boolean }) => <div data-testid="chat" data-readonly={String(!!readOnly)} />,}));vi.mock('../botReadState', () => ({ getBotLastReadAt: () => null, markBotRead: vi.fn() }));@@ -162,6 +162,30 @@ describe('history ownership gate disposes the clicked island card', () => {mocks.location = { state: { islandEntryId: '42' } };});+ // 测试价值: 渠道专线不在 history() 中, 旧门禁无法显示; 最小输入是 get() 的 channel 投影。+ // unit: 复用真实历史页验证只读挂载和归属失败时不处置提醒, 补齐既有历史用例的角色缺口。+ it.each(['active', 'archived'])('shows an owned %s IM lane in the same read-only view', async (status) => {+ history.mockResolvedValue([]);+ get.mockResolvedValue({ ...profile, sessions: [{ id: 'old-a', kind: 'channel', role: 'channel', status }] });+ const view = render(<BotHistorySessionView />);+ await waitFor(() => expect(view.getByTestId('chat').dataset.readonly).toBe('true'));+ expect(consumeEntryAlert).toHaveBeenCalledExactlyOnceWith('old-a', '42');+ });++ it.each([+ { id: 'other', role: 'channel', status: 'active' },+ { id: 'old-a', role: 'channel', status: 'deleted' },+ { id: 'old-a', role: 'group', status: 'active' },+ { id: 'old-a', role: 'delegation', status: 'active' },+ ])('does not grant IM transcript access from an unrelated/deleted projection: %j', async (projection) => {+ history.mockResolvedValue([]);+ get.mockResolvedValue({ ...profile, sessions: [projection] });+ const view = render(<BotHistorySessionView />);+ await act(async () => {});+ expect(view.queryByTestId('chat')).toBeNull();+ expect(consumeEntryAlert).not.toHaveBeenCalled();+ });+it('disposes only once its gate has shown the transcript', async () => {let resolveGate!: (rows: unknown[]) => void;history.mockReturnValueOnce(new Promise((resolve) => { resolveGate = resolve; }));diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botSessionOwners.test.ts b/apps/desktop/src/renderer/features/bots/__tests__/botSessionOwners.test.tsindex 56bfc5ea80..db15b0a741 100644--- a/apps/desktop/src/renderer/features/bots/__tests__/botSessionOwners.test.ts+++ b/apps/desktop/src/renderer/features/bots/__tests__/botSessionOwners.test.ts@@ -57,6 +57,17 @@ function profile(over: Partial<BotProfile> = {}): BotProfile {}describe('伙伴归属表', () => {+ // 测试价值: 灵动岛/通知统一入口遇到 IM channel 原先落入不可用的可写页。+ // 最小失败输入: 只有一条 channel 投影; unit, 直接验证生产路由结果。+ it('opens hidden IM tasks through the read-only history gate', () => {+ const bot = profile({ sessions: [+ { id: 's/feishu', role: 'channel', kind: 'channel', status: 'active' },+ ] as BotProfile['sessions'] });+ expect(botRouteForOwnedSession([bot], 's/feishu')).toEqual({+ route: '/bots/bot-a/history/s%2Ffeishu', consumesAlert: false, gateConsumesAlert: true,+ });+ });+it('主对话、渠道任务、归档历史三种都收', () => {const owners = buildBotSessionOwners([profile()]);expect([...owners.keys()].sort()).toEqual(['s-main', 's-old', 's-telegram']);diff --git a/apps/desktop/src/renderer/features/bots/botSessionOwners.ts b/apps/desktop/src/renderer/features/bots/botSessionOwners.tsindex 11d0b93264..7bc6100bca 100644--- a/apps/desktop/src/renderer/features/bots/botSessionOwners.ts+++ b/apps/desktop/src/renderer/features/bots/botSessionOwners.ts@@ -82,7 +82,8 @@ export function botRouteForOwnedSession(consumesAlert: false,};}- if (projection?.kind === 'history' || projection?.role === 'history') {+ if (projection?.kind === 'history' || projection?.role === 'history'+ || projection?.kind === 'channel' || projection?.role === 'channel') {// Its ownership gate re-checks after the route commits and may redirect away, so the// gate itself disposes the card once it shows the transcript.return { route: `${botRoute}/history/${encodeURIComponent(sessionId)}`, consumesAlert: false, gateConsumesAlert: true };diff --git a/docs/product-rules/cindy-bots-runtime.md b/docs/product-rules/cindy-bots-runtime.mdindex 7f68b057ef..902caa324f 100644--- a/docs/product-rules/cindy-bots-runtime.md+++ b/docs/product-rules/cindy-bots-runtime.md@@ -149,6 +149,10 @@ Discord 传输层只放行主人,钉钉群里被 @ 时成员也能触发(成「消息平台」页每条连接下有「隐藏任务」小节:列出这条连接名下的主人私聊(伙伴主任务)与各群 / 话题 / 外部用户私聊专线,每条可「重新开始」——复用伙伴已有的 `restartBotCanonicalRuntime` 交接(同一条任务、记录与记忆不删,下一条消息换干净的原生会话),不另写换会话逻辑,见 `im/shared/botImLaneRuntime.ts`。+点击小节里的记录或灵动岛上的渠道任务,在主界面复用归档历史的只读详情页+(`/bots/:id/history/:sid`),不另开窗口,不恢复或归档任务,也不让渠道专线进入左侧普通任务列表。+打开前按伙伴的持久归属投影校验;仍在运行的专线继续显示消息更新。「重新开始」与打开详情是独立操作,+继续沿用同一条任务保留完整记录。本机 Hermes / OpenClaw 导入(见文末同名一节)把来源的消息机器人(Telegram / Discord / 飞书,Hermes 另有企业微信 / 钉钉)列成单独一行「消息机器人」、默认勾选;导入时先用来源自己的命令把它在原 Agent 里停掉并确认停下,再用同一个`addBotImConnection` 建成这位伙伴的连接,连不上就把原开关还原。主人不明、停不下或连不上时导入照常完成,该项标「需处理」,