倪程伟
fcb488c567
feat(workspace): chat-uploads 上传目录工作空间/Agent 感知化 ( #422 )
...
* feat(workspace): chat-uploads 上传目录工作空间/Agent 感知化 (#421 )
把硬编码的 data/chat-uploads/{conversationId}/ 改为按工作空间/Agent 解析,
解析优先级:Agent workspaceBasePath → Workspace basePath → 可配置默认目录
(新配置 mateclaw.chat.upload.base-dir,默认 data/chat-uploads,保持现网零行为变化)。
- 新增 ChatUploadLocationResolver 中央解析器:写路径返回唯一根,读/清理
路径返回候选根列表(工作空间根 + 默认根)做双重查找,保证迁移前旧附件
仍可解析/清理;conversationId→ConversationEntity 查询带 5min 缓存。
- 新增 ChatUploadProperties + ChatUploadAutoConfiguration(启动建目录)。
- 复用 AgentGraphBuilder.resolveAgentBasePath(提升为 public)的优先级与
安全规则(相对路径在 workspace 根下解析,绝对路径逃逸被拒)。
- 所有写入/读取点改为走 resolver;读取点走双重查找。
- 解决 Spring 循环依赖(resolver → agentService → ... → conversationService
→ resolver):resolver 的 AgentService 注入加 @Lazy。
向后兼容:默认目录不变;双重查找覆盖历史消息里的相对路径;
服务端点 URL 契约不变,前端无需改动。
测试:新增 ChatUploadLocationResolverTest(8 用例);修复受影响的现有测试构造。
* refactor(workspace): address review findings on chat-uploads resolver (#421 )
应用 code review 的 4 项修复:
1. (correctness) ChatUploadLocationResolver 缓存新增 ConversationDeletedEvent
监听器,删除会话时立即失效 conversationId→ConversationEntity 映射。
否则备份恢复后用相同 id 重建会话,会继承最长 5 分钟的过期 workspace/agent
映射,导致 cleanAttachmentFiles 走错(过期的)上传目录。复用既有
@EventListener-on-bean 模式(与 AsyncTaskService / WorkspaceLookupCache 一致)。
2. 收紧 resolveWorkspaceScopedRoot 里 3 个过宽的 catch(Exception) →
MateClawException + warn,让真正的 bug(NPE / DataAccessException)暴露
而非被静默降级为 debug 日志。
3. 更新 ChatController.upload 过期注释:会话尚未创建时附件暂存默认目录,
会话创建后读取走双重查找仍能命中。
4. 移除不可达分支(agentWorkspaceId != workspaceId)—— 会话的 agent 必然
归属会话的 workspace(创建时强约束),直接用会话 workspace 即可,
少一次冗余 DB 查询与一层推测性逻辑。
测试:ChatUploadLocationResolverTest (8) + ConversationServiceCleanAttachmentFilesTest (2) 全绿。
2026-06-26 14:20:54 +08:00
matevip
6a4318c268
fix(channel): IM conversations respect per-conversation model selection ( #183 )
2026-05-20 17:49:03 +08:00
matevip
43136fc663
fix(channel): sweep orphan tool rows + guard rules; scope rule name to channel
2026-05-20 16:35:57 +08:00
matevip
12ff190392
feat(feishu): transcribe inbound voice messages via SttService
2026-05-20 16:35:46 +08:00
matevip
6b397a10ed
feat(feishu): inbound file/audio/video download — SDK path + cache push
2026-05-20 15:53:40 +08:00
matevip
a9fa8e7fb1
sync: interactive approval card on Feishu via Schema-2.0 button + card.action callback
2026-05-20 12:05:47 +08:00
matevip
35f010d7a1
sync: Feishu CardKit streaming-card adapter via cardkit/v1 SDK
2026-05-20 11:37:12 +08:00
matevip
0e1b8ca564
sync: componentized media upload SPI + Feishu SDK-backed file sender
2026-05-20 11:23:33 +08:00
matevip
0ffc224623
chore(test): backfill mateclaw-server/src/test/ that earlier PRIVATE_ITEMS pattern accidentally excluded
...
The PRIVATE_ITEMS list contained the bare 'test' entry, which rsync
interprets as 'any directory named test at any depth' — so it caught
the root-level /test/ scratch directory (intended) AND every src/test/
under each module (not intended).
Pattern is already anchored to /test (root-only). This commit rsyncs
the accumulated src/test/ tree forward so opensource has the unit tests
that have been written / updated against existing src/main/ code since
the pattern regression. Going forward each per-commit sync will carry
src/test/ files along with the main change.
2026-05-12 17:38:08 +08:00