Open History to see the last commit
1<script setup lang="ts">
2import { ref } from 'vue'
3
4const props = defineProps<{
5 isLoading: boolean
6}>()
7
8const emit = defineEmits<{
9 send: [message: string]
10 stop: []
11}>()
12
13const input = ref('')
14const textareaRef = ref<HTMLTextAreaElement>()
15
16const handleSend = () => {
17 if (input.value.trim() && !props.isLoading) {
18 emit('send', input.value)
19 input.value = ''
20 if (textareaRef.value) {
21 textareaRef.value.style.height = 'auto'
22 }
23 }
24}
25
26const handleKeydown = (e: KeyboardEvent) => {
27 if (e.key === 'Enter' && !e.shiftKey && input.value.trim()) {
28 e.preventDefault()
29 handleSend()
30 }
31}
32
33const handleInput = () => {
34 if (textareaRef.value) {
35 textareaRef.value.style.height = 'auto'
36 textareaRef.value.style.height =
37 Math.min(textareaRef.value.scrollHeight, 200) + 'px'
38 }
39}
40</script>
41
42<template>
43 <div class="border-t border-orange-500/10 bg-gray-900/80 backdrop-blur-sm">
44 <div class="w-full px-4 py-3">
45 <div class="space-y-3">
46 <div v-if="isLoading" class="flex items-center justify-center">
47 <button
48 @click="emit('stop')"
49 class="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-sm font-medium transition-colors flex items-center gap-2"
50 >
51 <svg class="w-4 h-4 fill-current" viewBox="0 0 24 24">
52 <rect x="6" y="6" width="12" height="12" />
53 </svg>
54 Stop
55 </button>
56 </div>
57 <div class="relative">
58 <textarea
59 ref="textareaRef"
60 v-model="input"
61 @keydown="handleKeydown"
62 @input="handleInput"
63 placeholder="Type something clever (or don't, we won't judge)..."
64 class="w-full rounded-lg border border-orange-500/20 bg-gray-800/50 pl-4 pr-12 py-3 text-sm text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-orange-500/50 focus:border-transparent resize-none overflow-hidden shadow-lg"
65 rows="1"
66 :disabled="isLoading"
67 :style="{ minHeight: '44px', maxHeight: '200px' }"
68 ></textarea>
69 <button
70 @click="handleSend"
71 :disabled="!input.trim() || isLoading"
72 class="absolute right-2 top-1/2 -translate-y-1/2 p-2 text-orange-500 hover:text-orange-400 disabled:text-gray-500 transition-colors focus:outline-none"
73 >
74 <svg
75 class="w-4 h-4"
76 fill="none"
77 stroke="currentColor"
78 viewBox="0 0 24 24"
79 >
80 <path
81 stroke-linecap="round"
82 stroke-linejoin="round"
83 stroke-width="2"
84 d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8"
85 />
86 </svg>
87 </button>
88 </div>
89 </div>
90 </div>
91 </div>
92</template>