diff --git a/src/components/prompt-input.tsx b/src/components/prompt-input.tsx index 18ca7c5c..5621de5c 100644 --- a/src/components/prompt-input.tsx +++ b/src/components/prompt-input.tsx @@ -1,15 +1,13 @@ -import { createSignal, Show, onMount, createEffect, For } from "solid-js" +import { createSignal, Show, onMount } from "solid-js" import AgentSelector from "./agent-selector" import ModelSelector from "./model-selector" import FilePicker from "./file-picker" -import AttachmentChip from "./attachment-chip" import { addToHistory, getHistory } from "../stores/message-history" -import { getAttachments, addAttachment, removeAttachment, clearAttachments } from "../stores/attachments" +import { getAttachments, addAttachment, clearAttachments } from "../stores/attachments" import { createFileAttachment } from "../types/attachment" import type { Attachment } from "../types/attachment" import Kbd from "./kbd" import HintRow from "./hint-row" -import { isMac } from "../lib/keyboard-utils" import { getActiveInstance } from "../stores/instances" interface PromptInputProps { @@ -133,7 +131,9 @@ export default function PromptInput(props: PromptInputProps) { const previousAtPosition = atPosition() - if (previousAtPosition !== null && lastAtIndex !== previousAtPosition) { + if (previousAtPosition !== null && lastAtIndex === -1) { + setIgnoredAtPositions(new Set()) + } else if (previousAtPosition !== null && lastAtIndex !== previousAtPosition) { setIgnoredAtPositions((prev) => { const next = new Set(prev) next.delete(previousAtPosition) @@ -171,13 +171,16 @@ export default function PromptInput(props: PromptInputProps) { if (pos !== null) { const before = currentPrompt.substring(0, pos) const after = currentPrompt.substring(cursorPos) - const newPrompt = before + " " + after + const attachmentText = `@${filename}` + const newPrompt = before + attachmentText + " " + after setPrompt(newPrompt) setTimeout(() => { if (textareaRef) { - const newCursorPos = pos + 1 + const newCursorPos = pos + attachmentText.length + 1 textareaRef.setSelectionRange(newCursorPos, newCursorPos) + textareaRef.style.height = "auto" + textareaRef.style.height = Math.min(textareaRef.scrollHeight, 200) + "px" } }, 0) } @@ -202,10 +205,6 @@ export default function PromptInput(props: PromptInputProps) { function handleFilePickerNavigate(_direction: "up" | "down") {} - function handleRemoveAttachment(attachmentId: string) { - removeAttachment(props.instanceId, props.sessionId, attachmentId) - } - function handleDragOver(e: DragEvent) { e.preventDefault() e.stopPropagation() @@ -264,14 +263,6 @@ export default function PromptInput(props: PromptInputProps) { /> - 0}> -
- - {(att) => handleRemoveAttachment(att.id)} />} - -
-
-