Skip to content

Commit

Permalink
Merge pull request #606 from aws-samples/markdown-memo
Browse files Browse the repository at this point in the history
長いチャットで入力が遅くなる問題
  • Loading branch information
tbrand authored Aug 15, 2024
2 parents d0c0ad8 + 4c8a289 commit 07b83f2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions browser-extension/src/app/features/chat/ChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const ChatMessage: React.FC<Props> = (props) => {
className={twMerge(
'border-t last:border-b p-2',
isUser ? 'bg-aws-squid-ink brightness-150' : '',
props.className
props.className,
)}
>
{message.title && (
Expand All @@ -39,7 +39,7 @@ const ChatMessage: React.FC<Props> = (props) => {
className={twMerge(
'transition-all ',
message.role === 'system' && isOpen && 'max-h-[300px] overflow-y-auto',
message.role === 'system' && !isOpen && 'max-h-0 overflow-hidden'
message.role === 'system' && !isOpen && 'max-h-0 overflow-hidden',
)}
>
{message.content.split('\n').map((c, idx) => (
Expand Down
2 changes: 1 addition & 1 deletion browser-extension/src/app/features/chat/InputContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ ${formValues[idx]}
<div key={idx}>
<div className="text-xs">{def.label}</div>
<TextareaChatContent
value={def.autoCopy ? content : formValues[idx] ?? ''}
value={def.autoCopy ? content : (formValues[idx] ?? '')}
onChange={(value) => {
setFormValues(
produce(formValues, (draft) => {
Expand Down
8 changes: 4 additions & 4 deletions browser-extension/src/app/features/chat/chatSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const chatSlice = createSlice({
},
updateMessageContent: (
state,
action: PayloadAction<TabId & { index: number; content: string }>
action: PayloadAction<TabId & { index: number; content: string }>,
) => {
setInitialStateIfNeeded(state, action.payload.tabId);
state[action.payload.tabId].messages[action.payload.index].content = action.payload.content;
Expand All @@ -63,7 +63,7 @@ export const replaceMessages =
setMessages({
tabId,
messages,
})
}),
);
};

Expand All @@ -78,7 +78,7 @@ export const pushMessages =
messages: produce(currentMessages, (draft) => {
draft.push(...messages);
}),
})
}),
);
};

Expand All @@ -95,7 +95,7 @@ export const overwriteLatestMessage =
tabId,
index: currentMessages.length - 1,
content: content.replace(/<([^>]+)>([\s\S]*?)<\/\1>/, '$2'),
})
}),
);
};

Expand Down
2 changes: 1 addition & 1 deletion browser-extension/src/app/features/chat/useChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const useChat = () => {
role: 'assistant',
content: '▍',
},
])
]),
);

// Assistant の発言を更新
Expand Down
4 changes: 2 additions & 2 deletions packages/web/src/components/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const ImageRenderer = (props: any) => {
return <img id={props.id} src={src} />;
};

const Markdown: React.FC<Props> = ({ className, prefix, children }) => {
const Markdown = React.memo(({ className, prefix, children }: Props) => {
return (
<ReactMarkdown
className={`${
Expand Down Expand Up @@ -114,6 +114,6 @@ const Markdown: React.FC<Props> = ({ className, prefix, children }) => {
}}
/>
);
};
});

export default Markdown;

0 comments on commit 07b83f2

Please sign in to comment.