Skip to content

Commit 326c59b

Browse files
Changing input field
1 parent b4b72d7 commit 326c59b

3 files changed

Lines changed: 23 additions & 17 deletions

File tree

src/app/chat/[chatId]/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export default function ChatPage() {
101101
for (const line of lines) {
102102
if (line.trim()) {
103103
try {
104+
console.log(line);
104105
const response: ChatStreamCompletionResponse = JSON.parse(line);
105106
updateMessages(response);
106107
if (response.done) {
@@ -190,7 +191,7 @@ export default function ChatPage() {
190191

191192
return (
192193
<Protected>
193-
<div className="flex h-svh w-full flex-row gap-0">
194+
<div className="flex h-svh flex-row gap-0">
194195
<ChatMenuNavbar />
195196

196197
<div className="flex w-full flex-col">

src/app/components/InputField.tsx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default function InputField({ onSubmit, messageStreaming }: InputFieldPro
8787
<div className="flex flex-col items-center gap-2">
8888
<form
8989
onSubmit={handleSubmit}
90-
className="m-auto w-4/6 rounded-lg border border-secondaryColor bg-white px-4 py-2 shadow-sm"
90+
className="m-auto w-5/6 rounded-lg border border-secondaryColor bg-white px-4 py-2 shadow-sm"
9191
>
9292
{/* TODO: If '.png,.jpg,.jpeg,.heif', display image */}
9393
<div className="flex gap-2">
@@ -118,12 +118,22 @@ export default function InputField({ onSubmit, messageStreaming }: InputFieldPro
118118
))}
119119
</div>
120120
<div className="flex items-center">
121+
<textarea
122+
autoFocus
123+
ref={textareaRef}
124+
onChange={autoResizeTextarea}
125+
onKeyDown={handleKeyDown}
126+
placeholder={`Message ${selectedModel}`}
127+
className="max-h-[150px] flex-1 resize-none border-none text-gray-700 placeholder-gray-400 outline-none"
128+
rows={1}
129+
/>
130+
121131
<button
122132
onClick={(e) => {
123133
e.preventDefault();
124134
fileInputRef.current?.click();
125135
}}
126-
className="mr-3 text-black hover:opacity-60"
136+
className="ml-3 mr-3 text-black hover:opacity-60"
127137
>
128138
<svg
129139
xmlns="http://www.w3.org/2000/svg"
@@ -142,18 +152,9 @@ export default function InputField({ onSubmit, messageStreaming }: InputFieldPro
142152
</button>
143153
<input type="file" ref={fileInputRef} onChange={handleFileChange} className="hidden" />
144154

145-
<textarea
146-
autoFocus
147-
ref={textareaRef}
148-
onChange={autoResizeTextarea}
149-
onKeyDown={handleKeyDown}
150-
placeholder={`Message ${selectedModel}`}
151-
className="max-h-[150px] flex-1 resize-none border-none text-gray-700 placeholder-gray-400 outline-none"
152-
rows={1}
153-
/>
154-
155155
{messageStreaming ? (
156156
// TODO: Handle aborting message streaming
157+
157158
<button className="ml-3">
158159
<svg
159160
xmlns="http://www.w3.org/2000/svg"
@@ -166,7 +167,12 @@ export default function InputField({ onSubmit, messageStreaming }: InputFieldPro
166167
<path
167168
strokeLinecap="round"
168169
strokeLinejoin="round"
169-
d="M14.25 9v6m-4.5 0V9M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"
170+
d="M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"
171+
/>
172+
<path
173+
strokeLinecap="round"
174+
strokeLinejoin="round"
175+
d="M9 9.563C9 9.252 9.252 9 9.563 9h4.874c.311 0 .563.252.563.563v4.874c0 .311-.252.563-.563.563H9.564A.562.562 0 0 1 9 14.437V9.564Z"
170176
/>
171177
</svg>
172178
</button>

src/app/components/chat/ChatMessage.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ export default function ChatMessage({ lastMessage, streaming, message }: ChatMes
9999
)}
100100
</div>
101101
<ReactMarkdown
102-
className={'whitespace-pre-line'}
103102
remarkPlugins={[remarkGfm]}
104103
components={{
105104
code({
@@ -115,11 +114,11 @@ export default function ChatMessage({ lastMessage, streaming, message }: ChatMes
115114
const match = /language-(\w+)/.exec(className || '');
116115
return !inline && match ? (
117116
<SyntaxHighlighter style={materialDark} language={match[1]} PreTag="div" {...props}>
118-
{String(children).replace(/\n$/, '')}
117+
{String(children)}
119118
</SyntaxHighlighter>
120119
) : (
121120
<code className={className} {...props}>
122-
{children}
121+
{String(children)}
123122
</code>
124123
);
125124
},

0 commit comments

Comments
 (0)