mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
fix(frontend): float one jump-to-latest button above the composer
Match the mobile app: while the transcript is scrolled up, show a centered round button above the composer instead of swapping the mobile composer tools button for an arrow and hiding the desktop arrow when the prompt has text. The composer tools menu now stays available on mobile at all times, and the desktop in-composer arrow is gone.
This commit is contained in:
1 parent
67cfd862b1
commit
36a5693b5c
9 files changed
+57
-145
No files matched your search
@@ -148,7 +148,6 @@ describe('PromptInput command submission', () => {
|
||||
const defaultProps = {
|
||||
directory: '/test',
|
||||
sessionID: 'test-session',
|
||||
showScrollButton: false,
|
||||
isSessionActive: false,
|
||||
isStreamingResponse: false,
|
||||
onScrollToBottom: vi.fn(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { render, screen, fireEvent, waitFor, within, act } from '@testing-library/react'
|
||||
import { render, screen, fireEvent, waitFor, act } from '@testing-library/react'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import { PromptInput } from './PromptInput'
|
||||
import { useComposerDraftStore } from '@/stores/composerDraftStore'
|
||||
@@ -94,7 +94,6 @@ const createTestQueryClient = () => new QueryClient({
|
||||
const defaultProps = {
|
||||
directory: '/test',
|
||||
sessionID: 'test-session',
|
||||
showScrollButton: false,
|
||||
isSessionActive: false,
|
||||
isStreamingResponse: false,
|
||||
onScrollToBottom: vi.fn(),
|
||||
@@ -281,55 +280,22 @@ describe('PromptInput composer layout', () => {
|
||||
expect(screen.getByTestId('model-quick-select')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('swaps the composer tools button for a scroll-to-bottom arrow while scrolled up', () => {
|
||||
renderComponent({ showScrollButton: true })
|
||||
|
||||
const actions = controlsRow().lastElementChild as HTMLElement
|
||||
expect(within(actions).getByRole('button', { name: 'Scroll to bottom' })).toBeInTheDocument()
|
||||
expect(screen.queryByTestId('composer-tools-menu')).not.toBeInTheDocument()
|
||||
expect(within(controlsRow().firstElementChild as HTMLElement).getByTestId('agent-quick-select')).toBeInTheDocument()
|
||||
expect(within(controlsRow().firstElementChild as HTMLElement).getByTestId('model-quick-select')).toBeInTheDocument()
|
||||
expect(screen.queryByText('Latest')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('keeps the scroll-to-bottom arrow on the right while the prompt is focused', () => {
|
||||
renderComponent({ showScrollButton: true })
|
||||
|
||||
fireEvent.focus(promptInput())
|
||||
|
||||
const keys = screen.getByRole('toolbar', { name: 'Insert' })
|
||||
expect(within(keys).getByRole('button', { name: 'bash !' })).toBeInTheDocument()
|
||||
|
||||
const actions = controlsRow().lastElementChild as HTMLElement
|
||||
expect(within(actions).getByRole('button', { name: 'Scroll to bottom' })).toBeInTheDocument()
|
||||
expect(screen.queryByTestId('composer-tools-menu')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('keeps the scroll-to-bottom arrow while the prompt has text', () => {
|
||||
renderComponent({ showScrollButton: true })
|
||||
|
||||
fireEvent.change(promptInput(), { target: { value: 'hello' } })
|
||||
|
||||
expect(screen.getByRole('button', { name: 'Scroll to bottom' })).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('scrolls to the bottom from the swapped arrow and keeps the composer tools box size', () => {
|
||||
const onScrollToBottom = vi.fn()
|
||||
renderComponent({ showScrollButton: true, onScrollToBottom })
|
||||
|
||||
const arrow = screen.getByRole('button', { name: 'Scroll to bottom' })
|
||||
expect(arrow).toHaveClass('size-11', 'p-0')
|
||||
|
||||
fireEvent.click(arrow)
|
||||
|
||||
expect(onScrollToBottom).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('keeps the composer tools button while at the bottom of the transcript', () => {
|
||||
renderComponent({ showScrollButton: false })
|
||||
it('keeps the composer tools button at the bottom of the transcript', () => {
|
||||
renderComponent()
|
||||
|
||||
expect(screen.getByTestId('composer-tools-menu')).toBeInTheDocument()
|
||||
expect(screen.queryByRole('button', { name: 'Scroll to bottom' })).not.toBeInTheDocument()
|
||||
expect(screen.queryByRole('button', { name: 'Jump to latest' })).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('keeps the composer tools button while the prompt has text', () => {
|
||||
renderComponent()
|
||||
|
||||
fireEvent.change(promptInput(), { target: { value: 'hello' } })
|
||||
|
||||
expect(screen.getByTestId('composer-tools-menu')).toBeInTheDocument()
|
||||
expect(screen.queryByRole('button', { name: 'Scroll to bottom' })).not.toBeInTheDocument()
|
||||
expect(screen.queryByRole('button', { name: 'Jump to latest' })).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('keeps the voice button and composer tools on the right side of the controls row', () => {
|
||||
@@ -343,24 +309,6 @@ describe('PromptInput composer layout', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('desktop scroll button visibility', () => {
|
||||
const desktopScrollButton = () => screen.getByTitle('Scroll to bottom')
|
||||
|
||||
it('hides the desktop scroll arrow once the prompt has text', () => {
|
||||
renderComponent({ showScrollButton: true })
|
||||
|
||||
fireEvent.change(promptInput(), { target: { value: 'hello' } })
|
||||
|
||||
expect(desktopScrollButton()).toHaveClass('invisible')
|
||||
})
|
||||
|
||||
it('shows the desktop scroll arrow while the prompt is empty', () => {
|
||||
renderComponent({ showScrollButton: true })
|
||||
|
||||
expect(desktopScrollButton()).toHaveClass('visible')
|
||||
})
|
||||
})
|
||||
|
||||
describe('mobile voice button', () => {
|
||||
beforeEach(() => {
|
||||
mocks.useMobile.mockReturnValue(true)
|
||||
|
||||
@@ -92,7 +92,6 @@ const createTestQueryClient = () => new QueryClient({
|
||||
const defaultProps = {
|
||||
directory: '/test',
|
||||
sessionID: 'session-a',
|
||||
showScrollButton: false,
|
||||
isSessionActive: false,
|
||||
isStreamingResponse: false,
|
||||
onScrollToBottom: vi.fn(),
|
||||
|
||||
@@ -146,7 +146,6 @@ describe('PromptInput goal mode', () => {
|
||||
const defaultProps = {
|
||||
directory: '/test',
|
||||
sessionID: 'test-session',
|
||||
showScrollButton: false,
|
||||
isSessionActive: false,
|
||||
isStreamingResponse: false,
|
||||
onScrollToBottom: vi.fn(),
|
||||
|
||||
@@ -135,7 +135,6 @@ describe('PromptInput agent mention submission', () => {
|
||||
const defaultProps = {
|
||||
directory: '/test',
|
||||
sessionID: 'test-session',
|
||||
showScrollButton: false,
|
||||
isSessionActive: false,
|
||||
isStreamingResponse: false,
|
||||
onScrollToBottom: vi.fn(),
|
||||
|
||||
@@ -152,7 +152,6 @@ describe('PromptInput voice conversation', () => {
|
||||
const defaultProps = {
|
||||
directory: '/test',
|
||||
sessionID: 'test-session',
|
||||
showScrollButton: false,
|
||||
isSessionActive: false,
|
||||
isStreamingResponse: false,
|
||||
onScrollToBottom: vi.fn(),
|
||||
@@ -401,7 +400,6 @@ describe('PromptInput submission', () => {
|
||||
const defaultProps = {
|
||||
directory: '/test',
|
||||
sessionID: 'test-session',
|
||||
showScrollButton: false,
|
||||
isSessionActive: false,
|
||||
isStreamingResponse: false,
|
||||
onScrollToBottom: vi.fn(),
|
||||
|
||||
@@ -20,10 +20,10 @@ import { FINE_POINTER_MEDIA_QUERY, useMediaQuery } from '@/hooks/useMediaQuery'
|
||||
|
||||
import { usePermissions } from '@/contexts/EventContext'
|
||||
import { isLocalOpenCodeServer, useOpenCodeServerId } from '@/contexts/OpenCodeServerContext'
|
||||
import { ArrowDown, Upload, X, Mic, Target } from 'lucide-react'
|
||||
import { Upload, X, Mic, Target } from 'lucide-react'
|
||||
|
||||
import { SquareFill } from '@/components/ui/square-fill'
|
||||
import { IconToggleButton, getIconToggleButtonClassName } from '@/components/ui/icon-toggle-button'
|
||||
import { IconToggleButton } from '@/components/ui/icon-toggle-button'
|
||||
|
||||
import { PromptSuggestions, type PromptSuggestion } from './PromptSuggestions'
|
||||
import { ComposerActivityBar } from './ComposerActivityBar'
|
||||
@@ -39,7 +39,7 @@ import { detectMentionTrigger, parsePromptToInput, getFilename, getDirectory, ty
|
||||
import { matchText, rankByMatch, type MatchRange } from '@/lib/fuzzyMatch'
|
||||
import { getNextPrimaryAgentId } from '@/lib/primaryAgents'
|
||||
import { getNextFavoriteModel } from '@/lib/favoriteModels'
|
||||
import { cn, randomId } from '@/lib/utils'
|
||||
import { randomId } from '@/lib/utils'
|
||||
import { showToast } from '@/lib/toast'
|
||||
import { findModelInfo, isSameModelSelection } from '@opencode-manager/shared/opencode'
|
||||
import { isOpenSessionGoal } from '@opencode-manager/shared/schemas'
|
||||
@@ -131,7 +131,6 @@ interface PromptInputProps {
|
||||
sessionID: string
|
||||
onVoiceConversationActiveChange?: (active: boolean) => void
|
||||
onSuggestionsOpenChange?: (open: boolean) => void
|
||||
showScrollButton?: boolean
|
||||
isSessionActive?: boolean
|
||||
isStreamingResponse?: boolean
|
||||
onScrollToBottom: () => void
|
||||
@@ -144,7 +143,6 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
|
||||
sessionID,
|
||||
onVoiceConversationActiveChange,
|
||||
onSuggestionsOpenChange,
|
||||
showScrollButton,
|
||||
isSessionActive = false,
|
||||
isStreamingResponse = false,
|
||||
onScrollToBottom,
|
||||
@@ -1101,7 +1099,6 @@ if (isIOS && isSecureContext && navigator.clipboard && navigator.clipboard.read)
|
||||
const composerModeStyle = composerMode ? COMPOSER_MODE_STYLES[composerMode] : null
|
||||
const isTakeoverOpen = isMobile && isSuggestionListOpen
|
||||
const showStopButton = isSessionActive
|
||||
const showMobileScrollButton = isMobile && showScrollButton
|
||||
const hasOpenGoal = isOpenSessionGoal(sessionGoal)
|
||||
const lockedReason = permissionMode?.lockedReason ?? null
|
||||
const goalButtonLabel = lockedReason === 'schedule'
|
||||
@@ -1362,15 +1359,6 @@ return (
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5 md:gap-2 flex-shrink-0">
|
||||
{!isMobile && (
|
||||
<button
|
||||
onClick={onScrollToBottom}
|
||||
className={`p-2 rounded-lg bg-background/80 hover:bg-accent/90 text-primary hover:text-primary-hover transition-all duration-200 active:scale-95 hover:scale-105 shadow-md border border-primary/20 backdrop-blur-md ring-1 ring-primary/15 ${showScrollButton && !hasPromptContent ? 'visible' : 'invisible'}`}
|
||||
title="Scroll to bottom"
|
||||
>
|
||||
<ArrowDown className="w-6 h-6" />
|
||||
</button>
|
||||
)}
|
||||
{showStopButton && (
|
||||
<button
|
||||
onClick={handleStop}
|
||||
@@ -1396,18 +1384,7 @@ return (
|
||||
<Upload className="w-5 h-5" />
|
||||
</button>
|
||||
{showVoiceMic && renderVoiceMic()}
|
||||
{showMobileScrollButton ? (
|
||||
<button
|
||||
type="button"
|
||||
aria-label="Scroll to bottom"
|
||||
title="Scroll to bottom"
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={onScrollToBottom}
|
||||
className={cn(getIconToggleButtonClassName(false), 'flex items-center justify-center size-11 p-0')}
|
||||
>
|
||||
<ArrowDown className="w-5 h-5" />
|
||||
</button>
|
||||
) : isMobile && directory && (
|
||||
{isMobile && directory && (
|
||||
<ComposerToolsMenu
|
||||
sessionID={sessionID}
|
||||
directory={directory}
|
||||
|
||||
Reference in new issue
Block a user