From bb708510fe3c8bddf95d2ae37699e4d0444d4198 Mon Sep 17 00:00:00 2001 From: fengsilin Date: Fri, 8 May 2026 09:16:45 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E7=94=A8=E6=88=B7=E5=80=8D=E7=8E=87?= =?UTF-8?q?=E6=B8=A0=E9=81=93-=E6=A8=A1=E5=9E=8B=E7=BA=A7=E8=81=94?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=99=A8=E8=AE=BE=E8=AE=A1=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude --- ...cascading-channel-model-selector-design.md | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 docs/superpowers/specs/2026-05-08-cascading-channel-model-selector-design.md diff --git a/docs/superpowers/specs/2026-05-08-cascading-channel-model-selector-design.md b/docs/superpowers/specs/2026-05-08-cascading-channel-model-selector-design.md new file mode 100644 index 0000000..be58b76 --- /dev/null +++ b/docs/superpowers/specs/2026-05-08-cascading-channel-model-selector-design.md @@ -0,0 +1,41 @@ +--- +created: 2026-05-08 +status: approved +--- + +# Cascading Channel-Model Selector for User Ratio + +## Goal + +Improve the "Add Ratio" modal in UserRatioSection: select channel first, then pick a model from that channel's supported models via dropdown instead of manual text input. + +## Scope + +Single file: `web/src/components/table/users/modals/UserRatioSection.jsx` + +No backend changes — the existing `/api/channel/` endpoint already returns the `models` field (comma-separated string) for each channel. + +## Design + +### Data flow + +1. `loadChannels()` fetches channel list, stores two things: + - `channelOptions`: `[{ label, value }]` for the channel dropdown (existing) + - `channelMap`: `{ [channelId]: channelObject }` for looking up `models` by channel ID (new) +2. When user selects a channel in the form: + - Parse `channel.models` by comma into an array + - Set `modelOptions` to `[{ label: model, value: model }]` for each model + - Clear any previously selected model value +3. Model dropdown uses `modelOptions` with `filter` and `showClear`, disabled when no channel is selected + +### Form field order + +1. Channel (Select, with search) — existing +2. Model (Select, with search) — changed from Input to Select +3. Ratio (InputNumber) — existing + +### What does NOT change + +- Backend API and data model +- Table columns and display +- Submit payload format (`model_name`, `channel_id`, `ratio`)