From 6e409592b509546f1ab8c796435247843a197951 Mon Sep 17 00:00:00 2001 From: LucasDLTG Date: Wed, 29 Apr 2026 15:12:44 +0200 Subject: [PATCH] fix: centered input + default stream --- src/components/chat/ChatUI.tsx | 86 ++++++++++++++++++---------------- src/components/chat/stream.ts | 2 +- 2 files changed, 47 insertions(+), 41 deletions(-) diff --git a/src/components/chat/ChatUI.tsx b/src/components/chat/ChatUI.tsx index cac6448..d9cb649 100644 --- a/src/components/chat/ChatUI.tsx +++ b/src/components/chat/ChatUI.tsx @@ -39,7 +39,7 @@ export default function ChatUI({ stop: [''], repeatPenalty: 1.1, seed: 0, - stream: false, + stream: true, keepAlive: '5m', }); @@ -108,7 +108,8 @@ export default function ChatUI({ if (!res.ok) { let message = 'Request failed'; - if (res.status === 500) message = 'Server error (likely model too large or OOM)'; + if (res.status === 500) + message = 'Server error (likely model too large or OOM)'; else if (res.status === 401) message = 'Unauthorized'; else message = data?.message ?? data?.error ?? message; throw new Error(message); @@ -179,55 +180,60 @@ export default function ChatUI({ /> - {/* Messages */} + {/* Messages + centered input when empty */}
-
- {messages.map((msg, i) => ( -
- {msg.role === 'user' ? 'You' : 'AI'}: {msg.content} - {/* Blinking cursor shown on the last message while streaming */} - {loading && - settings.stream && - i === messages.length - 1 && - msg.role === ASSISTANT_ROLE && ( - - )} -
- ))} - {loading && !settings.stream && ( -
Thinking...
- )} -
-
- - {/* Input — floats center when empty, slides to bottom on first message */} -
-
- {messages.length === 0 && ( -

+ {messages.length === 0 ? ( + /* ── Empty state: input centered within the chat column only ── */ +

+

Start a conversation…

- )} + setInput(e.target.value)} + onKeyDown={(e) => + e.key === 'Enter' && !loading && sendMessage() + } + disabled={loading} + className="w-full max-w-2xl p-3 rounded-xl bg-black/20 border border-muted outline-none disabled:opacity-50" + placeholder="Message..." + /> +
+ ) : ( + /* ── Active chat: messages list ── */ +
+ {messages.map((msg, i) => ( +
+ {msg.role === 'user' ? 'You' : 'AI'}: {msg.content} + {loading && + settings.stream && + i === messages.length - 1 && + msg.role === ASSISTANT_ROLE && ( + + )} +
+ ))} + {loading && !settings.stream && ( +
Thinking...
+ )} +
+ )} + + + {/* Input bar — only shown once conversation has started */} + {messages.length > 0 && ( +
setInput(e.target.value)} onKeyDown={(e) => e.key === 'Enter' && !loading && sendMessage()} disabled={loading} - className="w-full p-3 rounded-xl bg-black/20 border border-muted outline-none disabled:opacity-50" + className="w-full max-w-2xl mx-auto block p-3 rounded-xl bg-black/20 border border-muted outline-none disabled:opacity-50" placeholder="Message..." />
-
+ )}
); -} \ No newline at end of file +} diff --git a/src/components/chat/stream.ts b/src/components/chat/stream.ts index 7f247e3..7e1648d 100644 --- a/src/components/chat/stream.ts +++ b/src/components/chat/stream.ts @@ -118,4 +118,4 @@ export async function fetchChatStream( } return res; -} \ No newline at end of file +}