mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-08 07:17:39 +00:00
feat: refactor ChatInput with autocomplete, suggestion management, and settings integration
Extract word detection and suggestion logic into reusable utilities and hooks. Add FloatingOverlay and Autocomplete components for intelligent input assistance. Integrate settings panel and abort button directly into ChatInput component. Simplify SessionHeader by removing settings dialog (now in ChatInput).
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { useMemo } from 'react'
|
||||
import { findActiveWord } from '@/utils/findActiveWord'
|
||||
|
||||
/**
|
||||
* Hook that detects the active word at the cursor position
|
||||
* Returns the active word string if cursor is on a word starting with one of the prefixes
|
||||
*/
|
||||
export function useActiveWord(
|
||||
text: string,
|
||||
selection: { start: number; end: number },
|
||||
prefixes: string[] = ['@', '/']
|
||||
) {
|
||||
return useMemo(() => {
|
||||
const w = findActiveWord(text, selection, prefixes)
|
||||
if (w) {
|
||||
return w.activeWord
|
||||
}
|
||||
return null
|
||||
}, [text, selection.start, selection.end, prefixes])
|
||||
}
|
||||
Reference in New Issue
Block a user