@@ -6,17 +6,17 @@ import {
66 Container ,
77 Flex ,
88 Heading ,
9- Input ,
109 Text ,
1110 Badge ,
11+ Textarea ,
12+ Spinner ,
1213} from "@chakra-ui/react" ;
1314import {
1415 ArrowsClockwiseIcon ,
1516 CaretRightIcon ,
1617 QuestionIcon ,
1718} from "@phosphor-icons/react" ;
1819import { Tooltip } from "@/components/ui/tooltip" ;
19- import useChatStore from "@/app/store/chatStore" ;
2020import GlobalHeader from "../../components/GlobalHeader" ;
2121
2222type PromptMarqueeProps = {
@@ -36,14 +36,19 @@ export default function LandingHero({
3636 const [ inputValue , setInputValue ] = useState ( "" ) ;
3737 const [ isInputFocused , setIsInputFocused ] = useState ( false ) ;
3838 const [ ready , setReady ] = useState ( false ) ;
39- const { sendMessage , isLoading } = useChatStore ( ) ;
39+ const [ sendingPrompt , setSendingPrompt ] = useState ( false ) ;
4040
4141 useEffect ( ( ) => {
4242 setReady ( true ) ;
4343 } , [ ] ) ;
4444
4545 useEffect ( ( ) => {
46- if ( isInputFocused || inputValue . length > 0 ) return ; // Pause timer if typing
46+ setSendingPrompt ( false ) ;
47+ } , [ ] ) ;
48+
49+ useEffect ( ( ) => {
50+ if ( ! ready || isInputFocused || inputValue . length > 0 || sendingPrompt )
51+ return ; // Pause timer if typing or sendingPrompt
4752 const interval = setInterval ( ( ) => {
4853 setPromptTimer ( ( prev ) => {
4954 if ( prev > 1 ) {
@@ -57,17 +62,36 @@ export default function LandingHero({
5762 } ) ;
5863 } , 1000 ) ;
5964 return ( ) => clearInterval ( interval ) ;
60- } , [ prompts . length , setPromptIndex , isInputFocused , inputValue ] ) ;
65+ } , [
66+ prompts . length ,
67+ setPromptIndex ,
68+ isInputFocused ,
69+ inputValue ,
70+ sendingPrompt ,
71+ ] ) ;
6172 // Measure the width of one set of prompts after render
6273
6374 const LANDING_PAGE_VERSION = process . env . NEXT_PUBLIC_LANDING_PAGE_VERSION ;
6475
76+ const handleKeyDown = ( e : React . KeyboardEvent < HTMLTextAreaElement > ) => {
77+ // Submit on Enter (without Shift) or Command+Enter
78+ if (
79+ ( e . key === "Enter" && ! e . shiftKey && ! e . metaKey ) ||
80+ ( e . key === "Enter" && e . metaKey )
81+ ) {
82+ e . preventDefault ( ) ; // Prevents newline
83+ submitPrompt ( ) ;
84+ }
85+ // If Shift+Enter, do nothing: allow newline
86+ } ;
87+
6588 const submitPrompt = async ( ) => {
66- if ( isLoading ) return ;
89+ if ( sendingPrompt ) return ;
90+ setSendingPrompt ( true ) ;
6791 const message = inputValue . trim ( ) || prompts [ promptIndex ] ;
6892 localStorage . setItem ( "bypassWelcomeModal" , "true" ) ;
69- await sendMessage ( message ) ;
70- router . push ( " /app" ) ;
93+ const encodedMessage = encodeURI ( message ) ;
94+ router . push ( ` /app?prompt= ${ encodedMessage } ` ) ;
7195 } ;
7296
7397 return (
@@ -155,7 +179,7 @@ export default function LandingHero({
155179 { ( LANDING_PAGE_VERSION === "public" ||
156180 LANDING_PAGE_VERSION === "limited" ) && (
157181 < Box rounded = "xl" bg = "bg" p = "4" zIndex = "10" >
158- < Input
182+ < Textarea
159183 key = {
160184 ! isInputFocused && inputValue === ""
161185 ? promptIndex
@@ -165,6 +189,7 @@ export default function LandingHero({
165189 onChange = { ( e ) => setInputValue ( e . target . value ) }
166190 onFocus = { ( ) => setIsInputFocused ( true ) }
167191 onBlur = { ( ) => setIsInputFocused ( false ) }
192+ onKeyDown = { handleKeyDown }
168193 p = "0"
169194 outline = "none"
170195 borderWidth = "0"
@@ -176,6 +201,16 @@ export default function LandingHero({
176201 _focusWithin = { {
177202 animationPlayState : "paused" ,
178203 } }
204+ aria-label = "Ask a question..."
205+ minH = "20px"
206+ autoresize
207+ maxH = "3lh"
208+ border = "none"
209+ color = { sendingPrompt ? "fg.subtle" : "fg" }
210+ _placeholder = { { color : sendingPrompt ? "fg.subtle" : "fg" } }
211+ disabled = { sendingPrompt }
212+ _disabled = { { opacity : 1 } }
213+ _focus = { { outline : "none" , boxShadow : "none" } }
179214 />
180215 < Flex justifyContent = "space-between" mt = "4" gap = { 4 } >
181216 < Flex gap = "2" alignItems = "flex-start" flexDirection = "column" >
@@ -196,7 +231,9 @@ export default function LandingHero({
196231 bg : "secondary.100" ,
197232 animation : ready ? "fillWidth" : "none" ,
198233 animationPlayState :
199- isInputFocused || inputValue . length > 0
234+ isInputFocused ||
235+ inputValue . length > 0 ||
236+ sendingPrompt
200237 ? "paused"
201238 : "running" ,
202239 } }
@@ -219,9 +256,10 @@ export default function LandingHero({
219256 rounded = "lg"
220257 onClick = { submitPrompt }
221258 title = "Submit prompt to assistant and go to application"
222- disabled = { isLoading }
259+ disabled = { sendingPrompt }
223260 >
224- Go
261+ { sendingPrompt ? < Spinner size = "sm" mr = { 2 } /> : null }
262+ { sendingPrompt ? "Sending" : "Go" }
225263 < CaretRightIcon weight = "bold" />
226264 </ Button >
227265 </ Flex >
0 commit comments