From 2412a9bd4fe417db27b54ca6c7bfb543c99a349d Mon Sep 17 00:00:00 2001 From: su-fen <715041@qq.com> Date: Tue, 1 Sep 2026 13:36:48 +0800 Subject: [PATCH] =?UTF-8?q?fix(settings):=20=E9=81=BF=E5=85=8D=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E4=B8=8B=E6=8B=89=E5=B1=95=E5=BC=80=E6=97=B6=E6=8A=BD?= =?UTF-8?q?=E5=B1=89=E4=B8=8B=E6=96=B9=E5=AD=97=E6=AE=B5=E8=A2=AB=E9=A1=B6?= =?UTF-8?q?=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- .../src/pages/settings/modelPicker.tsx | 288 +++++++++--------- 1 file changed, 147 insertions(+), 141 deletions(-) diff --git a/crates/agent-ui/src/pages/settings/modelPicker.tsx b/crates/agent-ui/src/pages/settings/modelPicker.tsx index 350ec7810..0b3331325 100644 --- a/crates/agent-ui/src/pages/settings/modelPicker.tsx +++ b/crates/agent-ui/src/pages/settings/modelPicker.tsx @@ -141,154 +141,160 @@ export function ModelPicker({ .filter((group) => group.opts.length > 0) : groups; + // Menu.Root is a fragment. When open, Base UI injects FocusGuard siblings + // around the trigger; Tailwind v4 `space-y-*` then treats the trigger as + // `:not(:last-child)` and adds margin-bottom, shifting fields below. + // A single wrapper keeps those guards out of the parent spacing context. return ( - - - - - {selectedOption ? ( - - ) : ( - - )} - - - {selectedOption ? selectedOption.label : placeholder} - - - + + - - -
-
- - setSearch(e.target.value)} - placeholder={searchPlaceholder ?? t("chat.searchModel")} - className="min-w-0 flex-1 bg-transparent text-xs text-foreground outline-none placeholder:text-muted-foreground/60" - onKeyDown={(e) => e.stopPropagation()} - /> -
-
-
- {noneLabel && !normalizedSearch ? ( - onChange("")} + > + + - - - {noneLabel} - - {value === "" ? : null} - - ) : null} - {filteredGroups.length === 0 ? ( -
- {emptyLabel ?? t("chat.noModelFound")} + {selectedOption ? ( + + ) : ( + + )} + + + {selectedOption ? selectedOption.label : placeholder} + + + + + +
+
+ + setSearch(e.target.value)} + placeholder={searchPlaceholder ?? t("chat.searchModel")} + className="min-w-0 flex-1 bg-transparent text-xs text-foreground outline-none placeholder:text-muted-foreground/60" + onKeyDown={(e) => e.stopPropagation()} + />
- ) : ( - filteredGroups.map((group, groupIndex) => { - const expanded = isGroupExpanded(group.id); - return ( -
- {groupIndex > 0 || (noneLabel && !normalizedSearch) ? ( - - ) : null} - {collapsibleGroups ? ( - toggleGroup(group.id)} - aria-expanded={expanded} - title={expanded ? t("chat.collapseProvider") : t("chat.expandProvider")} - className="sticky top-0 z-10 flex h-[30px] shrink-0 cursor-pointer items-center gap-1.5 rounded-md bg-popover/60 px-2 py-0 text-xs font-medium text-muted-foreground/80 backdrop-blur-xl transition-colors data-[highlighted]:bg-muted/40 supports-[backdrop-filter]:bg-popover/40" - > - - {group.name} - - {group.opts.length} - - - - ) : null} - {!collapsibleGroups || expanded - ? group.opts.map((option) => { - const isSelected = option.value === value; - return ( - onChange(option.value)} - className={cn( - "h-[30px] max-w-full shrink-0 justify-between gap-3 overflow-hidden rounded-md py-0 text-xs font-normal leading-5 text-foreground transition-none data-[highlighted]:bg-foreground/[0.05]", - isSelected && - "bg-foreground/[0.07] font-medium data-[highlighted]:bg-foreground/[0.09]", - )} - > - - - {option.label} - {option.description ? ( - - {option.description} - +
+
+ {noneLabel && !normalizedSearch ? ( + onChange("")} + className={cn( + "h-[30px] max-w-full shrink-0 justify-between gap-3 overflow-hidden rounded-md py-0 text-xs font-normal leading-5 text-foreground transition-none data-[highlighted]:bg-foreground/[0.05]", + value === "" && + "bg-foreground/[0.07] font-medium data-[highlighted]:bg-foreground/[0.09]", + )} + > + + + {noneLabel} + + {value === "" ? : null} + + ) : null} + {filteredGroups.length === 0 ? ( +
+ {emptyLabel ?? t("chat.noModelFound")} +
+ ) : ( + filteredGroups.map((group, groupIndex) => { + const expanded = isGroupExpanded(group.id); + return ( +
+ {groupIndex > 0 || (noneLabel && !normalizedSearch) ? ( + + ) : null} + {collapsibleGroups ? ( + toggleGroup(group.id)} + aria-expanded={expanded} + title={expanded ? t("chat.collapseProvider") : t("chat.expandProvider")} + className="sticky top-0 z-10 flex h-[30px] shrink-0 cursor-pointer items-center gap-1.5 rounded-md bg-popover/60 px-2 py-0 text-xs font-medium text-muted-foreground/80 backdrop-blur-xl transition-colors data-[highlighted]:bg-muted/40 supports-[backdrop-filter]:bg-popover/40" + > + + {group.name} + + {group.opts.length} + + + + ) : null} + {!collapsibleGroups || expanded + ? group.opts.map((option) => { + const isSelected = option.value === value; + return ( + onChange(option.value)} + className={cn( + "h-[30px] max-w-full shrink-0 justify-between gap-3 overflow-hidden rounded-md py-0 text-xs font-normal leading-5 text-foreground transition-none data-[highlighted]:bg-foreground/[0.05]", + isSelected && + "bg-foreground/[0.07] font-medium data-[highlighted]:bg-foreground/[0.09]", + )} + > + + + {option.label} + {option.description ? ( + + {option.description} + + ) : null} + + {isSelected ? ( + ) : null} - - {isSelected ? ( - - ) : null} - - ); - }) - : null} -
- ); - }) - )} -
- - + + ); + }) + : null} +
+ ); + }) + )} +
+ + +
); }