Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
Merge origin/main into fix/6508-workbench-empty
ylliuuu66788851736e28
diff --cc apps/desktop/src/main/bot-autonomy/__tests__/hub.test.tsindex 1e1895ca80,81402eb394..782753a43d--- a/apps/desktop/src/main/bot-autonomy/__tests__/hub.test.ts+++ b/apps/desktop/src/main/bot-autonomy/__tests__/hub.test.ts@@@ -9,11 -9,9 +9,11 @@@ import { afterEach, beforeEach, expectimport type { BotAutonomyRuntime } from '../runtime.js';import type { RoutineEngine } from '@cindy/maker-scheduler';import type { LocalSessionMeta } from '../taskWatch.js';+import type { BotGlance } from '../../../shared/botAutonomy.js';const h = vi.hoisted(() => ({- scope: 'a', scheduler: 'sched' as string | null,+ scope: 'a', scheduler: 'sched' as string | null, ready: true,- glance: vi.fn(),++ glance: vi.fn(), refreshRemote: vi.fn(),readMetas: vi.fn(), readOwnership: vi.fn(),}));vi.mock('../../appSessionState.js', () => ({@@@ -39,15 -37,12 +39,16 @@@ const events = ['mine', 'delegated', 'ssourceId: 'host:sessions', event: { id: subject, type: 'finished', subject, occurredAt: 2, data: {} },}));beforeEach(() => {- h.scope = 'a'; h.scheduler = 'sched';+ h.scope = 'a'; h.scheduler = 'sched'; h.ready = true;++ h.refreshRemote.mockReset().mockResolvedValue(undefined);+ h.glance.mockReset().mockReturnValue({+ botId: 'sched', scope: 'all', waiting: [], working: [], lastSweepAt: 0, doneToday: 0, offlineDevices: [],+ } satisfies BotGlance);const bots = new Map([['sched', { status: 'active', allowSchedulerFollow: false }]]);h.readMetas.mockReset().mockResolvedValue([meta('mine'), meta('delegated'), meta('shared', 'shared')]);h.readOwnership.mockReset().mockResolvedValue({ bots, creatorBySession: new Map([['delegated', 'sched']]), responsibleByBot: new Map() });setActiveBotAutonomy({ scope: 'a', engine: {} as RoutineEngine,- runtime: { glance: h.glance, watch: { isReady: () => h.ready, list: () => [], getBots: () => bots } } as unknown as BotAutonomyRuntime });- runtime: { watch: { isReady: () => true, list: () => [], getBots: () => bots } } as unknown as BotAutonomyRuntime });++ runtime: { glance: h.glance, watch: { isReady: () => h.ready, getSchedulerBotId: () => h.scheduler, refreshRemote: h.refreshRemote, list: () => [], getBots: () => bots } } as unknown as BotAutonomyRuntime });});afterEach(() => setActiveBotAutonomy(null));@@@ -67,19 -62,39 +68,57 @@@ it('defers rather than authorizing a duexpect(await currentFollowUpEvents('sched', events)).toBeNull();});+// #6508: the public glance reader must not report a successful empty workbench+// before its host/ownership is ready. Existing coverage only exercised follow-up+// authorization. Minimal unit inputs: missing, stale, or unready runtime.+it.each(['missing', 'stale', 'unready'] as const)('rejects a %s runtime instead of reporting no work', (state) => {+ if (state === 'missing') setActiveBotAutonomy(null);+ if (state === 'stale') h.scope = 'other';+ if (state === 'unready') h.ready = false;+ expect(() => getBotAutonomyGlance('sched')).toThrow(/\[PRECONDITION_FAILED\]/u);+ expect(h.glance).not.toHaveBeenCalled();++ expect(h.refreshRemote).not.toHaveBeenCalled();+});++it('returns the actual empty projection once ready, preserving scope and visibility options', () => {+ const options = { excludeBotIds: new Set(['hidden']) };+ expect(getBotAutonomyGlance('sched', options)).toMatchObject({ botId: 'sched', scope: 'all', waiting: [], working: [] });+ expect(h.glance).toHaveBeenCalledWith('sched', options);+});+++ // Unit §6.3: UI probe versus explicit view read, including an owner change while IO waits.+ it('only refreshes remote state for an explicit scheduler workbench read and discards cross-account results', async () => {+ const remote = vi.fn(async () => {});+ const projection = { botId: 'sched', waiting: [] };+ setActiveBotAutonomy({ scope: 'a', engine: {} as RoutineEngine, runtime: {- watch: { getSchedulerBotId: () => 'sched', refreshRemote: remote },++ watch: { isReady: () => true, getSchedulerBotId: () => 'sched', refreshRemote: remote },+ glance: () => projection,+ } as unknown as BotAutonomyRuntime });+ expect(await getBotAutonomyGlance('sched', undefined, false)).toBe(projection);+ await getBotAutonomyGlance('own');+ expect(remote).not.toHaveBeenCalled();+ expect(await getBotAutonomyGlance('sched')).toBe(projection);+ expect(remote).toHaveBeenCalledOnce();+ remote.mockImplementationOnce(async () => { h.scope = 'b'; });+ expect(() => getBotAutonomyGlance('sched')).toThrow('PRECONDITION_FAILED');+ });++ // Unit regression for #6675: a nonresponding peer must not block the first cached+ // glance. Existing immediate remote mocks cannot expose the unresolved IPC.+ it('returns the cached glance while a remote peer is still pending or fails', async () => {+ let rejectRemote!: (error: Error) => void;+ const pending = new Promise<void>((_resolve, reject) => { rejectRemote = reject; });+ const projection = { botId: 'sched', working: [{ sessionId: 'local' }] };+ setActiveBotAutonomy({ scope: 'a', engine: {} as RoutineEngine, runtime: {- watch: { getSchedulerBotId: () => 'sched', refreshRemote: () => pending },++ watch: { isReady: () => true, getSchedulerBotId: () => 'sched', refreshRemote: () => pending },+ glance: () => projection,+ } as unknown as BotAutonomyRuntime });+ try {+ // The detached permission handler also consumes this synchronous projection.+ expect(getBotAutonomyGlance('sched')).toBe(projection);+ } finally {+ rejectRemote(new Error('remote unavailable'));+ await Promise.resolve();+ }+ expect(await getBotAutonomyGlance('sched', undefined, false)).toBe(projection);+ });diff --cc apps/desktop/src/main/bot-autonomy/hub.tsindex fb2324209c,824c1a74db..d937e197f6--- a/apps/desktop/src/main/bot-autonomy/hub.ts+++ b/apps/desktop/src/main/bot-autonomy/hub.ts@@@ -63,12 -63,24 +63,22 @@@ export function noteBotAutonomyInputProruntime.watch.applyInputProjection(projection as BotAutonomyInputProjection);}- export function getBotAutonomyGlance(botId: string, options?: GlanceOptions): BotGlance {-function emptyGlance(botId: string): BotGlance {- return { botId, scope: 'own', waiting: [], working: [], lastSweepAt: 0, doneToday: 0, offlineDevices: [] };-}-+ export function getBotAutonomyGlance(+ botId: string, options?: GlanceOptions, refreshRemote = true,+ ): BotGlance {if (isAppSessionBoundaryPending()) throwIpcError('PRECONDITION_FAILED', 'App session is switching; retry later.');const active = current && scopeIsCurrent(current.scope) ? current.runtime : null;- if (!active) return emptyGlance(botId);+ // 与伙伴工具读取保持一致:运行体或归属未就绪不是「没有任务」。+ // 沿用已有错误协议,旧查看端也能进入读取失败分支;就绪后的变化推送会触发重读。+ if (!active?.watch.isReady()) throwIpcError('PRECONDITION_FAILED', 'Bot autonomy is not ready; retry later.');+ const scope = activeOwnerScopeKey();+ // The hidden auto-open probe and Agent reads use cached projections only.+ // Return cached/local rows immediately; the watch pushes changes when remote IO settles.+ if (refreshRemote && active.watch.getSchedulerBotId() === botId) {+ void active.watch.refreshRemote().catch((error) => log.warn('autonomy remote refresh failed', { error: errorCode(error) }));+ }+ assertOwner(scope);+ if (current?.runtime !== active) throwIpcError('PRECONDITION_FAILED', 'Task observation changed; retry later.');return active.glance(botId, options);}diff --cc apps/desktop/src/renderer/features/bots/BotWorkbench.tsxindex e3bf83d7e3,4db5394bca..0ce8638e8a--- a/apps/desktop/src/renderer/features/bots/BotWorkbench.tsx+++ b/apps/desktop/src/renderer/features/bots/BotWorkbench.tsx@@@ -1,9 -1,8 +1,9 @@@import { useCallback, useEffect, useId, useMemo, useState, type ReactNode } from 'react';import { useTranslation } from 'react-i18next';- import { useNavigate } from 'react-router-dom';+ import { useInRouterContext, useNavigate, type NavigateFunction } from 'react-router-dom';import { Button } from '@/components/ui/button';+import { ErrorNotice } from '@/components/ui/error-notice';import { Spinner } from '@/components/ui/spinner';import { getDataOwnerGeneration, isDataOwnerGenerationCurrent } from '@/contexts/dataOwnerGeneration';import { useDeviceLinkDeviceList } from '@/features/device-link/useDeviceLinkDeviceList';diff --cc docs/verification/issue-6508/README.mdindex b4622a2fbf,0000000000..26cc19bde8mode 100644,000000..100644--- a/docs/verification/issue-6508/README.md+++ b/docs/verification/issue-6508/README.md@@@ -1,95 -1,0 +1,106 @@@+# #6508:工作台空态修正与 macOS 验证++验证日期:2026-10-21。分支:`fix/6508-workbench-empty`。+基线:`f25a95f3b289d74b6aa4f18c78f8e2693b1ba4c6`,检查时包含本次未提交的修复。++## 结论与范围++本次修正两个已由回归测试证明的问题:++1. 宿主运行体不存在、归属已过期或尚未就绪时,返回既有 `PRECONDITION_FAILED`,不再返回成功的空投影。+2. 已读到缓存结果后刷新失败时,保留任务行并显示读取失败,隐藏安静空态和扫描成功页脚;后续读取成功时恢复。++**尚未复现 #6508 所述的「正常打开为空、关闭时闪现内容、重开仍为空」。**+本次改动不能被视为已确认解决该闪现现象,也不构成关闭 issue 的依据。+[原报告及评论](https://github.com/makecindy/cindy/issues/6508)未确认关闭对象,未提供录屏;+Windows/CN 仅是提交时快照。Windows 验证本次明确跳过,未用平台标志模拟代替实机结果。++## macOS 实机++环境:macOS ARM64、Electron 42.11.12、Global、隔离 userData。通过仓库安全入口启动:++```sh+pnpm restart:desktop:remote --region=global --isolated=@worktree+```++启动返回 `DESKTOP_DEV_VERDICT=ready`,界面分支核对为 `fix/6508-workbench-empty@f25a95f`。+经真实 IPC 读取远程伙伴已有工作台,不发送消息、不响应权限、不修改任务。+从伙伴头部的「打开工作台」进入,分别关闭标签和收起侧栏,再从同一入口重开。+Light/Dark 打开及重开截图均已目检,均显示 2 条「在做」,文字及布局正常。++改前对照仅把 `BotWorkbench.tsx` 临时换成基线版本,其余本地代码及远端宿主不变;+不是完整旧版本重跑。对照结束后已还原修复文件并核对字节一致。++| 代码 | 主题 | 关闭操作 | 关闭前 → 重开后行数 | 采样帧数 | 空态帧数 |+| --- | --- | --- | --- | --- | --- |+| 改前渲染代码 | light | 关闭标签 | 2 → 2 | 59 | 0 |+| 改前渲染代码 | light | 收起 | 2 → 2 | 62 | 0 |+| 改前渲染代码 | dark | 关闭标签 | 2 → 2 | 58 | 0 |+| 改前渲染代码 | dark | 收起 | 2 → 2 | 62 | 0 |+| 本次修复 | light | 关闭标签 | 2 → 2 | 58 | 0 |+| 本次修复 | light | 收起 | 2 → 2 | 62 | 0 |+| 本次修复 | dark | 关闭标签 | 2 → 2 | 61 | 0 |+| 本次修复 | dark | 收起 | 2 → 2 | 61 | 0 |++每次关闭采集约 1 秒 `requestAnimationFrame` 数据,只记录相对时间、挂载状态、行数、+空态布尔值(修复后另含宽度)。共 483 帧未观察到空态;这不是屏幕录屏,不能据此断言+所有合成器帧均无闪烁。两种主题下,改前与改后都没有复现原报告。++其他入口与限制:++- 独立工作台窗口记录到 `useNavigate() may be used only in the context of a <Router> component.`,+ 与 [#6487](https://github.com/makecindy/cindy/pull/6487) 描述一致;后续截图为加载遮罩。+ 此错误未混同为 #6508 的空态闪现,也未纳入本次修复。+- 调用 macOS 原生关闭自身入口并尝试激活后,未捕获显隐事件,不能计为有效的主窗口关闭/重开验证。+- 未验证 Windows、CN 或原报告者环境;未建立宿主未就绪与关闭闪现的因果关系。++## 双主题组件检查++在隔离 Electron 中加载真实 `BotWorkbench`、读取 hook、样式和主题,模拟宿主 API 数据。+加载、真空态、初次失败、缓存空结果后失败、缓存非空结果后失败、正常内容,+Light/Dark 共 12 个组合通过通用 UI 检查。++首次缓存空结果失败场景截得过早,不能作为失败终态证据。修正临时场景的事件时序后,+两个缓存失败场景的 4 个组合重跑通过并重新目检:失败提示可见、旧任务行保留、+安静空态与成功页脚隐藏。此检查未替换产品模块,但使用了模拟宿主数据,不能替代实机复现。++原始截图、帧记录与临时场景保存在验证 worktree 的 Git 忽略目录+`artifacts/issue-6508-real/`、`artifacts/ui-check/`、`tmp/6508-workbench.tsx`,+未随本次提交发布。此文保存可独立阅读的结果及限制,自动回归随源码提交。++## 回归与静态检查++先补回归、再修复:初始两个测试文件 **5 失败 / 13 通过**;生产代码修正后 **18 通过**。+新增测试覆盖运行体缺失/过期/未就绪、真实空结果、缓存刷新失败与恢复、+加载/失败区分、卸载重开,以及较早空响应不得覆盖较新非空响应。++扩展验证 **7 个文件、80 项测试通过**:++```sh+pnpm --filter desktop exec vitest run \+ src/main/bot-autonomy/__tests__/hub.test.ts \+ src/main/bot-autonomy/__tests__/runtime.test.ts \+ src/main/bot-autonomy/__tests__/taskWatch.test.ts \+ src/main/bot-autonomy/__tests__/autonomyRules.test.ts \+ src/renderer/features/bots/__tests__/BotWorkbenchView.test.tsx \+ src/renderer/features/bots/__tests__/botWorkbenchLifecycle.test.tsx \+ src/renderer/features/right-sidebar/lib/__tests__/openBotWorkbenchTab.test.ts \+ --maxWorkers=2+pnpm --filter desktop run --if-present typecheck+pnpm check:dev-docs+git diff --check+```++Desktop 类型检查、文档检查及 diff 空白检查通过。首次类型检查因 Mobile 工作区依赖未安装失败,+补齐依赖后重跑通过;没有通过修改源码或弱化检查消除该环境错误。没有执行完整仓库测试或远端 CI。++++## 同步主干后的补充验证++++2026-10-21 同步 `origin/main@fc15f8464a`(含 #6675),保留远程状态按需刷新、++立即返回缓存投影与账号切换校验,同时保留本 PR 的宿主就绪检查。++冲突仅涉及 `hub.ts` 与对应测试;补充断言未就绪时不触发远程刷新。++上述同一组定向命令重跑:**7 个文件、94 项测试通过**(Vitest 总耗时 3.26 秒);++Desktop 类型检查、文档检查(10 项)与 diff 空白检查均通过。++++上文 macOS 实机与组件截图均为同步前的验证,未在同步后重新拍摄;++Windows 仍未验证,原始关闭闪现仍未复现。