feat: /profile command (#203)

This commit is contained in:
Devansh Jain
2025-12-13 12:42:30 -08:00
committed by GitHub
parent 0dda14103a
commit d592fde824
7 changed files with 599 additions and 103 deletions

View File

@@ -37,6 +37,7 @@ export function Input({
currentModel,
messageQueue,
onEnterQueueEditMode,
onEscapeCancel,
}: {
visible?: boolean;
streaming: boolean;
@@ -53,6 +54,7 @@ export function Input({
currentModel?: string | null;
messageQueue?: string[];
onEnterQueueEditMode?: () => void;
onEscapeCancel?: () => void;
}) {
const [value, setValue] = useState("");
const [escapePressed, setEscapePressed] = useState(false);
@@ -115,9 +117,28 @@ export function Input({
settings.env?.LETTA_BASE_URL ||
LETTA_CLOUD_API_URL;
// Handle profile confirmation: Enter confirms, any other key cancels
// When onEscapeCancel is provided, TextInput is unfocused so we handle all keys here
useInput((_input, key) => {
if (!visible) return;
if (!onEscapeCancel) return;
// Enter key confirms the action - trigger submit with empty input
if (key.return) {
onSubmit("");
return;
}
// Any other key cancels
onEscapeCancel();
});
// Handle escape key for interrupt (when streaming) or double-escape-to-clear (when not)
useInput((_input, key) => {
if (!visible) return;
// Skip if onEscapeCancel is provided - handled by the confirmation handler above
if (onEscapeCancel) return;
if (key.escape) {
// When streaming, use Esc to interrupt
if (streaming && onInterrupt && !interruptRequested) {
@@ -509,6 +530,7 @@ export function Input({
onSubmit={handleSubmit}
cursorPosition={cursorPos}
onCursorMove={setCurrentCursorPosition}
focus={!onEscapeCancel}
/>
</Box>
</Box>