Compare commits
1 Commits
fix/input-
...
fix/inputb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
776fb27a58 |
@@ -51,7 +51,7 @@ export function useTextareaResize(options: UseTextareaResizeOptions = {}): UseTe
|
|||||||
const { maxHeight = 400, minHeight = 30, autoResize = true } = options
|
const { maxHeight = 400, minHeight = 30, autoResize = true } = options
|
||||||
|
|
||||||
const textareaRef = useRef<TextAreaRef>(null)
|
const textareaRef = useRef<TextAreaRef>(null)
|
||||||
const [customHeight, setCustomHeight] = useState<number>()
|
const [customHeight, setCustomHeight] = useState<number | undefined>(undefined)
|
||||||
const [isExpanded, setIsExpanded] = useState(false)
|
const [isExpanded, setIsExpanded] = useState(false)
|
||||||
|
|
||||||
const resize = useCallback(
|
const resize = useCallback(
|
||||||
|
|||||||
@@ -177,8 +177,10 @@ const AgentSessionInputbarInner: FC<InnerProps> = ({ assistant, agentId, session
|
|||||||
resize: resizeTextArea,
|
resize: resizeTextArea,
|
||||||
focus: focusTextarea,
|
focus: focusTextarea,
|
||||||
setExpanded,
|
setExpanded,
|
||||||
isExpanded: textareaIsExpanded
|
isExpanded: textareaIsExpanded,
|
||||||
} = useTextareaResize({ maxHeight: 400, minHeight: 30 })
|
customHeight,
|
||||||
|
setCustomHeight
|
||||||
|
} = useTextareaResize({ maxHeight: 500, minHeight: 30 })
|
||||||
const { sendMessageShortcut, apiServer } = useSettings()
|
const { sendMessageShortcut, apiServer } = useSettings()
|
||||||
|
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@@ -474,6 +476,8 @@ const AgentSessionInputbarInner: FC<InnerProps> = ({ assistant, agentId, session
|
|||||||
text={text}
|
text={text}
|
||||||
onTextChange={setText}
|
onTextChange={setText}
|
||||||
textareaRef={textareaRef}
|
textareaRef={textareaRef}
|
||||||
|
height={customHeight}
|
||||||
|
onHeightChange={setCustomHeight}
|
||||||
resizeTextArea={resizeTextArea}
|
resizeTextArea={resizeTextArea}
|
||||||
focusTextarea={focusTextarea}
|
focusTextarea={focusTextarea}
|
||||||
placeholder={placeholderText}
|
placeholder={placeholderText}
|
||||||
|
|||||||
@@ -143,9 +143,11 @@ const InputbarInner: FC<InputbarInnerProps> = ({ assistant: initialAssistant, se
|
|||||||
resize: resizeTextArea,
|
resize: resizeTextArea,
|
||||||
focus: focusTextarea,
|
focus: focusTextarea,
|
||||||
setExpanded,
|
setExpanded,
|
||||||
isExpanded: textareaIsExpanded
|
isExpanded: textareaIsExpanded,
|
||||||
|
customHeight,
|
||||||
|
setCustomHeight
|
||||||
} = useTextareaResize({
|
} = useTextareaResize({
|
||||||
maxHeight: 400,
|
maxHeight: 500,
|
||||||
minHeight: 30
|
minHeight: 30
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -257,7 +259,7 @@ const InputbarInner: FC<InputbarInnerProps> = ({ assistant: initialAssistant, se
|
|||||||
setText('')
|
setText('')
|
||||||
setFiles([])
|
setFiles([])
|
||||||
setTimeoutTimer('sendMessage_1', () => setText(''), 500)
|
setTimeoutTimer('sendMessage_1', () => setText(''), 500)
|
||||||
setTimeoutTimer('sendMessage_2', () => resizeTextArea(true), 0)
|
setTimeoutTimer('sendMessage_2', () => resizeTextArea(), 0)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.warn('Failed to send message:', error as Error)
|
logger.warn('Failed to send message:', error as Error)
|
||||||
parent?.recordException(error as Error)
|
parent?.recordException(error as Error)
|
||||||
@@ -478,6 +480,8 @@ const InputbarInner: FC<InputbarInnerProps> = ({ assistant: initialAssistant, se
|
|||||||
text={text}
|
text={text}
|
||||||
onTextChange={setText}
|
onTextChange={setText}
|
||||||
textareaRef={textareaRef}
|
textareaRef={textareaRef}
|
||||||
|
height={customHeight}
|
||||||
|
onHeightChange={setCustomHeight}
|
||||||
resizeTextArea={resizeTextArea}
|
resizeTextArea={resizeTextArea}
|
||||||
focusTextarea={focusTextarea}
|
focusTextarea={focusTextarea}
|
||||||
isLoading={loading}
|
isLoading={loading}
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ export interface InputbarCoreProps {
|
|||||||
resizeTextArea: (force?: boolean) => void
|
resizeTextArea: (force?: boolean) => void
|
||||||
focusTextarea: () => void
|
focusTextarea: () => void
|
||||||
|
|
||||||
|
height: number | undefined
|
||||||
|
onHeightChange: (height: number) => void
|
||||||
|
|
||||||
supportedExts: string[]
|
supportedExts: string[]
|
||||||
isLoading: boolean
|
isLoading: boolean
|
||||||
|
|
||||||
@@ -104,6 +107,8 @@ export const InputbarCore: FC<InputbarCoreProps> = ({
|
|||||||
textareaRef,
|
textareaRef,
|
||||||
resizeTextArea,
|
resizeTextArea,
|
||||||
focusTextarea,
|
focusTextarea,
|
||||||
|
height,
|
||||||
|
onHeightChange,
|
||||||
supportedExts,
|
supportedExts,
|
||||||
isLoading,
|
isLoading,
|
||||||
onPause,
|
onPause,
|
||||||
@@ -131,8 +136,6 @@ export const InputbarCore: FC<InputbarCoreProps> = ({
|
|||||||
} = useSettings()
|
} = useSettings()
|
||||||
const quickPanelTriggersEnabled = forceEnableQuickPanelTriggers ?? enableQuickPanelTriggers
|
const quickPanelTriggersEnabled = forceEnableQuickPanelTriggers ?? enableQuickPanelTriggers
|
||||||
|
|
||||||
const [textareaHeight, setTextareaHeight] = useState<number>()
|
|
||||||
|
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const [isTranslating, setIsTranslating] = useState(false)
|
const [isTranslating, setIsTranslating] = useState(false)
|
||||||
const { getLanguageByLangcode } = useTranslate()
|
const { getLanguageByLangcode } = useTranslate()
|
||||||
@@ -539,7 +542,7 @@ export const InputbarCore: FC<InputbarCoreProps> = ({
|
|||||||
const handleMouseMove = (e: MouseEvent) => {
|
const handleMouseMove = (e: MouseEvent) => {
|
||||||
const deltaY = startDragY.current - e.clientY
|
const deltaY = startDragY.current - e.clientY
|
||||||
const newHeight = Math.max(40, Math.min(400, startHeight.current + deltaY))
|
const newHeight = Math.max(40, Math.min(400, startHeight.current + deltaY))
|
||||||
setTextareaHeight(newHeight)
|
onHeightChange(newHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleMouseUp = () => {
|
const handleMouseUp = () => {
|
||||||
@@ -550,7 +553,7 @@ export const InputbarCore: FC<InputbarCoreProps> = ({
|
|||||||
document.addEventListener('mousemove', handleMouseMove)
|
document.addEventListener('mousemove', handleMouseMove)
|
||||||
document.addEventListener('mouseup', handleMouseUp)
|
document.addEventListener('mouseup', handleMouseUp)
|
||||||
},
|
},
|
||||||
[config.enableDragDrop, setTextareaHeight, textareaRef]
|
[config.enableDragDrop, onHeightChange, textareaRef]
|
||||||
)
|
)
|
||||||
|
|
||||||
const onQuote = useCallback(
|
const onQuote = useCallback(
|
||||||
@@ -667,11 +670,11 @@ export const InputbarCore: FC<InputbarCoreProps> = ({
|
|||||||
variant="borderless"
|
variant="borderless"
|
||||||
spellCheck={enableSpellCheck}
|
spellCheck={enableSpellCheck}
|
||||||
rows={2}
|
rows={2}
|
||||||
autoSize={textareaHeight ? false : { minRows: 2, maxRows: 20 }}
|
autoSize={height ? false : { minRows: 2, maxRows: 20 }}
|
||||||
styles={{ textarea: TextareaStyle }}
|
styles={{ textarea: TextareaStyle }}
|
||||||
style={{
|
style={{
|
||||||
fontSize,
|
fontSize,
|
||||||
height: textareaHeight,
|
height: height,
|
||||||
minHeight: '30px'
|
minHeight: '30px'
|
||||||
}}
|
}}
|
||||||
disabled={isTranslating || searching}
|
disabled={isTranslating || searching}
|
||||||
|
|||||||
Reference in New Issue
Block a user