fix: 修复多处小型回归#4946
Conversation
WalkthroughThis PR addresses four bug fixes and enhancements spanning backend APIs, relay stream handling, task orchestration, and frontend UX: token creation now returns the created token, Claude streaming preserves intentional model mapping, remix operations use upstream task identifiers, clipboard detection safeguards HTTP deployments, missing UI translations are filled for multiple locales, and popover styling becomes responsive. ChangesBackend API and Relay Logic Improvements
Frontend Polish and Localization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ast-grep (0.42.2)web/classic/src/components/table/channels/modals/EditChannelModal.jsxThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
relay/channel/claude/relay_claude_test.go (1)
55-75: ⚡ Quick winConsider adding a complementary test case for when model is not mapped.
The test correctly verifies that mapped model names are preserved. For completeness, consider adding a test case that verifies the model name IS updated when
IsModelMapped=false:📝 Suggested additional test case
func TestHandleStreamResponseDataUpdatesUnmappedModelName(t *testing.T) { gin.SetMode(gin.TestMode) recorder := httptest.NewRecorder() c, _ := gin.CreateTestContext(recorder) c.Request = httptest.NewRequest("POST", "/v1/messages", nil) info := &relaycommon.RelayInfo{ RelayFormat: types.RelayFormatClaude, ChannelMeta: &relaycommon.ChannelMeta{ IsModelMapped: false, UpstreamModelName: "original-model", }, } claudeInfo := &ClaudeResponseInfo{Usage: &dto.Usage{}} data := `{"type":"message_start","message":{"id":"msg_123","model":"provider-claude-model","usage":{"input_tokens":1,"output_tokens":1}}}` err := HandleStreamResponseData(c, info, claudeInfo, data) require.Nil(t, err) require.Equal(t, "provider-claude-model", info.UpstreamModelName) }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@relay/channel/claude/relay_claude_test.go` around lines 55 - 75, Add a complementary unit test to verify behaviour when the channel is not model-mapped: create a test (e.g., TestHandleStreamResponseDataUpdatesUnmappedModelName) that sets relaycommon.RelayInfo.ChannelMeta.IsModelMapped = false with an initial UpstreamModelName, calls HandleStreamResponseData with a Claude stream payload containing "model":"provider-claude-model", asserts no error, and asserts info.UpstreamModelName was updated to "provider-claude-model"; this ensures HandleStreamResponseData updates the upstream model when IsModelMapped is false.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@relay/channel/claude/relay_claude_test.go`:
- Around line 55-75: Add a complementary unit test to verify behaviour when the
channel is not model-mapped: create a test (e.g.,
TestHandleStreamResponseDataUpdatesUnmappedModelName) that sets
relaycommon.RelayInfo.ChannelMeta.IsModelMapped = false with an initial
UpstreamModelName, calls HandleStreamResponseData with a Claude stream payload
containing "model":"provider-claude-model", asserts no error, and asserts
info.UpstreamModelName was updated to "provider-claude-model"; this ensures
HandleStreamResponseData updates the upstream model when IsModelMapped is false.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: fd1940ad-205e-452f-b63a-8df58554faa7
📒 Files selected for processing (12)
controller/token.gocontroller/token_test.gorelay/channel/claude/relay-claude.gorelay/channel/claude/relay_claude_test.gorelay/relay_task.goweb/classic/src/components/table/channels/modals/EditChannelModal.jsxweb/classic/src/i18n/locales/fr.jsonweb/classic/src/i18n/locales/ja.jsonweb/classic/src/i18n/locales/ru.jsonweb/classic/src/i18n/locales/vi.jsonweb/classic/src/i18n/locales/zh-TW.jsonweb/default/src/components/data-table/faceted-filter.tsx
Important
📝 变更描述 / Description
本 PR 集中修复 6 个相互独立的小型回归:
message_start只有在未发生模型映射时才更新UpstreamModelName,避免 AWS Claude 覆盖模型重定向后的计费/日志模型名。navigator.clipboard.readText是否存在,避免 HTTP 环境白屏。🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
go test ./controller ./relay ./relay/channel/task/sora:通过go test ./controller -run TestAddTokenReturnsCreatedToken:通过go test ./relay/channel/claude -run TestHandleStreamResponseDataPreservesMappedModelName:通过cd web/default && npx --yes bun run build:通过(本机 Node 20.13.1 低于 Rspack 推荐版本,构建仍成功)cd web/classic && npx --yes bun run build:通过(仅有 Browserslist 数据过期与 lottie-web eval 的既有警告)备注:
go test ./relay/channel/claude整包测试目前会在既有TestRequestOpenAI2ClaudeMessage_*file_content 转换断言上失败,和本 PR 修改的流式模型名逻辑无关;本 PR 新增的 Claude 回归用例已单独通过。Summary by CodeRabbit
New Features
Bug Fixes
Localization
Style
Tests