Welcome to the first chapter of the PromptInput project tutorial!
Before we dive into how the system processes what you type, we need to understand how the system communicates back to you while you are typing.
Imagine driving a car. You spend most of your time looking through the windshield (the Input Area), but you frequently glance down at the dashboard to check your speed, fuel, and warning lights.
The Footer Status Dashboard is that dashboard for your terminal.
In a standard Command Line Interface (CLI), you usually just get a blinking cursor. You might wonder:
The Footer Status Dashboard solves this by orchestrating a reactive strip of information immediately below your cursor. It dynamically changes based on Context.
To build this dashboard, we break it down into three distinct concepts:
INSERT vs COMMAND), permissions, and background tasks.At a high level, the Footer is a React component that takes the current state of your application as "props" and decides what to show.
Here is a simplified example of how you might implement the Footer in your main application loop:
// Example usage in a parent component
<PromptInputFooter
mode="prompt"
vimMode="INSERT"
isLoading={true}
exitMessage={{ show: false }}
toolPermissionContext={currentPermissions}
/>
What happens here?
mode: Tells the footer we are in standard prompt mode.vimMode: Triggers the visual "INSERT" indicator.isLoading: Switches the hints to show cancellation options instead of navigation options.Let's look under the hood. The Footer isn't just one static line of text; it is a decision engine.
When the application state changes (e.g., you press a key or a background task starts), the Footer recalculates its layout.
PromptInputFooter.tsx)
The main entry point is PromptInputFooter. It checks how wide your terminal is to decide if it should squish everything into one column or spread it out.
function PromptInputFooter(props: Props) {
const { columns } = useTerminalSize();
const isNarrow = columns < 80;
// If showing autocomplete suggestions, prioritize that view
if (props.suggestions.length) {
return <PromptInputFooterSuggestions {...props} />;
}
// Otherwise render the dashboard
return (
<Box flexDirection={isNarrow ? 'column' : 'row'}>
{/* Content goes here */}
</Box>
);
}
Explanation: We use a hook to get the terminal size. If isNarrow is true, we stack items vertically. If there are autocomplete suggestions (covered in Autocomplete Suggestion Overlay), they take over the footer entirely.
PromptInputFooterLeftSide.tsx)This is where the magic happens. This component decides exactly which indicators to show. For example, if you are in Vim mode, it takes priority over standard hints.
// Inside PromptInputFooterLeftSide
const showVim = isVimModeEnabled() &&
vimMode === "INSERT" &&
!isSearching;
if (showVim) {
// If in Vim Insert mode, show the indicator explicitly
return <Text dimColor>-- INSERT --</Text>;
}
Explanation: The code checks a specific combination of flags. You must be in Vim mode, specifically inside "INSERT", and not currently searching history.
Hints are not static strings. They are built as an array depending on what the user is doing.
// Building the hint parts array
const parts = [];
if (isLoading) {
// If the AI is thinking, show how to stop it
parts.push(<KeyboardShortcutHint shortcut="Esc" action="interrupt" />);
} else if (hasBackgroundTasks) {
// If agents are running, show how to manage them
parts.push(<KeyboardShortcutHint shortcut="Ctrl+T" action="show tasks" />);
}
Explanation: This approach ensures the UI is never cluttered. You only see the "interrupt" hint when there is actually something to interrupt.
Sometimes, critical system information needs to bypass standard hints. For example, if the application is running in a Sandbox environment or has stashed changes.
From PromptInputStashNotice.tsx:
export function PromptInputStashNotice({ hasStash }: Props) {
if (!hasStash) return null;
return (
<Box paddingLeft={2}>
<Text dimColor>
{figures.pointerSmall} Stashed (auto-restores after submit)
</Text>
</Box>
);
}
Explanation: This component follows the "Return Null" pattern. If there is no stash, it renders nothing (null), taking up zero space in the DOM.
The Footer Status Dashboard acts as the grounded source of truth for the user. By combining responsive design with conditional rendering logic, it ensures that users always know the state of the system without being overwhelmed by information.
Now that we have a place to display information, we need to handle the user's actual keystrokes.
Next Chapter: Smart Input Processing
Generated by Code IQ