Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix: align LLM profile switcher styling with Tools button (#617)

Hiep Le15ea3e134b0d
diff --git a/src/components/features/chat/switch-profile-button.tsx b/src/components/features/chat/switch-profile-button.tsx
index 7680d9be70..324c411b35 100644
--- a/src/components/features/chat/switch-profile-button.tsx
+++ b/src/components/features/chat/switch-profile-button.tsx
@@ -1,6 +1,5 @@
import React from "react";
import { useTranslation } from "react-i18next";
-import { Typography } from "#/ui/typography";
import { I18nKey } from "#/i18n/declaration";
import ChevronDownSmallIcon from "#/icons/chevron-down-small.svg?react";
import { useLlmProfiles } from "#/hooks/query/use-llm-profiles";
@@ -8,6 +7,7 @@ import { useSwitchLlmProfileAndLog } from "#/hooks/mutation/use-switch-llm-profi
import { useActiveConversation } from "#/hooks/query/use-active-conversation";
import { useOptionalConversationId } from "#/hooks/use-conversation-id";
import { useModelStore } from "#/stores/model-store";
+import { cn } from "#/utils/utils";
import { SwitchProfileContextMenu } from "./switch-profile-context-menu";
export function SwitchProfileButton() {
@@ -69,16 +69,21 @@ export function SwitchProfileButton() {
title={activeProfileModel ?? undefined}
aria-haspopup="menu"
aria-expanded={contextMenuOpen}
- className="flex items-center gap-1 border border-[#4B505F] rounded-[100px] transition-opacity cursor-pointer hover:opacity-80 disabled:opacity-50 disabled:cursor-not-allowed pl-2 max-w-[200px]"
+ className={cn(
+ "inline-flex items-center gap-1 rounded-[100px] border border-transparent px-1.5 text-sm font-normal leading-5 text-[var(--oh-muted)] whitespace-nowrap min-w-0 transition-[border-color,color] max-w-[200px]",
+ "hover:text-white hover:bg-white/10 cursor-pointer",
+ "disabled:opacity-50 disabled:cursor-not-allowed",
+ )}
>
- <Typography.Text className="text-white text-sm not-italic font-normal leading-5 truncate">
+ <span className="truncate">
{activeProfileName ?? t(I18nKey.LLM$SELECT_MODEL_PLACEHOLDER)}
- </Typography.Text>
+ </span>
<ChevronDownSmallIcon
- width={24}
- height={24}
- color="#ffffff"
+ width={18}
+ height={18}
+ color="currentColor"
className="shrink-0"
+ aria-hidden
/>
</button>
{contextMenuOpen && (
diff --git a/src/components/features/chat/switch-profile-context-menu.tsx b/src/components/features/chat/switch-profile-context-menu.tsx
index 2dee7ef5f0..0b67c84555 100644
--- a/src/components/features/chat/switch-profile-context-menu.tsx
+++ b/src/components/features/chat/switch-profile-context-menu.tsx
@@ -14,11 +14,14 @@ import { cn } from "#/utils/utils";
import type { ProfileInfo } from "#/api/profiles-service/profiles-service.api";
const rowBaseClassName = cn(
- "w-full flex gap-3 px-3 rounded",
- "text-start hover:bg-white/10 cursor-pointer text-nowrap",
+ "w-full flex flex-col gap-0.5 p-2 rounded",
+ "text-start hover:bg-[var(--oh-interactive-hover)] cursor-pointer text-nowrap",
+);
+const profileRowClassName = cn(rowBaseClassName, "h-auto");
+const linkRowClassName = cn(
+ "w-full flex items-center gap-2 p-2 rounded",
+ "text-start hover:bg-[var(--oh-interactive-hover)] cursor-pointer text-nowrap",
);
-const profileRowClassName = cn(rowBaseClassName, "h-auto items-start py-2.5");
-const linkRowClassName = cn(rowBaseClassName, "h-10 items-center");
interface SwitchProfileContextMenuProps {
profiles: ProfileInfo[];
@@ -60,9 +63,9 @@ export function SwitchProfileContextMenu({
testId="switch-profile-context-menu"
position="top"
alignment="left"
- className="z-[60] left-0 mb-2 bottom-full min-w-[280px] max-h-[60vh] overflow-y-auto p-1"
+ className="z-[60] left-0 mb-2 bottom-full min-w-[280px] max-h-[60vh] overflow-y-auto"
>
- <div className="px-3 pt-1 pb-0.5">
+ <div className="px-2 pt-1 pb-0.5">
<Typography.Text className="text-[11px] font-medium text-[var(--oh-text-dim)] uppercase tracking-wide leading-4">
{t(I18nKey.SETTINGS$AVAILABLE_PROFILES)}
</Typography.Text>
@@ -74,22 +77,37 @@ export function SwitchProfileContextMenu({
key={profile.name}
testId={`switch-profile-option-${profile.name}`}
onClick={(event) => handleSelect(event, profile.name)}
- className={cn(profileRowClassName, isActive && "bg-[#5C5D62]")}
+ className={cn(
+ profileRowClassName,
+ isActive && "bg-[var(--oh-interactive-hover)]",
+ )}
>
- <CircuitIcon width={16} height={16} className="shrink-0" />
<span
- className="flex min-w-0 flex-1 flex-col gap-0.5"
+ className="flex items-center gap-2 min-w-0"
title={profile.model ?? undefined}
>
- <span className="text-sm leading-5">{profile.name}</span>
- {profile.model && (
- <span className="truncate text-xs leading-4 text-[var(--oh-muted)]">
- {profile.model}
- </span>
+ <CircuitIcon
+ width={16}
+ height={16}
+ className="shrink-0"
+ aria-hidden
+ />
+ <span className="flex-1 truncate text-sm leading-5">
+ {profile.name}
+ </span>
+ {isActive && (
+ <CheckIcon
+ width={14}
+ height={14}
+ className="shrink-0"
+ aria-hidden
+ />
)}
</span>
- {isActive && (
- <CheckIcon width={14} height={14} className="shrink-0" />
+ {profile.model && (
+ <span className="block truncate text-xs leading-4 text-[var(--oh-muted)] pl-6">
+ {profile.model}
+ </span>
)}
</ContextMenuListItem>
);