11import { useState , useRef } from "react"
22import { InputGroup , InputGroupAddon , InputGroupButton , InputGroupTextarea } from "@/components/ui/input-group"
3- import { IconCommand , IconLoader , IconPlayerStopFilled , IconRecycle , IconSend , IconTerminal2 } from "@tabler/icons-react"
3+ import { IconCommand , IconLoader , IconPlayerStopFilled , IconSend , IconTerminal2 } from "@tabler/icons-react"
44import React from "react"
55import { VoiceInputButton } from "./voice-input-button"
66import type { TaskMessageHandlerStatus } from "@/components/console/task/task-message-handler"
77import type { AvailableCommand , AvailableCommands , TaskStreamStatus } from "./task-shared"
88import { Button } from "@/components/ui/button"
99import { DropdownMenu , DropdownMenuContent , DropdownMenuItem , DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
10- import {
11- AlertDialog ,
12- AlertDialogAction ,
13- AlertDialogCancel ,
14- AlertDialogContent ,
15- AlertDialogDescription ,
16- AlertDialogFooter ,
17- AlertDialogHeader ,
18- AlertDialogTitle ,
19- } from "@/components/ui/alert-dialog"
2010import { cn } from "@/lib/utils"
2111
2212
@@ -26,15 +16,13 @@ interface TaskChatInputBoxProps {
2616 onSend : ( content : string ) => void
2717 sending : boolean
2818 queueSize : number
29- sendResetSession : ( ) => Promise < boolean >
3019 executionTimeMs ?: number
3120 onCancel ?: ( ) => void
3221}
3322
34- export const TaskChatInputBox = ( { streamStatus, availableCommands, onSend, sending, queueSize, sendResetSession , executionTimeMs = 0 , onCancel } : TaskChatInputBoxProps ) => {
23+ export const TaskChatInputBox = ( { streamStatus, availableCommands, onSend, sending, queueSize, executionTimeMs = 0 , onCancel } : TaskChatInputBoxProps ) => {
3524 const [ content , setContent ] = useState ( '' )
3625 const [ isComposing , setIsComposing ] = useState ( false )
37- const [ resetDialogOpen , setResetDialogOpen ] = useState ( false )
3826 const textareaRef = useRef < HTMLTextAreaElement > ( null )
3927 const isExecuting = ( streamStatus === 'connected' || streamStatus === 'inited' )
4028
@@ -109,20 +97,11 @@ export const TaskChatInputBox = ({ streamStatus, availableCommands, onSend, send
10997 < div className = "flex flex-row gap-2 items-center min-w-0" >
11098 < DropdownMenu >
11199 < DropdownMenuTrigger asChild >
112- < Button variant = "outline" size = "icon-sm" className = "rounded-full" disabled = { controlsDisabled } >
100+ < Button variant = "outline" size = "icon-sm" className = "rounded-full" disabled = { controlsDisabled || ! showCommandItems } >
113101 < IconTerminal2 />
114102 </ Button >
115103 </ DropdownMenuTrigger >
116104 < DropdownMenuContent className = { showCommandItems ? "w-[min(90vw,32rem)] min-w-80 max-w-[min(90vw,32rem)]" : "w-48 min-w-48" } >
117- < DropdownMenuItem className = "flex flex-col items-start gap-1 whitespace-normal" onClick = { ( ) => setResetDialogOpen ( true ) } >
118- < div className = "flex min-w-0 flex-row flex-wrap items-center gap-2" >
119- < IconRecycle />
120- < div className = "font-bold text-xs" > 重置上下文</ div >
121- </ div >
122- < div className = "max-w-full truncate pl-6 text-xs text-muted-foreground" >
123- 清空当前会话上下文,后续操作将基于新的上下文继续进行。
124- </ div >
125- </ DropdownMenuItem >
126105 { showCommandItems && (
127106 < >
128107 { commandItems . map ( ( command : AvailableCommand , index : number ) => (
@@ -169,30 +148,6 @@ export const TaskChatInputBox = ({ streamStatus, availableCommands, onSend, send
169148 </ div >
170149 </ InputGroupAddon >
171150 </ InputGroup >
172-
173- { /* Reset Session 确认对话框 */ }
174- < AlertDialog open = { resetDialogOpen } onOpenChange = { setResetDialogOpen } >
175- < AlertDialogContent >
176- < AlertDialogHeader >
177- < AlertDialogTitle > 重置上下文</ AlertDialogTitle >
178- < AlertDialogDescription >
179- 确定要重置当前上下文吗?后续操作将会基于新的上下文进行。
180- </ AlertDialogDescription >
181- </ AlertDialogHeader >
182- < AlertDialogFooter >
183- < AlertDialogCancel > 取消</ AlertDialogCancel >
184- < AlertDialogAction
185- onClick = { ( ) => {
186- void sendResetSession ( )
187- setResetDialogOpen ( false )
188- } }
189- >
190- 确认
191- </ AlertDialogAction >
192- </ AlertDialogFooter >
193- </ AlertDialogContent >
194- </ AlertDialog >
195-
196151 </ div >
197152 )
198153}
0 commit comments