| import { feature } from 'bun:bundle' |
| import { useMemo } from 'react' |
| import { useCommandQueue } from 'src/hooks/useCommandQueue.js' |
| import { useAppState } from 'src/state/AppState.js' |
| import { getGlobalConfig } from 'src/utils/config.js' |
| import { getExampleCommandFromCache } from 'src/utils/exampleCommands.js' |
| import { isQueuedCommandEditable } from 'src/utils/messageQueueManager.js' |
|
|
| |
| |
| const proactiveModule = |
| feature('PROACTIVE') || feature('KAIROS') |
| ? require('../../proactive/index.js') |
| : null |
|
|
| type Props = { |
| input: string |
| submitCount: number |
| viewingAgentName?: string |
| } |
|
|
| const NUM_TIMES_QUEUE_HINT_SHOWN = 3 |
| const MAX_TEAMMATE_NAME_LENGTH = 20 |
|
|
| export function usePromptInputPlaceholder({ |
| input, |
| submitCount, |
| viewingAgentName, |
| }: Props): string | undefined { |
| const queuedCommands = useCommandQueue() |
| const promptSuggestionEnabled = useAppState(s => s.promptSuggestionEnabled) |
| const placeholder = useMemo(() => { |
| if (input !== '') { |
| return |
| } |
|
|
| |
| if (viewingAgentName) { |
| const displayName = |
| viewingAgentName.length > MAX_TEAMMATE_NAME_LENGTH |
| ? viewingAgentName.slice(0, MAX_TEAMMATE_NAME_LENGTH - 3) + '...' |
| : viewingAgentName |
| return `Message @${displayName}…` |
| } |
|
|
| |
| |
| |
| if ( |
| queuedCommands.some(isQueuedCommandEditable) && |
| (getGlobalConfig().queuedCommandUpHintCount || 0) < |
| NUM_TIMES_QUEUE_HINT_SHOWN |
| ) { |
| return 'Press up to edit queued messages' |
| } |
|
|
| |
| |
| |
| if ( |
| submitCount < 1 && |
| promptSuggestionEnabled && |
| !proactiveModule?.isProactiveActive() |
| ) { |
| return getExampleCommandFromCache() |
| } |
| }, [ |
| input, |
| queuedCommands, |
| submitCount, |
| promptSuggestionEnabled, |
| viewingAgentName, |
| ]) |
|
|
| return placeholder |
| } |
|
|