Skip to content

feat(frontend): add fetch-from-upstream button in model mapping - #7413

Closed
Bliod-Cook wants to merge 2 commits into
QuantumNous:mainfrom
Bliod-Cook:feat/channel-mapping-upstream-models
Closed

Bliod-Cook wants to merge 2 commits into
QuantumNous:mainfrom
Bliod-Cook:feat/channel-mapping-upstream-models

Conversation

@Bliod-Cook

@Bliod-Cook Bliod-Cook commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ 提交说明 / PR Notice

English template: .github/PULL_REQUEST_TEMPLATE/en.md

Important

  • 描述可用 AI 辅助。提交前请审阅全文,并声明对其负责,避免未经核对的直接粘贴。
  • 请按本模板填写后再提交。

🔗 关联任务 / Related Issue

  • 新功能请填写下方 Issue 编号;若还没有对应 Issue,请先自行创建。功能讨论请放在 Issue 中进行。

  • 改动较大或方向性变更,请先在关联 Issue 中与维护者达成一致,再提交 PR。

  • Bug 修复请关联对应 Issue。设计取舍、理解偏差或预期不一致,更适合作为讨论或功能请求。

  • Closes 模型重定向时允许从上游拉取模型 #6101

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix)
  • ✨ 新功能 (New feature)
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

📝 变更描述 / Description

(简述做了什么、为什么生效。如果难以简述,建议先拆分范围,或在 Issue 中与维护者对齐。)

重新实现了旧版UI中在模型重定向设置中,从上游拉取模型填入的按钮

实现方式是为现有模型列表增加单选模式,因此自带结果缓存,可以保证操作的流畅性

附加更改:

  1. 修复弹窗操作时输入框抢占焦点的问题。
  2. 修复在从未配置模型重定向时,第一次添加模型映射不会成功的问题
  3. 移除原来的输入框的 datalist 候选提示,我认为这个功能对操作没有带来过多的便捷性

📸 运行证明 / Proof of Work

(请写明如何验证:实际步骤与观察结果。UI 变更请附截图或录屏;Bug 修复请说明复现过程与修复后结果。)

旧版UI的图片:
image
新版UI的图片:
image

✅ 提交前检查项 / Checklist

  • 人工确认: 无论描述是否由 AI 生成,我已审阅全部内容,并声明对其准确性与完整性负责。
  • 非重复提交: 我已搜索现有的 Issues 与 PRs,确认不是重复提交。
  • 新功能关联 Issue: 若此 PR 标记为 New feature,我已关联对应 Issue;若尚无 Issue,我已先自行创建。
  • 事前沟通: 若改动较大或涉及方向性变更,已在关联 Issue 中与维护者沟通并达成一致。
  • 功能范围: 本 PR 不是 Coding Plan、逆向渠道、第三方封装接口,也不是对 Codex 渠道类型的改动。
  • 范围聚焦: 本 PR 为一项聚焦改动,未包含无关代码。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

Summary by CodeRabbit

  • New Features

    • Added a dialog-based model picker for supported channel configurations.
    • Fetch, refresh, and apply discovered upstream models from the channel setup interface.
    • Added single-model selection with search, keyboard navigation, and clear empty-state messaging.
    • Preserved manual model entry and supported mapping formats alongside discovered models.
  • Bug Fixes

    • Prevented clicks from portaled popups from incorrectly triggering input-group actions.

@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 700fd5cf-7bfd-4965-a4e4-43205c790688

📥 Commits

Reviewing files that changed from the base of the PR and between 4e3b889 and 169061c.

📒 Files selected for processing (5)
  • web/src/features/channels/components/__tests__/channel-configuration.test.tsx
  • web/src/features/channels/components/__tests__/model-mapping-editor.test.tsx
  • web/src/features/channels/components/drawers/channel-mutate-drawer.tsx
  • web/src/features/channels/components/model-mapping-editor.tsx
  • web/src/features/channels/components/upstream-model-selection.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


Walkthrough

Channel configuration now supports selecting discovered upstream models for mapping rows. The picker uses single-selection controls and connects to channel discovery state. Manual target editing remains available. Tests cover discovery, picker interactions, permissions, and mapping updates.

