feat: implement platform-specific expand chat input with mobile optimizations
- Add platform detection (Electron vs Web) for expand behavior - Electron: 3-state (normal → 50% → 80%) with double-click - Web/Mobile: 2-state (normal → expanded) with instant single tap - Implement fixed 15-line height for web/mobile (360px, capped) - Add orientation-aware height calculation (landscape vs portrait) - Remove tooltip on web/mobile, keep for Electron desktop - Add responsive placeholder text to prevent overlap on mobile - Desktop: "Type your message, @file, @agent, or paste images and text..." - Mobile (≤640px): "Type message, @file, @agent..." - Delete dev-docs/expand-chat-input.md per upstream feedback Addresses PR feedback to simplify from 3-state to 2-state for web/mobile while maintaining rich desktop experience in Electron app.
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { createSignal, Show } from "solid-js"
|
||||
import { Maximize2, Minimize2 } from "lucide-solid"
|
||||
import { isElectronHost } from "../lib/runtime-env"
|
||||
|
||||
interface ExpandButtonProps {
|
||||
expandState: () => "normal" | "fifty" | "eighty"
|
||||
onToggleExpand: (nextState: "normal" | "fifty" | "eighty") => void
|
||||
expandState: () => "normal" | "fifty" | "eighty" | "expanded"
|
||||
onToggleExpand: (nextState: "normal" | "fifty" | "eighty" | "expanded") => void
|
||||
}
|
||||
|
||||
export default function ExpandButton(props: ExpandButtonProps) {
|
||||
@@ -11,7 +12,23 @@ export default function ExpandButton(props: ExpandButtonProps) {
|
||||
const [clickTimer, setClickTimer] = createSignal<number | null>(null)
|
||||
const DOUBLE_CLICK_THRESHOLD = 300
|
||||
|
||||
// Check if we're in Electron (desktop app with 3-state support)
|
||||
const isDesktopApp = isElectronHost()
|
||||
|
||||
function handleClick() {
|
||||
const current = props.expandState()
|
||||
|
||||
if (!isDesktopApp) {
|
||||
// Web/Mobile: Simple 2-state toggle (instant, no delay)
|
||||
if (current === "normal") {
|
||||
props.onToggleExpand("expanded")
|
||||
} else {
|
||||
props.onToggleExpand("normal")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Electron: 3-state with double-click detection
|
||||
const now = Date.now()
|
||||
const lastClick = clickTime()
|
||||
const isDoubleClick = now - lastClick < DOUBLE_CLICK_THRESHOLD
|
||||
@@ -23,8 +40,6 @@ export default function ExpandButton(props: ExpandButtonProps) {
|
||||
setClickTimer(null)
|
||||
}
|
||||
|
||||
const current = props.expandState()
|
||||
|
||||
if (isDoubleClick) {
|
||||
// Double click behavior - execute immediately
|
||||
if (current === "normal") {
|
||||
@@ -55,6 +70,11 @@ export default function ExpandButton(props: ExpandButtonProps) {
|
||||
}
|
||||
|
||||
const getTooltip = () => {
|
||||
// No tooltip for web/mobile - only Electron gets tooltips
|
||||
if (!isDesktopApp) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const current = props.expandState()
|
||||
if (current === "normal") {
|
||||
return "Click to expand (50%) • Double-click to expand further (80%)"
|
||||
@@ -65,17 +85,22 @@ export default function ExpandButton(props: ExpandButtonProps) {
|
||||
}
|
||||
}
|
||||
|
||||
const isExpanded = () => {
|
||||
const state = props.expandState()
|
||||
return state !== "normal"
|
||||
}
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
class="prompt-expand-button"
|
||||
class={`prompt-expand-button ${isDesktopApp ? "desktop-mode" : "web-mode"}`}
|
||||
onClick={handleClick}
|
||||
disabled={false}
|
||||
aria-label="Toggle chat input height"
|
||||
data-tooltip={getTooltip()}
|
||||
>
|
||||
<Show
|
||||
when={props.expandState() === "normal"}
|
||||
when={!isExpanded()}
|
||||
fallback={<Minimize2 class="h-5 w-5" aria-hidden="true" />}
|
||||
>
|
||||
<Maximize2 class="h-5 w-5" aria-hidden="true" />
|
||||
|
||||
Reference in New Issue
Block a user