Skip to content

Commit 0f6537e

Browse files
authored
feat(web): Add support for multiline input (#491)
* Add support for new lines in web UI
1 parent d7e4cea commit 0f6537e

File tree

1 file changed

+37
-15
lines changed

1 file changed

+37
-15
lines changed

pkg/ui/html/index.html

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,35 @@
5151
}
5252
</script>
5353
<style>
54-
/* Custom scrollbar */
54+
/* Modern, subtle scrollbar */
5555
.custom-scrollbar::-webkit-scrollbar {
56-
width: 6px;
56+
width: 8px;
57+
height: 8px;
5758
}
5859
.custom-scrollbar::-webkit-scrollbar-track {
59-
background: #f1f5f9;
60-
}
61-
.dark .custom-scrollbar::-webkit-scrollbar-track {
62-
background: #1e293b;
60+
background: transparent;
6361
}
6462
.custom-scrollbar::-webkit-scrollbar-thumb {
65-
background: #cbd5e1;
66-
border-radius: 3px;
63+
background: #94a3b8;
64+
border-radius: 4px;
65+
border: 2px solid transparent;
66+
background-clip: content-box;
6767
}
6868
.dark .custom-scrollbar::-webkit-scrollbar-thumb {
69-
background: #475569;
69+
background: #52525b;
7070
}
7171
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
72-
background: #94a3b8;
72+
background: #475569;
7373
}
7474
.dark .custom-scrollbar::-webkit-scrollbar-thumb:hover {
75-
background: #64748b;
75+
background: #71717a;
76+
}
77+
.custom-scrollbar {
78+
scrollbar-width: thin;
79+
scrollbar-color: #94a3b8 transparent;
80+
}
81+
.dark .custom-scrollbar {
82+
scrollbar-color: #52525b transparent;
7683
}
7784

7885
/* Dark mode for body background */
@@ -285,6 +292,15 @@
285292
const messagesEndRef = useRef(null);
286293
const inputRef = useRef(null);
287294

295+
// Auto-resize textarea
296+
useEffect(() => {
297+
if (inputRef.current) {
298+
inputRef.current.style.height = 'auto';
299+
const scrollHeight = inputRef.current.scrollHeight;
300+
inputRef.current.style.height = scrollHeight + 'px';
301+
}
302+
}, [input]);
303+
288304
const toggleOutput = (messageIndex) => {
289305
const newExpanded = new Set(expandedOutputs);
290306
if (newExpanded.has(messageIndex)) {
@@ -819,18 +835,24 @@ <h2 className={`text-2xl font-bold ${isDarkMode ? 'text-white' : 'text-gray-900'
819835
<div className="max-w-4xl mx-auto">
820836
<form onSubmit={handleSubmit} className="flex space-x-3">
821837
<div className="flex-1 relative">
822-
<input
838+
<textarea
823839
ref={inputRef}
824-
type="text"
825840
value={input}
826841
onChange={(e) => setInput(e.target.value)}
842+
onKeyDown={(e) => {
843+
if (e.key === 'Enter' && !e.shiftKey) {
844+
e.preventDefault();
845+
handleSubmit(e);
846+
}
847+
}}
827848
placeholder={getInputPlaceholder()}
828849
disabled={!canSendMessage}
829-
className={`w-full px-4 py-3 pr-12 border rounded-xl shadow-sm focus:outline-none focus:ring-2 focus:ring-brand-500 focus:border-transparent transition-colors ${
850+
className={`w-full px-4 py-3 pr-12 border rounded-xl shadow-sm focus:outline-none focus:ring-2 focus:ring-brand-500 focus:border-transparent transition-colors resize-none overflow-y-auto max-h-40 custom-scrollbar align-bottom ${
830851
isDarkMode
831852
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400'
832853
: 'bg-white border-gray-300 text-gray-900 placeholder-gray-400'
833854
} ${!canSendMessage ? (isDarkMode ? 'bg-gray-800 text-gray-500' : 'bg-gray-50 text-gray-500') : ''}`}
855+
rows="1"
834856
/>
835857
{agentState === 'running' && (
836858
<div className="absolute right-3 top-1/2 transform -translate-y-1/2">
@@ -841,7 +863,7 @@ <h2 className={`text-2xl font-bold ${isDarkMode ? 'text-white' : 'text-gray-900'
841863
<button
842864
type="submit"
843865
disabled={!canSendMessage || !input.trim()}
844-
className="px-6 py-3 bg-gradient-to-r from-brand-500 to-brand-600 text-white rounded-xl hover:from-brand-600 hover:to-brand-700 focus:outline-none focus:ring-2 focus:ring-brand-500 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 font-medium shadow-sm"
866+
className="px-6 py-3 bg-gradient-to-r from-brand-500 to-brand-600 text-white rounded-xl hover:from-brand-600 hover:to-brand-700 focus:outline-none focus:ring-2 focus:ring-brand-500 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 font-medium shadow-sm self-end"
845867
>
846868
Send
847869
</button>

0 commit comments

Comments
 (0)