Changes

Upstream model mapping

Layer / File(s) Summary
Single-selection model UI
web/src/features/channels/components/upstream-model-selection.tsx, web/src/features/channels/components/__tests__/upstream-model-selection.test.tsx
UpstreamModelSelection supports radio-based single selection and hides multiple-selection controls in that mode. Multiple-selection behavior remains checkbox-based.
Mapping editor integration
web/src/features/channels/components/model-mapping-editor.tsx, web/src/features/channels/components/__tests__/model-mapping-editor.test.tsx
ModelMappingEditor accepts an optional target picker and routes selected models through row updates. Echoed values matching the last emitted value do not replace visual rows. Tests cover manual editing and controlled updates.
Picker and drawer discovery flow
web/src/features/channels/components/upstream-model-picker.tsx, web/src/features/channels/components/drawers/channel-mutate-drawer.tsx, web/src/components/ui/input-group.tsx, web/src/features/channels/components/__tests__/channel-configuration.test.tsx
The drawer connects discovery state and feedback to the picker. The picker supports fetching, refreshing, canceling, and applying a discovered model. Tests cover permissions, discovery states, cancellation, mapping preservation, and unsupported channel types. Portaled clicks outside an input group addon no longer trigger its input-focus handler.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant ChannelMutateDrawer
  participant UpstreamModelPicker
  participant UpstreamModelSelection
  participant ModelMappingEditor
  ChannelMutateDrawer->>UpstreamModelPicker: provide discovery state and fetch callback
  UpstreamModelPicker->>ChannelMutateDrawer: request model discovery
  ChannelMutateDrawer->>UpstreamModelPicker: return models and status
  UpstreamModelPicker->>UpstreamModelSelection: display discovered models
  UpstreamModelSelection->>UpstreamModelPicker: return selected model
  UpstreamModelPicker->>ModelMappingEditor: apply selected model
Loading

Suggested reviewers: calcium-ion

Merge Risk: ⚪ Minimal · up to 16906

This adds an upstream-model picker to channel model mapping while keeping manual entry available. No concrete merge-blocking issue is evident from the supplied changes and tests.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 16906

The picker reuses existing discovery permissions and the normal channel-save flow. No new permission bypass or independent configuration write was identified. Backend authorization and persistence guarantees were not fully evaluated.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The added flow affects the selected channel’s mapping draft and can trigger its existing upstream discovery requests. Credentials and connection settings remain owned by the drawer; the picker receives discovery state and callbacks rather than credentials.

Trust Boundaries and Controls

  • observed — Discovery authority remains differentiated between sensitive preview operations and saved-channel operations. The picker is disabled without that authority, and the fetch callback independently checks permission, supported channel type, and required creation credentials. These frontend checks do not establish server-side enforcement.

Resilience and Maintainability Implications

  • observed — Discovery invalidates prior requests when request identity or enabled state changes and ignores superseded responses. The picker blocks Apply during loading, errors, or stale discovery and resets tentative selection on opening, containing stale-result and canceled-selection propagation.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding a frontend control to fetch upstream models for model mapping.
Linked Issues check ✅ Passed The changes satisfy issue #6101. UpstreamModelPicker adds a picker beside each upstream-model input, fetches upstream models, supports refresh and retry feedback, and applies one selected model to t…
Out of Scope Changes check ✅ Passed The changes remain within issue #6101. The input-focus fix, model-mapping draft synchronization, first-row handling, single-selection support, discovery feedback, and related tests support the upstrea…
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit taps the model door,
New names hop across the floor.
One radio wins the mapping race,
Manual edits keep their place.
The picker closes; drafts stay neat,
And carrots celebrate the feat.

Comment @coderabbitai help to get the list of available commands.

Resolve channel UI conflicts while retaining the upstream model picker, editable model comboboxes, batch redirects, redirect aliases, and stable selection tabs. Preserve draft rows when the form echoes mapping changes and cover the combined editor with a regression test.

Validation: 140 relevant Vitest tests passed; bun run typecheck, targeted oxlint, formatting checks, seven-locale translation-key checks, and bun run build passed. AI-assisted conflict resolution.
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