Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backend/chainlit/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
# Autoscroll new user messages at the top of the window
user_message_autoscroll = true

# Autoscroll new assistant messages
assistant_message_autoscroll = true

# Automatically tag threads with the current chat profile (if a chat profile is used)
auto_tag_thread = true

Expand Down Expand Up @@ -308,6 +311,7 @@ class FeaturesSettings(BaseModel):
slack: SlackFeature = Field(default_factory=SlackFeature)
latex: bool = False
user_message_autoscroll: bool = True
assistant_message_autoscroll: bool = True
unsafe_allow_html: bool = False
auto_tag_thread: bool = True
edit_message: bool = True
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/components/chat/ScrollContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Button } from '@/components/ui/button';

interface Props {
autoScrollUserMessage?: boolean;
autoScrollAssistantMessage?: boolean;
autoScrollRef?: MutableRefObject<boolean>;
children: React.ReactNode;
className?: string;
Expand All @@ -22,6 +23,7 @@ interface Props {
export default function ScrollContainer({
autoScrollRef,
autoScrollUserMessage,
autoScrollAssistantMessage,
children,
className
}: Props) {
Expand Down Expand Up @@ -63,13 +65,13 @@ export default function ScrollContainer({
// Scroll to position the message at the top
if (afterMessagesHeight === 0) {
scrollToPosition();
} else if (autoScrollRef?.current) {
} else if (autoScrollAssistantMessage && autoScrollRef?.current) {
ref.current.scrollTop = ref.current.scrollHeight;
}
} else if (autoScrollRef?.current) {
} else if (autoScrollAssistantMessage && autoScrollRef?.current) {
ref.current.scrollTop = ref.current.scrollHeight;
}
}, [autoScrollUserMessage, autoScrollRef]);
}, [autoScrollUserMessage, autoScrollAssistantMessage, autoScrollRef]);

// Find and set a ref to the last user message element
useEffect(() => {
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/chat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ const Chat = () => {
<ErrorBoundary>
<ScrollContainer
autoScrollUserMessage={config?.features?.user_message_autoscroll}
autoScrollAssistantMessage={
config?.features?.assistant_message_autoscroll
}
autoScrollRef={autoScrollRef}
>
<div
Expand Down
3 changes: 3 additions & 0 deletions libs/copilot/src/chat/body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ const Chat = () => {
<ErrorBoundary>
<ScrollContainer
autoScrollUserMessage={config?.features?.user_message_autoscroll}
autoScrollAssistantMessage={
config?.features?.assistant_message_autoscroll
}
autoScrollRef={autoScrollRef}
>
<div
Expand Down
1 change: 1 addition & 0 deletions libs/react-client/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export interface IChainlitConfig {
audio: IAudioConfig;
unsafe_allow_html?: boolean;
user_message_autoscroll?: boolean;
assistant_message_autoscroll?: boolean;
latex?: boolean;
edit_message?: boolean;
mcp?: {
Expand Down
Loading