Skip to content

feat: 会话附件删除接口与图片输入模型兼容投影 (clean v2)#714

Open
wynxing wants to merge 6 commits into
1024XEngineer:mainfrom
wynxing:feat-session-asset-delete-v2
Open

feat: 会话附件删除接口与图片输入模型兼容投影 (clean v2)#714
wynxing wants to merge 6 commits into
1024XEngineer:mainfrom
wynxing:feat-session-asset-delete-v2

Conversation

@wynxing
Copy link
Copy Markdown
Collaborator

@wynxing wynxing commented Jun 7, 2026

Clean version of PR #712 without formatting noise.

Changes:

  • Reverted 8 files with only formatting changes (trailing newlines, import reordering, tab alignment)
  • All feature changes preserved

This PR replaces #712 with a cleaner diff.

wynxing added 6 commits June 7, 2026 10:28
- 从 RuntimePort 拆出 SessionAssetPort 独立端口,新增 DeleteSessionAsset 方法
- Gateway 注册 DELETE /api/session-assets 端点,多工作区路由和安全 ACL 适配
- CLI Bridge 实现 DeleteSessionAsset,修复 Save 缺少会话存在性校验、Open 缺少 os.ErrNotExist 映射
- Runtime 图片投影:不支持图片的模型对历史图片替换为占位文本,不修改持久化消息
- Runtime 拒绝不支持的当前图片输入,避免上游 400
- Web ChatInput 取消上传时调用 deleteSessionAsset 释放服务端资源
- Web useSessionStore 新增 _pendingNewSession 防止新会话期间自动切换
- 修复 handleSessionAssetRead 中 ACL 检查使用了 sessionAssetDeleteMethod 的 bug
- 修复 handleSessionAssetDelete 中 ACL 检查使用了 sessionAssetReadMethod 的 bug
- 为 newStablePromptSources 添加 nil source 过滤,防止 collectPromptSections panic
- 补充 ACL 独立生效测试(read-only 和 delete-only ACL 场景)
- 补充 nil source 和 mixed nil/valid source 测试
- 补充 multi_workspace Delete 不支持 SessionAssetPort 的错误返回测试
- 补充图片投影空消息和混合消息的边界测试
…setPort 方法被提升的测试缺陷

将 recordingPortWithoutSessionAsset 的嵌入类型从 *recordingPort 改为 RuntimePort 接口,
避免 Go 方法提升机制将 SessionAssetPort 的方法也一并提升,导致类型断言永远成功。
TestNetworkServerSessionAssetACLIndependent 直接用 sessionAssetReadMethod/
sessionAssetDeleteMethod(混合大小写)作为 allow map 键,但 IsAllowed 查找时
用 strings.ToLower 归一化,导致键不匹配返回 403。改用 normalizedMethodSet()
构造内层 map,与生产代码 NewStrictControlPlaneACL 保持一致。
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Copy link
Copy Markdown
Contributor

@fennoai fennoai Bot left a comment

Choose a reason for hiding this comment

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

发现 1 个需要处理的问题。

验证未完成:本地环境中 go 不可用,且 vitest 二进制不可执行,因此未能运行目标测试。

未能定位到 diff 行的发现

  • internal/gateway/network_server.go:698: 这里仍然只允许 GET, POST, OPTIONS,但本 PR 新增的 GatewayAPI.deleteSessionAsset() 会发起带 AuthorizationX-NeoCode-Workspace-HashDELETE 请求。浏览器在跨源场景会先发送 preflight,如果 Access-Control-Allow-Methods 不包含 DELETE,实际删除请求会被浏览器拦截,导致 Web 端无法清理已上传但发送失败的附件。请把 DELETE 加入允许方法,并补一个 OPTIONS 预检覆盖。

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 7, 2026

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.

1 participant