2026-02-05 00:07:24 +08:00
|
|
|
import React from 'react';
|
|
|
|
|
import { cn } from '@/lib/utils';
|
|
|
|
|
import { useConfigStore } from '@/stores/useConfigStore';
|
|
|
|
|
import { getModelDisplayName } from './mobileControlsUtils';
|
2026-06-28 13:33:55 +03:00
|
|
|
import { ProviderLogo } from '@/components/ui/ProviderLogo';
|
2026-06-09 00:01:38 +03:00
|
|
|
import { useI18n } from '@/lib/i18n';
|
2026-02-05 00:07:24 +08:00
|
|
|
|
|
|
|
|
interface MobileModelButtonProps {
|
|
|
|
|
onOpenModel: () => void;
|
|
|
|
|
className?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const MobileModelButton: React.FC<MobileModelButtonProps> = ({ onOpenModel, className }) => {
|
2026-06-09 00:01:38 +03:00
|
|
|
const { t } = useI18n();
|
2026-04-04 02:19:55 +03:00
|
|
|
const currentModelId = useConfigStore((state) => state.currentModelId);
|
2026-06-28 13:33:55 +03:00
|
|
|
const currentProviderId = useConfigStore((state) => state.currentProviderId);
|
2026-04-04 02:19:55 +03:00
|
|
|
const getCurrentProvider = useConfigStore((state) => state.getCurrentProvider);
|
2026-02-05 00:07:24 +08:00
|
|
|
const currentProvider = getCurrentProvider();
|
2026-06-09 00:01:38 +03:00
|
|
|
const modelLabel = getModelDisplayName(currentProvider, currentModelId, t('chat.modelControls.selectModel'));
|
2026-02-05 00:07:24 +08:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={onOpenModel}
|
|
|
|
|
className={cn(
|
2026-06-28 13:33:55 +03:00
|
|
|
'inline-flex min-w-0 items-stretch',
|
|
|
|
|
'rounded-lg',
|
2026-02-05 00:07:24 +08:00
|
|
|
'typography-micro font-medium text-foreground/80',
|
|
|
|
|
'focus:outline-none hover:bg-[var(--interactive-hover)]',
|
|
|
|
|
className
|
|
|
|
|
)}
|
|
|
|
|
style={{ height: '26px', maxHeight: '26px', minHeight: '26px' }}
|
|
|
|
|
title={modelLabel}
|
|
|
|
|
>
|
2026-06-28 13:33:55 +03:00
|
|
|
<span className="flex h-full w-full min-w-0 items-center gap-1">
|
|
|
|
|
{currentProviderId ? (
|
|
|
|
|
<ProviderLogo providerId={currentProviderId} className="size-4 flex-shrink-0" />
|
|
|
|
|
) : null}
|
|
|
|
|
<span className="truncate">{modelLabel}</span>
|
2026-02-07 06:30:08 -03:00
|
|
|
</span>
|
2026-02-05 00:07:24 +08:00
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
};
|