feat: integrate ExpandButton and apply dynamic height to textarea

This commit is contained in:
bizzkoot
2026-01-11 20:07:48 +08:00
parent 1122c19648
commit 0fefff3b0a

View File

@@ -1,6 +1,7 @@
import { createSignal, Show, onMount, For, onCleanup, createEffect, on, untrack } from "solid-js" import { createSignal, Show, onMount, For, onCleanup, createEffect, on, untrack } from "solid-js"
import { ArrowBigUp, ArrowBigDown } from "lucide-solid" import { ArrowBigUp, ArrowBigDown } from "lucide-solid"
import UnifiedPicker from "./unified-picker" import UnifiedPicker from "./unified-picker"
import ExpandButton from "./expand-button"
import { addToHistory, getHistory } from "../stores/message-history" import { addToHistory, getHistory } from "../stores/message-history"
import { getAttachments, addAttachment, clearAttachments, removeAttachment } from "../stores/attachments" import { getAttachments, addAttachment, clearAttachments, removeAttachment } from "../stores/attachments"
import { resolvePastedPlaceholders } from "../lib/prompt-placeholders" import { resolvePastedPlaceholders } from "../lib/prompt-placeholders"
@@ -719,7 +720,13 @@ export default function PromptInput(props: PromptInputProps) {
if (!props.onAbortSession || !props.isSessionBusy) return if (!props.onAbortSession || !props.isSessionBusy) return
void props.onAbortSession() void props.onAbortSession()
} }
function handleExpandToggle(nextState: "normal" | "fifty" | "eighty") {
setExpandState(nextState)
// Keep focus on textarea
textareaRef?.focus()
}
function handleInput(e: Event) { function handleInput(e: Event) {
const target = e.target as HTMLTextAreaElement const target = e.target as HTMLTextAreaElement
@@ -1197,7 +1204,12 @@ export default function PromptInput(props: PromptInputProps) {
onBlur={() => setIsFocused(false)} onBlur={() => setIsFocused(false)}
disabled={props.disabled} disabled={props.disabled}
rows={4} rows={4}
style={attachments().length > 0 ? { "padding-top": "8px" } : {}} style={{
"padding-top": attachments().length > 0 ? "8px" : "0",
"height": getExpandedHeight(),
"overflow-y": expandState() !== "normal" ? "auto" : "visible",
"transition": "height 0.25s ease",
}}
spellcheck={false} spellcheck={false}
autocorrect="off" autocorrect="off"
autoCapitalize="off" autoCapitalize="off"
@@ -1227,6 +1239,12 @@ export default function PromptInput(props: PromptInputProps) {
</button> </button>
</div> </div>
</Show> </Show>
<div class="prompt-expand-top">
<ExpandButton
expandState={expandState}
onToggleExpand={handleExpandToggle}
/>
</div>
<Show when={shouldShowOverlay()}> <Show when={shouldShowOverlay()}>
<div class={`prompt-input-overlay ${mode() === "shell" ? "shell-mode" : ""}`}> <div class={`prompt-input-overlay ${mode() === "shell" ? "shell-mode" : ""}`}>
<Show <Show