fix(desktop): 移除附件启动扫描并增加缓存目录清理 - #3410
Conversation
Signed-off-by: DavidShen <david@xd.com>
|
| Filename | Overview |
|---|---|
| apps/desktop/src/main/bootstrap-electron.ts | 移除启动期附件扫描,新增由 Main 解析固定目录、校验当前 owner 并执行确认清理的 IPC 接线。 |
| apps/desktop/src/main/file-browser/remote-file-cache.ts | 删除启动附件清扫实现,并将显式草稿丢弃清理限制在当前 owner 的直属 .bin 文件。 |
| apps/desktop/src/main/cindy-media/storageIpc.ts | 为两个固定缓存目录新增打开和清理处理器,并将底层错误转换为安全 IPC 错误。 |
| apps/desktop/src/renderer/components/settings/StorageManagementCard.tsx | 设置页新增图片与附件缓存目录的打开、清理按钮及操作状态处理。 |
| apps/desktop/src/preload/preload.ts | 暴露四个无路径参数的固定缓存目录 IPC 方法。 |
Sequence Diagram
sequenceDiagram
participant U as 用户
participant R as Renderer 设置页
participant P as Preload
participant M as Main 进程
participant F as 当前 owner 缓存目录
U->>R: 点击清理附件缓存
R->>P: clearChatAttachmentsDir()
P->>M: 固定 IPC(无路径参数)
M->>M: 校验可信 Renderer 并捕获 owner scope
M->>U: 显示原生破坏性确认框
U-->>M: 确认
M->>M: 再次校验 owner scope
M->>F: 递归删除当前 owner 目录
F-->>M: 完成
M-->>P: "{ cleared: true }"
P-->>R: 更新操作状态
Reviews (6): Last reviewed commit: "fix(desktop): 明确缓存清理按钮对象" | Re-trigger Greptile
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 00616e0943
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@DavidShenXD 👋 这个 PR 还有 3 条 review conversation 没 resolve(apps/desktop/src/main/bootstrap-electron.ts / apps/desktop/src/main/file-browser/remote-file-cache.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
Signed-off-by: DavidShen <david@xd.com>
反馈已处理已处理:
变更:
验证:
备注:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cdf4ca3d54
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Signed-off-by: DavidShen <david@xd.com>
反馈已处理已处理:
变更:
验证:
备注:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4c6cf06810
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@DavidShenXD 👋 这个 PR 还有 3 条 review conversation 没 resolve(apps/desktop/src/main/bootstrap-electron.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
Signed-off-by: DavidShen <david@xd.com>
反馈已处理已处理:
变更:
验证:
备注:
|
Signed-off-by: DavidShen <david@xd.com>
反馈已处理已处理:
变更:
验证:
备注:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 85792ff3e3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Signed-off-by: DavidShen <david@xd.com>
反馈已处理已处理:
变更:
验证:
备注:
|
|
命中 UI 路径(apps/desktop/src/renderer/components/settings/StorageManagementCard.tsx)但 description 未附界面效果证据——建议补充改动后效果:截图/录屏,或改动后界面的 HTML 页面(`html 代码块、.html 附件或在线预览链接),便于确认界面符合 DESIGN.md 设计规范 |
反馈已处理已处理:
变更:
验证:
<!doctype html>
<html lang="zh-CN">
<meta charset="utf-8" />
<meta name="color-scheme" content="light dark" />
<title>缓存目录清理入口 - 改后效果</title>
<style>
:root {
--page: #f4f4f2; --card: #ffffff; --text: #20201f; --muted: #70706c;
--border: #deded9; --danger: #e33737; --danger-text: #ffffff;
}
@media (prefers-color-scheme: dark) {
:root {
--page: #1f1f1e; --card: #292927; --text: #f2f2ef; --muted: #aaa9a3;
--border: #444440; --danger: #ef5b5b; --danger-text: #111111;
}
}
* { box-sizing: border-box; }
body { margin: 0; padding: 24px; background: var(--page); color: var(--text); font: 13px/1.45 system-ui, sans-serif; }
main { max-width: 720px; margin: auto; display: grid; gap: 20px; }
.card, .confirm { background: var(--card); border: 1px solid var(--border); border-radius: 14px; }
h2 { margin: 0; padding: 16px 18px 10px; font-size: 14px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; border-top: 1px solid var(--border); }
.copy { min-width: 0; }
.copy strong { display: block; font-weight: 500; }
.copy p, .confirm p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; flex: none; gap: 8px; }
button { border: 1px solid var(--border); border-radius: 999px; padding: 6px 11px; background: transparent; color: var(--text); font: inherit; font-weight: 500; }
.confirm { padding: 18px; }
.confirm strong { font-size: 14px; }
.confirm .actions { justify-content: flex-end; margin-top: 16px; }
.danger { border-color: transparent; background: var(--danger); color: var(--danger-text); }
</style>
<main>
<section class="card" aria-label="存储空间">
<h2>存储空间</h2>
<div class="row">
<div class="copy">
<strong>图片缓存目录</strong>
<p>Cindy 不会自动扫描或清理此目录。删除文件后,历史消息中的图片可能无法显示。</p>
</div>
<div class="actions"><button>打开目录</button><button>清理图片缓存</button></div>
</div>
<div class="row">
<div class="copy">
<strong>消息附件缓存目录</strong>
<p>发送的部分附件会保存在这里。删除文件后,历史消息中的附件可能无法打开。</p>
</div>
<div class="actions"><button>打开目录</button><button>清理附件缓存</button></div>
</div>
</section>
<section class="confirm" aria-label="图片缓存清理确认">
<strong>清理图片缓存?</strong>
<p>只会删除图片缓存目录中的文件,不会读取消息数据库。清理后,历史消息中的图片可能无法显示,且无法恢复。</p>
<div class="actions"><button class="danger">清理图片缓存</button><button autofocus>取消</button></div>
</section>
<section class="confirm" aria-label="附件缓存清理确认">
<strong>清理消息附件缓存?</strong>
<p>只会删除消息附件缓存目录中的文件,不会读取消息数据库。清理后,历史消息中的部分附件可能无法打开,且无法恢复。</p>
<div class="actions"><button class="danger">清理附件缓存</button><button>取消</button></div>
</section>
</main>
</html>
备注:
|
这次改了什么
摘要
移除 Desktop 启动时针对聊天附件旧缓存执行的消息历史扫描,避免
LIKE + json_tree全表查询长期占用单一数据库 worker。设置页同时为图片缓存和消息附件缓存提供固定目录的“打开目录 / 一键清理”入口;清理动作只删除 Main 进程解析出的对应目录,不读取消息数据库或媒体账本。变更类型
feat新功能fix缺陷修复refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
UI 变化
docs/design-rules/DESIGN.md§4 Buttons / Dialog & Modal、§5 Border Radius Scale、§10 Light / Dark Dual-Mode Delivery Gate、§11 Voice & Content。按钮使用 pill 圆角,复用共享确认对话框和现有语义 token,五种语言同步提供文案;未新增硬编码颜色怎么验证的
自动验证
手工验证
未执行 Desktop 实机点击与目录删除验证;固定目录边界、可信 Renderer 校验、无路径参数、无数据库读取及确认交互由定向单测和源码契约测试覆盖。
未执行的验证
pnpm test:unit;按仓库工作流仅运行pnpm test:unit:related,完整单测由 GitHub CI 执行风险
风险分类
影响与回滚
userData下的图片缓存目录cc-agent/images与消息附件缓存目录chat-attachment-cache。清理 IPC 不接收 Renderer 路径,只删除 Main 侧固定目录,不查询消息数据库或媒体账本;不涉及 SSH 工作目录、device-link 或 Mobile 入口apps/mobile原生配置、原生依赖、模块或任何 runtime fingerprint 输入提交前检查
git commit -s,见 DCO)