feat(frontend): improve model selection experience (#237)

* chore: remove dead code and unused exports

* fix: preserve model form during config refresh

Signed-off-by: mehmet turac <mehmetturac@gmail.com>

* loop: model-select-fix completed after 11 iterations

* fix(frontend): show provider prefix for duplicate models in quick select dropdown

When the same model exists under multiple providers, show the provider name
for both entries so users can distinguish them. Detects duplicates by modelID
across all favorites and recents.

* refactor(frontend): replace useTallScrollContent with scroll visibility hook

* fix: harden mirror push rollback

* Remove Load button from skill cards, clicking card loads skill

* feat(backend): add plugin installation support and schema updates

* refactor(frontend): remove unused useHeaderScrollVisibility hook

* refactor(frontend): replace model dropdown with bottom sheet selector

Replace DropdownMenu-based ModelQuickSelect with a bottom sheet
implementation featuring favorites, recents, provider browsing, and
search. Remove onShowModelsDialog prop from PromptInput and
SessionDetail, using data attribute trigger instead. Fix ZodIssueCode
deprecation, input text color, and portal rendering for bottom sheet.

* fix(frontend): simplify session model restore and fix mobile swipe reset

* loop: single-source-models completed after 10 iterations

* refactor(frontend): add desktop sidebar layout to model quick select

* refactor(frontend): improve model selector with connected providers, favorites, and recent management

* fix(frontend): constrain model name width to prevent overflow in prompt input

* fix(frontend): adjust padding and styling in model quick select

* fix(frontend): add optimistic removal with rollback for recent models

---------
This commit is contained in:
Chris Scott authored and GitHub committed 2026-05-25 09:47:59 -04:00
1 parent f492faa84b
commit 03bd3dac95
45 files changed
+1728 -1148

No files matched your search

@@ -1,80 +0,0 @@
import { useEffect, useRef } from 'react'
interface FileSuggestionsProps {
isOpen: boolean
files: string[]
onSelect: (file: string) => void
onClose: () => void
selectedIndex?: number
}
export function FileSuggestions({
isOpen,
files,
onSelect,
onClose,
selectedIndex = 0
}: FileSuggestionsProps) {
const listRef = useRef<HTMLDivElement>(null)
useEffect(() => {
if (!isOpen) return
const handleClickOutside = (e: MouseEvent) => {
if (listRef.current && !listRef.current.contains(e.target as Node)) {
onClose()
}
}
document.addEventListener('mousedown', handleClickOutside)
return () => document.removeEventListener('mousedown', handleClickOutside)
}, [isOpen, onClose])
useEffect(() => {
if (!isOpen || !listRef.current) return
const selectedItem = listRef.current.children[selectedIndex] as HTMLElement
if (selectedItem) {
selectedItem.scrollIntoView({ block: 'nearest' })
}
}, [selectedIndex, isOpen])
if (!isOpen || files.length === 0) return null
const getFilename = (path: string) => path.split('/').pop() || path
const getDirectory = (path: string) => {
const parts = path.split('/')
return parts.slice(0, -1).join('/') || '.'
}
return (
<div
ref={listRef}
className="absolute bottom-full left-0 right-0 mb-2 z-50 bg-background border border-border rounded-lg shadow-xl max-h-48 md:max-h-[40vh] lg:max-h-[50vh] overflow-y-auto"
>
{files.map((file, idx) => (
<button
key={file}
onMouseDown={(e) => e.preventDefault()}
onTouchEnd={(e) => {
e.preventDefault()
onSelect(file)
}}
onClick={() => onSelect(file)}
className={`w-full px-3 py-2 text-left transition-colors ${
idx === selectedIndex
? 'bg-primary text-primary-foreground'
: 'hover:bg-muted text-foreground'
}`}
>
<div className="font-mono text-sm font-medium">
{getFilename(file)}
</div>
<div className="text-xs opacity-70 mt-0.5">
{getDirectory(file)}
</div>
</button>
))}
</div>
)
}
@@ -1,48 +0,0 @@
import { memo } from 'react'
import { X, Loader2 } from 'lucide-react'
import { useRemoveMessage } from '@/hooks/useRemoveMessage'
import { useMobile } from '@/hooks/useMobile'
import type { MessageWithParts } from '@/api/types'
interface MessageActionButtonsProps {
opcodeUrl: string
sessionId: string
directory?: string
message: MessageWithParts
}
export const MessageActionButtons = memo(function MessageActionButtons({
opcodeUrl,
sessionId,
directory,
message
}: MessageActionButtonsProps) {
const isMobile = useMobile()
const removeMessage = useRemoveMessage({ opcodeUrl, sessionId, directory })
const handleRemove = () => {
if (removeMessage.isPending) return
removeMessage.mutate({ messageID: message.info.id })
}
if (message.info.role !== 'assistant') {
return null
}
return (
<div className={`flex items-center gap-1 ${isMobile ? 'opacity-100' : 'opacity-0 group-hover:opacity-100'} transition-opacity`}>
<button
onClick={handleRemove}
disabled={removeMessage.isPending}
className="p-1 rounded hover:bg-destructive/20 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
title="Remove this message and all after it"
>
{removeMessage.isPending ? (
<Loader2 className="w-3.5 h-3.5 animate-spin" />
) : (
<X className="w-3.5 h-3.5" />
)}
</button>
</div>
)
})
@@ -77,10 +77,6 @@ vi.mock('@/stores/sessionAgentStore', () => ({
useSessionAgentStore: mocks.useSessionAgentStore,
}))
vi.mock('@/hooks/useAgents', () => ({
useAgents: mocks.useAgents,
}))
vi.mock('@/contexts/EventContext', () => ({
usePermissions: () => ({
hasForSession: vi.fn().mockReturnValue(false),
@@ -399,7 +395,7 @@ describe('PromptInput STT Gesture Tests', () => {
expect(voiceButtons.length).toBeGreaterThan(0)
})
it('does NOT render mobile in-row ArrowDown button', async () => {
it('renders mobile in-row Latest button when showScrollButton is true', async () => {
mocks.useMobile.mockReturnValue(true)
render(
@@ -408,7 +404,8 @@ describe('PromptInput STT Gesture Tests', () => {
</QueryClientProvider>
)
expect(screen.queryByTitle('Scroll to bottom')).not.toBeInTheDocument()
expect(screen.getByTitle('Scroll to bottom')).toBeInTheDocument()
expect(screen.getByText('Latest')).toBeInTheDocument()
})
})
})
+33 -23
View File
@@ -67,9 +67,8 @@ interface PromptInputProps {
showScrollButton?: boolean
isSessionActive?: boolean
isStreamingResponse?: boolean
onScrollToBottom?: () => void
onScrollToBottom: () => void
onShowSessionsDialog?: () => void
onShowModelsDialog?: () => void
onShowHelpDialog?: () => void
onToggleDetails?: () => boolean
onExportSession?: () => void
@@ -86,7 +85,6 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
isStreamingResponse = false,
onScrollToBottom,
onShowSessionsDialog,
onShowModelsDialog,
onShowHelpDialog,
onToggleDetails,
onExportSession,
@@ -182,7 +180,7 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
sessionID,
directory,
onShowSessionsDialog,
onShowModelsDialog,
onShowModelsDialog: undefined,
onShowHelpDialog,
onToggleDetails,
onExportSession,
@@ -994,7 +992,7 @@ if (isIOS && isSecureContext && navigator.clipboard && navigator.clipboard.read)
staleTime: 30000,
})
const { model, modelString, setModel: setStoredModel, setActiveModel } = useModelSelection(opcodeUrl, directory)
const { model, modelString, setModel: setStoredModel, restoreSessionModel } = useModelSelection(opcodeUrl, directory)
const setStoreVariant = useModelStore((state) => state.setVariant)
const clearStoreVariant = useModelStore((state) => state.clearVariant)
@@ -1005,8 +1003,7 @@ if (isIOS && isSecureContext && navigator.clipboard && navigator.clipboard.read)
if (syncedSessionModelRef.current === sessionModelSyncKey) return
if (!sessionAgent.model) return
const restored = setActiveModel(sessionAgent.model)
if (!restored) return
restoreSessionModel(sessionAgent.model)
syncedSessionModelRef.current = sessionModelSyncKey
@@ -1015,7 +1012,7 @@ if (isIOS && isSecureContext && navigator.clipboard && navigator.clipboard.read)
} else {
clearStoreVariant(sessionAgent.model)
}
}, [clearStoreVariant, sessionAgent.model, sessionAgent.variant, sessionModelSyncKey, setActiveModel, setStoreVariant])
}, [clearStoreVariant, sessionAgent.model, sessionAgent.variant, sessionModelSyncKey, restoreSessionModel, setStoreVariant])
const currentModel = modelString || ''
const displayModelName = useMemo(() => {
@@ -1034,6 +1031,7 @@ if (isIOS && isSecureContext && navigator.clipboard && navigator.clipboard.read)
const { hasVariants, currentVariant, cycleVariant } = useVariants(opcodeUrl, directory)
const showStopButton = isSessionActive
const hideSecondaryButtons = isMobile && isSessionActive
const showMobileScrollButton = isMobile && showScrollButton
const voiceFeedbackState: VoiceStatusOverlayState | null = isTogglingRecording
? 'starting'
: isProcessing
@@ -1211,27 +1209,39 @@ return (
<div className="flex gap-1.5 md:gap-2 items-center justify-between">
<div className="flex gap-1.5 md:gap-2 items-center min-w-0">
<AgentQuickSelect
opcodeUrl={opcodeUrl}
directory={directory}
currentAgent={currentMode}
onAgentChange={handleAgentChange}
isBashMode={isBashMode}
disabled={disabled}
/>
{showMobileScrollButton ? (
<button
type="button"
onClick={onScrollToBottom}
className="flex items-center gap-1.5 px-3 min-h-[36px] rounded-lg text-xs font-medium border bg-zinc-950/80 hover:bg-zinc-900/90 text-blue-300 hover:text-blue-200 border-blue-400/20 shadow-md backdrop-blur-md transition-all duration-200 active:scale-95 ring-1 ring-blue-400/15"
title="Scroll to bottom"
aria-label="Scroll to bottom"
>
<ArrowDown className="w-4 h-4" />
<span>Latest</span>
</button>
) : (
<AgentQuickSelect
opcodeUrl={opcodeUrl}
directory={directory}
currentAgent={currentMode}
onAgentChange={handleAgentChange}
isBashMode={isBashMode}
disabled={disabled}
/>
)}
{isSessionActive ? (
<div className="px-2.5 py-1.5 md:px-3 md:py-2 rounded-lg text-xs md:text-sm font-medium text-muted-foreground max-w-[120px] md:max-w-[180px]">
<SessionStatusIndicator sessionID={sessionID} showLabel />
</div>
) : (
!hideSecondaryButtons && (
<ModelQuickSelect
opcodeUrl={opcodeUrl}
directory={directory}
onOpenFullDialog={() => onShowModelsDialog?.()}
>
!hideSecondaryButtons && !showMobileScrollButton && (
<ModelQuickSelect
opcodeUrl={opcodeUrl}
directory={directory}
>
<button
className="px-2.5 py-0.5 md:px-3 min-h-[36px] min-w-0 rounded-lg text-xs md:text-sm font-medium border bg-muted border-border text-muted-foreground hover:bg-muted-foreground/10 hover:border-foreground/30 transition-colors cursor-pointer w-full md:w-auto md:max-w-[220px] dark:border-white/30 flex flex-col items-start justify-center overflow-hidden"
className="px-2.5 py-0.5 md:px-3 min-h-[36px] min-w-0 rounded-lg text-xs md:text-sm font-medium border bg-muted border-border text-muted-foreground hover:bg-muted-foreground/10 hover:border-foreground/30 transition-colors cursor-pointer w-full md:w-auto max-w-[130px] md:max-w-[220px] dark:border-white/30 flex flex-col items-start justify-center overflow-hidden"
>
<span className="truncate w-full text-left">{displayModelName || 'Select model'}</span>
{hasVariants && currentVariant && (