@@ -17,14 +17,9 @@ import { HistoryDialog } from "@/components/history-dialog"
1717import { ModelSelector } from "@/components/model-selector"
1818import { ResetWarningModal } from "@/components/reset-warning-modal"
1919import { SaveDialog } from "@/components/save-dialog"
20+
2021import { Button } from "@/components/ui/button"
21- import { Switch } from "@/components/ui/switch"
2222import { Textarea } from "@/components/ui/textarea"
23- import {
24- Tooltip ,
25- TooltipContent ,
26- TooltipTrigger ,
27- } from "@/components/ui/tooltip"
2823import { useDiagram } from "@/contexts/diagram-context"
2924import { useDictionary } from "@/hooks/use-dictionary"
3025import { formatMessage } from "@/lib/i18n/utils"
@@ -152,12 +147,9 @@ interface ChatInputProps {
152147 File ,
153148 { text : string ; charCount : number ; isExtracting : boolean }
154149 >
155- showHistory ?: boolean
156- onToggleHistory ?: ( show : boolean ) => void
150+
157151 sessionId ?: string
158152 error ?: Error | null
159- minimalStyle ?: boolean
160- onMinimalStyleChange ?: ( value : boolean ) => void
161153 // Model selector props
162154 models ?: FlattenedModel [ ]
163155 selectedModelId ?: string
@@ -175,29 +167,23 @@ export function ChatInput({
175167 files = [ ] ,
176168 onFileChange = ( ) => { } ,
177169 pdfData = new Map ( ) ,
178- showHistory = false ,
179- onToggleHistory = ( ) => { } ,
180170 sessionId,
181171 error = null ,
182- minimalStyle = false ,
183- onMinimalStyleChange = ( ) => { } ,
184172 models = [ ] ,
185173 selectedModelId,
186174 onModelSelect = ( ) => { } ,
187175 showUnvalidatedModels = false ,
188176 onConfigureModels = ( ) => { } ,
189177} : ChatInputProps ) {
190178 const dict = useDictionary ( )
191- const {
192- diagramHistory,
193- saveDiagramToFile,
194- showSaveDialog,
195- setShowSaveDialog,
196- } = useDiagram ( )
179+ const { diagramHistory, saveDiagramToFile } = useDiagram ( )
180+
197181 const textareaRef = useRef < HTMLTextAreaElement > ( null )
198182 const fileInputRef = useRef < HTMLInputElement > ( null )
199183 const [ isDragging , setIsDragging ] = useState ( false )
200184 const [ showClearDialog , setShowClearDialog ] = useState ( false )
185+ const [ showHistory , setShowHistory ] = useState ( false )
186+ const [ showSaveDialog , setShowSaveDialog ] = useState ( false )
201187 // Allow retry when there's an error (even if status is still "streaming" or "submitted")
202188 const isDisabled =
203189 ( status === "streaming" || status === "submitted" ) && ! error
@@ -385,99 +371,58 @@ export function ChatInput({
385371 onOpenChange = { setShowClearDialog }
386372 onClear = { handleClear }
387373 />
388-
389- < HistoryDialog
390- showHistory = { showHistory }
391- onToggleHistory = { onToggleHistory }
392- />
393-
394- < Tooltip >
395- < TooltipTrigger asChild >
396- < div className = "flex items-center gap-1.5" >
397- < Switch
398- id = "minimal-style"
399- checked = { minimalStyle }
400- onCheckedChange = { onMinimalStyleChange }
401- className = "scale-75"
402- />
403- < label
404- htmlFor = "minimal-style"
405- className = { `text-xs cursor-pointer select-none ${
406- minimalStyle
407- ? "text-primary font-medium"
408- : "text-muted-foreground"
409- } `}
410- >
411- { minimalStyle
412- ? dict . chat . minimalStyle
413- : dict . chat . styledMode }
414- </ label >
415- </ div >
416- </ TooltipTrigger >
417- < TooltipContent side = "top" >
418- { dict . chat . minimalTooltip }
419- </ TooltipContent >
420- </ Tooltip >
421374 </ div >
422375
423376 < div className = "flex items-center gap-1 overflow-hidden justify-end" >
424- < ButtonWithTooltip
425- type = "button"
426- variant = "ghost"
427- size = "sm"
428- onClick = { ( ) => onToggleHistory ( true ) }
429- disabled = { isDisabled || diagramHistory . length === 0 }
430- tooltipContent = { dict . chat . diagramHistory }
431- className = "h-8 w-8 p-0 text-muted-foreground hover:text-foreground"
432- >
433- < History className = "h-4 w-4" />
434- </ ButtonWithTooltip >
435-
436- < ButtonWithTooltip
437- type = "button"
438- variant = "ghost"
439- size = "sm"
440- onClick = { ( ) => setShowSaveDialog ( true ) }
441- disabled = { isDisabled }
442- tooltipContent = { dict . chat . saveDiagram }
443- className = "h-8 w-8 p-0 text-muted-foreground hover:text-foreground"
444- >
445- < Download className = "h-4 w-4" />
446- </ ButtonWithTooltip >
447-
448- < SaveDialog
449- open = { showSaveDialog }
450- onOpenChange = { setShowSaveDialog }
451- onSave = { ( filename , format ) =>
452- saveDiagramToFile ( filename , format , sessionId )
453- }
454- defaultFilename = { `diagram-${ new Date ( )
455- . toISOString ( )
456- . slice ( 0 , 10 ) } `}
457- />
458-
459- < ButtonWithTooltip
460- type = "button"
461- variant = "ghost"
462- size = "sm"
463- onClick = { triggerFileInput }
464- disabled = { isDisabled }
465- tooltipContent = { dict . chat . uploadFile }
466- className = "h-8 w-8 p-0 text-muted-foreground hover:text-foreground"
467- >
468- < ImageIcon className = "h-4 w-4" />
469- </ ButtonWithTooltip >
470-
471- < input
472- type = "file"
473- ref = { fileInputRef }
474- className = "hidden"
475- onChange = { handleFileChange }
476- accept = "image/*,.pdf,application/pdf,text/*,.md,.markdown,.json,.csv,.xml,.yaml,.yml,.toml"
477- multiple
478- disabled = { isDisabled }
479- />
480-
377+ < div className = "flex items-center gap-1 overflow-x-hidden" >
378+ < ButtonWithTooltip
379+ type = "button"
380+ variant = "ghost"
381+ size = "sm"
382+ onClick = { ( ) => setShowHistory ( true ) }
383+ disabled = {
384+ isDisabled || diagramHistory . length === 0
385+ }
386+ tooltipContent = { dict . chat . diagramHistory }
387+ className = "h-8 w-8 p-0 text-muted-foreground hover:text-foreground"
388+ >
389+ < History className = "h-4 w-4" />
390+ </ ButtonWithTooltip >
391+
392+ < ButtonWithTooltip
393+ type = "button"
394+ variant = "ghost"
395+ size = "sm"
396+ onClick = { ( ) => setShowSaveDialog ( true ) }
397+ disabled = { isDisabled }
398+ tooltipContent = { dict . chat . saveDiagram }
399+ className = "h-8 w-8 p-0 text-muted-foreground hover:text-foreground"
400+ >
401+ < Download className = "h-4 w-4" />
402+ </ ButtonWithTooltip >
403+
404+ < ButtonWithTooltip
405+ type = "button"
406+ variant = "ghost"
407+ size = "sm"
408+ onClick = { triggerFileInput }
409+ disabled = { isDisabled }
410+ tooltipContent = { dict . chat . uploadFile }
411+ className = "h-8 w-8 p-0 text-muted-foreground hover:text-foreground"
412+ >
413+ < ImageIcon className = "h-4 w-4" />
414+ </ ButtonWithTooltip >
415+
416+ < input
417+ type = "file"
418+ ref = { fileInputRef }
419+ className = "hidden"
420+ onChange = { handleFileChange }
421+ accept = "image/*,.pdf,application/pdf,text/*,.md,.markdown,.json,.csv,.xml,.yaml,.yml,.toml"
422+ multiple
423+ disabled = { isDisabled }
424+ />
425+ </ div >
481426 < ModelSelector
482427 models = { models }
483428 selectedModelId = { selectedModelId }
@@ -486,9 +431,7 @@ export function ChatInput({
486431 disabled = { isDisabled }
487432 showUnvalidatedModels = { showUnvalidatedModels }
488433 />
489-
490434 < div className = "w-px h-5 bg-border mx-1" />
491-
492435 < Button
493436 type = "submit"
494437 disabled = { isDisabled || ! input . trim ( ) }
@@ -510,6 +453,20 @@ export function ChatInput({
510453 </ div >
511454 </ div >
512455 </ div >
456+ < HistoryDialog
457+ showHistory = { showHistory }
458+ onToggleHistory = { setShowHistory }
459+ />
460+ < SaveDialog
461+ open = { showSaveDialog }
462+ onOpenChange = { setShowSaveDialog }
463+ onSave = { ( filename , format ) =>
464+ saveDiagramToFile ( filename , format , sessionId )
465+ }
466+ defaultFilename = { `diagram-${ new Date ( )
467+ . toISOString ( )
468+ . slice ( 0 , 10 ) } `}
469+ />
513470 </ form >
514471 )
515472}
0 commit comments