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): 移除启动图片清扫并提供缓存目录入口

DavidShena2b82aefbebb
diff --git a/apps/desktop/src/main/__tests__/imageCacheOrphanSweep.test.ts b/apps/desktop/src/main/__tests__/imageCacheOrphanSweep.test.ts
deleted file mode 100644
index 9ac876e5ad..0000000000
--- a/apps/desktop/src/main/__tests__/imageCacheOrphanSweep.test.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Locks in the DB-reference side of startup draft image sweeping.
- */
-
-import { describe, expect, it, vi } from 'vitest';
-import path from 'node:path';
-import os from 'node:os';
-import { randomUUID } from 'node:crypto';
-
-const userDataDir = path.join(os.tmpdir(), `image-cache-orphan-sweep-${randomUUID()}`);
-
-vi.mock('electron', () => ({
- app: {
- getPath: () => userDataDir,
- },
-}));
-
-const { collectReferencedImageUrlsFromDb, collectReferencedImageUrlsFromRows } =
- await import('../imageCacheOrphanSweep');
-
-describe('imageCacheOrphanSweep reference collection', () => {
- it('collects session xdt-image references from JSON and markdown content', () => {
- const rows = [
- {
- content: JSON.stringify({
- text: 'see image',
- images: [{ url: 'xdt-image://session-a/a.png' }],
- }),
- },
- {
- content: 'inline markdown ![x](xdt-image://session-b/b.webp)',
- },
- {
- content: JSON.stringify({
- images: [{ url: 'xdt-image://feishu-media-images/remote.png' }],
- }),
- },
- ];
-
- expect(collectReferencedImageUrlsFromRows(rows)).toEqual([
- 'xdt-image://session-a/a.png',
- 'xdt-image://session-b/b.webp',
- ]);
- });
-
- it('queries only visible message history when collecting startup references', () => {
- let sql = '';
- const db = {
- prepare(input: string) {
- sql = input;
- return {
- all: () => [{ content: '{"images":[{"url":"xdt-image://session-a/a.png"}]}' }],
- };
- },
- };
-
- expect(collectReferencedImageUrlsFromDb(db)).toEqual(['xdt-image://session-a/a.png']);
- expect(sql).toContain('rewind_at IS NULL');
- expect(sql).toContain("content LIKE '%xdt-image://%'");
- });
-});
diff --git a/apps/desktop/src/main/__tests__/imageCacheStartupSweepDisabled.test.ts b/apps/desktop/src/main/__tests__/imageCacheStartupSweepDisabled.test.ts
new file mode 100644
index 0000000000..a0d6f4f09c
--- /dev/null
+++ b/apps/desktop/src/main/__tests__/imageCacheStartupSweepDisabled.test.ts
@@ -0,0 +1,35 @@
+import { describe, expect, it } from 'vitest';
+import fs from 'node:fs';
+
+describe('legacy image cache settings', () => {
+ it('does not scan message history during startup', () => {
+ const bootstrap = fs.readFileSync(
+ new URL('../bootstrap-electron.ts', import.meta.url),
+ 'utf8',
+ );
+
+ expect(bootstrap).not.toContain('sweepStartupDraftImages');
+ expect(bootstrap).not.toContain('image-cache-orphan-sweep');
+ });
+
+ it('does not expose automatic scan or cleanup handlers', () => {
+ const storageIpc = fs.readFileSync(
+ new URL('../cindy-media/storageIpc.ts', import.meta.url),
+ 'utf8',
+ );
+
+ expect(storageIpc).not.toContain('scanLegacyDraftImages');
+ expect(storageIpc).not.toContain('cleanupLegacyDraftImages');
+ expect(storageIpc).not.toContain('FROM messages INDEXED BY');
+ });
+
+ it('guards the fixed directory opener with the trusted renderer check', () => {
+ const bootstrap = fs.readFileSync(
+ new URL('../bootstrap-electron.ts', import.meta.url),
+ 'utf8',
+ );
+ const start = bootstrap.indexOf("ipcMain.handle('cindy-media:legacy-images-open-dir'");
+ expect(start).toBeGreaterThan(-1);
+ expect(bootstrap.slice(start, start + 300)).toContain('assertTrustedAppRendererEvent(event)');
+ });
+});
diff --git a/apps/desktop/src/main/bootstrap-electron.ts b/apps/desktop/src/main/bootstrap-electron.ts
index 2293114f45..f2a70753d1 100644
--- a/apps/desktop/src/main/bootstrap-electron.ts
+++ b/apps/desktop/src/main/bootstrap-electron.ts
@@ -255,7 +255,6 @@ import {
stageLocalFileToCache,
sweepStagedChatAttachmentsOnStartup,
} from './file-browser/remote-file-cache';
-import { sweepStartupDraftImages } from './imageCacheOrphanSweep';
import { sweepLegacyDialogueWorkingDirs } from './localDb/dialogueWorkdirSelfHeal';
import { legacyDialogueUserDataDirNames } from '@cindy/maker-shared/brand-identity';
import * as videoCacheStore from './videoCacheStore';
@@ -7007,6 +7006,19 @@ const registerIpcHandlers = () => {
getQueueScanTexts: collectAgentInputQueueScanTexts,
loadSnapshotPayloads: loadAllQueueSnapshotPayloads,
getRegisteredDraftUrls: getAllRegisteredDraftUrls,
+ openLegacyImagesDir: async () => {
+ const rootDir = imageCacheStore.getCacheRoot();
+ try {
+ const stat = await fs.promises.lstat(rootDir);
+ if (!stat.isDirectory()) return false;
+ } catch (err) {
+ if ((err as NodeJS.ErrnoException)?.code === 'ENOENT') return false;
+ throw err;
+ }
+ const error = await shell.openPath(rootDir);
+ if (error) throw new Error(error);
+ return true;
+ },
});
ipcMain.handle('cindy-media:storage-stats', () => storageHandlers.stats());
ipcMain.handle('cindy-media:storage-scan', (_event, params: { draftUrls: string[] }) =>
@@ -7026,6 +7038,10 @@ const registerIpcHandlers = () => {
) => storageHandlers.cleanup(params),
);
ipcMain.handle('cindy-media:storage-reconcile', () => storageHandlers.reconcile());
+ ipcMain.handle('cindy-media:legacy-images-open-dir', (event) => {
+ assertTrustedAppRendererEvent(event);
+ return storageHandlers.openLegacyImagesDir();
+ });
}
// F5: SDK send-time temporary base64 read (renderer-initiated; main-initiated
@@ -7504,7 +7520,7 @@ app.on('ready', async () => {
// 必须先 await ensureLifecycleDbClient(内部 await createDbClient → worker
// spawn + db open + migration scan + smoke,约 1-2s),把 client 经
// setCurrentDbClient 暴露给全局 getDbClient() 之后,后续 attemptStartScheduler /
- // attemptStartEmbeddingHost / sweepStartupDraftImages 才能拿到 ready 的 DbClient。
+ // attemptStartEmbeddingHost 等后续启动任务才能拿到 ready 的 DbClient。
//
// 历史:MR2.0 时这里是 fire-and-forget,scheduler/embedding 走老 getDrizzle/getRawDb
// 路径不受影响。MR2.2 把 158 callsite 切到 DbClient 后,fire-and-forget 让后续
@@ -7804,23 +7820,6 @@ app.on('ready', async () => {
elapsedMs: Math.round(performance.now() - startedAt),
});
}
- void sweepStartupDraftImages({
- dbClient: getDbClient(),
- processStartedAtMs: PROCESS_STARTED_AT_MS,
- })
- .then((result) => {
- if (result.removed === 0 && result.removedDanglingMeta === 0 && result.errors === 0)
- return;
- createLogger('image-cache-orphan-sweep').info(
- 'startup draft image sweep completed',
- result,
- );
- })
- .catch((err) => {
- createLogger('image-cache-orphan-sweep').warn('startup draft image sweep failed', {
- error: err instanceof Error ? err.message : String(err),
- });
- });
},
(err) => {
accountSwitchLog.warn('account provider readiness rejected unexpectedly', {
diff --git a/apps/desktop/src/main/cindy-media/__tests__/storageIpc.test.ts b/apps/desktop/src/main/cindy-media/__tests__/storageIpc.test.ts
index 3d27b53dbc..b6a695bdc0 100644
--- a/apps/desktop/src/main/cindy-media/__tests__/storageIpc.test.ts
+++ b/apps/desktop/src/main/cindy-media/__tests__/storageIpc.test.ts
@@ -98,6 +98,7 @@ function makeHandlers(overrides?: {
queueTexts?: string[];
snapshotPayloads?: string[];
registeredDraftUrls?: string[];
+ openLegacyImagesDir?: () => Promise<boolean>;
}) {
return createStorageIpcHandlers({
getQueueScanTexts: () => overrides?.queueTexts ?? [],
@@ -105,6 +106,7 @@ function makeHandlers(overrides?: {
getRegisteredDraftUrls: () => overrides?.registeredDraftUrls ?? [],
db,
legacyRootDir: legacyRoot,
+ openLegacyImagesDir: overrides?.openLegacyImagesDir ?? (async () => false),
});
}
@@ -120,7 +122,7 @@ describe('stats(占用总览)', () => {
expect(res.blobs.totalCount).toBe(2);
expect(res.blobs.totalBytes).toBe(a.bytes + c.bytes);
expect(res.blobs.cacheBytes).toBe(c.bytes);
- expect(res.legacy.bytes).toBe(6); // 'legacy'
+ expect(res.legacy.bytes).toBe(0); // Settings mount never walks the legacy image root.
expect(res.deadDirs).toHaveLength(3);
});
});
@@ -219,3 +221,13 @@ describe('reconcile(体检只报不删)', () => {
expect(await ledger.getBlobInfo(missing.hash, db)).not.toBeNull();
});
});
+
+describe('legacy images directory', () => {
+ it('opens only through the fixed-purpose main dependency', async () => {
+ const openLegacyImagesDir = vi.fn(async () => true);
+ const result = await makeHandlers({ openLegacyImagesDir }).openLegacyImagesDir();
+
+ expect(result).toEqual({ opened: true });
+ expect(openLegacyImagesDir).toHaveBeenCalledWith();
+ });
+});
diff --git a/apps/desktop/src/main/cindy-media/storageIpc.ts b/apps/desktop/src/main/cindy-media/storageIpc.ts
index a79b96d936..410a962e36 100644
--- a/apps/desktop/src/main/cindy-media/storageIpc.ts
+++ b/apps/desktop/src/main/cindy-media/storageIpc.ts
@@ -5,7 +5,7 @@
* ipcMain.handle 适配,测试用内存 harness 直接调 handler body。
*
* 交互契约(一律先报数后动手):
- * - stats:占用总览(账面统计 + 历史兼容层只读占用 + 死目录);
+ * - stats:占用总览(账面统计 + 死目录;不在设置页挂载时遍历历史图片目录);
* - scan:清理预检——renderer 随参带草稿附件 URL(§4 暂存区 (1)),这里
* 叠加内存队列 (2) 与崩溃快照 (3) 组成活引用集,产出各类可清理项报数;
* - cleanup:执行清理——只认 scan 返回并经用户确认的指纹/目录清单,执行
@@ -41,6 +41,8 @@ export interface StorageIpcDeps {
db?: ledger.LedgerDb;
/** 测试注入死目录根;生产缺省 userData/cc-agent。 */
legacyRootDir?: string;
+ /** Fixed-purpose directory opener. It returns false when the legacy directory is absent. */
+ openLegacyImagesDir?: () => Promise<boolean>;
}
export interface StorageStatsResult {
@@ -127,14 +129,29 @@ async function collectLive(deps: StorageIpcDeps, draftUrls: string[]): Promise<S
export function createStorageIpcHandlers(deps: StorageIpcDeps) {
return {
+ async openLegacyImagesDir(): Promise<{ opened: boolean }> {
+ if (!deps.openLegacyImagesDir) {
+ throwIpcError('INTERNAL', 'legacy image directory opener is unavailable');
+ }
+ try {
+ return { opened: await deps.openLegacyImagesDir() };
+ } catch (err) {
+ log.warn('open legacy image directory failed', {
+ error: err instanceof Error ? err.message : String(err),
+ });
+ throwIpcError('INTERNAL', 'failed to open legacy image directory');
+ }
+ },
+
async stats(): Promise<StorageStatsResult> {
try {
- const [blobs, legacy, deadDirs] = await Promise.all([
+ const [blobs, deadDirs] = await Promise.all([
ledger.getStorageStats(deps.db),
- legacyDeadDirs.getLegacyRootUsage(deps.legacyRootDir),
legacyDeadDirs.scanDeadDirs(deps.legacyRootDir),
]);
- return { success: true, blobs, legacy, deadDirs };
+ // The legacy root can contain many image sidecars. Do not walk it when the
+ // settings page mounts; users manage that fixed directory outside Cindy.
+ return { success: true, blobs, legacy: { bytes: 0, fileCount: 0 }, deadDirs };
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
log.warn('storage stats failed', { error: message });
diff --git a/apps/desktop/src/main/imageCacheOrphanSweep.ts b/apps/desktop/src/main/imageCacheOrphanSweep.ts
deleted file mode 100644
index 336c847389..0000000000
--- a/apps/desktop/src/main/imageCacheOrphanSweep.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * Startup orphan sweep for unsent draft images.
- *
- * The renderer composer draft is intentionally in-memory only, but image bytes
- * for an existing session live on disk. On a new process start any file still
- * marked as `draft` and not referenced by SQLite message history is no longer
- * reachable by the UI, so it can be removed.
- */
-
-import * as imageCacheStore from './imageCacheStore.js';
-import type { DbClient } from './localDb/client/DbClient.js';
-
-type RawDbLike = {
- prepare(sql: string): {
- all(): unknown[];
- };
-};
-
-type MessageContentRow = {
- content: unknown;
-};
-
-const REFERENCED_IMAGE_ROWS_SQL = `SELECT content
- FROM messages
- WHERE rewind_at IS NULL
- AND content LIKE '%xdt-image://%'`;
-
-export interface StartupDraftImageSweepResult extends imageCacheStore.SweepDraftImagesResult {
- referencedUrls: number;
-}
-
-function isMessageContentRow(row: unknown): row is MessageContentRow {
- return !!row && typeof row === 'object' && 'content' in row;
-}
-
-export function collectReferencedImageUrlsFromRows(rows: unknown[]): string[] {
- const urls = new Set<string>();
- for (const row of rows) {
- if (!isMessageContentRow(row)) continue;
- for (const url of imageCacheStore.collectSessionImageUrls(row.content)) {
- urls.add(url);
- }
- }
- return [...urls];
-}
-
-export function collectReferencedImageUrlsFromDb(db: RawDbLike): string[] {
- const rows = db
- .prepare(REFERENCED_IMAGE_ROWS_SQL)
- .all();
- return collectReferencedImageUrlsFromRows(rows);
-}
-
-export async function collectReferencedImageUrlsFromDbClient(
- dbClient: Pick<DbClient, 'query'>,
-): Promise<string[]> {
- const rows = await dbClient.query<MessageContentRow>(REFERENCED_IMAGE_ROWS_SQL);
- return collectReferencedImageUrlsFromRows(rows);
-}
-
-export async function sweepStartupDraftImages(params: {
- db?: RawDbLike;
- dbClient?: Pick<DbClient, 'query'>;
- processStartedAtMs: number;
-}): Promise<StartupDraftImageSweepResult> {
- const referencedUrls = params.dbClient
- ? await collectReferencedImageUrlsFromDbClient(params.dbClient)
- : collectReferencedImageUrlsFromDb(params.db!);
- const sweep = await imageCacheStore.sweepDraftImages({
- referencedUrls,
- createdBeforeMs: params.processStartedAtMs,
- });
- return { ...sweep, referencedUrls: referencedUrls.length };
-}
diff --git a/apps/desktop/src/main/imageCacheStore.ts b/apps/desktop/src/main/imageCacheStore.ts
index 5c82cfdab5..33eaab1fce 100644
--- a/apps/desktop/src/main/imageCacheStore.ts
+++ b/apps/desktop/src/main/imageCacheStore.ts
@@ -10,7 +10,6 @@
* cleanup-session / cleanup-files)
* - xdt-image:// protocol handler
* - agentManager.buildContentBlocks (F5 temporary base64 read)
- * - startup orphan sweep for unsent draft images
*
* Security model: every URL→absPath resolution funnels through `resolveSafe`
* which path-resolves against the cache root and rejects anything that escapes.
diff --git a/apps/desktop/src/preload/preload.ts b/apps/desktop/src/preload/preload.ts
index 77111a9e6f..40d1f90ada 100644
--- a/apps/desktop/src/preload/preload.ts
+++ b/apps/desktop/src/preload/preload.ts
@@ -3867,6 +3867,9 @@ contextBridge.exposeInMainWorld('electronAPI', {
ipcRenderer.send('cindy-media:report-draft-urls', urls);
},
+ openLegacyImagesDir: (): Promise<{ opened: boolean }> =>
+ ipcRenderer.invoke('cindy-media:legacy-images-open-dir'),
+
stats: (): Promise<{
success: boolean;
error?: string;
diff --git a/apps/desktop/src/renderer/components/settings/StorageManagementCard.tsx b/apps/desktop/src/renderer/components/settings/StorageManagementCard.tsx
index 064dbe6214..d05c9e6ae7 100644
--- a/apps/desktop/src/renderer/components/settings/StorageManagementCard.tsx
+++ b/apps/desktop/src/renderer/components/settings/StorageManagementCard.tsx
@@ -55,6 +55,15 @@ export function StorageManagementCard() {
void refreshStats();
}, []);
+ const handleOpenLegacyImagesDir = async () => {
+ try {
+ const result = await window.electronAPI.cindyMediaStorage.openLegacyImagesDir();
+ if (!result.opened) toast.info(t('settings.about.storage.legacyImagesDirectoryMissing'));
+ } catch {
+ toast.error(t('settings.about.storage.legacyImagesOpenFailed'));
+ }
+ };
+
const handleScan = async () => {
if (cleanupBusyRef.current) return;
cleanupBusyRef.current = true;
@@ -159,11 +168,22 @@ export function StorageManagementCard() {
: ''}
</span>
</div>
- {stats?.success && stats.legacy.bytes > 0 && (
+ </div>
+
+ <Divider />
+
+ <div className="flex items-center justify-between gap-3 px-[18px] py-4">
+ <div className="flex min-w-0 flex-col gap-1">
+ <span className="text-13 text-[var(--settings-section-sublabel)]">
+ {t('settings.about.storage.legacyImagesLabel')}
+ </span>
<p className="text-12 leading-[1.4] text-[var(--settings-section-sublabel)] opacity-70">
- {t('settings.about.storage.legacyUsage', { size: formatBytes(stats.legacy.bytes) })}
+ {t('settings.about.storage.legacyImagesDescription')}
</p>
- )}
+ </div>
+ <CardButton onClick={handleOpenLegacyImagesDir}>
+ {t('settings.about.storage.legacyImagesOpenButton')}
+ </CardButton>
</div>
<Divider />
diff --git a/apps/desktop/src/renderer/components/settings/__tests__/StorageManagementCard.test.tsx b/apps/desktop/src/renderer/components/settings/__tests__/StorageManagementCard.test.tsx
new file mode 100644
index 0000000000..21ac387ce0
--- /dev/null
+++ b/apps/desktop/src/renderer/components/settings/__tests__/StorageManagementCard.test.tsx
@@ -0,0 +1,93 @@
+// @vitest-environment jsdom
+
+import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+const { toast } = vi.hoisted(() => ({
+ toast: {
+ success: vi.fn(),
+ error: vi.fn(),
+ info: vi.fn(),
+ },
+}));
+
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+vi.mock('@/lib/toast', () => ({ toast }));
+vi.mock('@/lib/composerDraftStore', () => ({ getAllDraftAttachmentUrls: () => [] }));
+
+import { StorageManagementCard } from '../StorageManagementCard';
+
+function storageApi() {
+ return {
+ reportDraftUrls: vi.fn(),
+ openLegacyImagesDir: vi.fn(async () => ({ opened: true })),
+ stats: vi.fn(async () => ({
+ success: true,
+ blobs: { totalCount: 0, totalBytes: 0, cacheCount: 0, cacheBytes: 0 },
+ legacy: { bytes: 0, fileCount: 0 },
+ deadDirs: [],
+ })),
+ scan: vi.fn(),
+ cleanup: vi.fn(),
+ reconcile: vi.fn(),
+ };
+}
+
+beforeEach(() => {
+ toast.success.mockReset();
+ toast.error.mockReset();
+ toast.info.mockReset();
+ Object.defineProperty(window, 'electronAPI', {
+ configurable: true,
+ value: { cindyMediaStorage: storageApi() },
+ });
+});
+
+afterEach(cleanup);
+
+describe('StorageManagementCard legacy images', () => {
+ it('renders the directory action without scanning legacy images', async () => {
+ render(<StorageManagementCard />);
+
+ await waitFor(() => {
+ expect(window.electronAPI.cindyMediaStorage.stats).toHaveBeenCalledWith();
+ });
+ expect(
+ screen.getByRole('button', { name: 'settings.about.storage.legacyImagesOpenButton' }),
+ ).toBeTruthy();
+ expect(window.electronAPI.cindyMediaStorage.scan).not.toHaveBeenCalled();
+ expect(window.electronAPI.cindyMediaStorage.cleanup).not.toHaveBeenCalled();
+ });
+
+ it('opens the fixed legacy image directory through the dedicated API', async () => {
+ render(<StorageManagementCard />);
+
+ fireEvent.click(
+ screen.getByRole('button', { name: 'settings.about.storage.legacyImagesOpenButton' }),
+ );
+
+ await waitFor(() => {
+ expect(window.electronAPI.cindyMediaStorage.openLegacyImagesDir).toHaveBeenCalledWith();
+ });
+ });
+
+ it('reports a missing legacy directory without creating one', async () => {
+ vi.mocked(window.electronAPI.cindyMediaStorage.openLegacyImagesDir).mockResolvedValue({
+ opened: false,
+ });
+ render(<StorageManagementCard />);
+
+ fireEvent.click(
+ screen.getByRole('button', { name: 'settings.about.storage.legacyImagesOpenButton' }),
+ );
+
+ await waitFor(() => {
+ expect(toast.info).toHaveBeenCalledWith(
+ 'settings.about.storage.legacyImagesDirectoryMissing',
+ );
+ });
+ });
+});
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index cce2d90bf7..05495a82da 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -821,6 +821,11 @@
"usageValue": "{{size}} ({{count}} files, {{cacheSize}} cache)",
"statsFailed": "Stats temporarily unavailable",
"legacyUsage": "Legacy data (read-only, not part of cleanup): {{size}}",
+ "legacyImagesLabel": "Image cache folder",
+ "legacyImagesDescription": "Cindy does not scan or clean this folder automatically. Deleting files may make images in message history unavailable; review them before deleting.",
+ "legacyImagesOpenButton": "Open folder",
+ "legacyImagesDirectoryMissing": "The image cache folder was not found",
+ "legacyImagesOpenFailed": "Could not open the image cache folder. Try again.",
"cleanupLabel": "Disk cleanup",
"cleanupDescription": "Scans for media files no session references anymore, oversized caches, and obsolete folders. Shows the numbers first and deletes only after you confirm; images in composer drafts and queued messages are protected automatically.",
"scanButton": "Scan",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index a367cefbfe..9254412ece 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -821,6 +821,11 @@
"usageValue": "{{size}}({{count}} ファイル、うちキャッシュ {{cacheSize}})",
"statsFailed": "統計は一時的に利用できません",
"legacyUsage": "旧バージョンのデータ(読み取り専用、クリーンアップ対象外): {{size}}",
+ "legacyImagesLabel": "画像キャッシュフォルダー",
+ "legacyImagesDescription": "Cindy はこのフォルダーを自動でスキャンまたはクリーンアップしません。ファイルを削除するとメッセージ履歴の画像が表示できなくなる場合があるため、内容を確認してから操作してください。",
+ "legacyImagesOpenButton": "フォルダーを開く",
+ "legacyImagesDirectoryMissing": "画像キャッシュフォルダーが見つかりません",
+ "legacyImagesOpenFailed": "画像キャッシュフォルダーを開けませんでした。もう一度お試しください。",
"cleanupLabel": "ディスククリーンアップ",
"cleanupDescription": "どのセッションからも参照されていないメディアファイル、上限を超えたキャッシュ、不要になったフォルダをスキャンします。まず件数を表示し、確認後にのみ削除します。入力欄の下書きや送信待ちメッセージ内の画像は自動的に保護されます。",
"scanButton": "スキャン",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 24715f5603..641041a957 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -821,6 +821,11 @@
"usageValue": "{{size}}({{count}}개 파일, 캐시 {{cacheSize}} 포함)",
"statsFailed": "통계를 일시적으로 사용할 수 없습니다",
"legacyUsage": "이전 버전 데이터(읽기 전용, 정리 대상 아님): {{size}}",
+ "legacyImagesLabel": "이미지 캐시 폴더",
+ "legacyImagesDescription": "Cindy는 이 폴더를 자동으로 검사하거나 정리하지 않습니다. 파일을 삭제하면 메시지 기록의 이미지가 표시되지 않을 수 있으므로 확인 후 작업해 주세요.",
+ "legacyImagesOpenButton": "폴더 열기",
+ "legacyImagesDirectoryMissing": "이미지 캐시 폴더를 찾을 수 없습니다",
+ "legacyImagesOpenFailed": "이미지 캐시 폴더를 열 수 없습니다. 다시 시도해 주세요.",
"cleanupLabel": "디스크 정리",
"cleanupDescription": "어떤 세션에서도 참조하지 않는 미디어 파일, 한도를 초과한 캐시, 사용하지 않는 폴더를 검사합니다. 먼저 수치를 보여주고 확인 후에만 삭제합니다. 입력창 초안과 대기 중인 메시지의 이미지는 자동으로 보호됩니다.",
"scanButton": "검사",
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 68d07b5a0b..e3083a9f4f 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -821,6 +821,11 @@
"usageValue": "{{size}}({{count}} 个文件,含缓存 {{cacheSize}})",
"statsFailed": "统计暂不可用",
"legacyUsage": "旧版本数据(只读,不参与清理):{{size}}",
+ "legacyImagesLabel": "图片缓存目录",
+ "legacyImagesDescription": "Cindy 不会自动扫描或清理此目录。删除文件后,历史消息中的图片可能无法显示,请自行确认后操作。",
+ "legacyImagesOpenButton": "打开目录",
+ "legacyImagesDirectoryMissing": "没有找到图片缓存目录",
+ "legacyImagesOpenFailed": "无法打开图片缓存目录,请重试",
"cleanupLabel": "磁盘清理",
"cleanupDescription": "扫描没有被任何任务引用的媒体文件、超限缓存与废弃目录。先报数,确认后才删除;输入框草稿和排队消息里的图片会被自动保护。",
"scanButton": "扫描",
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 ad675a4480..21b10671c4 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -821,6 +821,11 @@
"usageValue": "{{size}}({{count}} 個檔案,含快取 {{cacheSize}})",
"statsFailed": "統計暫不可用",
"legacyUsage": "舊版本資料(只讀,不參與清理):{{size}}",
+ "legacyImagesLabel": "圖片快取目錄",
+ "legacyImagesDescription": "Cindy 不會自動掃描或清理此目錄。刪除檔案後,歷史訊息中的圖片可能無法顯示,請自行確認後操作。",
+ "legacyImagesOpenButton": "開啟目錄",
+ "legacyImagesDirectoryMissing": "找不到圖片快取目錄",
+ "legacyImagesOpenFailed": "無法開啟圖片快取目錄,請重試",
"cleanupLabel": "磁碟清理",
"cleanupDescription": "掃描沒有被任何任務引用的媒體檔案、超限快取與廢棄目錄。先報數,確認後才刪除;輸入框草稿和排隊訊息裡的圖片會被自動保護。",
"scanButton": "掃描",
diff --git a/apps/desktop/src/renderer/vite-env.d.ts b/apps/desktop/src/renderer/vite-env.d.ts
index 235e65ba1f..23c4799f78 100644
--- a/apps/desktop/src/renderer/vite-env.d.ts
+++ b/apps/desktop/src/renderer/vite-env.d.ts
@@ -3462,6 +3462,7 @@ interface ElectronAPI {
cindyMediaStorage: {
/** 本窗口草稿附件 URL 变化时上报(fire-and-forget;多窗口防误删取证)。 */
reportDraftUrls: (urls: string[]) => void;
+ openLegacyImagesDir: () => Promise<{ opened: boolean }>;
stats: () => Promise<{
success: boolean;
error?: string;