Skip to content

[6233] 附件转换 PDF 在 ready 或 error 后清理 - #4766

Merged
PinkMagicFly merged 1 commit into
mainfrom
pigmagicfly/6233/attachment-pdf-cleanup
Oct 27, 2026
Merged

PinkMagicFly merged 1 commit into
mainfrom
pigmagicfly/6233/attachment-pdf-cleanup

Conversation

@PinkMagicFly

Copy link
Copy Markdown
Contributor

What

将 .tmu/.tm/.stem 附件转换出的 PDF 改为仅供 ingest 使用的临时文件:

  • dispatch_attachment_ingest 按 taskId 登记宿主转换 PDF。
  • onAttachmentReady 与 onAttachmentError 在事件入口删除 PDF,并尝试删除为空的 UUID 父目录;即使面板已关闭也能清理。
  • 转换成功后面板关闭、条目取消或 ingest 派发失败时,直接清理产物。
  • 普通 PDF 附件不删除原文件;extract/ 抽取缓存与 LLM 读取路径不变。

任务文档:LiiiLabs/dev-agent#257。

Why

转换 PDF 不会被第二次使用。附件抽取完成后,LLM 只按 sha256 读取 extract/result.json,长期保留转换 PDF 只会增加磁盘占用。

真假插件协议

  • 假插件:先写任意假 content 到 extract/result.json,再直接 ready;删除 PDF 后,假 LLM 仍能读取缓存并完成注入。
  • liii 真插件:未命中时先读取 PDF、完成抽取并写缓存,再 ready;缓存命中时先刷新缓存再 ready,不再读取 PDF。error 是本次 ingest 的失败终态,同样清理。
  • ready 表示缓存已写入或刷新,不表示 LLM 已读取;LLM 后续只读 extract/,无需 PDF。

本次只读核实 liii 源码,未修改 liii。

验证

  • ~/.local/bin/xmake b --yes qt_chat_controller_test && ~/.local/bin/xmake r qt_chat_controller_test:43 passed,0 failed;覆盖 ready 删除、error 删除及普通 PDF 保留。
  • ~/.local/bin/xmake b --yes stem && ~/.local/bin/xmake r chat-protocol-test:78 correct,0 failed;覆盖删除 PDF 后的假插件缓存闭环。
  • gf fmt --changed-since=main、gf fmt --check、git diff --check:通过。
  • 未运行 GUI 或真插件联网测试。

🤖 Generated with Claude Code

@MoonL79 MoonL79 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@PinkMagicFly
PinkMagicFly merged commit 8ec2d05 into main Oct 27, 2026
6 checks passed
@PinkMagicFly
PinkMagicFly deleted the pigmagicfly/6233/attachment-pdf-cleanup branch October 27, 2026 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants