π File detail
components/PromptInput/usePromptInputPlaceholder.ts
π§© .tsπ 77 linesπΎ 2,391 bytesπ text
β Back to All Filesπ― Use case
This file lives under βcomponents/β, which covers shared React UI pieces. On the API surface it exposes usePromptInputPlaceholder β mainly functions, hooks, or classes. Dependencies touch bun:bundle, React UI, and src.
Generated from folder role, exports, dependency roots, and inline comments β not hand-reviewed for every path.
π§ Inline summary
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'
π€ Exports (heuristic)
usePromptInputPlaceholder
π External import roots
Package roots from from "β¦" (relative paths omitted).
bun:bundlereactsrc
π₯οΈ Source preview
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
}