mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
Merge dev: STT feature, git date fixes, and session improvements (#82)
* fix session last active * Feature/sst (#81) * Use CSS field-sizing for textarea auto-height and abort STT recording on clear * Fix invalid date display in git commits * Use Unix timestamps for git log dates
This commit is contained in:
1 parent
21010956f7
commit
cb1714a4e0
17 files changed
+2475
-76
No files matched your search
@@ -29,17 +29,26 @@ export function Combobox({
|
||||
allowCustomValue = true,
|
||||
}: ComboboxProps) {
|
||||
const [isOpen, setIsOpen] = useState(false)
|
||||
const [inputValue, setInputValue] = useState(value)
|
||||
const [inputValue, setInputValue] = useState(() => {
|
||||
const selectedOption = options.find(o => o.value === value)
|
||||
return selectedOption?.label || value
|
||||
})
|
||||
const [selectedIndex, setSelectedIndex] = useState(0)
|
||||
const [isUserTyping, setIsUserTyping] = useState(false)
|
||||
const inputRef = useRef<HTMLInputElement>(null)
|
||||
const listRef = useRef<HTMLDivElement>(null)
|
||||
const containerRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
setInputValue(value)
|
||||
}, [value])
|
||||
if (!isUserTyping) {
|
||||
const selectedOption = options.find(o => o.value === value)
|
||||
setInputValue(selectedOption?.label || value)
|
||||
}
|
||||
}, [value, options, isUserTyping])
|
||||
|
||||
const filteredOptions = options.filter(option =>
|
||||
const isExactMatch = options.some(o => o.value === value || o.label === inputValue)
|
||||
|
||||
const filteredOptions = (isExactMatch && !isUserTyping) ? options : options.filter(option =>
|
||||
option.value.toLowerCase().includes(inputValue.toLowerCase()) ||
|
||||
option.label.toLowerCase().includes(inputValue.toLowerCase()) ||
|
||||
(option.description?.toLowerCase().includes(inputValue.toLowerCase()))
|
||||
@@ -87,11 +96,13 @@ export function Combobox({
|
||||
}, [selectedIndex, isOpen])
|
||||
|
||||
const handleSelect = useCallback((optionValue: string) => {
|
||||
setInputValue(optionValue)
|
||||
const selectedOption = options.find(o => o.value === optionValue)
|
||||
setInputValue(selectedOption?.label || optionValue)
|
||||
onChange(optionValue)
|
||||
setIsOpen(false)
|
||||
setIsUserTyping(false)
|
||||
inputRef.current?.blur()
|
||||
}, [onChange])
|
||||
}, [onChange, options])
|
||||
|
||||
const handleKeyDown = useCallback((e: React.KeyboardEvent) => {
|
||||
if (!isOpen) {
|
||||
@@ -137,6 +148,7 @@ export function Combobox({
|
||||
const newValue = e.target.value
|
||||
setInputValue(newValue)
|
||||
setIsOpen(true)
|
||||
setIsUserTyping(true)
|
||||
if (allowCustomValue) {
|
||||
onChange(newValue)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user