Skip to content

Commit 4f829c2

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/mermaid
* origin/main: feature: add configuration option for default sidebar state (Chainlit#2065) Fix File Icons (Chainlit#2067) fix: flickering (Chainlit#2068) feat: add ids for most commonly customized ui elements (Chainlit#2069) chore: prepare release (Chainlit#2061)
2 parents 55983c4 + 0c9f118 commit 4f829c2

File tree

18 files changed

+61
-12
lines changed

18 files changed

+61
-12
lines changed

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ All notable changes to Chainlit will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

7+
## [2.4.302] - 2025-03-26
8+
9+
### Added
10+
11+
- Add thinking token support to langchain callback handler
12+
13+
### Fixed
14+
15+
- Pasting issues in the chat input
16+
- Rename nl-NL.json to nl.json
17+
718
## [2.4.301] - 2025-03-24
819

920
### Fixed

backend/chainlit/config.py

+3
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@
137137
138138
# layout = "wide"
139139
140+
# default_sidebar_state = "open"
141+
140142
# Description of the assistant. This is used for HTML tags.
141143
# description = ""
142144
@@ -272,6 +274,7 @@ class UISettings(DataClassJsonMixin):
272274
font_family: Optional[str] = None
273275
default_theme: Optional[Literal["light", "dark"]] = "dark"
274276
layout: Optional[Literal["default", "wide"]] = "default"
277+
default_sidebar_state: Optional[Literal["open", "closed"]] = "open"
275278
github: Optional[str] = None
276279
# Optional custom CSS file that allows you to customize the UI
277280
custom_css: Optional[str] = None

backend/chainlit/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
except metadata.PackageNotFoundError:
66
# Case where package metadata is not available, default to a 'non-outdated' version.
77
# Ref: config.py::load_settings()
8-
__version__ = "2.4.301"
8+
__version__ = "2.4.302"

backend/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "chainlit"
3-
version = "2.4.301"
3+
version = "2.4.302"
44
keywords = [
55
'LLM',
66
'Agents',

frontend/src/App.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { cn } from '@/lib/utils';
12
import { useEffect } from 'react';
23
import { RouterProvider } from 'react-router-dom';
34
import { useRecoilValue } from 'recoil';
@@ -7,6 +8,7 @@ import { useAuth, useChatSession, useConfig } from '@chainlit/react-client';
78

89
import ChatSettingsModal from './components/ChatSettings';
910
import { ThemeProvider } from './components/ThemeProvider';
11+
import { Loader } from '@/components/Loader';
1012
import { Toaster } from '@/components/ui/sonner';
1113

1214
import { userEnvState } from 'state/user';
@@ -80,6 +82,15 @@ function App() {
8082

8183
<ChatSettingsModal />
8284
<RouterProvider router={router} />
85+
86+
<div
87+
className={cn(
88+
'bg-[hsl(var(--background))] flex items-center justify-center fixed size-full p-2 top-0',
89+
isReady && 'hidden'
90+
)}
91+
>
92+
<Loader className="!size-6" />
93+
</div>
8394
</ThemeProvider>
8495
);
8596
}

frontend/src/components/LeftSidebar/Search.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export default function SearchChats() {
9393
<Tooltip>
9494
<TooltipTrigger asChild>
9595
<Button
96+
id="search-chats-button"
9697
onClick={() => setOpen(!open)}
9798
size="icon"
9899
variant="ghost"

frontend/src/components/LeftSidebar/ThreadHistory.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export function ThreadHistory() {
129129
<SidebarGroup>
130130
<SidebarMenu>
131131
{threadHistory ? (
132-
<div className="flex-grow">
132+
<div id="thread-history" className="flex-grow">
133133
<ThreadList
134134
threadHistory={threadHistory}
135135
error={error}

frontend/src/components/chat/MessageComposer/Attachment.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ interface AttachmentProps {
1616
}
1717

1818
const Attachment: React.FC<AttachmentProps> = ({ name, mime, children }) => {
19-
const extension = (
20-
mime ? mime.split('/').pop() : 'txt'
21-
) as DefaultExtensionType;
19+
let extension: DefaultExtensionType;
20+
if (name.includes('.')) {
21+
extension = name.split('.').pop()!.toLowerCase() as DefaultExtensionType;
22+
} else {
23+
extension = mime ? (mime.split('/').pop() || 'txt') as DefaultExtensionType : 'txt' as DefaultExtensionType;
24+
}
2225

2326
return (
2427
<TooltipProvider delayDuration={100}>

frontend/src/components/chat/MessageComposer/Input.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ const Input = forwardRef<InputMethods, Props>(
243243
const textData = event.clipboardData?.getData('text/plain');
244244
if (textData) {
245245
const escapedText = escapeHtml(textData);
246+
247+
document.execCommand('insertText', false, textData);
248+
246249
const textWithNewLines = escapedText.replace(/\n/g, '<br>');
247250

248251
// Get selection from the element's ownerDocument instead of window
@@ -407,7 +410,7 @@ const Input = forwardRef<InputMethods, Props>(
407410
contentEditable
408411
data-placeholder={placeholder}
409412
className={cn(
410-
'min-h-10 max-h-[250px] overflow-y-auto w-full focus:outline-none focus:ring-0 focus:ring-offset-0 focus-visible:ring-0 focus-visible:ring-offset-0 empty:before:content-[attr(data-placeholder)] empty:before:text-muted-foreground',
413+
'min-h-10 max-h-[250px] whitespace-pre-wrap overflow-y-auto w-full focus:outline-none focus:ring-0 focus:ring-offset-0 focus-visible:ring-0 focus-visible:ring-offset-0 empty:before:content-[attr(data-placeholder)] empty:before:text-muted-foreground',
411414
className
412415
)}
413416
onInput={handleInput}

frontend/src/components/chat/MessageComposer/index.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ export default function MessageComposer({
146146
]);
147147

148148
return (
149-
<div className="bg-accent dark:bg-card rounded-3xl p-3 px-4 w-full min-h-24 flex flex-col">
149+
<div
150+
id="message-composer"
151+
className="bg-accent dark:bg-card rounded-3xl p-3 px-4 w-full min-h-24 flex flex-col"
152+
>
150153
{attachments.length > 0 ? (
151154
<div className="mb-1">
152155
<Attachments />

frontend/src/components/chat/Messages/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ const Messages = memo(
7272
scorableRun={scorableRun}
7373
/>
7474
) : null}
75-
{showToolCoTLoader || showHiddenCoTLoader ? (
75+
{(showToolCoTLoader || showHiddenCoTLoader) &&
76+
m.name !== 'on_chat_start' ? (
7677
<BlinkingCursor />
7778
) : null}
7879
</React.Fragment>

frontend/src/components/chat/Starters.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ export default function Starters({ className }: Props) {
2828
if (!starters?.length) return null;
2929

3030
return (
31-
<div className={cn('flex gap-2 justify-center flex-wrap', className)}>
31+
<div
32+
id="starters"
33+
className={cn('flex gap-2 justify-center flex-wrap', className)}
34+
>
3235
{starters?.map((starter, i) => (
3336
<Starter key={i} starter={starter} />
3437
))}

frontend/src/components/chat/WelcomeScreen.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export default function WelcomeScreen(props: Props) {
7878

7979
return (
8080
<div
81+
id="welcome-screen"
8182
className={cn(
8283
'flex flex-col -mt-[60px] gap-4 w-full flex-grow items-center justify-center welcome-screen mx-auto transition-opacity duration-500 opacity-0 delay-100',
8384
isVisible && 'opacity-100'

frontend/src/components/header/ApiKeys.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default function ApiKeys() {
2424
<TooltipTrigger asChild>
2525
<Link to="/env">
2626
<Button
27+
id="api-keys-button"
2728
size="icon"
2829
variant="ghost"
2930
className="text-muted-foreground hover:text-muted-foreground"

frontend/src/components/header/SidebarTrigger.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default function SidebarTrigger() {
1818
<Tooltip>
1919
<TooltipTrigger asChild>
2020
<Button
21+
id="sidebar-trigger-button"
2122
onClick={() =>
2223
isMobile ? setOpenMobile(!openMobile) : setOpen(!open)
2324
}

frontend/src/components/header/UserNav.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ export default function UserNav() {
2424
return (
2525
<DropdownMenu>
2626
<DropdownMenuTrigger asChild>
27-
<Button variant="ghost" className="relative h-8 w-8 rounded-full">
27+
<Button
28+
id="user-nav-button"
29+
variant="ghost"
30+
className="relative h-8 w-8 rounded-full"
31+
>
2832
<Avatar className="h-8 w-8">
2933
<AvatarImage src={user?.metadata.image} alt="user image" />
3034
<AvatarFallback className="bg-primary text-primary-foreground font-semibold">

frontend/src/pages/Page.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ const Page = ({ children }: Props) => {
5252
const historyEnabled = config?.dataPersistence && data?.requireLogin;
5353

5454
return (
55-
<SidebarProvider>
55+
<SidebarProvider
56+
defaultOpen={config?.ui.default_sidebar_state !== 'closed'}
57+
>
5658
{historyEnabled ? (
5759
<>
5860
<LeftSidebar />

libs/react-client/src/types/config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export interface IChainlitConfig {
3333
font_family?: string;
3434
default_theme?: 'light' | 'dark';
3535
layout?: 'default' | 'wide';
36+
default_sidebar_state?: 'open' | 'closed';
3637
cot: 'hidden' | 'tool_call' | 'full';
3738
github?: string;
3839
custom_css?: string;

0 commit comments

Comments
 (0)