refactor(mobile): group MoreDrawer items and remove command/file mention entries

This commit is contained in:
Chris Scott committed 2026-10-08 00:18:01 -04:00
1 parent 485ab940aa
commit a9331cb484
12 files changed
+114 -257

No files matched your search

@@ -3,7 +3,6 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
import { render, screen, fireEvent, act, waitFor } from '@testing-library/react'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { PromptInput, type PromptInputHandle } from './PromptInput'
import { useUIState } from '@/stores/uiStateStore'
import { BUILTIN_COMMANDS } from '@/lib/builtinCommands'
import { createCommandActionsMock, stubMatchMedia } from '@/test/test-utils'
@@ -209,8 +208,6 @@ describe('PromptInput command submission', () => {
mocks.useSendErrorStore.mockImplementation((selector: (state: unknown) => unknown) => selector({ errors: {} }))
suggestionProps.isOpen = false
suggestionProps.selectedIndex = 0
useUIState.getState().clearPendingPromptCommand()
useUIState.getState().clearPendingPromptFile()
})
afterEach(() => {
@@ -269,13 +266,13 @@ describe('PromptInput command submission', () => {
})
it('sends parsed command attachments and offsets to runCommand without injecting the selected agent', async () => {
mocks.useFileSearch.mockReturnValue({ files: ['src/App.tsx'] })
const { container } = renderComponent()
act(() => {
useUIState.getState().selectPromptFile('src/App.tsx')
})
const input = await screen.findByPlaceholderText('Send a message...')
fireEvent.change(input, { target: { value: '@App' } })
await waitFor(() => expect(suggestionProps.isOpen).toBe(true))
fireEvent.keyDown(input, { key: 'Enter' })
await waitFor(() => expect(input).toHaveValue('@App.tsx '))
await attachImage(container)
@@ -2,7 +2,6 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
import { render, screen, fireEvent, waitFor, act } from '@testing-library/react'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { PromptInput } from './PromptInput'
import { useUIState } from '@/stores/uiStateStore'
import { createCommandActionsMock, stubMatchMedia } from '@/test/test-utils'
const mocks = vi.hoisted(() => ({
@@ -194,8 +193,6 @@ describe('PromptInput goal mode', () => {
mocks.useUserBash.mockImplementation((selector: (state: unknown) => unknown) => selector({ addUserBashCommand: vi.fn() }))
mocks.useSessionAgentStore.mockImplementation((selector: (state: unknown) => unknown) => selector({ setAgent: mocks.setAgent }))
mocks.useSendErrorStore.mockImplementation((selector: (state: unknown) => unknown) => selector({ errors: {} }))
useUIState.getState().clearPendingPromptCommand()
useUIState.getState().clearPendingPromptFile()
})
afterEach(() => {
@@ -2,7 +2,6 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'
import { render, screen, fireEvent, waitFor } from '@testing-library/react'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { PromptInput } from './PromptInput'
import { useUIState } from '@/stores/uiStateStore'
import { createCommandActionsMock } from '@/test/test-utils'
const mocks = vi.hoisted(() => ({
@@ -194,8 +193,6 @@ describe('PromptInput agent mention submission', () => {
mocks.useSessionAgentStore.mockImplementation((selector: (state: unknown) => unknown) => selector({ setAgent: vi.fn() }))
suggestionProps.isOpen = false
suggestionProps.selectedIndex = 0
useUIState.getState().clearPendingPromptCommand()
useUIState.getState().clearPendingPromptFile()
})
it('sends an @agent mention as an attachment without switching the session agent', async () => {
@@ -2,7 +2,6 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'
import { render, screen, fireEvent, act, waitFor } from '@testing-library/react'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { PromptInput } from './PromptInput'
import { useUIState } from '@/stores/uiStateStore'
import { createCommandActionsMock } from '@/test/test-utils'
const createTestQueryClient = () => new QueryClient({
@@ -211,8 +210,6 @@ describe('PromptInput STT Gesture Tests', () => {
mocks.useUserBash.mockImplementation((selector) => selector({ addUserBashCommand: vi.fn() }))
mocks.useSessionAgentStore.mockImplementation((selector) => selector({ setAgent: mockSetAgent }))
mocks.useSendErrorStore.mockImplementation((selector) => selector({ errors: {} }))
useUIState.getState().clearPendingPromptCommand()
useUIState.getState().clearPendingPromptFile()
})
const renderComponent = (sttOverrides: Partial<MockSTTReturn> = {}) => {
@@ -421,33 +418,6 @@ describe('PromptInput STT Gesture Tests', () => {
expect(screen.getAllByTitle('Stop').length).toBeGreaterThan(0)
})
it('inserts a command selected from the mobile drawer', async () => {
renderComponent()
act(() => {
useUIState.getState().selectPromptCommand({
name: 'help',
description: 'Show help',
})
})
await waitFor(() => {
expect(screen.getByPlaceholderText('Send a message...')).toHaveValue('/help ')
})
})
it('inserts a file selected from the mobile drawer', async () => {
renderComponent()
act(() => {
useUIState.getState().selectPromptFile('src/App.tsx')
})
await waitFor(() => {
expect(screen.getByPlaceholderText('Send a message...')).toHaveValue('@App.tsx ')
})
})
it('quick tap starts recording through click only', async () => {
mockStartRecording.mockResolvedValue(true)
@@ -10,7 +10,6 @@ import { useSTT } from '@/hooks/useSTT'
import { useUserBash } from '@/stores/userBashStore'
import { useSessionAgentStore } from '@/stores/sessionAgentStore'
import { useUIState } from '@/stores/uiStateStore'
import { useSendErrorStore } from '@/stores/sendErrorStore'
import { useRecentCommandsStore } from '@/stores/recentCommandsStore'
import { useTouchTapSelect } from '@/hooks/useTouchTapSelect'
@@ -166,10 +165,6 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
const promptRef = useRef(prompt)
const attachedFilesRef = useRef(attachedFiles)
const imageAttachmentsRef = useRef(imageAttachments)
const pendingPromptCommand = useUIState((state) => state.pendingPromptCommand)
const pendingPromptFile = useUIState((state) => state.pendingPromptFile)
const clearPendingPromptCommand = useUIState((state) => state.clearPendingPromptCommand)
const clearPendingPromptFile = useUIState((state) => state.clearPendingPromptFile)
const {
isRecording,
@@ -582,16 +577,10 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
handleSubmitRef.current()
}, [prompt])
useEffect(() => {
if (!pendingPromptCommand) return
handleCommandSelect(pendingPromptCommand.command)
clearPendingPromptCommand()
}, [pendingPromptCommand, handleCommandSelect, clearPendingPromptCommand])
const insertFileMention = useCallback((filePath: string, range: { start: number, end: number } | null = mentionRange) => {
const insertFileMention = useCallback((filePath: string, range: { start: number, end: number }) => {
const filename = getFilename(filePath)
const beforeMention = range ? prompt.slice(0, range.start) : `${prompt}${prompt.trim() ? ' ' : ''}`
const afterMention = range ? prompt.slice(range.end) : ''
const beforeMention = prompt.slice(0, range.start)
const afterMention = prompt.slice(range.end)
const newPrompt = beforeMention + '@' + filename + ' ' + afterMention
setPrompt(newPrompt)
@@ -612,13 +601,7 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
})
focusPromptAt(beforeMention.length + filename.length + 2)
}, [directory, mentionRange, prompt, focusPromptAt])
useEffect(() => {
if (!pendingPromptFile) return
insertFileMention(pendingPromptFile.path, null)
clearPendingPromptFile()
}, [pendingPromptFile, insertFileMention, clearPendingPromptFile])
}, [directory, prompt, focusPromptAt])
const handleMentionSelect = (item: MentionItem) => {
if (!mentionRange || !textareaRef.current) return