Skip to content
Open
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
11 changes: 10 additions & 1 deletion frontend/src/components/chat/MessagesContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ const MessagesContainer = ({ navigate }: Props) => {
const knownSideElementsRef = useRef<Map<string, IMessageElement>>(new Map());
const knownSideOrderRef = useRef<string[]>([]);

// Check if side panel should auto-open based on config
const shouldAutoOpenSidePanel = config?.features?.side_panel?.default_state !== 'closed';

useEffect(() => {
const sideElements = elements.filter((e) => e.display === 'side');

Expand All @@ -104,6 +107,12 @@ const MessagesContainer = ({ navigate }: Props) => {
return;
}

// If default_state is 'closed', don't auto-open the side panel
// User must manually click to open it via onElementRefClick
if (!shouldAutoOpenSidePanel) {
return;
}

const prevMap = knownSideElementsRef.current;
const prevOrder = knownSideOrderRef.current;
const currentIds = sideElements.map((e) => e.id);
Expand All @@ -123,7 +132,7 @@ const MessagesContainer = ({ navigate }: Props) => {
elements: sideElements
});
}
}, [elements]);
}, [elements, shouldAutoOpenSidePanel]);

const onElementRefClick = useCallback(
(element: IMessageElement) => {
Expand Down
26 changes: 25 additions & 1 deletion libs/copilot/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,30 @@ export default function App({ widgetConfig }: Props) {

const defaultTheme = widgetConfig.theme || data?.default_theme;

// Detect third-party cookie blocking errors
const isCookieBlockedError = (error: string): boolean => {
const lowerError = error.toLowerCase();
return (
lowerError.includes('set-cookie') ||
lowerError.includes('cookie') ||
lowerError.includes('blocked') ||
lowerError.includes('third-party') ||
lowerError.includes('third party')
);
};

// Format error message with helpful instructions for cookie issues
const formatAuthError = (err: unknown): string => {
const errorStr = String(err);
if (isCookieBlockedError(errorStr)) {
return (
'Authentication failed due to third-party cookies being blocked. ' +
'Please allow third-party cookies in your browser settings to use the Copilot.'
);
}
return errorStr;
};

useEffect(() => {
if (fetchError) return;
if (!isAuthenticated) {
Expand All @@ -63,7 +87,7 @@ export default function App({ widgetConfig }: Props) {
} else {
apiClient
.jwtAuth(widgetConfig.accessToken)
.catch((err) => setAuthError(String(err)));
.catch((err) => setAuthError(formatAuthError(err)));
}
} else {
setAuthError(undefined);
Expand Down
3 changes: 3 additions & 0 deletions libs/react-client/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export interface IChainlitConfig {
}[];
};
features: {
side_panel?: {
default_state?: 'open' | 'closed';
};
spontaneous_file_upload?: {
enabled?: boolean;
max_size_mb?: number;
Expand Down