Skip to content

Commit

Permalink
Merge pull request #24 from sdcb/dev
Browse files Browse the repository at this point in the history
fix r300 mobile style is bad
  • Loading branch information
sdcb authored Jan 2, 2025
2 parents de06583 + 31cf4eb commit bec070a
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 21 deletions.
11 changes: 8 additions & 3 deletions src/FE/components/ChatMessage/ChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,20 @@ export const ChatMessage: FC<Props> = memo(
}) => {
const hasMultipleSpan = selectedMessages.find((x) => x.length > 1);
return (
<div className={cn('w-4/5 m-auto p-4', !hasMultipleSpan && 'w-3/5')}>
<div
className={cn(
'w-4/5 m-auto p-4',
!hasMultipleSpan && 'w-full md:w-3/5',
)}
>
{selectedMessages.map((messages, index) => {
return (
<div
key={'message-group-' + index}
className={cn(
messages.find((x) => x.role === ChatRole.User)
? 'flex w-full justify-end'
: 'grid grid-cols-[repeat(auto-fit,minmax(375px,1fr))] gap-4',
: 'md:grid md:grid-cols-[repeat(auto-fit,minmax(375px,1fr))] gap-4',
)}
>
{messages.map((message) => {
Expand Down Expand Up @@ -89,7 +94,7 @@ export const ChatMessage: FC<Props> = memo(
)}
>
{!hasMultipleSpan && (
<div className="w-9 h-9">
<div className="w-9 h-9 hidden md:block">
<IconRobot className="w-7 h-7 mr-1" />
</div>
)}
Expand Down
42 changes: 42 additions & 0 deletions src/FE/components/ChatMessage/RegenerateAction.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import useTranslation from '@/hooks/useTranslation';

import { IconRefresh } from '@/components/Icons';

import Tips from '../Tips/Tips';
import { Button } from '../ui/button';

interface Props {
hidden?: boolean;
modelName?: string;
onRegenerate: () => any;
}

export const RegenerateAction = (props: Props) => {
const { t } = useTranslation();
const { hidden, onRegenerate } = props;

const Render = () => {
return (
<Tips
trigger={
<Button
variant="ghost"
className="p-1 m-0 h-7 w-7"
onClick={(e) => {
onRegenerate();
e.stopPropagation();
}}
>
<IconRefresh />
</Button>
}
side="bottom"
content={t('Regenerate')!}
/>
);
};

return <>{!hidden && Render()}</>;
};

export default RegenerateAction;
17 changes: 9 additions & 8 deletions src/FE/components/ChatMessage/ResponseMessageActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ChangeModelAction from './ChangeModelAction';
import CopyAction from './CopyAction';
import GenerateInformationAction from './GenerateInformationAction';
import PaginationAction from './PaginationAction';
import RegenerateAction from './RegenerateAction';

export interface ResponseMessage {
id: string;
Expand Down Expand Up @@ -42,13 +43,7 @@ const ResponseMessageActions = (props: Props) => {
onChangeMessage,
onRegenerate,
} = props;
const {
id: messageId,
siblingIds,
modelId,
modelName,
modelProviderId,
} = message;
const { id: messageId, siblingIds, modelId, modelName, parentId } = message;
const currentMessageIndex = siblingIds.findIndex((x) => x === messageId);

return (
Expand All @@ -68,11 +63,17 @@ const ResponseMessageActions = (props: Props) => {
<div className="visible flex gap-0 items-center">
<CopyAction text={message.content.text} />
<GenerateInformationAction message={message} />
<RegenerateAction
hidden={readonly}
onRegenerate={() => {
onRegenerate && onRegenerate(parentId!, modelId);
}}
/>
<ChangeModelAction
readonly={readonly}
models={models}
onChangeModel={(model) => {
onRegenerate && onRegenerate(message.parentId!, model.modelId);
onRegenerate && onRegenerate(parentId!, model.modelId);
}}
showRegenerate={models.length > 0}
modelName={modelName!}
Expand Down
13 changes: 6 additions & 7 deletions src/FE/pages/home/_components/Chat/ChatHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ const ChatHeader = () => {
};

const AddBtnRender = () => (
<div className="flex items-center rounded-md">
<div className="flex items-center rounded-md mx-1">
{selectedChat.spans.length < MAX_SELECT_MODEL_COUNT && (
<ChatModelDropdownMenu
models={models}
className="text-base"
className="text-sm"
content={
<Tips
trigger={
Expand Down Expand Up @@ -108,22 +108,21 @@ const ChatHeader = () => {
<div className="flex justify-between items-center w-full">
<div
className={cn(
'flex justify-start ml-24 h-11 items-center overflow-auto',
'flex justify-start ml-24 h-12 items-center overflow-auto',
showChatBar && 'ml-6',
)}
>
<div className="flex gap-y-1 flex-wrap h-11 items-center overflow-auto">
<div className="flex gap-2 flex-wrap h-10 items-center overflow-auto">
{selectedChat.spans.map((span) => (
<div
className="flex hover:bg-muted p-1 rounded-md"
className="flex bg-muted rounded-md"
key={'chat-header-' + span.spanId}
>
<ChatModelDropdownMenu
key={'change-model-' + span.modelId}
models={models}
modelName={span.modelName}
className="text-sm"
triggerClassName="hover:bg-transparent"
content={span?.modelName}
hideIcon={true}
onChangeModel={(model) => {
Expand All @@ -139,7 +138,7 @@ const ChatHeader = () => {
handleRemoveChatModel(span.spanId);
}}
variant="ghost"
className="p-1 m-0 h-auto hover:bg-transparent"
className="py-1 px-0 pr-1 m-0 h-auto hover:bg-transparent"
>
<IconX />
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/FE/pages/home/_components/Chat/ChatModelInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const ChatModelInfo = (props: { modelId: number; modelName: string }) => {

return (
<div className="flex flex-col">
<label className="mb-2 text-base text-left text-neutral-700 dark:text-neutral-400 font-semibold">
<label className="mb-2 text-left">
{modelName}
</label>
<div className="flex items-center">
Expand Down
2 changes: 1 addition & 1 deletion src/FE/pages/home/_components/Chat/ChatModelSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const ChatModelSetting = () => {
return (
<div
key={'chat-model-' + span.spanId}
className="space-y-4 rounded-lg border border-neutral-200 p-4 dark:border-neutral-600"
className="space-y-4 rounded-lg p-4 border"
>
<ChatModelInfo
modelId={span.modelId}
Expand Down
2 changes: 1 addition & 1 deletion src/FE/pages/home/_components/Chatbar/Conversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ const ConversationComponent = ({ chat }: Props) => {
>
<IconDots className="hover:opacity-50" size={16} />
</DropdownMenuTrigger>
<DropdownMenuContent className="w-42">
<DropdownMenuContent className="w-42 border-none">
<DropdownMenuItem
className="flex justify-start gap-3"
onClick={handleOpenChangeTitleModal}
Expand Down

0 comments on commit bec070a

Please sign in to comment.