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(teammates): 近况待办加「帮我查查」与「每天帮我查一次」

zqchris8ff7e94ea4b8
diff --git a/apps/desktop/scripts/fixtures/teammate-glance/glance-fixture.tsx b/apps/desktop/scripts/fixtures/teammate-glance/glance-fixture.tsx
index 2fc4501e93..f13203c4e7 100644
--- a/apps/desktop/scripts/fixtures/teammate-glance/glance-fixture.tsx
+++ b/apps/desktop/scripts/fixtures/teammate-glance/glance-fixture.tsx
@@ -38,7 +38,15 @@ function items(caseName: string): TeammateTodo[] {
mountPage({
route: '/bots/cindy-default',
host: (ctx) => ({
- localDb: { bots: { todos: { list: async () => ({ items: items(ctx.case), version: 1 }), update: forbid('todos.update') } } },
+ localDb: { bots: { todos: {
+ list: async () => ({ items: items(ctx.case), version: 1 }),
+ update: forbid('todos.update'),
+ // 「每天帮我查一次」:默认关;打开浮层时只读不写。
+ dailyCheck: async (_botId: string, enabled?: boolean) => {
+ if (enabled !== undefined) throw new Error('dailyCheck write is not expected in this page');
+ return false;
+ },
+ } } },
maker: { onBotWorkbenchChanged: subscription('todos') },
deviceLink: { invoke: forbid('deviceLink.invoke'), onRemotePush: subscription('remote') },
openPath: forbid('openPath'),
diff --git a/apps/desktop/scripts/fixtures/teammate-glance/ui-page.mjs b/apps/desktop/scripts/fixtures/teammate-glance/ui-page.mjs
index 7d65779bac..715afee0e8 100644
--- a/apps/desktop/scripts/fixtures/teammate-glance/ui-page.mjs
+++ b/apps/desktop/scripts/fixtures/teammate-glance/ui-page.mjs
@@ -10,7 +10,7 @@ export default {
viewport: { width: 1040, height: 760 },
real: 'BotSessionContentHeader, BotGlancePopover (computers, todos, outputs, due dots, context menu), Radix popover/menu, theme and translations',
notCovered:
- 'Live todo/delegation data, cloud companion home switching, remote teammates over device-link, sending the quoted todo, opening files',
+ 'Live todo/delegation data, cloud companion home switching, remote teammates over device-link, sending the quoted todo or 帮我查查, toggling the daily check, opening files',
stubs: {
'src/renderer/features/bots/botStore': {
partial: `export const useBotProfiles=()=>${data}.case==='new'?[]:[{id:'cindy-default',name:'Cindy',templateId:'cindy',status:'active',sessionId:'chat-1'}];export const useBotUnreadCounts=()=>({});`,
@@ -30,7 +30,7 @@ export default {
cases: {
default: { about: 'Cindy on several computers, todos with one due today, finished deliverables' },
menu: { about: 'Right-clicking a todo offers only Delete' },
- new: { about: 'A new teammate: only the Computers block, no empty todos or outputs' },
+ new: { about: 'A new teammate: Computers, and the todo block with only 帮我查查 and the daily switch; no outputs' },
},
async ready(page) {
await page.getByTestId('bot-glance-button').waitFor();
@@ -47,13 +47,16 @@ export default {
const popover = page.getByTestId('bot-glance-popover');
await popover.waitFor();
if (ui.case === 'new') {
- assert.equal(await page.getByTestId('bot-glance-todo').count(), 0, 'no todos block');
+ assert.equal(await page.getByTestId('bot-glance-todo').count(), 0, 'no todo rows');
+ assert.equal(await page.getByTestId('bot-glance-check').count(), 1, '帮我查查 even without todos');
+ assert.equal(await page.getByTestId('bot-glance-daily-check').count(), 1, 'daily switch');
assert.equal(await page.getByTestId('bot-glance-output').count(), 0, 'no outputs block');
assert.equal(await page.getByTestId('bot-glance-computer').count(), 1, 'only this computer');
await ui.capture('open');
return;
}
assert.equal(await page.getByTestId('bot-glance-todo').count(), 5, 'five todos before Show more');
+ assert.equal(await page.getByTestId('bot-glance-check').count(), 1, '帮我查查 first in the todo block');
assert.equal(await page.getByTestId('bot-glance-output').count(), 3, 'three outputs before Show more');
assert.equal(await page.getByTestId('bot-glance-computer').count(), 2, 'offline computers folded');
const box = await popover.boundingBox();
diff --git a/apps/desktop/src/main/bot-autonomy/todoCheckRoutine.ts b/apps/desktop/src/main/bot-autonomy/todoCheckRoutine.ts
new file mode 100644
index 0000000000..0b7feeffc9
--- /dev/null
+++ b/apps/desktop/src/main/bot-autonomy/todoCheckRoutine.ts
@@ -0,0 +1,44 @@
+/**
+ * 内置「每天查待办」例行任务(cindy-bots-runtime.md §6.3.4「伙伴近况」):主人在近况里打开
+ * 「每天帮我查一次」时才建,工作日 9:00 让伙伴在已授权的来源里找需要主人以后处理的新事项。
+ *
+ * - 每个伙伴最多一条,id 固定为 builtinTodoCheckRoutineId(botId);关掉只是暂停,再打开恢复同一条。
+ * - 指令是例行任务那一轮的用户侧指令,不是 system 段;改措辞要递增 TODO_CHECK_PROMPT_VERSION,
+ * 下次打开时宿主按新模板重写。
+ * - silentWhenIdle:没查到新待办不打扰主人。
+ * - 与内置「跟进」一样不参与云端同步,只在当前运行的电脑上存在。
+ */
+import { createHash } from 'node:crypto';
+import type { RoutineInput } from '@cindy/maker-scheduler';
+import { BUILTIN_TODO_CHECK_ROUTINE_PREFIX } from '../../shared/botAutonomy.js';
+
+/** 与例行任务引擎的 creationId 校验一致。 */
+const ROUTINE_ID_PATTERN = /^[a-zA-Z0-9_-]{16,128}$/;
+
+export function builtinTodoCheckRoutineId(botId: string): string {
+ const plain = `${BUILTIN_TODO_CHECK_ROUTINE_PREFIX}${botId}`;
+ if (ROUTINE_ID_PATTERN.test(plain)) return plain;
+ return `${BUILTIN_TODO_CHECK_ROUTINE_PREFIX}${createHash('sha256').update(botId).digest('hex').slice(0, 40)}`;
+}
+
+export const TODO_CHECK_PROMPT_VERSION = 1;
+
+/** 内置规则的保存名;渲染层按 builtin 字段本地化显示,这里只是落盘值。 */
+export const TODO_CHECK_ROUTINE_NAME = '每天查待办';
+
+/** 工作日 9:00,按这台电脑的时区。 */
+export const TODO_CHECK_CRON = '0 9 * * 1-5';
+
+export function buildTodoCheckRoutinePrompt(): string {
+ return '看看我已连接的邮箱、飞书等来源里,上次检查之后有没有需要我以后处理的新事项,有就按待办规则记下来。只用已经授权的来源,没连接的不要说查过;没有新待办就不用提醒我。';
+}
+
+export function buildTodoCheckRoutineInput(timezone: string): RoutineInput {
+ return {
+ name: TODO_CHECK_ROUTINE_NAME,
+ prompt: buildTodoCheckRoutinePrompt(),
+ enabled: true,
+ silentWhenIdle: true,
+ triggers: [{ id: 'weekday-morning', kind: 'cron', expression: TODO_CHECK_CRON, timezone }],
+ };
+}
diff --git a/apps/desktop/src/main/localDb/ipc/botRemoteResourceProvider.ts b/apps/desktop/src/main/localDb/ipc/botRemoteResourceProvider.ts
index f1dc0751e7..b866b0b849 100644
--- a/apps/desktop/src/main/localDb/ipc/botRemoteResourceProvider.ts
+++ b/apps/desktop/src/main/localDb/ipc/botRemoteResourceProvider.ts
@@ -20,6 +20,8 @@ import {
listBotRemoteResourceSources,
} from './bots.js';
import { RemoteResourceRegistryError, remoteResourceRegistry } from '../../device-link/remoteResourceRegistry.js';
+import { routineTools } from '../../routines/service.js';
+import { broadcastBotRemoteResourceChanged } from '../../maker-ipc/botRemoteResourceInvalidation.js';
import { getBotRemoteMessageService } from '../../maker-ipc/botRemoteMessageReceiver.js';
import {
BOT_REMOTE_RESOURCE_KIND,
@@ -101,8 +103,12 @@ export function registerBotRemoteResourceProvider(management?: typeof botRemoteM
if (!isDataOwnerBroadcastScopeCurrent(scope)) throw new RemoteResourceRegistryError('NOT_FOUND', 'Account changed');
const page = queryTodoItems(all.items, request.query ? JSON.parse(request.query) as TodoListQuery : {});
page.items = page.items.map(botTodoRemoteProjection);
+ // 近况「每天帮我查一次」的当前状态;旧客户端忽略,新客户端缺这个字段(旧宿主)时不显示开关。
+ // 例行任务读不到(引擎未就绪、伙伴暂停)时不带这个字段,待办照常返回。
+ const dailyCheck = await routineTools.todoCheckEnabled(botId).catch(() => undefined);
+ if (!isDataOwnerBroadcastScopeCurrent(scope)) throw new RemoteResourceRegistryError('NOT_FOUND', 'Account changed');
return {ref:request.ref,revision:createHash('sha256').update(JSON.stringify(all.items)).digest('hex'),display:{title:source.name},links:[],
- blocks:[{id:'todos',primitive:'teammate-todos',fallbackMarkdown:page.items.map(t=>t.title+' — '+t.progress).join('\n').slice(0,8000),data:page}]};
+ blocks:[{id:'todos',primitive:'teammate-todos',fallbackMarkdown:page.items.map(t=>t.title+' — '+t.progress).join('\n').slice(0,8000),data:{...page,...(dailyCheck === undefined ? {} : {dailyCheck})}}]};
}
if (management && (request.ref.id === 'create' || request.ref.id.startsWith('settings:'))) {
@@ -162,6 +168,19 @@ export function registerBotRemoteResourceProvider(management?: typeof botRemoteM
if (!isDataOwnerBroadcastScopeCurrent(scope)) throw new RemoteResourceRegistryError('NOT_FOUND', 'Account changed');
return {effects:[],todo:result ? botTodoRemoteProjection(result) : null};
}
+ if (request.actionId === 'todo-daily-check') {
+ const scope = captureDataOwnerBroadcastScope();
+ if (!request.resourceRef?.id.startsWith('todos:')) throw new RemoteResourceRegistryError('NOT_FOUND', 'Todo resource required');
+ const botId = request.resourceRef.id.slice(6);
+ const candidate = await getBotRemoteResourceSource(botId);
+ const [source] = candidate ? visibleBotRemoteResourceSources([candidate]) : [];
+ if (!source || !isDataOwnerBroadcastScopeCurrent(scope)) throw new RemoteResourceRegistryError('NOT_FOUND', 'Teammate unavailable');
+ if (typeof request.input?.enabled !== 'boolean') throw new RemoteResourceRegistryError('INVALID_PARAMS', 'enabled must be boolean');
+ const dailyCheck = await routineTools.setTodoCheck(botId, request.input.enabled);
+ if (!isDataOwnerBroadcastScopeCurrent(scope)) throw new RemoteResourceRegistryError('NOT_FOUND', 'Account changed');
+ broadcastBotRemoteResourceChanged(botId);
+ return { effects: [], dailyCheck };
+ }
if (management && request.actionId === 'open-agent-import' && request.resourceRef?.id === 'create') return {
effects: [{ kind: 'navigate', target: { kind: 'resource', ref: { collectionId: 'companion-import', kind: 'import', id: 'sources' } } }],
diff --git a/apps/desktop/src/main/localDb/ipc/bots.ts b/apps/desktop/src/main/localDb/ipc/bots.ts
index 97489d65ca..c56f96b1c9 100644
--- a/apps/desktop/src/main/localDb/ipc/bots.ts
+++ b/apps/desktop/src/main/localDb/ipc/bots.ts
@@ -114,6 +114,7 @@ import { getResolvedMainLocale } from '../../i18n.js';
import { SUPPORTED_LOCALES, type SupportedLocale } from '../../../shared/locale.js';
import { normalizeBotWelcomeContext, type BotWelcomeContext } from '../../../shared/botWelcomeContext';
import { broadcastBotRemoteResourceChanged } from '../../maker-ipc/botRemoteResourceInvalidation.js';
+import { routineTools } from '../../routines/service.js';
import { createBotMemoryService } from '../../maker-ipc/botMemoryService.js';
const log = createLogger('bots');
@@ -2586,6 +2587,17 @@ export function registerBotIpc(): void {
owner.assertCurrent();return result;
});
}
+ // 近况「每天帮我查一次」:不传 enabled 只读,传了就开 / 关内置「每天查待办」。返回当前是否开着。
+ ipcMain.handle('local-db:bots:todos:daily-check', async (event, rawBotId: unknown, rawEnabled: unknown) => {
+ assertTrustedAppRendererEvent(event);
+ const botId = readText(rawBotId, 'botId', 128, true);
+ if (rawEnabled !== undefined && typeof rawEnabled !== 'boolean') throw new Error('Invalid enabled');
+ const owner = captureBotOperationOwner();
+ const result = rawEnabled === undefined ? await routineTools.todoCheckEnabled(botId) : await routineTools.setTodoCheck(botId, rawEnabled);
+ owner.assertCurrent();
+ if (rawEnabled !== undefined) broadcastBotRemoteResourceChanged(botId);
+ return result;
+ });
// Exact per-task responsibility IDs from the current owner, without message bodies.
ipcMain.handle('local-db:bots:workbench:follow-scopes', async (event) => {
assertTrustedAppRendererEvent(event);
diff --git a/apps/desktop/src/main/routines/__tests__/service.test.ts b/apps/desktop/src/main/routines/__tests__/service.test.ts
index 7a9b5ce527..ad207d05fe 100644
--- a/apps/desktop/src/main/routines/__tests__/service.test.ts
+++ b/apps/desktop/src/main/routines/__tests__/service.test.ts
@@ -108,6 +108,19 @@ it('dispatches into the current canonical task through the existing silent runne
expect((await routineTools.history('bot', routine.id))[0].resultText).toBe('Reviewed PR');
});
+it('turns the teammate\'s weekday todo check on and off as one built-in routine', async () => {
+ // 近况里的「每天帮我查一次」:打开建内置例行任务,关掉只暂停,再打开复用同一条,不重复建。
+ expect(await routineTools.todoCheckEnabled('bot')).toBe(false);
+ expect(await routineTools.setTodoCheck('bot', true)).toBe(true);
+ const [routine] = await routineTools.list('bot');
+ expect(routine).toMatchObject({ builtin: 'todo-check', enabled: true, silentWhenIdle: true,
+ triggers: [{ kind: 'cron', expression: '0 9 * * 1-5' }] });
+ expect(await routineTools.setTodoCheck('bot', false)).toBe(false);
+ expect(await routineTools.todoCheckEnabled('bot')).toBe(false);
+ expect(await routineTools.setTodoCheck('bot', true)).toBe(true);
+ expect((await routineTools.list('bot')).map(row => [row.id, row.enabled])).toEqual([[routine.id, true]]);
+});
+
it('skips a demoted teammate\'s routine while its home is another computer, keeping the rule', async () => {
companionHomes.update({ enabled: true, selfDeviceId: 'desk', humanActorId: 'human', demotedBotIds: ['bot'],
actors: [{ id: 'actor', externalId: 'bot', name: 'Bot', avatar: null, homeDeviceId: 'laptop' }] });
diff --git a/apps/desktop/src/main/routines/service.ts b/apps/desktop/src/main/routines/service.ts
index 100e8c83bd..9e33763800 100644
--- a/apps/desktop/src/main/routines/service.ts
+++ b/apps/desktop/src/main/routines/service.ts
@@ -29,7 +29,8 @@ import { getCurrentDbClientSnapshot } from '../localDb/client/current.js';
import { botProfiles } from '../localDb/schema.js';
import { isCompanionShadowed } from '../companion-cloud/homes.js';
import { currentFollowUpEvents } from '../bot-autonomy/hub.js';
-import { BUILTIN_FOLLOW_UP_ROUTINE_PREFIX } from '../../shared/botAutonomy.js';
+import { BUILTIN_FOLLOW_UP_ROUTINE_PREFIX, BUILTIN_TODO_CHECK_ROUTINE_PREFIX } from '../../shared/botAutonomy.js';
+import { TODO_CHECK_PROMPT_VERSION, buildTodoCheckRoutineInput, builtinTodoCheckRoutineId } from '../bot-autonomy/todoCheckRoutine.js';
/** Bootstrap supplies live getters without a service -> scheduler -> IPC dependency cycle. */
export interface RoutineHostDeps {
@@ -520,6 +521,27 @@ export const routineTools = {
return engine.history(id);
}),
sources: async () => (await getRoutineEngine()).listSources(),
+ /** 近况里「每天帮我查一次」:内置「每天查待办」是否存在且开着。 */
+ todoCheckEnabled: (botId: string) => withBot(botId, (engine) =>
+ engine.list(botId).some((routine) => routine.id === builtinTodoCheckRoutineId(botId) && routine.enabled)),
+ /**
+ * 打开时按模板落地(首次创建,或模板版本变化时重写)并恢复;关掉只暂停,保留同一条。
+ * 内置规则只能经 ensureBuiltin 写内容,这里的 put 只切换 enabled。
+ */
+ setTodoCheck: (botId: string, enabled: boolean) => withBot(botId, async (engine, scope) => {
+ const id = builtinTodoCheckRoutineId(botId);
+ let routine = engine.list(botId).find((row) => row.id === id) ?? null;
+ if (enabled) {
+ const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC';
+ routine = await engine.ensureBuiltin(botId, 'todo-check', buildTodoCheckRoutineInput(timezone), id, TODO_CHECK_PROMPT_VERSION);
+ assertScope(scope);
+ if (!routine) throw new Error('The teammate is paused');
+ }
+ if (!routine || routine.enabled === enabled) return enabled && !!routine;
+ const { name, prompt, triggers, silentWhenIdle, preRunHook } = routine;
+ const saved = await engine.put(botId, { name, prompt, triggers, silentWhenIdle, preRunHook, enabled }, id, routine.revision);
+ return saved.enabled;
+ }),
};
/** A stopped/crashed plugin must not continue to appear as a listening source. */
@@ -576,7 +598,8 @@ export async function importCompanionRoutines(botId: string, routines: Companion
const builtinIds = new Set(listed.filter((routine) => routine.builtin).map((routine) => routine.id));
const now = Date.now();
for (const routine of routines) {
- if (builtinIds.has(routine.id) || routine.id.startsWith(BUILTIN_FOLLOW_UP_ROUTINE_PREFIX)) continue;
+ if (builtinIds.has(routine.id) || routine.id.startsWith(BUILTIN_FOLLOW_UP_ROUTINE_PREFIX)
+ || routine.id.startsWith(BUILTIN_TODO_CHECK_ROUTINE_PREFIX)) continue;
const foreignHook = !!routine.input.preRunHook?.command?.trim() && routine.originDeviceId !== selfDeviceId;
const passed = routine.input.triggers.some((trigger) => trigger.kind === 'once' && trigger.at <= now);
const input: RoutineInput = { ...routine.input, enabled: routine.input.enabled && !foreignHook && !passed };
diff --git a/apps/desktop/src/preload/preload.ts b/apps/desktop/src/preload/preload.ts
index 33ecd72e7f..47086dff1f 100644
--- a/apps/desktop/src/preload/preload.ts
+++ b/apps/desktop/src/preload/preload.ts
@@ -5757,6 +5757,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
list: (botId: string) => ipcRenderer.invoke('local-db:bots:todos:list', botId),
update: (botId: string, patch: import('@cindy/maker-shared/teammate-todo').TodoPatch) => ipcRenderer.invoke('local-db:bots:todos:update', botId, patch),
act: (botId: string, input: {id:string;revision:number;requestId:string;locale?:string}) => ipcRenderer.invoke('local-db:bots:todos:act', botId, input),
+ dailyCheck: (botId: string, enabled?: boolean) => ipcRenderer.invoke('local-db:bots:todos:daily-check', botId, enabled),
},
projects: {
list: (botId: string): Promise<import('../shared/botWorkbench').BotProjectOption[]> =>
diff --git a/apps/desktop/src/renderer/features/bots/BotGlancePopover.tsx b/apps/desktop/src/renderer/features/bots/BotGlancePopover.tsx
index 01b4aefd10..72cc7bb48a 100644
--- a/apps/desktop/src/renderer/features/bots/BotGlancePopover.tsx
+++ b/apps/desktop/src/renderer/features/bots/BotGlancePopover.tsx
@@ -2,12 +2,13 @@
* 伙伴「近况」浮层(伙伴聊天头部的网格按钮)。只有三块,没有内容的块整块不出现:
* - 电脑:伙伴在哪台上运行,点另一台在线的电脑就换过去;离线的收进「离线 N 台」。
* 云端伙伴换主力电脑沿用原来的确认流程;Cindy 的多台副本直接打开那台上的她。
- * - 待办:主人要做的事。没有按钮:点一条就作为引用放进输入框,由主人一句话交代;右键只能删除(可撤销)。
- * 到期的那条在期限前带红点,入口在主人还没看过时也亮同样的红点。
+ * - 待办:主人要做的事。第一行「帮我查查」让伙伴现在去已连接的来源里找新待办(作为主人的一句话发进对话),
+ * 下面一行开关让伙伴每个工作日早上自己查一次。待办本身没有按钮:点一条就作为引用放进输入框,
+ * 由主人一句话交代;右键只能删除(可撤销)。到期的那条在期限前带红点,入口在主人还没看过时也亮同样的红点。
* - 输出内容:伙伴开的任务做完时留下的成品文件,点开即打开;别的电脑上的打开来源任务。
*/
import { useEffect, useMemo, useRef, useState, type KeyboardEvent, type MouseEvent, type ReactNode } from 'react';
-import { Check, ChevronDown, LayoutGrid, Monitor } from 'lucide-react';
+import { Check, ChevronDown, LayoutGrid, Monitor, ScanSearch } from 'lucide-react';
import { createPortal } from 'react-dom';
import { useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
@@ -23,6 +24,11 @@ import {
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
+import { Switch } from '@/components/ui/switch';
+import { getDataOwnerGeneration, isDataOwnerGenerationCurrent } from '@/contexts/dataOwnerGeneration';
+import type { Session } from '@/lib/ccAgent.types';
+import { makerChatStore } from '@/lib/makerChatStore';
+import * as sessionService from '@/lib/sessionService';
import { remoteProjectsStore } from '@/features/device-link/remoteProjectsStore';
import { useDeviceLinkDeviceList } from '@/features/device-link/useDeviceLinkDeviceList';
import { insertTodoReferenceIntoComposer } from '@/lib/composerActionsBus';
@@ -40,7 +46,15 @@ import { useBotProfiles, useBotUnreadCounts } from './botStore';
import { cloudRemoteBots, withoutCloudCompanions, withoutShadowedBots } from './companionCloudPresentation';
import { useCompanionCloud } from './companionCloudStore';
import { cindyDeviceKey, cindyDeviceOptions, isCindyDeviceBot } from './cindyDeviceRoster';
-import { dueTodos, hasUnseenDue, markDueSeen, patchGlanceTodo, useGlanceTodos, type GlanceTodoHost } from './botGlanceTodos';
+import {
+ dueTodos,
+ hasUnseenDue,
+ markDueSeen,
+ patchGlanceTodo,
+ setGlanceDailyCheck,
+ useGlanceTodos,
+ type GlanceTodoHost,
+} from './botGlanceTodos';
import { useRemoteBots } from './useRemoteBots';
/** 每块先列几条,其余收进「显示更多」。 */
@@ -354,6 +368,50 @@ function TodoRow({
);
}
+/**
+ * 「帮我查查」:以主人的一句话发进伙伴对话,和主人自己打字发送走同一条路径(远程伙伴同样带来源设备标记)。
+ * 用的是伙伴对话当前的模型、思考档位与权限。
+ */
+async function sendToTeammate(sessionId: string, deviceId: string | undefined, text: string): Promise<boolean> {
+ const owner = getDataOwnerGeneration();
+ const row = deviceId
+ ? (remoteProjectsStore.getDeviceSessions(deviceId).find((session) => session.id === sessionId) ??
+ ((await window.electronAPI.deviceLink.invoke(deviceId, 'local-db:sessions:get', [sessionId])) as Session | null))
+ : await sessionService.get(sessionId);
+ if (!isDataOwnerGenerationCurrent(owner) || !row?.workingDir) return false;
+ return makerChatStore.sendMessage(sessionId, text, row.model, row.effort, row.permissionMode, row.workingDir);
+}
+
+function DailyCheckSwitch({ host, todos }: { host: GlanceTodoHost; todos: ReturnType<typeof useGlanceTodos> }) {
+ const { t } = useTranslation();
+ const [busy, setBusy] = useState(false);
+ const checked = todos.todos.dailyCheck;
+ if (checked === null) return null;
+ const change = async (next: boolean) => {
+ setBusy(true);
+ try {
+ todos.setDailyCheck(await setGlanceDailyCheck(host, next));
+ } catch {
+ toast.error(t('bots.glance.dailyCheckFailed'));
+ } finally {
+ setBusy(false);
+ }
+ };
+ return (
+ <label
+ data-testid="bot-glance-daily-check"
+ className="flex min-h-11 w-full cursor-pointer items-center gap-3 rounded-lg px-2 py-1.5 hover:bg-[var(--surface-hover)]"
+ >
+ <span className="w-5 shrink-0" aria-hidden />
+ <span className="min-w-0 flex-1">
+ <span className="block truncate text-13 text-[var(--text-primary)]">{t('bots.glance.dailyCheck')}</span>
+ <span className="block truncate text-12 text-[var(--text-tertiary)]">{t('bots.glance.dailyCheckMeta')}</span>
+ </span>
+ <Switch checked={checked} disabled={busy} onCheckedChange={(next) => void change(next)} />
+ </label>
+ );
+}
+
function Todos({
host,
sessionId,
@@ -371,7 +429,15 @@ function Todos({
const [menu, setMenu] = useState<{ todo: TeammateTodo; x: number; y: number } | null>(null);
const menuOrigin = useRef<HTMLButtonElement | null>(null);
const { open, done, doneTotal, openTotal } = todos.todos;
- if (open.length === 0 && doneTotal === 0) return null;
+
+ const check = () => {
+ onClose();
+ void sendToTeammate(sessionId, host.deviceId, t('bots.glance.checkPrompt'))
+ .then((sent) => {
+ if (!sent) toast.error(t('bots.glance.checkFailed'));
+ })
+ .catch(() => toast.error(t('bots.glance.checkFailed')));
+ };
const quote = (todo: TeammateTodo) => {
onClose();
@@ -412,6 +478,14 @@ function Todos({
const hiddenCount = Math.max(0, openTotal - TODO_PREVIEW);
return (
<Section label={t('bots.glance.todos')}>
+ <Row
+ testId="bot-glance-check"
+ icon={<ScanSearch size={16} />}
+ title={t('bots.glance.check')}
+ meta={t('bots.glance.checkMeta')}
+ onClick={check}
+ />
+ <DailyCheckSwitch host={host} todos={todos} />
{visible.map((todo) => (
<TodoRow
key={todo.id}
diff --git a/apps/desktop/src/renderer/features/bots/BotRoutines.tsx b/apps/desktop/src/renderer/features/bots/BotRoutines.tsx
index 0847c849e6..baf9fdea3c 100644
--- a/apps/desktop/src/renderer/features/bots/BotRoutines.tsx
+++ b/apps/desktop/src/renderer/features/bots/BotRoutines.tsx
@@ -266,8 +266,8 @@ export function BotRoutines({
{!loading && !error && !routines.length && (
<p className="text-[var(--text-secondary)]">{t('routines.empty')}</p>
)}
- {routines.map((routine) => routine.builtin === 'follow-up' ? (
- <BuiltinFollowUpRow
+ {routines.map((routine) => routine.builtin ? (
+ <BuiltinRoutineRow
key={routine.id}
routine={routine}
disabled={busy}
@@ -861,7 +861,10 @@ function routineInput(routine: Routine): RoutineInput {
/**
* 宿主内置的「跟进」:指令与触发条件由宿主维护,这里不进编辑器、不能删,只能暂停或恢复。
*/
-function BuiltinFollowUpRow({
+/** 内置例行任务(跟进、每天查待办)的文案键;名称与说明随界面语言,不用宿主存的名字。 */
+const BUILTIN_COPY = { 'follow-up': 'routines.builtinFollowUp', 'todo-check': 'routines.builtinTodoCheck' } as const;
+
+function BuiltinRoutineRow({
routine,
disabled,
onEnabledChange,
@@ -871,7 +874,8 @@ function BuiltinFollowUpRow({
onEnabledChange: (enabled: boolean) => void;
}) {
const { t } = useTranslation();
- const name = t('routines.builtinFollowUp.name');
+ const copy = BUILTIN_COPY[routine.builtin ?? 'follow-up'];
+ const name = t(`${copy}.name`);
return (
<div className="flex min-h-12 w-full items-start gap-3 rounded-lg px-3 py-3">
{routine.activity ? (
@@ -884,7 +888,7 @@ function BuiltinFollowUpRow({
<span className="min-w-0 flex-1">
<span className="block truncate">{name}</span>
{/* 触发条件由宿主维护、条数多且来源重复,这里只写一句白话,不逐条列出。 */}
- <span className="block text-12 text-[var(--text-secondary)]">{t('routines.builtinFollowUp.hint')}</span>
+ <span className="block text-12 text-[var(--text-secondary)]">{t(`${copy}.hint`)}</span>
</span>
<Switch
aria-label={name}
diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botGlancePopover.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/botGlancePopover.test.tsx
index 121be9f1ce..f5dcc7df4b 100644
--- a/apps/desktop/src/renderer/features/bots/__tests__/botGlancePopover.test.tsx
+++ b/apps/desktop/src/renderer/features/bots/__tests__/botGlancePopover.test.tsx
@@ -7,6 +7,7 @@
* - Bug/规则依据:docs/product-rules/cindy-bots-runtime.md「伙伴近况」;近况取代右侧栏工作台后,待办不再有
* 行内按钮(点一条只交给对话),切电脑并进这里。
* - 现有覆盖缺口:这是新入口;头部测试只验证按钮存在,不覆盖浮层内的行为。
+ * - 「帮我查查」与「每天帮我查一次」:没有待办时也在;前者以主人的一句话走普通发送,后者经宿主开关内置例行任务。
* - 最小失败输入:一条今天到期的待办 + 一份带成品文件的委派 + Cindy 在另一台在线、一台离线的电脑上。
* - tier:unit(jsdom 渲染真实组件,宿主 API 用内存 fake)。
* - 实测耗时:见 PR(pnpm --dir apps/desktop exec vitest run 本文件)。
@@ -24,6 +25,7 @@ const h = vi.hoisted(() => ({
local: [] as Array<Record<string, unknown>>,
remote: [] as Array<Record<string, unknown>>,
delegations: [] as Array<Record<string, unknown>>,
+ send: vi.fn(async () => true),
}));
vi.mock('react-i18next', () => ({
@@ -37,6 +39,10 @@ vi.mock('react-router-dom', () => ({ useNavigate: () => h.navigate }));
vi.mock('@/lib/composerActionsBus', () => ({ insertTodoReferenceIntoComposer: h.insert }));
vi.mock('@/lib/toast', () => ({ toast: { info: h.toastInfo, error: h.toastError } }));
vi.mock('@/lib/orcaSessionIdentity', () => ({ resolveSessionRoute: async (id: string) => `/cc-agent/${id}` }));
+vi.mock('@/lib/makerChatStore', () => ({ makerChatStore: { sendMessage: h.send } }));
+vi.mock('@/lib/sessionService', () => ({
+ get: async (id: string) => ({ id, model: 'm', effort: 'high', permissionMode: 'auto', workingDir: '/w' }),
+}));
vi.mock('../BotAvatar', () => ({ BotAvatar: () => <span data-testid="bot-avatar" /> }));
vi.mock('../botStore', () => ({ useBotProfiles: () => h.local, useBotUnreadCounts: () => ({}) }));
vi.mock('../useRemoteBots', () => ({ useRemoteBots: () => h.remote }));
@@ -78,15 +84,18 @@ let items: TeammateTodo[] = [];
const list = vi.fn(async () => ({ items, version: 1 as const }));
const update = vi.fn(async (_botId: string, patch: { id: string }) => ({ ...todo(patch.id), revision: 4 }));
const openPath = vi.fn(async () => ({ ok: true }));
+let dailyOn = false;
+const dailyCheck = vi.fn(async (_botId: string, enabled?: boolean) => (dailyOn = enabled ?? dailyOn));
beforeEach(() => {
items = [];
+ dailyOn = false;
h.local = [];
h.remote = [];
h.delegations = [];
window.localStorage.clear();
(window as unknown as { electronAPI: unknown }).electronAPI = {
- localDb: { bots: { todos: { list, update } } },
+ localDb: { bots: { todos: { list, update, dailyCheck } } },
maker: { onBotWorkbenchChanged: () => () => undefined },
deviceLink: { invoke: vi.fn(), onRemotePush: () => () => undefined },
openPath,
@@ -131,6 +140,20 @@ describe('BotGlanceButton', () => {
expect(update).toHaveBeenLastCalledWith('bot-1', { id: 't1', expectedRevision: 4, operation: 'restore' });
});
+ it('asks the teammate to check for todos as the owner, and switches the weekday check on', async () => {
+ await openGlance();
+ // No todos yet: the section still offers 「帮我查查」 and the daily switch.
+ fireEvent.click(await screen.findByTestId('bot-glance-check'));
+ await waitFor(() => expect(h.send).toHaveBeenCalledWith('s1', 'bots.glance.checkPrompt', 'm', 'high', 'auto', '/w'));
+
+ fireEvent.click(screen.getByTestId('bot-glance-button'));
+ const toggle = (await screen.findByTestId('bot-glance-daily-check')).querySelector('[role="switch"]')!;
+ expect(toggle.getAttribute('aria-checked')).toBe('false');
+ fireEvent.click(toggle);
+ await waitFor(() => expect(toggle.getAttribute('aria-checked')).toBe('true'));
+ expect(dailyCheck).toHaveBeenLastCalledWith('bot-1', true);
+ });
+
it('lights the entry dot for a due todo until 近况 is opened, and marks the row itself', async () => {
items = [todo('due', { sourceDeadline: { kind: 'date', date: today, timeZone: 'UTC' } }), todo('later')];
render(<BotGlanceButton bot={bot} cloudHome={false} />);
diff --git a/apps/desktop/src/renderer/features/bots/botGlanceTodos.ts b/apps/desktop/src/renderer/features/bots/botGlanceTodos.ts
index f578ebd01d..9071193fdb 100644
--- a/apps/desktop/src/renderer/features/bots/botGlanceTodos.ts
+++ b/apps/desktop/src/renderer/features/bots/botGlanceTodos.ts
@@ -43,14 +43,17 @@ export interface GlanceTodos {
doneTotal: number;
/** 最早一条「稍后再说」到期的时刻;到时重读,让它回到列表。 */
nextDeferredAt: string | null;
+ /** 「每天帮我查一次」是否开着;那台电脑的宿主还不支持时为 null,开关不出现。 */
+ dailyCheck: boolean | null;
}
-const EMPTY: GlanceTodos = { open: [], openTotal: 0, done: [], doneTotal: 0, nextDeferredAt: null };
+const EMPTY: GlanceTodos = { open: [], openTotal: 0, done: [], doneTotal: 0, nextDeferredAt: null, dailyCheck: null };
interface TodoPage {
items: TeammateTodo[];
total: number;
nextDeferredAt?: string | null;
+ dailyCheck?: boolean;
}
function todosRef(botId: string) {
@@ -66,10 +69,15 @@ async function readRemotePage(deviceId: string, botId: string, query: TodoListQu
const resource = await window.electronAPI.deviceLink.invoke(deviceId, REMOTE_RESOURCE_GET_CHANNEL, [request]);
const blocks = (resource as { blocks?: Array<{ primitive?: string; data?: unknown }> } | null)?.blocks;
const page = blocks?.find((block) => block.primitive === 'teammate-todos')?.data as
- | { items?: TeammateTodo[]; total?: number; nextDeferredAt?: string | null }
+ | { items?: TeammateTodo[]; total?: number; nextDeferredAt?: string | null; dailyCheck?: unknown }
| undefined;
if (!page || !Array.isArray(page.items)) throw new Error('invalid todo page');
- return { items: page.items, total: page.total ?? page.items.length, nextDeferredAt: page.nextDeferredAt ?? null };
+ return {
+ items: page.items,
+ total: page.total ?? page.items.length,
+ nextDeferredAt: page.nextDeferredAt ?? null,
+ ...(typeof page.dailyCheck === 'boolean' ? { dailyCheck: page.dailyCheck } : {}),
+ };
}
/** 一类待办按页读完(宿主单页上限 25);页数在开头读到的总数内收敛,总数中途变化时以最新一页为准。 */
@@ -87,11 +95,12 @@ async function readAll(
if (page.items.length === 0) break;
items.push(...page.items);
}
- return { items: items.slice(0, MAX_ITEMS), total, nextDeferredAt: first.nextDeferredAt ?? null };
+ return { items: items.slice(0, MAX_ITEMS), total, nextDeferredAt: first.nextDeferredAt ?? null, dailyCheck: first.dailyCheck };
}
async function readTodos(host: GlanceTodoHost): Promise<GlanceTodos> {
let readPage: (query: TodoListQuery) => Promise<TodoPage>;
+ let dailyCheck: Promise<boolean | null> | null = null;
if (host.deviceId) {
const deviceId = host.deviceId;
readPage = (query) => readRemotePage(deviceId, host.botId, query);
@@ -99,17 +108,35 @@ async function readTodos(host: GlanceTodoHost): Promise<GlanceTodos> {
const { items } = await window.electronAPI.localDb.bots.todos.list(host.botId);
const now = new Date();
readPage = async (query) => queryTodoItems(items, query, now);
+ // 读不到开关(伙伴暂停等)时只是不显示开关,待办照常。
+ dailyCheck = (async () => window.electronAPI.localDb.bots.todos.dailyCheck(host.botId))().catch(() => null);
}
- const [open, done] = await Promise.all([readAll(readPage, 'open'), readAll(readPage, 'done')]);
+ const [open, done, localDailyCheck] = await Promise.all([readAll(readPage, 'open'), readAll(readPage, 'done'), dailyCheck]);
return {
open: open.items,
openTotal: open.total,
done: [...done.items].reverse(),
doneTotal: done.total,
nextDeferredAt: open.nextDeferredAt ?? null,
+ dailyCheck: host.deviceId ? (open.dailyCheck ?? null) : (localDailyCheck ?? null),
};
}
+/** 打开或关掉伙伴的「每天帮我查一次」(宿主上的内置例行任务);返回宿主确认后的状态。 */
+export async function setGlanceDailyCheck(host: GlanceTodoHost, enabled: boolean): Promise<boolean> {
+ if (!host.deviceId) return window.electronAPI.localDb.bots.todos.dailyCheck(host.botId, enabled);
+ const result = await window.electronAPI.deviceLink.invoke(host.deviceId, REMOTE_RESOURCE_INVOKE_CHANNEL, [{
+ client: { protocolVersion: 1, primitives: ['teammate-todos'] },
+ collectionId: 'teammates',
+ actionId: 'todo-daily-check',
+ resourceRef: todosRef(host.botId),
+ input: { enabled },
+ }]);
+ const value = (result as { dailyCheck?: unknown } | null)?.dailyCheck;
+ if (typeof value !== 'boolean') throw new Error('invalid daily check result');
+ return value;
+}
+
/** 本机或那台电脑上的一次待办更新;撤销删除走同一条路径的 `restore`。 */
export async function patchGlanceTodo(host: GlanceTodoHost, patch: TodoPatch): Promise<TeammateTodo | null> {
if (!host.deviceId) return window.electronAPI.localDb.bots.todos.update(host.botId, patch);
@@ -193,7 +220,12 @@ export function useGlanceTodos(host: GlanceTodoHost, enabled = true) {
return scheduleTodoDeferralRefresh(next, () => void refresh());
}, [botId, enabled, nextDeferredAt, refresh, state.loaded, state.todos]);
- return { ...state, refresh };
+ /** 宿主确认后的开关状态先写进当前列表,不等下一次读取。 */
+ const setDailyCheck = useCallback((dailyCheck: boolean) => {
+ setState((previous) => ({ ...previous, todos: { ...previous.todos, dailyCheck } }));
+ }, []);
+
+ return { ...state, refresh, setDailyCheck };
}
const SEEN_PREFIX = 'cindy:bots:glance-due-seen:';
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 4baaecb609..a810f20109 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -9021,6 +9021,13 @@
"undo": "Undo",
"undoFailed": "Couldn't undo. Try again.",
"deleteFailed": "Couldn't delete. Try again.",
+ "check": "Check for me",
+ "checkMeta": "Look for new todos in connected mail and chats",
+ "checkPrompt": "Check my connected sources, like mail and messages, for anything new I need to handle, and add it to my todos.",
+ "checkFailed": "Couldn't send. Try again.",
+ "dailyCheck": "Check every day",
+ "dailyCheckMeta": "Weekdays at 9:00, quiet when nothing is new",
+ "dailyCheckFailed": "Couldn't save. Try again.",
"outputs": "Outputs",
"outputMeta": "{{time}} · {{task}}",
"openFailed": "Couldn't open the file",
@@ -16050,6 +16057,10 @@
"builtinFollowUp": {
"name": "Follow-up (built-in)",
"hint": "Wakes it when a session is stuck, waiting for you, errors out, hits the usage limit, or finishes. Built in, so it can only be paused or resumed."
+ },
+ "builtinTodoCheck": {
+ "name": "Daily todo check (built-in)",
+ "hint": "Looks for new todos in connected sources on weekdays at 9:00 and stays quiet when there is nothing new. Turned on or off from the glance; it can only be paused or resumed."
}
},
"cindyMakeDoctor": {
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index d2b628e654..8842d8e5e1 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -8987,6 +8987,13 @@
"undo": "元に戻す",
"undoFailed": "元に戻せませんでした。もう一度お試しください",
"deleteFailed": "削除できませんでした。もう一度お試しください",
+ "check": "確認して",
+ "checkMeta": "接続済みのメールやメッセージから新しい Todo を探します",
+ "checkPrompt": "接続済みのメールやメッセージなどに、私が対応すべき新しい用件がないか確認して、あれば Todo に追加して。",
+ "checkFailed": "送信できませんでした。もう一度お試しください",
+ "dailyCheck": "毎日確認する",
+ "dailyCheckMeta": "平日 9:00、新しい Todo がなければ通知しません",
+ "dailyCheckFailed": "保存できませんでした。もう一度お試しください",
"outputs": "成果物",
"outputMeta": "{{time}} · {{task}}",
"openFailed": "ファイルを開けませんでした",
@@ -16000,6 +16007,10 @@
"builtinFollowUp": {
"name": "フォロー(組み込み)",
"hint": "セッションが止まったとき、返信待ちになったとき、エラーになったとき、使用量の上限に達したとき、完了したときに起こします。組み込みのため、一時停止と再開のみできます。"
+ },
+ "builtinTodoCheck": {
+ "name": "毎日の Todo 確認(組み込み)",
+ "hint": "平日 9:00 に接続済みのソースから新しい Todo を探し、なければ通知しません。近況からオン・オフでき、一時停止と再開のみできます。"
}
},
"cindyMakeDoctor": {
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 83a4de6ce4..09388a265c 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -8987,6 +8987,13 @@
"undo": "실행 취소",
"undoFailed": "실행 취소하지 못했습니다. 다시 시도하세요",
"deleteFailed": "삭제하지 못했습니다. 다시 시도하세요",
+ "check": "확인해 줘",
+ "checkMeta": "연결된 메일과 메시지에서 새 할 일을 찾습니다",
+ "checkPrompt": "연결된 메일, 메시지 등에서 내가 처리해야 할 새 일이 있는지 확인하고, 있으면 할 일에 추가해 줘.",
+ "checkFailed": "보내지 못했습니다. 다시 시도하세요",
+ "dailyCheck": "매일 확인",
+ "dailyCheckMeta": "평일 9:00, 새 할 일이 없으면 알리지 않습니다",
+ "dailyCheckFailed": "저장하지 못했습니다. 다시 시도하세요",
"outputs": "결과물",
"outputMeta": "{{time}} · {{task}}",
"openFailed": "파일을 열지 못했습니다",
@@ -16000,6 +16007,10 @@
"builtinFollowUp": {
"name": "후속 관리(기본 제공)",
"hint": "세션이 멈추거나, 응답을 기다리거나, 오류가 나거나, 사용량 한도에 도달하거나, 끝나면 깨웁니다. 기본 제공 루틴이라 일시 중지와 재개만 할 수 있습니다."
+ },
+ "builtinTodoCheck": {
+ "name": "매일 할 일 확인(기본 제공)",
+ "hint": "평일 9:00에 연결된 소스에서 새 할 일을 찾고, 없으면 알리지 않습니다. 근황에서 켜고 끌 수 있으며 일시 중지와 재개만 할 수 있습니다."
}
},
"cindyMakeDoctor": {
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 db661b3f6a..9ec9f4980a 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -8987,6 +8987,13 @@
"undo": "撤销",
"undoFailed": "没能撤销,请重试",
"deleteFailed": "没能删除,请重试",
+ "check": "帮我查查",
+ "checkMeta": "在已连接的邮件和消息里找新待办",
+ "checkPrompt": "帮我查查已连接的邮箱、消息等来源里,有没有需要我处理的新事项,有就记成待办。",
+ "checkFailed": "没能发送,请重试",
+ "dailyCheck": "每天帮我查一次",
+ "dailyCheckMeta": "工作日 9:00,没有新待办不打扰",
+ "dailyCheckFailed": "没能保存,请重试",
"outputs": "输出内容",
"outputMeta": "{{time}} · {{task}}",
"openFailed": "没能打开文件",
@@ -16000,6 +16007,10 @@
"builtinFollowUp": {
"name": "跟进(内置)",
"hint": "任务卡住、等你、出错、撞上用量上限或做完时叫醒它;内置,只能暂停或恢复。"
+ },
+ "builtinTodoCheck": {
+ "name": "每天查待办(内置)",
+ "hint": "工作日 9:00 在已连接的来源里找新待办,没有就不打扰;在近况里开关,只能暂停或恢复。"
}
},
"cindyMakeDoctor": {
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 9a98461f2e..f23e55be6c 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -8987,6 +8987,13 @@
"undo": "復原",
"undoFailed": "無法復原,請重試",
"deleteFailed": "無法刪除,請重試",
+ "check": "幫我查查",
+ "checkMeta": "在已連接的郵件和訊息裡找新待辦",
+ "checkPrompt": "幫我查查已連接的信箱、訊息等來源裡,有沒有需要我處理的新事項,有就記成待辦。",
+ "checkFailed": "沒能傳送,請重試",
+ "dailyCheck": "每天幫我查一次",
+ "dailyCheckMeta": "工作日 9:00,沒有新待辦不打擾",
+ "dailyCheckFailed": "沒能儲存,請重試",
"outputs": "輸出內容",
"outputMeta": "{{time}} · {{task}}",
"openFailed": "無法開啟檔案",
@@ -16000,6 +16007,10 @@
"builtinFollowUp": {
"name": "跟進(內建)",
"hint": "任務卡住、等你、出錯、撞上用量上限或做完時叫醒它;內建,只能暫停或恢復。"
+ },
+ "builtinTodoCheck": {
+ "name": "每天查待辦(內建)",
+ "hint": "工作日 9:00 在已連接的來源裡找新待辦,沒有就不打擾;在近況裡開關,只能暫停或恢復。"
}
},
"cindyMakeDoctor": {
diff --git a/apps/desktop/src/renderer/vite-env.d.ts b/apps/desktop/src/renderer/vite-env.d.ts
index eb8af15892..2e9a55b7e6 100644
--- a/apps/desktop/src/renderer/vite-env.d.ts
+++ b/apps/desktop/src/renderer/vite-env.d.ts
@@ -4972,6 +4972,8 @@ interface ElectronAPI {
list: (botId:string) => Promise<{items:import('@cindy/maker-shared/teammate-todo').TeammateTodo[];version:1}>;
update: (botId:string, patch:import('@cindy/maker-shared/teammate-todo').TodoPatch) => Promise<import('@cindy/maker-shared/teammate-todo').TeammateTodo>;
act: (botId:string, input:{id:string;revision:number;requestId:string;locale?:string}) => Promise<import('@cindy/maker-shared/teammate-todo').TeammateTodo | null>;
+ /** 近况「每天帮我查一次」:不传 enabled 只读;返回当前是否开着。 */
+ dailyCheck: (botId:string, enabled?:boolean) => Promise<boolean>;
};
projects: {
list: (botId: string) => Promise<import('../shared/botWorkbench').BotProjectOption[]>;
diff --git a/apps/desktop/src/shared/botAutonomy.ts b/apps/desktop/src/shared/botAutonomy.ts
index 85ad8d1c79..88efcb6237 100644
--- a/apps/desktop/src/shared/botAutonomy.ts
+++ b/apps/desktop/src/shared/botAutonomy.ts
@@ -18,6 +18,9 @@ export const HOST_SESSIONS_SOURCE_ID = 'host:sessions';
/** 内置跟进例行任务的 id 前缀;完整 id 由主进程 builtinRoutine.ts 的 builtinFollowUpRoutineId 生成,幂等。 */
export const BUILTIN_FOLLOW_UP_ROUTINE_PREFIX = 'builtin-follow-up-';
+/** 内置「每天查待办」例行任务的 id 前缀;主人在近况里打开时才建,完整 id 见 todoCheckRoutine.ts。 */
+export const BUILTIN_TODO_CHECK_ROUTINE_PREFIX = 'builtin-todo-check-';
+
/** 出厂 Cindy 助理的稳定 id;仅用于邀请入口,不意味着已开启自动跟进。 */
export const DEFAULT_SCHEDULER_BOT_ID = 'cindy-default';
diff --git a/apps/mobile/app/sessions/[sessionId].tsx b/apps/mobile/app/sessions/[sessionId].tsx
index 42ebec6451..78e672fb83 100644
--- a/apps/mobile/app/sessions/[sessionId].tsx
+++ b/apps/mobile/app/sessions/[sessionId].tsx
@@ -9653,6 +9653,23 @@ function SessionScreenContent() {
requestAnimationFrame(() => composerInputRef.current?.focus());
}, [applyComposerDocument, canUseComposer, companionResource]);
+ // 伙伴近况里的「帮我查查」:输入框空着就作为主人的一句话直接发出(与手动发送同一条路径,带来源设备);
+ // 已有草稿或附件时不替主人连同草稿一起发,只把这句话放进输入框。
+ const askCompanionInComposer = useCallback((text: string) => {
+ if (!canUseComposer) return;
+ const idle = !composerDocumentHasContent(composerDocumentRef.current)
+ && attachments.length === 0 && pendingUploads.length === 0 && !queueEditingRef.current;
+ if (idle && sendLatestRef.current) {
+ void sendLatestRef.current({ documentOverride: textComposerDocument(text) });
+ return;
+ }
+ const node = { type: 'text' as const, text: composerDocumentHasContent(composerDocumentRef.current) ? `\n${text}` : text };
+ const editor = composerInputRef.current;
+ if (editor) editor.insertNode(node);
+ else applyComposerDocument(appendComposerNode(composerDocumentRef.current, node));
+ requestAnimationFrame(() => composerInputRef.current?.focus());
+ }, [applyComposerDocument, attachments.length, canUseComposer, pendingUploads.length]);
+
const deleteMessage = useCallback((clientId: string) => {
if (!deviceId || messageActionBusy) return;
// 运行中能否删由被控端判定:点停止后本地运行态可能晚于被控端收敛,
@@ -9756,6 +9773,7 @@ function SessionScreenContent() {
working={!!companionWorkingLabel}
sessionId={sessionId ?? ''}
onQuoteTodo={quoteTodoInComposer}
+ onAskCompanion={askCompanionInComposer}
onSearch={() => setSearchOpen(true)}
onBack={goBackToHome} />
</> : <SessionHeaderBar
diff --git a/apps/mobile/src/__tests__/CompanionHeaderNavigation.test.tsx b/apps/mobile/src/__tests__/CompanionHeaderNavigation.test.tsx
index 74d7853ce5..1fc0727d56 100644
--- a/apps/mobile/src/__tests__/CompanionHeaderNavigation.test.tsx
+++ b/apps/mobile/src/__tests__/CompanionHeaderNavigation.test.tsx
@@ -58,7 +58,7 @@ afterEach(() => act(() => root.unmount()));
it('goes back from the chat instead of opening a drawer, opens 近况 from the avatar and the profile from settings', async () => {
const onBack = vi.fn(), onSearch = vi.fn();
- await act(async () => root.render(<CompanionHeader sessionId="s1" onQuoteTodo={() => {}} resource={resource} deviceId="pc" deviceName="PC" online onBack={onBack} onSearch={onSearch} />));
+ await act(async () => root.render(<CompanionHeader sessionId="s1" onQuoteTodo={() => {}} onAskCompanion={() => {}} resource={resource} deviceId="pc" deviceName="PC" online onBack={onBack} onSearch={onSearch} />));
await act(async () => button('companion.back').click());
expect(h.dismiss).toHaveBeenCalledOnce();
expect(onBack).toHaveBeenCalledOnce();
@@ -76,17 +76,17 @@ it('goes back from the chat instead of opening a drawer, opens 近况 from the a
});
it('shows the computer and whether it is online, and breathes while the companion works', async () => {
- await act(async () => root.render(<CompanionHeader sessionId="s1" onQuoteTodo={() => {}} resource={resource} deviceId="pc" deviceName="Office iMac" online={false} working onBack={() => {}} onSearch={() => {}} />));
+ await act(async () => root.render(<CompanionHeader sessionId="s1" onQuoteTodo={() => {}} onAskCompanion={() => {}} resource={resource} deviceId="pc" deviceName="Office iMac" online={false} working onBack={() => {}} onSearch={() => {}} />));
expect(host.textContent).toContain('devices.resources.hostOffline · Office iMac');
expect(host.querySelector('[data-testid="ring"]')).not.toBeNull();
- await act(async () => root.render(<CompanionHeader sessionId="s1" onQuoteTodo={() => {}} resource={resource} deviceId="pc" deviceName="Office iMac" online onBack={() => {}} onSearch={() => {}} />));
+ await act(async () => root.render(<CompanionHeader sessionId="s1" onQuoteTodo={() => {}} onAskCompanion={() => {}} resource={resource} deviceId="pc" deviceName="Office iMac" online onBack={() => {}} onSearch={() => {}} />));
expect(host.textContent).toContain('Office iMac');
expect(host.textContent).not.toContain('devices.resources.hostOffline');
expect(host.querySelector('[data-testid="ring"]')).toBeNull();
});
it('keeps profile controls closed until the chat entry is validated', async () => {
- await act(async () => root.render(<CompanionHeader sessionId="s1" onQuoteTodo={() => {}} resource={resource} deviceId="pc" deviceName="PC" online controlsReady={false} onBack={() => {}} onSearch={() => {}} />));
+ await act(async () => root.render(<CompanionHeader sessionId="s1" onQuoteTodo={() => {}} onAskCompanion={() => {}} resource={resource} deviceId="pc" deviceName="PC" online controlsReady={false} onBack={() => {}} onSearch={() => {}} />));
expect(button('companion.settings').disabled).toBe(true);
expect(button('companion.identity').disabled).toBe(true);
expect(h.profile.visible).toBe(false);
@@ -127,7 +127,7 @@ const moduleConstant = (name: string) => source.statements.find(n => ts.isVariab
&& n.declarationList.declarations.some(d => d.name.getText(source) === name))!.getText(source);
const compiled = ts.transpileModule(`${moduleConstant('COMPANION_NATIVE_HEADER_OPTIONS')}
function PageHost({ bindings }) {
- const { auth, deviceId, sessionId, companionResource, companionEntry, shareSelectionActive, setSearchOpen, goBackToHome, companionWorkingLabel, quoteTodoInComposer } = bindings;
+ const { auth, deviceId, sessionId, companionResource, companionEntry, shareSelectionActive, setSearchOpen, goBackToHome, companionWorkingLabel, quoteTodoInComposer, askCompanionInComposer } = bindings;
const currentSession = null;
const isSideChatSheet = false;
const companionSettingsRequest = bindings.companionSettingsRequest;
@@ -143,7 +143,7 @@ const PageHost = new Function('React', 'useState', 'useHostManagedSession', 'Com
const pageBindings = () => ({ auth: h.auth, deviceId: 'pc', sessionId: 'session-a', shareSelectionActive: false,
companionEntry: { ready: true },
companionResource: { ref: { kind: 'bot', collectionId: 'bots', id: 'bot-a' }, display: { title: 'Cindy' } } as RemoteResource | null,
- setSearchOpen: vi.fn(), goBackToHome: vi.fn(), companionWorkingLabel: null as string | null, quoteTodoInComposer: vi.fn() });
+ setSearchOpen: vi.fn(), goBackToHome: vi.fn(), companionWorkingLabel: null as string | null, quoteTodoInComposer: vi.fn(), askCompanionInComposer: vi.fn() });
const showPage = (bindings: ReturnType<typeof pageBindings>) => act(async () => { root.render(<PageHost bindings={bindings} />); });
it('wires the page: title while entry validation runs, Back to the roster, and the working breath', async () => {
@@ -175,17 +175,17 @@ it('shows the ordinary task header on non-companion pages and while sharing', as
});
it('opens learning links in the existing profile sheet on the requested page', async () => {
- await act(async () => root.render(<CompanionHeader sessionId="s1" onQuoteTodo={() => {}} resource={resource} deviceId="pc" deviceName="PC" online onBack={() => {}} onSearch={() => {}}
+ await act(async () => root.render(<CompanionHeader sessionId="s1" onQuoteTodo={() => {}} onAskCompanion={() => {}} resource={resource} deviceId="pc" deviceName="PC" online onBack={() => {}} onSearch={() => {}}
settingsRequest={{ page: 'memory', sequence: 1 }} />));
expect(h.profile).toMatchObject({ visible: true, initialPage: 'memory' });
await act(async () => h.profile.onClose());
- await act(async () => root.render(<CompanionHeader sessionId="s1" onQuoteTodo={() => {}} resource={resource} deviceId="pc" deviceName="PC" online onBack={() => {}} onSearch={() => {}}
+ await act(async () => root.render(<CompanionHeader sessionId="s1" onQuoteTodo={() => {}} onAskCompanion={() => {}} resource={resource} deviceId="pc" deviceName="PC" online onBack={() => {}} onSearch={() => {}}
settingsRequest={{ page: 'capabilities', sequence: 2 }} />));
expect(h.profile).toMatchObject({ visible: true, initialPage: 'capabilities' });
});
it('reads todos only for an advertised, online host, and clears the due dot by opening 近况', async () => {
- const props = { resource, deviceId: 'pc', deviceName: 'PC', online: true, sessionId: 's1', onQuoteTodo: vi.fn(), onBack: vi.fn(), onSearch: vi.fn() };
+ const props = { resource, deviceId: 'pc', deviceName: 'PC', online: true, sessionId: 's1', onQuoteTodo: vi.fn(), onAskCompanion: vi.fn(), onBack: vi.fn(), onSearch: vi.fn() };
await act(async () => root.render(<CompanionHeader {...props} />));
expect(h.glanceTodos).toMatchObject({ botId: 'bot', deviceId: 'pc', enabled: false });
const withTodos: RemoteResource = { ...resource, links: [{ rel: 'todos', label: 'Todo', target: { kind: 'resource', ref: { collectionId: 'teammates', kind: 'bot', id: 'todos:bot' } } }] };
@@ -199,13 +199,16 @@ it('reads todos only for an advertised, online host, and clears the due dot by o
expect(h.markSeen).toHaveBeenCalledOnce();
// Quoting a todo goes to this chat's composer.
expect(h.glance.onQuoteTodo).toBe(props.onQuoteTodo);
+ // 「帮我查查」 is the owner's own words, sent through this chat's composer.
+ await act(async () => h.glance.onCheckTodos());
+ expect(props.onAskCompanion).toHaveBeenCalledWith('devices.glance.checkPrompt');
await act(async () => h.glance.onOpenTask('child-1'));
expect(h.push).toHaveBeenCalledWith({ pathname: '/sessions/[sessionId]', params: { sessionId: 'child-1', deviceId: 'pc' } });
});
it('names the main computer of a cloud companion and lets the profile change it', async () => {
h.cloud = { supported: true, actors: [{ kind: 'bot', externalId: 'bot', homeDeviceId: 'pc' }] };
- await act(async () => root.render(<CompanionHeader sessionId="s1" onQuoteTodo={() => {}} resource={resource} deviceId="pc" deviceName="Office iMac" online onBack={() => {}} onSearch={() => {}} />));
+ await act(async () => root.render(<CompanionHeader sessionId="s1" onQuoteTodo={() => {}} onAskCompanion={() => {}} resource={resource} deviceId="pc" deviceName="Office iMac" online onBack={() => {}} onSearch={() => {}} />));
expect(host.textContent).toContain('devices.cloudCompanion.runsOn');
await act(async () => button('companion.settings').click());
await act(async () => h.profile.onOpenHome());
@@ -223,7 +226,7 @@ it('names the main computer of a cloud companion and lets the profile change it'
});
it('offers no computer change for a companion without a known main computer', async () => {
- await act(async () => root.render(<CompanionHeader sessionId="s1" onQuoteTodo={() => {}} resource={resource} deviceId="pc" deviceName="PC" online onBack={() => {}} onSearch={() => {}} />));
+ await act(async () => root.render(<CompanionHeader sessionId="s1" onQuoteTodo={() => {}} onAskCompanion={() => {}} resource={resource} deviceId="pc" deviceName="PC" online onBack={() => {}} onSearch={() => {}} />));
await act(async () => button('companion.settings').click());
expect(h.profile.onOpenHome).toBeUndefined();
});
diff --git a/apps/mobile/src/i18n/locales/en/devices.json b/apps/mobile/src/i18n/locales/en/devices.json
index b44f232903..42d7c819d8 100644
--- a/apps/mobile/src/i18n/locales/en/devices.json
+++ b/apps/mobile/src/i18n/locales/en/devices.json
@@ -855,6 +855,12 @@
"undo": "Undo",
"undoFailed": "Couldn't undo. Try again.",
"deleteFailed": "Couldn't delete. Try again.",
+ "check": "Check for me",
+ "checkMeta": "Look for new todos in connected mail and chats",
+ "checkPrompt": "Check my connected sources, like mail and messages, for anything new I need to handle, and add it to my todos.",
+ "dailyCheck": "Check every day",
+ "dailyCheckMeta": "Weekdays at 9:00, quiet when nothing is new",
+ "dailyCheckFailed": "Couldn't save. Try again.",
"loadFailed": "Couldn't load todos",
"outputs": "Outputs",
"outputMeta": "{{time}} · {{task}}",
diff --git a/apps/mobile/src/i18n/locales/ja/devices.json b/apps/mobile/src/i18n/locales/ja/devices.json
index 8ef9df669d..01f3c6dcf4 100644
--- a/apps/mobile/src/i18n/locales/ja/devices.json
+++ b/apps/mobile/src/i18n/locales/ja/devices.json
@@ -855,6 +855,12 @@
"undo": "元に戻す",
"undoFailed": "元に戻せませんでした。もう一度お試しください",
"deleteFailed": "削除できませんでした。もう一度お試しください",
+ "check": "確認して",
+ "checkMeta": "接続済みのメールやメッセージから新しい Todo を探します",
+ "checkPrompt": "接続済みのメールやメッセージなどに、私が対応すべき新しい用件がないか確認して、あれば Todo に追加して。",
+ "dailyCheck": "毎日確認する",
+ "dailyCheckMeta": "平日 9:00、新しい Todo がなければ通知しません",
+ "dailyCheckFailed": "保存できませんでした。もう一度お試しください",
"loadFailed": "Todo を読み込めませんでした",
"outputs": "成果物",
"outputMeta": "{{time}} · {{task}}",
diff --git a/apps/mobile/src/i18n/locales/ko/devices.json b/apps/mobile/src/i18n/locales/ko/devices.json
index a58ca59335..5fbadf8ba3 100644
--- a/apps/mobile/src/i18n/locales/ko/devices.json
+++ b/apps/mobile/src/i18n/locales/ko/devices.json
@@ -855,6 +855,12 @@
"undo": "실행 취소",
"undoFailed": "실행 취소하지 못했습니다. 다시 시도하세요",
"deleteFailed": "삭제하지 못했습니다. 다시 시도하세요",
+ "check": "확인해 줘",
+ "checkMeta": "연결된 메일과 메시지에서 새 할 일을 찾습니다",
+ "checkPrompt": "연결된 메일, 메시지 등에서 내가 처리해야 할 새 일이 있는지 확인하고, 있으면 할 일에 추가해 줘.",
+ "dailyCheck": "매일 확인",
+ "dailyCheckMeta": "평일 9:00, 새 할 일이 없으면 알리지 않습니다",
+ "dailyCheckFailed": "저장하지 못했습니다. 다시 시도하세요",
"loadFailed": "할 일을 불러오지 못했습니다",
"outputs": "결과물",
"outputMeta": "{{time}} · {{task}}",
diff --git a/apps/mobile/src/i18n/locales/zh-CN/devices.json b/apps/mobile/src/i18n/locales/zh-CN/devices.json
index 235a3954a6..be020401ef 100644
--- a/apps/mobile/src/i18n/locales/zh-CN/devices.json
+++ b/apps/mobile/src/i18n/locales/zh-CN/devices.json
@@ -855,6 +855,12 @@
"undo": "撤销",
"undoFailed": "没能撤销,请重试",
"deleteFailed": "没能删除,请重试",
+ "check": "帮我查查",
+ "checkMeta": "在已连接的邮件和消息里找新待办",
+ "checkPrompt": "帮我查查已连接的邮箱、消息等来源里,有没有需要我处理的新事项,有就记成待办。",
+ "dailyCheck": "每天帮我查一次",
+ "dailyCheckMeta": "工作日 9:00,没有新待办不打扰",
+ "dailyCheckFailed": "没能保存,请重试",
"loadFailed": "没能读取待办",
"outputs": "输出内容",
"outputMeta": "{{time}} · {{task}}",
diff --git a/apps/mobile/src/i18n/locales/zh-TW/devices.json b/apps/mobile/src/i18n/locales/zh-TW/devices.json
index 614fddc506..5cf08b0a60 100644
--- a/apps/mobile/src/i18n/locales/zh-TW/devices.json
+++ b/apps/mobile/src/i18n/locales/zh-TW/devices.json
@@ -855,6 +855,12 @@
"undo": "復原",
"undoFailed": "無法復原,請重試",
"deleteFailed": "無法刪除,請重試",
+ "check": "幫我查查",
+ "checkMeta": "在已連接的郵件和訊息裡找新待辦",
+ "checkPrompt": "幫我查查已連接的信箱、訊息等來源裡,有沒有需要我處理的新事項,有就記成待辦。",
+ "dailyCheck": "每天幫我查一次",
+ "dailyCheckMeta": "工作日 9:00,沒有新待辦不打擾",
+ "dailyCheckFailed": "沒能儲存,請重試",
"loadFailed": "無法讀取待辦",
"outputs": "輸出內容",
"outputMeta": "{{time}} · {{task}}",
diff --git a/apps/mobile/src/session/CompanionGlanceSheet.tsx b/apps/mobile/src/session/CompanionGlanceSheet.tsx
index 5c096b50eb..5c78613ff5 100644
--- a/apps/mobile/src/session/CompanionGlanceSheet.tsx
+++ b/apps/mobile/src/session/CompanionGlanceSheet.tsx
@@ -2,11 +2,12 @@
* 伙伴近况(手机):点伙伴聊天顶栏的头像打开,与桌面 BotGlancePopover 同三块——电脑 / 待办 / 输出内容;
* 没内容的块整块不出现。规则见 docs/product-rules/cindy-bots-runtime.md「伙伴近况」,版式按原型
* Designs/cindy/teammate-glance(手机 r1.1):系统 sheet 外壳,内容是 inset grouped 卡片。
- * 待办行没有按钮:点一条交给对话(作为待办引用放进输入框),长按系统菜单只有「删除」,可撤销。
+ * 待办块第一行「帮我查查」让伙伴现在去已连接的来源里找新待办(作为主人的一句话发进对话),下面的开关让它
+ * 每个工作日早上自己查一次。待办行没有按钮:点一条交给对话(作为待办引用放进输入框),长按系统菜单只有「删除」,可撤销。
*/
import { useMemo, useRef, useState, type ReactNode } from 'react';
-import { Pressable, ScrollView, StyleSheet, View } from 'react-native';
-import { Check, ChevronDown, ChevronUp, Monitor } from 'lucide-react-native';
+import { Pressable, ScrollView, StyleSheet, Switch, View } from 'react-native';
+import { Check, ChevronDown, ChevronUp, Monitor, ScanSearch } from 'lucide-react-native';
import { useTranslation } from 'react-i18next';
import type { BotDelegationListResult } from '@cindy/maker-shared/botDelegation';
import { todoDateLabel, todoDue, type TeammateTodo } from '@cindy/maker-shared/teammate-todo';
@@ -51,7 +52,7 @@ function dayLabel(at: number, language: string): string {
export function CompanionGlanceSheet({
visible, onClose, name, avatar, botId, deviceId, deviceName, sessionId, online, cloudHome, todos,
- onQuoteTodo, onOpenTask, onOpenCindy, onSwitchHome,
+ onQuoteTodo, onCheckTodos, onOpenTask, onOpenCindy, onSwitchHome,
}: {
visible: boolean;
onClose(): void;
@@ -67,6 +68,8 @@ export function CompanionGlanceSheet({
cloudHome: boolean;
todos: GlanceTodoState;
onQuoteTodo(todo: TeammateTodo): void;
+ /** 「帮我查查」: ask the teammate, as the owner, to look for new todos now. */
+ onCheckTodos(): void;
onOpenTask(sessionId: string): void;
onOpenCindy(hosted: HostedRemoteCollectionItem): void;
onSwitchHome(): void;
@@ -84,7 +87,7 @@ export function CompanionGlanceSheet({
</View>
<Computers botId={botId} deviceId={deviceId} deviceName={deviceName} online={online} cloudHome={cloudHome}
onOpenCindy={hosted => afterClose(() => onOpenCindy(hosted))} onSwitchHome={() => afterClose(onSwitchHome)} />
- <Todos todos={todos} online={online} onQuote={todo => afterClose(() => onQuoteTodo(todo))} />
+ <Todos todos={todos} online={online} onQuote={todo => afterClose(() => onQuoteTodo(todo))} onCheck={() => afterClose(onCheckTodos)} />
<Outputs botId={botId} deviceId={deviceId} sessionId={sessionId} online={online}
onOpenTask={taskId => afterClose(() => onOpenTask(taskId))} />
</ScrollView>
@@ -188,23 +191,42 @@ function sourceText(todo: TeammateTodo, t: (key: string) => string): string {
return label && !kind.toLowerCase().includes(label.toLowerCase()) ? `${kind} · ${label}` : kind;
}
-function Todos({ todos, online, onQuote }: { todos: GlanceTodoState; online: boolean; onQuote(todo: TeammateTodo): void }) {
+function Todos({ todos, online, onQuote, onCheck }: {
+ todos: GlanceTodoState; online: boolean; onQuote(todo: TeammateTodo): void; onCheck(): void;
+}) {
const { t, i18n } = useTranslation();
+ const { colors } = useTheme();
const styles = useThemedStyles(makeStyles);
+ const [dailyBusy, setDailyBusy] = useState(false);
const [showAll, setShowAll] = useState(false);
const [showDone, setShowDone] = useState(false);
const [deleted, setDeleted] = useState<TeammateTodo | null>(null);
const [error, setError] = useState<string | null>(null);
- const { open, done, doneTotal, openTotal } = todos.todos;
+ const { open, done, doneTotal, openTotal, dailyCheck } = todos.todos;
+ // Not offered by this desktop, or not read yet while offline: no section at all.
+ if (!todos.loaded) return null;
+ const checkRow = <Row key="check" icon={<ScanSearch size={ICON_GLYPH} strokeWidth={iconStroke.regular} color={colors.textSecondary} />}
+ title={t('devices.glance.check')} meta={t('devices.glance.checkMeta')} onPress={online ? onCheck : undefined} testID="companion.glance.todo.check" />;
+ const changeDaily = async (next: boolean) => {
+ setError(null);
+ setDailyBusy(true);
+ try { await todos.setDailyCheck(next); } catch { setError(t('devices.glance.dailyCheckFailed')); } finally { setDailyBusy(false); }
+ };
+ // Older desktops do not report the switch; then only 「帮我查查」 shows.
+ const dailyRow = dailyCheck === null ? null : <Row key="daily" icon={<View />} title={t('devices.glance.dailyCheck')} meta={t('devices.glance.dailyCheckMeta')}
+ trailing={<Switch accessibilityLabel={t('devices.glance.dailyCheck')} value={dailyCheck} disabled={!online || dailyBusy}
+ onValueChange={value => void changeDaily(value)} testID="companion.glance.todo.daily" />} />;
+ const head = [checkRow, ...(dailyRow ? [dailyRow] : [])];
// A failed first read is not "no todos": keep the section with a retry instead of hiding it.
if (todos.failed && open.length === 0 && doneTotal === 0) return <Section label={t('devices.glance.todos')}>
+ {joinRows(head, true, styles)}
+ <View style={styles.divider} />
<Pressable accessibilityRole="button" onPress={() => void todos.refresh()} disabled={!online}
style={({ pressed }) => [styles.row, pressed && styles.rowPressed]} testID="companion.glance.todo.retry">
<Text numberOfLines={1} style={styles.undoNote}>{t('devices.glance.loadFailed')}</Text>
<Text style={styles.undoAction}>{t('devices.resources.retry')}</Text>
</Pressable>
</Section>;
- if (open.length === 0 && doneTotal === 0 && !deleted) return null;
const remove = async (todo: TeammateTodo) => {
setError(null);
@@ -256,7 +278,10 @@ function Todos({ todos, online, onQuote }: { todos: GlanceTodoState; online: boo
open={showDone} onPress={() => setShowDone(value => !value)} testID="companion.glance.todo.doneToggle" />);
if (showDone) rows.push(...done.map(todo => row(todo, true)));
return <View>
- <Section label={t('devices.glance.todos')}>{joinRows(rows, false, styles)}</Section>
+ <Section label={t('devices.glance.todos')}>
+ {joinRows(head, true, styles)}
+ {rows.length > 0 ? <><View style={styles.divider} />{joinRows(rows, false, styles)}</> : null}
+ </Section>
{error ? <Text accessibilityRole="alert" style={styles.error}>{error}</Text> : null}
</View>;
}
diff --git a/apps/mobile/src/session/CompanionHeader.tsx b/apps/mobile/src/session/CompanionHeader.tsx
index 54826271ee..7916aecf2b 100644
--- a/apps/mobile/src/session/CompanionHeader.tsx
+++ b/apps/mobile/src/session/CompanionHeader.tsx
@@ -35,13 +35,15 @@ export function CompanionHeader(props: {
sessionId: string;
/** Put a todo into this chat's composer as a reference; the owner then tells the teammate what to do. */
onQuoteTodo(todo: TeammateTodo): void;
+ /** Say something to the teammate as the owner: sent right away when the composer is empty, otherwise put into it. */
+ onAskCompanion(text: string): void;
onSearch(): void; onBack(): void;
}) {
const { accountGeneration } = useAuth();
return <CompanionHeaderContent key={accountGeneration} {...props} />;
}
-function CompanionHeaderContent({ resource, deviceId, deviceName, online, controlsReady = true, working = false, sessionId, onQuoteTodo, onSearch, onBack, settingsRequest }: Parameters<typeof CompanionHeader>[0]) {
+function CompanionHeaderContent({ resource, deviceId, deviceName, online, controlsReady = true, working = false, sessionId, onQuoteTodo, onAskCompanion, onSearch, onBack, settingsRequest }: Parameters<typeof CompanionHeader>[0]) {
const { t, i18n } = useTranslation();
const styles = useThemedStyles(makeStyles);
const navigation = useTeammateNavigation();
@@ -87,6 +89,7 @@ function CompanionHeaderContent({ resource, deviceId, deviceName, online, contro
<CompanionGlanceSheet visible={glance} onClose={() => setGlance(false)} name={name} avatar={resource.display.avatar} botId={resource.ref.id}
deviceId={deviceId} deviceName={deviceName} sessionId={sessionId} online={online} cloudHome={homed} todos={todos}
onQuoteTodo={onQuoteTodo}
+ onCheckTodos={() => onAskCompanion(t('devices.glance.checkPrompt'))}
onOpenTask={taskId => router.push({ pathname: '/sessions/[sessionId]', params: { sessionId: taskId, deviceId } })}
onOpenCindy={hosted => void navigation.openTeammate(hosted, { replace: true })}
onSwitchHome={() => setHomeSheet(true)} />
diff --git a/apps/mobile/src/session/useCompanionGlanceTodos.ts b/apps/mobile/src/session/useCompanionGlanceTodos.ts
index f235be1b7a..66cdedd81e 100644
--- a/apps/mobile/src/session/useCompanionGlanceTodos.ts
+++ b/apps/mobile/src/session/useCompanionGlanceTodos.ts
@@ -29,11 +29,13 @@ export interface GlanceTodos {
done: TeammateTodo[];
doneTotal: number;
nextDeferredAt: string | null;
+ /** Whether 「每天帮我查一次」 is on; null when the desktop does not support it yet (the switch stays hidden). */
+ dailyCheck: boolean | null;
}
-const EMPTY: GlanceTodos = { open: [], openTotal: 0, done: [], doneTotal: 0, nextDeferredAt: null };
+const EMPTY: GlanceTodos = { open: [], openTotal: 0, done: [], doneTotal: 0, nextDeferredAt: null, dailyCheck: null };
-interface Page { items: TeammateTodo[]; total: number; nextDeferredAt?: string | null }
+interface Page { items: TeammateTodo[]; total: number; nextDeferredAt?: string | null; dailyCheck?: unknown }
export function todosResourceRef(botId: string) {
return { collectionId: 'teammates', kind: 'bot', id: `todos:${botId}` } as const;
@@ -55,7 +57,7 @@ async function readAll(readPage: (query: TodoListQuery) => Promise<Page>, view:
if (page.items.length === 0) break;
items.push(...page.items);
}
- return { items: items.slice(0, MAX_ITEMS), total, nextDeferredAt: first.nextDeferredAt ?? null };
+ return { items: items.slice(0, MAX_ITEMS), total, nextDeferredAt: first.nextDeferredAt ?? null, dailyCheck: first.dailyCheck };
}
/**
@@ -85,7 +87,8 @@ export function useCompanionGlanceTodos({ deviceId, deviceName, botId, enabled }
const [open, done] = await Promise.all([readAll(readPage, 'open'), readAll(readPage, 'done')]);
if (mine !== epoch.current) return;
setState({
- todos: { open: open.items, openTotal: open.total, done: [...done.items].reverse(), doneTotal: done.total, nextDeferredAt: open.nextDeferredAt ?? null },
+ todos: { open: open.items, openTotal: open.total, done: [...done.items].reverse(), doneTotal: done.total, nextDeferredAt: open.nextDeferredAt ?? null,
+ dailyCheck: typeof open.dailyCheck === 'boolean' ? open.dailyCheck : null },
loaded: true,
failed: false,
});
@@ -127,7 +130,19 @@ export function useCompanionGlanceTodos({ deviceId, deviceName, botId, enabled }
return result?.todo ?? null;
}, [botId, deviceId, deviceName, i18n.language, invoke, openLink]);
- return { ...state, refresh, patch };
+ /** Turns the teammate's weekday-morning todo check on or off on its computer; resolves to the confirmed state. */
+ const setDailyCheck = useCallback(async (enabled: boolean): Promise<boolean> => {
+ await openLink(deviceId);
+ const result = await invokeRemoteResourceAction(invoke, { deviceId, deviceName }, {
+ collectionId: 'teammates', resourceRef: todosResourceRef(botId), actionId: 'todo-daily-check', input: { enabled },
+ }, i18n.language) as { dailyCheck?: unknown } | null;
+ if (typeof result?.dailyCheck !== 'boolean') throw new Error('INVALID_RESPONSE');
+ const dailyCheck = result.dailyCheck;
+ setState(previous => ({ ...previous, todos: { ...previous.todos, dailyCheck } }));
+ return dailyCheck;
+ }, [botId, deviceId, deviceName, i18n.language, invoke, openLink]);
+
+ return { ...state, refresh, patch, setDailyCheck };
}
/** Due todos; the entry dot only counts the ones the owner has not seen in 近况 yet. */
diff --git a/docs/product-rules/bot-routines.md b/docs/product-rules/bot-routines.md
index d5c1954d4b..523742f449 100644
--- a/docs/product-rules/bot-routines.md
+++ b/docs/product-rules/bot-routines.md
@@ -8,7 +8,7 @@
桌面入口在伙伴任务头部,打开标准右侧栏。列表进入详情后可修改指令、启停、立即运行、增删触发条件、删除规则和查看历史。立即运行先保存当前编辑,再运行,避免执行屏幕上看不到的旧指令。定时菜单提供每小时、每天、工作日、每周、每月、间隔和高级 Cron,保留 IANA 时区。事件菜单来自实际插件声明,不显示未接入平台的假入口。
-手机端不提供例行任务管理:移除「所有任务」下拉菜单的 `routines`、伙伴资料页的自动化入口和旧的独立自动化管理页,旧管理链接返回设备页。具体界面边界与[伙伴运行时合同](./cindy-bots-runtime.md)一致;下文例行任务管理及高级设置均适用于桌面端。移除手机入口不删除已有规则、任务数据或运行历史,不改变桌面执行服务、Remote Resources 协议或 Mobile 原生依赖。执行仍发生在电脑,没有宣称云端补投能力。
+手机端不提供例行任务管理(唯一例外是伙伴近况里「每天帮我查一次」开关,见下文「内置查待办例行任务」):移除「所有任务」下拉菜单的 `routines`、伙伴资料页的自动化入口和旧的独立自动化管理页,旧管理链接返回设备页。具体界面边界与[伙伴运行时合同](./cindy-bots-runtime.md)一致;下文例行任务管理及高级设置均适用于桌面端。移除手机入口不删除已有规则、任务数据或运行历史,不改变桌面执行服务、Remote Resources 协议或 Mobile 原生依赖。执行仍发生在电脑,没有宣称云端补投能力。
## 分层与执行
@@ -142,6 +142,18 @@ const receipt = await cindy.routines.request({
本机「等你」改由宿主直接提醒主人。伙伴暂停 / 归档时随伙伴的其它规则一起停摆,删除伙伴时一起清理。
- 云端伙伴的规则同步(companion cloud)不包含内置规则:每台电脑各自 ensure,执行只在主力电脑上发生。
+## 内置查待办例行任务
+
+伙伴近况「每天帮我查一次」开关背后的宿主内置规则(`builtin: 'todo-check'`,id 为 `builtin-todo-check-<伙伴 id>`,
+过长时与跟进同样改用 sha256 前缀)。实现见 `apps/desktop/src/main/bot-autonomy/todoCheckRoutine.ts` 与
+`routineTools.setTodoCheck`。
+
+- 只在主人打开开关时由 `ensureBuiltin` 建立,之后关掉只暂停、再打开复用同一条,不在启动或伙伴新建时自动建;默认不存在即为关。
+- 触发条件:cron `0 9 * * 1-5`(宿主所在时区,建立时取一次),`silentWhenIdle` 开启,没有新待办不打扰主人。
+- 指令由宿主模板生成(`TODO_CHECK_PROMPT_VERSION`),要求只用已授权的来源、没连接的不说查过,结果按待办规则记录;
+ 主人与伙伴都不能编辑,删除与改内容同样以 `BUILTIN_ROUTINE` 拒绝,桌面例行任务列表里只能暂停或恢复。
+- 不随云端伙伴同步;执行只在主力电脑上发生,与其它例行任务一致。
+
## 验证与边界
本节保留例行任务能力历次交付的验证记录,不代表当前手机端仍提供管理界面。移除手机入口的本次改动未做模拟器或真机验收。
diff --git a/docs/product-rules/cindy-bots-runtime.md b/docs/product-rules/cindy-bots-runtime.md
index a78ab5f85b..0eebd50d6a 100644
--- a/docs/product-rules/cindy-bots-runtime.md
+++ b/docs/product-rules/cindy-bots-runtime.md
@@ -851,6 +851,14 @@ Session 任务遵守同一套机制与呈现契约:
删除即同一问题不再记,可在提示里撤销。期限是今天或已过期的那条在期限前带红点;入口按钮在主人还没打开过近况时
亮同样的红点,打开即灭,期限变化算一次新的到期(本机按伙伴记住看过的到期项)。别的电脑上的伙伴经该电脑的
`todos:<botId>` 远程资源读写,与手机同一路径。
+- **帮我查查 / 每天帮我查一次**(2026-10-22 Chris 定):待办块第一行固定是「帮我查查」,没有待办时整块也在。
+ 点它把一句固定的话(让伙伴去已连接的邮箱、消息等来源找需要主人处理的新事项并记成待办)作为主人的消息发进伙伴对话:
+ 桌面走普通发送(`makerChatStore.sendMessage`,用伙伴对话当前的模型与权限);手机输入框空着时直接发出,已有草稿或附件时
+ 只把这句话放进输入框、不替主人连同草稿一起发。两端都带正常的来源设备标记,不由宿主代发。下一行开关「每天帮我查一次」
+ 打开伙伴的内置例行任务 `builtin: 'todo-check'`(工作日 9:00、没有新待办不提醒,见 bot-routines.md「内置查待办例行任务」),
+ 默认关;这是伙伴主动在来源里找待办的唯一入口,且只由主人在这里开启。桌面经 `local-db:bots:todos:daily-check`,
+ 别的电脑与手机经 `todos:<botId>` 远程资源的 `dailyCheck` 字段与 `todo-daily-check` 动作;旧宿主不带该字段时开关不出现。
+ 这是手机唯一的例行任务开关,不恢复手机的例行任务管理。
- **输出内容**:伙伴开的任务做完时留下的成品文件(委派回执里未删除、属于成品类型的文件),最近在前,先列 3 条;
点开本机文件,别的电脑上的打开来源任务。
- **手机**(2026-10-22):点伙伴聊天顶栏的头像(身份区)打开同内容的近况,设置按钮仍进伙伴资料。iOS 用系统 sheet
diff --git a/packages/maker-scheduler/src/routines.ts b/packages/maker-scheduler/src/routines.ts
index aedf2c1df8..c7245980c7 100644
--- a/packages/maker-scheduler/src/routines.ts
+++ b/packages/maker-scheduler/src/routines.ts
@@ -36,7 +36,8 @@ export type RoutineTrigger =
}>;
};
-export type RoutineBuiltin = "follow-up";
+/** Host-owned rules: per-teammate follow-up, and the owner-enabled daily todo check. */
+export type RoutineBuiltin = "follow-up" | "todo-check";
/** Stable error prefix for attempts to delete or rewrite a host-owned routine. */
export const BUILTIN_ROUTINE_ERROR = "BUILTIN_ROUTINE";
@@ -56,7 +57,7 @@ export interface Routine {
/** null explicitly removes the check; omission preserves it on older clients. */
preRunHook?: PreRunHookConfig | null;
/**
- * 宿主内置规则(目前只有每个伙伴一条的「跟进」)。由宿主模板生成,不接受用户/模型
+ * 宿主内置规则(每个伙伴一条的「跟进」,以及主人在近况里打开的「每天查待办」)。由宿主模板生成,不接受用户/模型
* 改写指令与触发条件、不能删除,只能暂停(enabled)。可选字段:旧数据与旧客户端缺省即普通规则,
* state 版本不变。
*/