usePromptInputPlaceholder.ts
components/PromptInput/usePromptInputPlaceholder.ts
77
Lines
2391
Bytes
1
Exports
7
Imports
10
Keywords
What this is
This page documents one file from the repository and includes its full source so you can read it without leaving the docs site.
Beginner explanation
This file is one piece of the larger system. Its name, directory, imports, and exports show where it fits. Start by reading the exports and related files first.
How it is used
Start from the exports list and related files. Those are the easiest clues for where this file fits into the system.
Expert explanation
Architecturally, this file intersects with ui-flow. It contains 77 lines, 7 detected imports, and 1 detected exports.
Important relationships
- components/PromptInput/HistorySearchInput.tsx
- components/PromptInput/IssueFlagBanner.tsx
- components/PromptInput/Notifications.tsx
- components/PromptInput/PromptInput.tsx
- components/PromptInput/PromptInputFooter.tsx
- components/PromptInput/PromptInputFooterLeftSide.tsx
- components/PromptInput/PromptInputFooterSuggestions.tsx
- components/PromptInput/PromptInputHelpMenu.tsx
Detected exports
usePromptInputPlaceholder
Keywords
viewingagentnameproactiveinputsubmitcountpromptsuggestionenabledfeatureusecommandqueueutilsmax_teammate_name_lengthqueuedcommands
Detected imports
bun:bundlereactsrc/hooks/useCommandQueue.jssrc/state/AppState.jssrc/utils/config.jssrc/utils/exampleCommands.jssrc/utils/messageQueueManager.js
Source notes
This page embeds the full file contents. Small or leaf files are still indexed honestly instead of being over-explained.
Full source
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'
// Dead code elimination: conditional import for proactive mode
/* eslint-disable @typescript-eslint/no-require-imports */
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
}
// Show teammate hint when viewing teammate
if (viewingAgentName) {
const displayName =
viewingAgentName.length > MAX_TEAMMATE_NAME_LENGTH
? viewingAgentName.slice(0, MAX_TEAMMATE_NAME_LENGTH - 3) + '...'
: viewingAgentName
return `Message @${displayName}…`
}
// Show queue hint if user has not seen it yet.
// Only count user-editable commands — task-notification and isMeta
// are hidden from the prompt area (see PromptInputQueuedCommands).
if (
queuedCommands.some(isQueuedCommandEditable) &&
(getGlobalConfig().queuedCommandUpHintCount || 0) <
NUM_TIMES_QUEUE_HINT_SHOWN
) {
return 'Press up to edit queued messages'
}
// Show example command if user has not submitted yet and suggestions are enabled.
// Skip in proactive mode — the model drives the conversation so onboarding
// examples are irrelevant and block prompt suggestions from showing.
if (
submitCount < 1 &&
promptSuggestionEnabled &&
!proactiveModule?.isProactiveActive()
) {
return getExampleCommandFromCache()
}
}, [
input,
queuedCommands,
submitCount,
promptSuggestionEnabled,
viewingAgentName,
])
return placeholder
}