diff --git a/src/components/file-picker.tsx b/src/components/file-picker.tsx index e3639d41..64480374 100644 --- a/src/components/file-picker.tsx +++ b/src/components/file-picker.tsx @@ -94,7 +94,7 @@ const FilePicker: Component = (props) => { isGitFile: false, })) - const filteredGitFiles = searchQuery + const filteredGitFiles = searchQuery.trim() ? gitFiles.filter((f) => f.path.toLowerCase().includes(searchQuery.toLowerCase())) : gitFiles const allFiles = [...filteredGitFiles, ...searchFiles] diff --git a/src/components/prompt-input.tsx b/src/components/prompt-input.tsx index 2fd69113..0dfe68d2 100644 --- a/src/components/prompt-input.tsx +++ b/src/components/prompt-input.tsx @@ -1,9 +1,9 @@ -import { createSignal, Show, onMount } from "solid-js" +import { createSignal, Show, onMount, For } from "solid-js" import AgentSelector from "./agent-selector" import ModelSelector from "./model-selector" import FilePicker from "./file-picker" import { addToHistory, getHistory } from "../stores/message-history" -import { getAttachments, addAttachment, clearAttachments } from "../stores/attachments" +import { getAttachments, addAttachment, clearAttachments, removeAttachment } from "../stores/attachments" import { createFileAttachment } from "../types/attachment" import type { Attachment } from "../types/attachment" import Kbd from "./kbd" @@ -38,6 +38,24 @@ export default function PromptInput(props: PromptInputProps) { const attachments = () => getAttachments(props.instanceId, props.sessionId) + function handleRemoveAttachment(attachmentId: string) { + removeAttachment(props.instanceId, props.sessionId, attachmentId) + + const currentAttachments = attachments() + const attachment = currentAttachments.find((a) => a.id === attachmentId) + if (attachment && attachment.source.type === "file") { + const filename = attachment.filename + const currentPrompt = prompt() + const newPrompt = currentPrompt.replace(`@${filename}`, "").replace(/\s+/g, " ").trim() + setPrompt(newPrompt) + + if (textareaRef) { + textareaRef.style.height = "auto" + textareaRef.style.height = Math.min(textareaRef.scrollHeight, 200) + "px" + } + } + } + onMount(async () => { const loaded = await getHistory(props.instanceFolder) setHistory(loaded) @@ -269,18 +287,39 @@ export default function PromptInput(props: PromptInputProps) { /> -