Skip to content

armgit / cindy

Public Imported from GitHub
0

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

fix(desktop): stop retrying unavailable cursor styling (#1722)

Dashe30ae509a0c5
diff --git a/apps/desktop/src/main/mcp-integrations/__tests__/computer.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/computer.test.ts
index 8d059434a0..b49e377713 100644
--- a/apps/desktop/src/main/mcp-integrations/__tests__/computer.test.ts
+++ b/apps/desktop/src/main/mcp-integrations/__tests__/computer.test.ts
@@ -999,7 +999,7 @@ describe('computer mcp integration', () => {
expectDriverSessionGenerations([payload.session], 'session-1', [0]);
});
- it('styles the TapTap cursor once per long-lived MCP session before actions', async () => {
+ it('styles the Cindy cursor once per long-lived MCP session before actions', async () => {
mcpCallToolMock
.mockResolvedValueOnce({ content: [{ type: 'text', text: '{"ok":true}' }] })
.mockResolvedValueOnce({ content: [{ type: 'text', text: '{"ok":true}' }] })
@@ -1028,16 +1028,23 @@ describe('computer mcp integration', () => {
'click',
'click',
]);
+ expect(mcpCallToolMock.mock.calls[0]?.[0]?.arguments).toMatchObject({
+ cursor_color: '#DF0C27',
+ cursor_label: BRAND_NAME,
+ });
+ expect(mcpCallToolMock.mock.calls[1]?.[0]?.arguments).toMatchObject({
+ gradient_colors: ['#DF0C27', '#A61629'],
+ bloom_color: '#DF0C27',
+ });
expect(mcpConnectMock).toHaveBeenCalledTimes(1);
});
- it('retries TapTap cursor styling after a transient styling failure', async () => {
+ it('retries Cindy cursor styling after a transient styling failure', async () => {
mcpCallToolMock
.mockRejectedValueOnce(new Error('motion unavailable'))
.mockResolvedValueOnce({ content: [{ type: 'text', text: '{"ok":true}' }] })
.mockResolvedValueOnce({ content: [{ type: 'text', text: '{"ok":true,"clicked":true}' }] })
.mockResolvedValueOnce({ content: [{ type: 'text', text: '{"ok":true}' }] })
- .mockResolvedValueOnce({ content: [{ type: 'text', text: '{"ok":true}' }] })
.mockResolvedValueOnce({ content: [{ type: 'text', text: '{"ok":true,"clicked":true}' }] });
await expect(callComputerDriverTool('click', {
@@ -1061,9 +1068,79 @@ describe('computer mcp integration', () => {
'set_agent_cursor_style',
'click',
'set_agent_cursor_motion',
+ 'click',
+ ]);
+ });
+
+ it('stops retrying unsupported cursor setup tools for the current MCP session', async () => {
+ mcpCallToolMock
+ .mockResolvedValueOnce({ content: [{ type: 'text', text: '{"ok":true}' }] })
+ .mockResolvedValueOnce({
+ isError: true,
+ content: [{ type: 'text', text: "Permission denied: tool 'set_agent_cursor_style' has no reviewed risk classification" }],
+ })
+ .mockResolvedValueOnce({ content: [{ type: 'text', text: '{"ok":true,"clicked":true}' }] })
+ .mockResolvedValueOnce({ content: [{ type: 'text', text: '{"ok":true,"clicked":true}' }] });
+
+ await expect(callComputerDriverTool('click', {
+ pid: 123,
+ window_id: 7,
+ x: 10,
+ y: 20,
+ }, { sessionId: 'session-unsupported-style' })).resolves.toEqual({ ok: true, clicked: true });
+ await expect(callComputerDriverTool('click', {
+ pid: 123,
+ window_id: 7,
+ x: 11,
+ y: 21,
+ }, { sessionId: 'session-unsupported-style' })).resolves.toEqual({ ok: true, clicked: true });
+
+ expect(mcpCallToolMock.mock.calls.map((call) => call[0]?.name)).toEqual([
+ 'set_agent_cursor_motion',
+ 'set_agent_cursor_style',
+ 'click',
+ 'click',
+ ]);
+ expect(mcpConnectMock).toHaveBeenCalledTimes(1);
+ });
+
+ it('retries unsupported cursor setup after the MCP session is recreated', async () => {
+ mcpCallToolMock
+ .mockResolvedValueOnce({ content: [{ type: 'text', text: '{"ok":true}' }] })
+ .mockResolvedValueOnce({
+ isError: true,
+ content: [{ type: 'text', text: "Permission denied: tool 'set_agent_cursor_style' has no reviewed risk classification" }],
+ })
+ .mockResolvedValueOnce({ content: [{ type: 'text', text: '{"ok":true,"clicked":true}' }] })
+ .mockResolvedValueOnce({ content: [{ type: 'text', text: '{"ok":true}' }] })
+ .mockResolvedValueOnce({ content: [{ type: 'text', text: '{"ok":true}' }] })
+ .mockResolvedValueOnce({ content: [{ type: 'text', text: '{"ok":true}' }] })
+ .mockResolvedValueOnce({ content: [{ type: 'text', text: '{"ok":true,"clicked":true}' }] });
+
+ await callComputerDriverTool('click', {
+ pid: 123,
+ window_id: 7,
+ x: 10,
+ y: 20,
+ }, { sessionId: 'session-style-recreated' });
+ await cleanupComputerDriverSession('session-style-recreated');
+ await callComputerDriverTool('click', {
+ pid: 123,
+ window_id: 7,
+ x: 11,
+ y: 21,
+ }, { sessionId: 'session-style-recreated' });
+
+ expect(mcpCallToolMock.mock.calls.map((call) => call[0]?.name)).toEqual([
+ 'set_agent_cursor_motion',
+ 'set_agent_cursor_style',
+ 'click',
+ 'end_session',
+ 'set_agent_cursor_motion',
'set_agent_cursor_style',
'click',
]);
+ expect(mcpConnectMock).toHaveBeenCalledTimes(2);
});
it('throws the driver stderr when a tool call exits non-zero', async () => {
@@ -3289,7 +3366,6 @@ describe('computer mcp integration', () => {
});
});
-
function currentPlatformReleaseAsset(version: string, size = 21147689) {
const name = getCuaDriverReleaseAssetName(version);
if (!name) throw new Error(`unsupported test platform: ${process.platform}/${process.arch}`);
diff --git a/apps/desktop/src/main/mcp-integrations/computer.ts b/apps/desktop/src/main/mcp-integrations/computer.ts
index 2c6870c203..d026c159b0 100644
--- a/apps/desktop/src/main/mcp-integrations/computer.ts
+++ b/apps/desktop/src/main/mcp-integrations/computer.ts
@@ -118,13 +118,15 @@ const CLI_FALLBACK_TOOL_NAMES = new Set<ComputerMcpToolName>([
'get_screen_size',
'get_cursor_position',
]);
-const TAPTAP_CURSOR_STYLE = {
- gradient_colors: ['#00D9C5', '#000050'],
- bloom_color: '#00D9C5',
+// The out-of-process driver cannot consume renderer theme tokens, so keep the
+// concrete Cindy brand palette here in sync with DESIGN.md §15.1 / §15.7.
+const CINDY_CURSOR_STYLE = {
+ gradient_colors: ['#DF0C27', '#A61629'],
+ bloom_color: '#DF0C27',
} as const;
-const TAPTAP_CURSOR_MOTION = {
+const CINDY_CURSOR_MOTION = {
cursor_icon: 'arrow',
- cursor_color: '#00D9C5',
+ cursor_color: '#DF0C27',
cursor_label: BRAND_NAME,
cursor_size: 30,
cursor_opacity: 0.96,
@@ -278,8 +280,12 @@ interface CuaMcpSessionEntry {
transport: StdioClientTransport;
ready: Promise<void>;
driverSessionId: string;
- styled: boolean;
+ cursorSetup: {
+ motion: CursorSetupState;
+ style: CursorSetupState;
+ };
}
+type CursorSetupState = 'pending' | 'applied' | 'unavailable';
interface ProcessSnapshotEntry {
pid: number;
@@ -2069,7 +2075,10 @@ function createCuaMcpSession(sessionId: string): CuaMcpSessionEntry {
client,
transport,
driverSessionId: getDriverSessionId(sessionId),
- styled: false,
+ cursorSetup: {
+ motion: 'pending',
+ style: 'pending',
+ },
ready: withTimeout(
client.connect(transport),
MCP_STARTUP_TIMEOUT_MS,
@@ -2217,28 +2226,33 @@ async function initializeDefaultCursorStyle(
session: string,
): Promise<void> {
if (!CURSOR_STYLED_TOOL_NAMES.has(name)) return;
- if (entry.styled) return;
- const calls: Array<{ tool: string; args: Record<string, unknown> }> = [
+ const calls: Array<{
+ stateKey: keyof CuaMcpSessionEntry['cursorSetup'];
+ tool: string;
+ args: Record<string, unknown>;
+ }> = [
{
+ stateKey: 'motion',
tool: 'set_agent_cursor_motion',
args: {
cursor_id: session,
- ...TAPTAP_CURSOR_MOTION,
+ ...CINDY_CURSOR_MOTION,
},
},
{
+ stateKey: 'style',
tool: 'set_agent_cursor_style',
args: {
cursor_id: session,
- gradient_colors: TAPTAP_CURSOR_STYLE.gradient_colors,
- bloom_color: TAPTAP_CURSOR_STYLE.bloom_color,
+ gradient_colors: CINDY_CURSOR_STYLE.gradient_colors,
+ bloom_color: CINDY_CURSOR_STYLE.bloom_color,
},
},
];
- let styled = true;
for (const call of calls) {
+ if (entry.cursorSetup[call.stateKey] !== 'pending') continue;
try {
await callCuaMcpTool(
entry,
@@ -2246,17 +2260,36 @@ async function initializeDefaultCursorStyle(
call.args,
STATUS_TIMEOUT_MS,
);
+ entry.cursorSetup[call.stateKey] = 'applied';
} catch (err) {
- styled = false;
+ const message = err instanceof Error ? err.message : String(err);
+ if (isCursorSetupUnavailableError(message)) {
+ entry.cursorSetup[call.stateKey] = 'unavailable';
+ logger.info('cua-driver cursor setup unavailable; continuing without it', {
+ tool: name,
+ cursorTool: call.tool,
+ session,
+ error: message,
+ });
+ continue;
+ }
logger.warn('failed to apply default cua-driver cursor style', {
tool: name,
cursorTool: call.tool,
session,
- error: err instanceof Error ? err.message : String(err),
+ error: message,
});
}
}
- entry.styled = styled;
+}
+
+/**
+ * Driver capability/policy failures cannot recover while the same MCP process
+ * remains alive. Remember them on the session entry so an optional cursor
+ * decoration never adds a rejected tool call to every real computer action.
+ */
+function isCursorSetupUnavailableError(message: string): boolean {
+ return /has no reviewed risk classification|method not found|unknown tool|tool .+ not found/i.test(message);
}
function readBooleanGrant(value: unknown): ComputerDriverPermissionGrant {
diff --git a/docs/design-rules/DESIGN.md b/docs/design-rules/DESIGN.md
index 0e6d72a9fa..fd5ef0e31d 100644
--- a/docs/design-rules/DESIGN.md
+++ b/docs/design-rules/DESIGN.md
@@ -1007,6 +1007,12 @@ The splash wordmark is a separate asset pair (`assets/splash/wordmark.png`, whit
- **Constraints**: the white QR background is a scanner-contrast requirement, not a general brand panel. Do not add a border, edge, shadow, motion or other decoration to the code.
- **Scope boundary**: this approval covers the current Alipay QR payment paths only. `BillingPaymentAction` currently does not carry a provider; any future non-Alipay `QR_CODE` channel must first add provider-aware rendering rather than inheriting this mark by default.
+**Sanctioned brand surface — Computer Use cursor (approved 2026-08-04).**
+
+- **Where**: the optional agent cursor configured by `apps/desktop/src/main/mcp-integrations/computer.ts` while Cindy Computer Use actions are running. Its arrow color and bloom use Brand red `#DF0C27`; the driver-required gradient transitions from Brand red to Deep brand red `#A61629`.
+- **Why the values are concrete**: the cursor is rendered by the out-of-process `cua-driver`, which cannot consume renderer CSS variables or the active theme registry. The fixed two-color brand palette is therefore identical in Light, Dark, and imported themes.
+- **Scope boundary**: this approval identifies Cindy's automated pointer only. It does not authorize brand red for ordinary controls, focus/caret states, buttons, or other working UI. Cursor styling remains optional; a driver capability/policy rejection degrades without blocking Computer Use and is remembered for the current MCP session.
+
### 15.8 status-badge-fg
- The orange badge (bg `status-bar-accent` `#EA6B17`) has its own foreground token `status-badge-fg`: **default mirrors `accent-pure-cta-fg`** (light white / dark black — zero change for the 9 existing themes); **CINDY overrides both modes to `#1F1F1F`** (near-black), contrast × `#EA6B17` = **5.19:1 ≥ 4.5** (user-approved; darken toward `#000000` if a future orange fails 4.5).