Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): recognize arrow-function source literals
DavidShenda95e939d85f
diff --git a/apps/desktop/src/main/device-link/__tests__/mobileToolProjection.test.ts b/apps/desktop/src/main/device-link/__tests__/mobileToolProjection.test.tsindex 8093f8e08d..f190b06f08 100644--- a/apps/desktop/src/main/device-link/__tests__/mobileToolProjection.test.ts+++ b/apps/desktop/src/main/device-link/__tests__/mobileToolProjection.test.ts@@ -31,6 +31,7 @@ describe('mobile tool projection', () => {const source = "const urls = ['xdt-file://open?path=%2Ftmp%2Ffixture.pdf', 'xdt-file:///tmp/example.html'];\n"+ "const path = enabled ? 'xdt-file:///tmp/conditional.pdf' : undefined\n"+ "const fallback = candidate || 'xdt-file:///tmp/logical.pdf'\n"+ + "const paths = names.map(() => 'Open xdt-file:///tmp/callback.pdf')\n"+ "const list = [/* first */ 'xdt-file:///tmp/a.pdf', // next\n 'xdt-file:///tmp/b.pdf']\n"+ '// source 中文\n'.repeat(1500);const row = { ...tool('Read'), role: 'tool_result', content: source };diff --git a/apps/mobile/src/__tests__/pluginResultRendering.test.ts b/apps/mobile/src/__tests__/pluginResultRendering.test.tsindex 805896ab24..afd9698ca2 100644--- a/apps/mobile/src/__tests__/pluginResultRendering.test.ts+++ b/apps/mobile/src/__tests__/pluginResultRendering.test.ts@@ -27,6 +27,7 @@ describe('plugin results are visible outside collapsed tool details', () => {const source = "const urls = ['xdt-file://open?path=%2Ftmp%2Ffixture.pdf', 'xdt-file:///tmp/example.html'];\n"+ "const path = enabled ? 'xdt-file:///tmp/conditional.pdf' : undefined\n"+ "const fallback = candidate || 'xdt-file:///tmp/logical.pdf'\n"+ + "const paths = names.map(() => 'Open xdt-file:///tmp/callback.pdf')\n"+ "const list = [/* first */ 'xdt-file:///tmp/a.pdf', // next\n 'xdt-file:///tmp/b.pdf']";for (const content of [source, { text: source }]) {const rows = messages(content);diff --git a/packages/maker-shared/src/__tests__/pluginResults.test.ts b/packages/maker-shared/src/__tests__/pluginResults.test.tsindex 0e18af7b12..59b991f85f 100644--- a/packages/maker-shared/src/__tests__/pluginResults.test.ts+++ b/packages/maker-shared/src/__tests__/pluginResults.test.ts@@ -4,6 +4,25 @@ import { hasVisibleHistoryResult } from '../historyViewProjection.js';const blob = (ext: string) => `cindy-media://blobs/${'a'.repeat(64)}.${ext}`;describe('portable plugin results', () => {+ it.each(["'", '"', String.fromCharCode(96)])('recognizes arrow-function source literals quoted with %s', (quote) => {+ const url = 'xdt-file:///tmp/callback.pdf';+ for (const content of [url, 'Open ' + url]) {+ const literal = quote + content + quote;+ for (const source of [+ 'const paths = names.map(() => ' + literal + ')',+ 'const path = () => ' + literal,+ 'const path = async () => /* example */\n ' + literal,+ ]) {+ expect(files(source), source).toEqual([]);+ expect(files(JSON.stringify({ text: source })), source).toEqual([]);+ expect(files(source + '\nSaved "' + url + '"')).toEqual([{ url, title: 'callback.pdf' }]);+ expect(files(JSON.stringify({ text: source, _xdt_model_files: [{ url, name: 'Callback' }] })))+ .toEqual([{ url, title: 'Callback' }]);+ }+ }+ // A Markdown quote marker alone is not the arrow operator.+ expect(files('> ' + quote + url + quote)).toEqual([{ url, title: 'callback.pdf' }]);+ });it.each(["'", '"', String.fromCharCode(96)])('handles long escaped source literals ending in a backslash: %s', (quote) => {const source = 'const message = ' + quote + ('\\' + quote).repeat(5000)+ ' Open xdt-file:///tmp/fixture.pdf' + '\\';diff --git a/packages/maker-shared/src/payloadSummary.ts b/packages/maker-shared/src/payloadSummary.tsindex b1164042f1..4d9288e4eb 100644--- a/packages/maker-shared/src/payloadSummary.ts+++ b/packages/maker-shared/src/payloadSummary.ts@@ -544,7 +544,7 @@ function looksLikeQuotedSourceLiteral(text: string, index: number, end: number):// Quotes alone also occur in prose and inline Markdown. Require source syntax// around the literal (assignment, collection entry, argument or conditional).const prefix = text.slice(0, index - 1).trimEnd();- return /(?:[=\[(,?]|&&|\|\||\breturn)$/.test(prefix)+ return /(?:[=\[(,?]|=>|&&|\|\||\breturn)$/.test(prefix)// A colon alone is also a prose label ("File:"). Require a preceding// conditional, allowing indented continuation lines but not new prose.|| (prefix.endsWith(':') && /\?(?:[^;\r\n]|\r?\n[ \t])*:$/.test(prefix))