feat(chat): delay session creation until first message

The app now opens to a new chat by default on startup
New chats no longer create a session until you send your first message
Fixed mobile and VSCode sessions handling for better consistency
This commit is contained in:
Bohdan Triapitsyn
2025-12-21 20:18:51 +02:00
parent 75ba954307
commit 7699aab123
12 changed files with 273 additions and 152 deletions
@@ -27,6 +27,7 @@ export const ChatContainer: React.FC = () => {
messageStreamStates,
trimToViewportWindow,
sessionActivityPhase,
newSessionDraft,
} = useSessionStore();
const streamingMessageId = React.useMemo(() => {
@@ -35,6 +36,7 @@ export const ChatContainer: React.FC = () => {
}, [currentSessionId, streamingMessageIds]);
const { isMobile } = useDeviceInfo();
const draftOpen = Boolean(newSessionDraft?.open);
const sessionMessages = React.useMemo(() => {
@@ -143,7 +145,7 @@ export const ChatContainer: React.FC = () => {
void load();
}, [currentSessionId, loadMessages, messages, scrollToBottom]);
if (!currentSessionId) {
if (!currentSessionId && !draftOpen) {
return (
<div
className="flex flex-col h-full bg-background"
@@ -156,6 +158,26 @@ export const ChatContainer: React.FC = () => {
);
}
if (!currentSessionId && draftOpen) {
return (
<div
className="flex flex-col h-full bg-background transform-gpu"
style={isMobile ? { paddingBottom: 'var(--oc-keyboard-inset, 0px)' } : undefined}
>
<div className="flex-1 flex items-center justify-center">
<OpenChamberLogo width={140} height={140} className="opacity-20" isAnimated />
</div>
<div className="relative bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80 z-10">
<ChatInput scrollToBottom={scrollToBottom} />
</div>
</div>
);
}
if (!currentSessionId) {
return null;
}
if (isLoading && sessionMessages.length === 0 && !streamingMessageId) {
const hasMessagesEntry = messages.has(currentSessionId);
if (!hasMessagesEntry) {