Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(dev): 模拟任务的消息在中断后补齐,手机端模拟目录改为用到时再构建
Dashfd3dcd9086c7
diff --git a/apps/desktop/src/main/localDb/__tests__/uiMockSeed.test.ts b/apps/desktop/src/main/localDb/__tests__/uiMockSeed.test.tsindex 0f15c72b58..d9efc42901 100644--- a/apps/desktop/src/main/localDb/__tests__/uiMockSeed.test.ts+++ b/apps/desktop/src/main/localDb/__tests__/uiMockSeed.test.ts@@ -4,7 +4,8 @@* Runs seedUiMockData against a database built by the real migration chain, so a* schema change that the shared catalog no longer satisfies (new NOT NULL column,* narrowed enum) fails here instead of leaving `--mock` with an empty task list.- * A second start must keep what the developer changed while testing.+ * A second start must keep what the developer changed while testing, and finish a+ * start that was interrupted between writing a task and its messages.*/import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';@@ -66,7 +67,19 @@ describe.skipIf(!canReplayMigrations)('ui mock seed', () => {sqlite.prepare("DELETE FROM sessions WHERE id = 'ui-mock-dialogue'").run();writeFileSync(readme, 'edited\n');+ // An interrupted first start (task written, messages not) must finish next time,+ // while a message deleted in the app (tombstone) must not come back.+ sqlite.prepare("DELETE FROM messages WHERE session_id = 'ui-mock-long-title'").run();+ sqlite.prepare("DELETE FROM messages WHERE session_id = 'ui-mock-archived'").run();+ sqlite.prepare(+ "INSERT INTO messages (id, client_id, session_id, role, content, created_at) VALUES ('tomb', 'tomb', 'ui-mock-archived', 'message_tombstone', '{}', 1)",+ ).run();+expect(await seed()).toBe(1);+ expect(sqlite.prepare("SELECT count(*) AS n FROM messages WHERE session_id = 'ui-mock-long-title'").get())+ .toEqual({ n: 2 });+ expect(sqlite.prepare("SELECT count(*) AS n FROM messages WHERE session_id = 'ui-mock-archived'").get())+ .toEqual({ n: 1 });expect(sqlite.prepare("SELECT title FROM sessions WHERE id = 'ui-mock-english'").get()).toEqual({ title: 'renamed' });expect(sqlite.prepare("SELECT count(*) AS n FROM messages WHERE session_id = 'ui-mock-dialogue'").get())diff --git a/apps/desktop/src/main/localDb/uiMockSeed.ts b/apps/desktop/src/main/localDb/uiMockSeed.tsindex 3841e10b2c..c99e000c27 100644--- a/apps/desktop/src/main/localDb/uiMockSeed.ts+++ b/apps/desktop/src/main/localDb/uiMockSeed.ts@@ -9,6 +9,7 @@*/import fs from 'node:fs';import path from 'node:path';+import { inArray } from 'drizzle-orm';import type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';import { buildUiMockRows, UI_MOCK_PROJECTS } from '@cindy/maker-shared/ui-mock';@@ -33,7 +34,7 @@ export function ensureUiMockProjects(projectRoot: string): void {}}-/** Insert the missing demo tasks and messages. Returns the number of new tasks. */+/** Insert the missing demo tasks and the messages of unfinished ones. Returns the number of new tasks. */export async function seedUiMockData({db,projectRoot,@@ -73,7 +74,21 @@ export async function seedUiMockData({.onConflictDoNothing().returning({ id: sessions.id });const newTaskIds = new Set(inserted.map((row) => row.id));- const newMessages = rows.messages.filter((row) => newTaskIds.has(row.sessionId));+ // Tasks and messages are two writes. A start interrupted between them leaves a mock+ // task without history, so a catalog task that has no message row at all is finished+ // too. A message the developer deleted leaves a tombstone row, so it is not restored.+ const catalogIds = rows.sessions.map((row) => row.id);+ const withHistory = new Set(+ (await db.selectDistinct({ id: messages.sessionId }).from(messages)+ .where(inArray(messages.sessionId, catalogIds))).map((row) => row.id),+ );+ const existing = await db.select({ id: sessions.id }).from(sessions)+ .where(inArray(sessions.id, catalogIds));+ const seedMessagesFor = new Set([+ ...newTaskIds,+ ...existing.map((row) => row.id).filter((id) => !withHistory.has(id)),+ ]);+ const newMessages = rows.messages.filter((row) => seedMessagesFor.has(row.sessionId));if (newMessages.length > 0) {await db.insert(messages)diff --git a/apps/mobile/src/__tests__/simIdentity.test.ts b/apps/mobile/src/__tests__/simIdentity.test.tsindex 8d9df8b6e4..f6af863d21 100644--- a/apps/mobile/src/__tests__/simIdentity.test.ts+++ b/apps/mobile/src/__tests__/simIdentity.test.ts@@ -58,9 +58,9 @@ describe('shared simulator environment', () => {it('treats the --mock UI data switch as part of the Metro environment', () => {const dir = mkdtempSync(join(tmpdir(), 'cindy-sim-env-'));try {- const env: Record<string, string> = {};+ const env = {} as NodeJS.ProcessEnv;expect(applySimMockArg(['--mock', '--json'], env)).toEqual(['--json']);- const real = readSimEnvironment(dir, {}, {});+ const real = readSimEnvironment(dir, {}, {} as NodeJS.ProcessEnv);const mock = readSimEnvironment(dir, {}, env);expect([real.uiMock, mock.uiMock]).toEqual([false, true]);expect(mock.envFingerprint).not.toBe(real.envFingerprint);diff --git a/apps/mobile/src/debug/visualMock.ts b/apps/mobile/src/debug/visualMock.tsindex 756f77509a..253bc486aa 100644--- a/apps/mobile/src/debug/visualMock.ts+++ b/apps/mobile/src/debug/visualMock.ts@@ -49,7 +49,9 @@ interface VisualRealDataSnapshot {const NOW = Date.parse('2026-07-18T08:00:00.000Z');const ISO_NOW = new Date(NOW).toISOString();-const UI_MOCK_ROWS = buildUiMockRows({ now: NOW, projectRoot: '/Users/demo/Projects' });+// Built on first use: this module is imported by production code, and only the dev mock reads it.+let uiMockRows: ReturnType<typeof buildUiMockRows> | null = null;+const getUiMockRows = () => uiMockRows ??= buildUiMockRows({ now: NOW, projectRoot: '/Users/demo/Projects' });const IMAGE_DATA_URL ='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAABaAgMAAABCqLXBAAAADFBMVEX9/f2BgoIgISTY2NXfCK5xAAAACXBIWXMAAAsTAAALEwEAmpwYAAACCklEQVR42uWXsU7DMBBAk1rqgKyy9xM6nVSJoQv9BJaKlbVh4QcQfEIXWMsQiSZFav8Ao0hMGVhY+IRMmTogVebslsah1Hd0QYKrYrXOq+98Pp99QcAW+bUDPrtF9U5gt8q7kGfmgRwlAwGmxW7zLjdvu931v5lqxYCSU2VY6KWkPNgBIxpMFI7ZSknVg3SOIzZjei7tETa9OQ22jJGdPg2GE2wKjh+n+Aw54PAPguFmUWM/6MSP8oKdCrz2gk6gjbygE3l3vwzWN8doJxjWN0y8E2zUwcmeYFIueKrR5IIzmQS/HXHcE2O+CjngSAaZUUmCNmoKBtjPJECbAdqfBzSYyACEbNLgNMiEyYAM0ORpBmjWM8gaDFBIUEGDqVpybASQ1WRe3fx9UXcPHmKgntdgLdGf1B0uXIf7wD5OZrOEHtXmIJEmtdBhBqvI5gSueuIELnsrmC0UscCbarv6wUtmkkp0wQPv9bvhbklwrJfWABLUWkfGgLOtJcS7hxtmCL6l6Uy/bAUFigPOEET3POrSC0ZIoFgDvKo7htC6mK7B3Ufc1IKLMTbKe2jOLLi8wqb0HsPHuhIvqJmgcEHlAQ9dsPSAronf616Dej9QccHyn1y5aDn/ydWVfRlmX6/ZF3ZWCYDHuWQVFXZcVpmCKV7Rhc/AFj6C48esqtrIoktIQYuE1XhAfgL4ANer/BnN/IZTAAAAAElFTkSuQmCC';@@ -455,7 +457,7 @@ function realDataProjection(snapshot: VisualRealDataSnapshot, sessionId: string)}function visualMockSessions(statusFilter?: string): RemoteSession[] {- const catalog = UI_MOCK_ROWS.sessions.map(catalogSession);+ const catalog = getUiMockRows().sessions.map(catalogSession);if (statusFilter === 'archived') return catalog.filter((session) => session.status === 'archived');const sessions = [...catalog.filter((session) => statusFilter === 'all' || session.status === 'active'),@@ -529,7 +531,7 @@ function visualMockMessages(sessionId: string): RemoteMessage[] {} as RemoteMessage));}const running = sessionId.includes('running');- const catalog = UI_MOCK_ROWS.messages.filter((row) => row.sessionId === sessionId);+ const catalog = getUiMockRows().messages.filter((row) => row.sessionId === sessionId);if (catalog.length > 0) {const lastAssistant = catalog.map((row) => row.role).lastIndexOf('assistant');return catalog.map((row, index) => {