From 1577bfa3cb50e15f5ac6c6a0cd4b53bea18380be Mon Sep 17 00:00:00 2001 From: Bob Lee Date: Tue, 17 Nov 2026 13:30:55 +0800 Subject: [PATCH] fix(settings): refine fallback channel routing layout in model editor --- .../ai/ModelSettingsPage.presentation.test.ts | 17 ++ .../settings/pages/ai/ModelSettingsPage.scss | 165 ++++++++++++++++- .../settings/pages/ai/ModelSettingsPage.tsx | 168 +++++++++++------- 3 files changed, 286 insertions(+), 64 deletions(-) diff --git a/src/web-ui/src/app/scenes/settings/pages/ai/ModelSettingsPage.presentation.test.ts b/src/web-ui/src/app/scenes/settings/pages/ai/ModelSettingsPage.presentation.test.ts index e34ae8bdbc..eadaab88b6 100644 --- a/src/web-ui/src/app/scenes/settings/pages/ai/ModelSettingsPage.presentation.test.ts +++ b/src/web-ui/src/app/scenes/settings/pages/ai/ModelSettingsPage.presentation.test.ts @@ -88,4 +88,21 @@ describe('ModelSettingsPage presentation', () => { /@container config-panel \(max-width: 360px\)\s*\{\s*&__cli-account\.openbitfun-config-page-row\s*\{[\s\S]*?grid-template-columns: minmax\(0, 1fr\);[\s\S]*?gap: var\(--openbitfun-space-2\);[\s\S]*?justify-content: flex-start;/, ); }); + + it('lays out fallback channels across the full row width below a standard-measure add picker', () => { + const start = source.indexOf('function renderChannelRoutingRows('); + const end = source.indexOf('const renderSelectedModelRows = () =>', start); + const channelRouting = source.slice(start, end); + + expect(start).toBeGreaterThan(-1); + expect(channelRouting).not.toContain(''); + expect(styles).toMatch( + /&__channel-route-row\.openbitfun-config-page-row\s*\{[\s\S]*?grid-template-columns: minmax\(0, 1fr\) minmax\(0, var\(--openbitfun-overlay-menu-inline-size\)\);/, + ); + expect(styles).toMatch(/&__channel-route-list\s*\{[\s\S]*?grid-column: 1 \/ -1;/); + expect(styles).not.toMatch(/&__channel-route-item\s*\{[^}]*flex-wrap:\s*wrap/); + }); }); diff --git a/src/web-ui/src/app/scenes/settings/pages/ai/ModelSettingsPage.scss b/src/web-ui/src/app/scenes/settings/pages/ai/ModelSettingsPage.scss index a2093bd6c6..9a80e610f1 100644 --- a/src/web-ui/src/app/scenes/settings/pages/ai/ModelSettingsPage.scss +++ b/src/web-ui/src/app/scenes/settings/pages/ai/ModelSettingsPage.scss @@ -1380,8 +1380,7 @@ gap: var(--openbitfun-space-2); } - &__account-pool, - &__channel-route { + &__account-pool { display: flex; flex-direction: column; gap: var(--openbitfun-space-3); @@ -1442,13 +1441,153 @@ min-inline-size: 0; } + &__channel-route-row.openbitfun-config-page-row { + grid-template-columns: minmax(0, 1fr) minmax(0, var(--openbitfun-overlay-menu-inline-size)); + row-gap: var(--openbitfun-space-3); + + &:has(.openbitfun-model-settings__channel-route-empty) { + grid-template-columns: minmax(0, 1fr) auto; + } + + &[data-has-fallbacks='true']:hover { + background: transparent; + } + + > .openbitfun-config-page-row__meta { + grid-column: 1; + grid-row: 1; + } + + > .openbitfun-config-page-row__control { + display: contents; + } + } + + &__channel-route { + display: contents; + } + + &__channel-route-picker { + grid-column: 2; + grid-row: 1; + align-self: center; + display: flex; + align-items: center; + justify-content: flex-end; + inline-size: 100%; + min-inline-size: 0; + + > [data-openbitfun-component='select'] { + inline-size: 100%; + min-inline-size: 0; + } + } + + &__channel-route-empty { + color: var(--openbitfun-color-content-muted); + font-size: var(--openbitfun-type-body-sm-font-size); + line-height: var(--openbitfun-type-body-sm-line-height); + text-align: end; + } + + &__channel-route-list { + grid-column: 1 / -1; + grid-row: 2; + display: flex; + flex-direction: column; + margin: 0; + padding: 0; + list-style: none; + min-inline-size: 0; + border: var(--openbitfun-border-width-default) solid var(--openbitfun-color-border-subtle); + border-radius: var(--openbitfun-radius-base); + background: var(--openbitfun-color-surface-subtle); + overflow: clip; + } + + &__channel-route-item { + display: flex; + align-items: center; + gap: var(--openbitfun-space-2); + min-inline-size: 0; + min-block-size: calc(var(--openbitfun-control-height-sm) + var(--openbitfun-space-1)); + padding: var(--openbitfun-space-1) var(--openbitfun-space-2) var(--openbitfun-space-1) var(--openbitfun-space-3); + + & + & { + border-block-start: var(--openbitfun-border-width-default) solid var(--openbitfun-color-border-subtle); + } + + &:focus-within { + background: var(--openbitfun-color-action-quiet-hover); + } + + @media (hover: hover) and (pointer: fine) { + &:hover { + background: var(--openbitfun-color-action-quiet-hover); + } + } + } + &__channel-route-index { flex: none; + display: inline-flex; + align-items: center; + justify-content: center; + inline-size: var(--openbitfun-space-5); + block-size: var(--openbitfun-space-5); + border-radius: var(--openbitfun-radius-pill); + background: var(--openbitfun-color-action-neutral-surface); color: var(--openbitfun-color-content-secondary); - font-size: var(--openbitfun-type-body-sm-font-size); + font-family: var(--openbitfun-type-meta-font-family); + font-size: var(--openbitfun-type-meta-font-size); + font-weight: var(--openbitfun-type-meta-font-weight); + line-height: var(--openbitfun-type-meta-line-height); font-variant-numeric: tabular-nums; } + &__channel-route-summary { + flex: 1 1 0; + display: flex; + align-items: center; + gap: var(--openbitfun-space-2); + min-inline-size: 0; + + > [data-openbitfun-component='status-pill'] { + flex: none; + } + } + + &__channel-route-name { + flex: 0 1 auto; + min-inline-size: 0; + color: var(--openbitfun-color-content-primary); + font-size: var(--openbitfun-type-body-sm-font-size); + line-height: var(--openbitfun-type-body-sm-line-height); + + &.is-missing { + color: var(--openbitfun-color-content-muted); + } + } + + &__channel-route-provider { + color: var(--openbitfun-color-content-secondary); + } + + &__channel-route-separator { + margin-inline: var(--openbitfun-space-1); + color: var(--openbitfun-color-content-muted); + } + + &__channel-route-model { + color: var(--openbitfun-color-content-primary); + font-weight: var(--openbitfun-type-label-sm-font-weight); + } + + &__channel-route-actions { + flex: none; + margin-inline-start: auto; + } + &__endpoint-row { > .openbitfun-config-page-row__meta { display: flex; @@ -2702,6 +2841,26 @@ &__subscription-login-actions { justify-content: flex-start; } + + &__channel-route-row.openbitfun-config-page-row { + grid-template-columns: minmax(0, 1fr); + row-gap: var(--openbitfun-space-2); + + .openbitfun-model-settings__channel-route-picker { + grid-column: 1; + grid-row: 2; + justify-content: flex-start; + } + + .openbitfun-model-settings__channel-route-list { + grid-column: 1; + grid-row: 3; + } + + .openbitfun-model-settings__channel-route-empty { + text-align: start; + } + } } @container config-panel (max-width: 360px) { diff --git a/src/web-ui/src/app/scenes/settings/pages/ai/ModelSettingsPage.tsx b/src/web-ui/src/app/scenes/settings/pages/ai/ModelSettingsPage.tsx index c12ef351f3..a462e3c15b 100644 --- a/src/web-ui/src/app/scenes/settings/pages/ai/ModelSettingsPage.tsx +++ b/src/web-ui/src/app/scenes/settings/pages/ai/ModelSettingsPage.tsx @@ -3162,13 +3162,15 @@ const ModelSettingsPage: React.FC = () => { ? aiModels.filter(model => model.channel_routing?.fallback_model_ids.includes(savedModelId)) : []; if (backupFor.length > 0 && fallbackIds.length === 0) { - return renderModelField( - t('channelRouting.label'), - - {t('channelRouting.isBackupOf', { + return ( + `${getProviderDisplayName(model)} · ${model.model_name}`).join(', '), })} - , + > + {null} + ); } const modelLabel = (id: string) => { @@ -3195,67 +3197,109 @@ const ModelSettingsPage: React.FC = () => { return ( <> 0 ? 'true' : undefined} label={t('channelRouting.label')} description={t('channelRouting.hint')} - align="start" + align="center" >
+
+ {candidates.length > 0 || fallbackIds.length > 0 ? ( + { - const id = String(value); - if (id) updateRouting({ fallback_model_ids: [...fallbackIds, id] }); - }} - options={candidates.map(model => ({ - value: model.id as string, - label: `${getProviderDisplayName(model)} · ${model.model_name}`, - }))} - size="sm" - /> - ) : ( - - {t('channelRouting.noCandidates')} - +
    + {fallbackIds.map((id, index) => { + const model = aiModels.find(item => item.id === id); + const providerName = model ? getProviderDisplayName(model) : undefined; + const fullLabel = model ? `${providerName} · ${model.model_name}` : id; + return ( +
  1. + +
    + {model ? ( + + {providerName} + + {model.model_name} + + ) : ( + <> + + {id} + + {t('channelRouting.missing')} + + )} +
    + + {fallbackIds.length > 1 && ( + <> + + } + disabled={isEditorSaving || index === 0} + onClick={() => updateRouting({ fallback_model_ids: moveItem(fallbackIds, index, -1) })} + /> + + + } + disabled={isEditorSaving || index === fallbackIds.length - 1} + onClick={() => updateRouting({ fallback_model_ids: moveItem(fallbackIds, index, 1) })} + /> + + + )} + + } + disabled={isEditorSaving} + onClick={() => updateRouting({ fallback_model_ids: fallbackIds.filter(item => item !== id) })} + /> + + +
  2. + ); + })} +
)}
@@ -3263,6 +3307,8 @@ const ModelSettingsPage: React.FC = () => { t('channelRouting.mode'),