From ec8b2d0d4f6ad2d8ab4e5c48ea23d8efbde17243 Mon Sep 17 00:00:00 2001 From: Bohdan Triapitsyn Date: Sat, 30 May 2026 00:16:28 +0300 Subject: [PATCH] fix: don't flash the empty state before the draft welcome on load MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On refresh the auto-open draft opens in an effect (after first paint), so ChatContainer briefly rendered ChatEmptyState (logo + 'start a new chat') before the welcome screen. When a draft is about to auto-open and there's no init error, render a neutral background instead — the empty state stays for the cases where it's actually meaningful (no auto-open, or init error). --- packages/ui/src/components/chat/ChatContainer.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/ui/src/components/chat/ChatContainer.tsx b/packages/ui/src/components/chat/ChatContainer.tsx index b7e5d103..641637ee 100644 --- a/packages/ui/src/components/chat/ChatContainer.tsx +++ b/packages/ui/src/components/chat/ChatContainer.tsx @@ -7,6 +7,7 @@ import { useInputStore } from '@/sync/input-store'; import { useUIStore } from '@/stores/useUIStore'; import { Skeleton } from '@/components/ui/skeleton'; import ChatEmptyState from './ChatEmptyState'; +import { useGlobalSyncStore } from '@/sync/global-sync-store'; import MessageList, { type MessageListHandle } from './MessageList'; import { PermissionCard } from './PermissionCard'; import { QuestionCard } from './QuestionCard'; @@ -552,6 +553,7 @@ export const ChatContainer: React.FC = ({ autoOpenDraft = tr const isVSCode = isVSCodeRuntime(); const chatSurfaceMode = useChatSurfaceMode(); const draftOpen = Boolean(newSessionDraft?.open); + const initError = useGlobalSyncStore((s) => s.error); const isDesktopExpandedInput = isExpandedInput && !isMobile; const useCompactDraftLayout = isMobile || isVSCode || chatSurfaceMode === 'mini-chat'; const messageListRef = React.useRef(null); @@ -802,6 +804,13 @@ export const ChatContainer: React.FC = ({ autoOpenDraft = tr }, [currentSessionId, ensureSessionRenderable, hasRenderableSessionSnapshot]); if (!currentSessionId && !draftOpen) { + // With auto-open, the draft welcome opens on the next tick (effect below), + // so the empty state is only ever transient here — render a neutral + // background instead of flashing the logo / "start a new chat" on refresh. + // Keep the empty state when there's nothing to auto-open or an init error to show. + if (autoOpenDraft && !initError) { + return
; + } return (