Skip to content

feat(gateway): 新增 deleteSession/renameSession/listFiles/listModels 等核心能力#537

Merged
pionxe merged 8 commits into1024XEngineer:mainfrom
Yumiue:gateway-backend-extract
May 1, 2026
Merged

feat(gateway): 新增 deleteSession/renameSession/listFiles/listModels 等核心能力#537
pionxe merged 8 commits into1024XEngineer:mainfrom
Yumiue:gateway-backend-extract

Conversation

@Yumiue
Copy link
Copy Markdown
Collaborator

@Yumiue Yumiue commented May 1, 2026

摘要

本 PR 从 #520 中提取 Gateway 后端核心改动,排除前端 web 文件,便于独立评审与合入。

变更内容

1. Gateway 核心模块 (internal/gateway/)

  • 扩展协议帧处理:新增 deleteSessionrenameSessionlistFileslistModelssetSessionModelgetSessionModel 等 handler
  • 新增 FileEntryModelEntrySessionModelResult 等契约类型
  • 强化安全校验与认证逻辑(本地模式支持、空 token 拦截)
  • 补齐 jsonrpcrpc_dispatchbootstrap 等核心模块的单元测试覆盖

2. CLI Gateway 运行时桥接 (internal/cli/gateway_*.go)

  • gateway_runtime_bridge 适配新增的 RuntimePort 方法
  • 引入 bridgeSessionStore / bridgeSessionLoader 接口,解耦对具体存储实现的依赖
  • 补齐 gateway_runtime_bridge_test.goroot_test.go 中 stub 的新接口实现

3. 文档 (docs/gateway-*.md)

  • 扩展 gateway-rpc-api.md,补充新增接口定义与示例
  • 更新 gateway-compatibility.md 兼容性说明

4. 必要依赖 (internal/app/bootstrap.go)

  • RuntimeBundle 补充 SessionStore 字段,支撑 gateway runtime bridge 的会话管理能力

测试计划

  • go build ./... 编译通过
  • go test ./internal/gateway/... 通过
  • go test ./internal/cli/... 通过

额外修复

  • 修复 gateway_runtime_bridge_test.gorpc_dispatch_test.go 中的测试 stub 编译错误(函数签名不匹配)

Yumiue and others added 4 commits May 1, 2026 10:35
- 扩展 gateway 协议帧处理:新增 deleteSession、renameSession、listFiles、
  listModels、setSessionModel、getSessionModel 等 handler
- 新增 FileEntry、ModelEntry、SessionModelResult 等契约类型
- 强化安全校验与认证逻辑(本地模式支持、空 token 拦截)
- 补齐 gateway 核心模块的单元测试覆盖
- app/bootstrap 补充 SessionStore 字段,支撑 gateway runtime bridge 的会话管理能力

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- gateway_runtime_bridge 适配新增的 DeleteSession、RenameSession、
  ListFiles、ListModels、SetSessionModel、GetSessionModel 等 RuntimePort 方法
- 桥接层引入 bridgeSessionStore / bridgeSessionLoader 接口,解耦对具体存储实现
- 补齐 gateway_runtime_bridge_test.go 与 root_test.go 中 stubRuntimePort 的新接口实现

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- 扩展 gateway-rpc-api.md,补充 deleteSession、renameSession、listFiles、
  listModels、setSessionModel、getSessionModel 等接口定义与示例
- 更新 gateway-compatibility.md 兼容性说明

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- rpc_dispatch_test: runtimePortOnlyStub 补充 CreateSession 方法,
  适配 RuntimePort 接口新增的方法签名
- gateway_runtime_bridge_test: 修复 3 处 newGatewayRuntimePortBridge 调用,
  补充 bridgeSessionStore 参数;为 runtimeStub 补充 DeleteSession / UpdateSessionState

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@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

@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.

完成四轮审查(代码质量、性能、安全、文档一致性)后,保留了 2 条需要关注的发现。

Comment thread internal/cli/gateway_runtime_bridge.go
Comment thread docs/gateway-compatibility.md Outdated
- dispatcher_integration_unix_test: urlschemeIntegrationRuntimeStub 补充
  DeleteSession、RenameSession、ListFiles、ListModels、SetSessionModel、
  GetSessionModel 方法,适配 RuntimePort 接口扩展

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Yumiue and others added 3 commits May 1, 2026 11:02
test(cli): 补齐 gateway_commands 日志级别与工作目录测试

- gateway-compatibility.md Stable Core 补充 deleteSession、renameSession、
  listFiles、listModels、setSessionModel、getSessionModel
- gateway_commands_test.go 新增 normalizeGatewayLogLevel 与 mustReadInheritedWorkdir 测试

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- bootstrap_test: 新增 6 个新 handler 错误路径测试、8 个 management port
  handler 错误路径测试、3 个 payload decode 分支测试、认证分支测试、
  错误码映射测试
- validate_test: 新增新 action 校验规则测试、InputParts 测试、decode
  错误测试、model/mcp 转换测试、frame action 有效性测试
- jsonrpc_test: 新增 12 个新 RPC 方法的 missing/invalid params 错误测试、
  可选参数方法测试

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
test(gateway): 补齐 gateway_runtime_bridge 错误路径与分支覆盖

- 将 configManager 和 providerSelection 字段改为接口类型
  (configManagerPort / providerSelectorPort),使测试可注入 mock
- 新增 DeleteSession、RenameSession、ListFiles、ListModels、
  SetSessionModel、GetSessionModel 错误路径测试
- 新增 Provider/MCP 管理错误路径测试
- 新增 resolveListFilesRoot、resolveProviderModelForSession、
  modelDisplayName 分支测试

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@pionxe pionxe merged commit b93c785 into 1024XEngineer:main May 1, 2026
3 checks passed
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