mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
fix: address findings from the full Docker evaluation of main
Critical and high: - repos: unlinking a local repo removes only the Manager reference and alias, never the repository files; confirm button reads "Unlink" - auth: rate-limit by the socket address; trust proxy headers only when AUTH_TRUSTED_PROXY_HEADERS is set (documented and forwarded in compose) - composer: per-session in-memory drafts (text, bash mode, attachments); Escape no longer clears the prompt - url params: compose same-tick updates so schedule dialogs stay closed after create/delete; delete dialog names the job Medium: - tool rows show failures (non-zero shell exit, failed exploration members) - voice conversation shows the specific error and a starting state - settings: Escape in dropdowns and the shortcut recorder no longer closes the dialog; mobile deep links open the requested section; one content tree per platform - closing pushed sheets, settings, tool panels and schedule dialogs goes back in history - login returns to the requested page; signed-out pages make no authenticated requests - action terminals keep their output (Manager-side output capture and replay) - unpushed-commit detection, commit message kept on failure - binary files with unknown extensions are detected and not editable - tool panel resizes when docked and floats as a dismissible sheet when the page is too narrow - Docker image runs tini as PID 1 Low: not-found states, add-repo and branch validation errors (4xx), search-aware empty states, mobile repo sort/filter/select cues, sidebar resize affordance and collapse shortcut, mobile unread badge, preview port filtering, terminal close handling, walkthrough empty state and helper session filtering, placeholder contrast, permission labels and focus, TTS task-list sanitizing, git identity email validation, quieter git logging, hermetic worktree tests, and accessible names for icon-only controls.
This commit is contained in:
1 parent
1c22ef6ea1
commit
4ec62cd4e7
191 files changed
+6674
-696
No files matched your search
@@ -0,0 +1,85 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import type { SessionMessageAssistantTool } from '@opencode-manager/shared/opencode'
|
||||
import { ExplorationGroup } from './ExplorationGroup'
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
useSettings: vi.fn(),
|
||||
useToolCallPermission: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/hooks/useSettings', () => ({
|
||||
useSettings: mocks.useSettings,
|
||||
}))
|
||||
|
||||
vi.mock('@/contexts/EventContext', () => ({
|
||||
useToolCallPermission: mocks.useToolCallPermission,
|
||||
}))
|
||||
|
||||
const readTool = (id: string, status: 'completed' | 'running' | 'error'): SessionMessageAssistantTool => {
|
||||
if (status === 'completed') {
|
||||
return {
|
||||
type: 'tool',
|
||||
id,
|
||||
name: 'read',
|
||||
state: { status, input: { filePath: '/repo/a.ts' }, content: [], metadata: {} },
|
||||
time: { created: 0, ran: 1, completed: 2 },
|
||||
}
|
||||
}
|
||||
if (status === 'error') {
|
||||
return {
|
||||
type: 'tool',
|
||||
id,
|
||||
name: 'read',
|
||||
state: { status, input: { filePath: '/repo/missing.ts' }, error: { type: 'tool.failed', message: 'File not found' }, metadata: {} },
|
||||
time: { created: 0, ran: 1, completed: 2 },
|
||||
}
|
||||
}
|
||||
return {
|
||||
type: 'tool',
|
||||
id,
|
||||
name: 'read',
|
||||
state: { status, input: { filePath: '/repo/a.ts' } },
|
||||
time: { created: 0, ran: 1 },
|
||||
}
|
||||
}
|
||||
|
||||
describe('ExplorationGroup', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
mocks.useSettings.mockReturnValue({
|
||||
preferences: { expandToolCalls: false },
|
||||
isLoading: false,
|
||||
updateSettings: vi.fn(),
|
||||
isUpdating: false,
|
||||
})
|
||||
mocks.useToolCallPermission.mockReturnValue(null)
|
||||
})
|
||||
|
||||
it('summarises a successful run and keeps the arrow marker', () => {
|
||||
render(<ExplorationGroup parts={[readTool('r1', 'completed'), readTool('r2', 'completed')]} messageID="msg_1" />)
|
||||
|
||||
const summary = screen.getByRole('button', { name: /Explored: 2 reads/ })
|
||||
expect(summary).toHaveTextContent('→')
|
||||
expect(summary).not.toHaveTextContent('✗')
|
||||
})
|
||||
|
||||
it('marks a run with a failed member and counts it in the label', () => {
|
||||
render(<ExplorationGroup parts={[readTool('r1', 'completed'), readTool('r2', 'error')]} messageID="msg_1" />)
|
||||
|
||||
const summary = screen.getByRole('button', { name: /Explored: 2 reads, 1 failed/ })
|
||||
const marker = screen.getByText('✗')
|
||||
expect(marker).toHaveClass('text-destructive')
|
||||
expect(summary).not.toHaveTextContent('→')
|
||||
})
|
||||
|
||||
it('keeps the spinner while an exploration run is still in progress', () => {
|
||||
const { container } = render(
|
||||
<ExplorationGroup parts={[readTool('r1', 'error'), readTool('r2', 'running')]} messageID="msg_1" />,
|
||||
)
|
||||
|
||||
expect(screen.getByRole('button', { name: /Exploring: 2 reads/ })).toBeInTheDocument()
|
||||
expect(screen.queryByText('✗')).not.toBeInTheDocument()
|
||||
expect(container.querySelector('.animate-spin')).not.toBeNull()
|
||||
})
|
||||
})
|
||||
@@ -3,7 +3,7 @@ import { ChevronRight, Loader2 } from 'lucide-react'
|
||||
import type { SessionMessageAssistantTool } from '@opencode-manager/shared/opencode'
|
||||
import { useSettings } from '@/hooks/useSettings'
|
||||
import { useToolCallPermission } from '@/contexts/EventContext'
|
||||
import { explorationLabel, isExplorationComplete } from '@/lib/explorationGroups'
|
||||
import { explorationFailureCount, explorationLabel, isExplorationComplete } from '@/lib/explorationGroups'
|
||||
import type { WalkthroughSource } from '@opencode-manager/shared/schemas'
|
||||
import { MessagePart } from './MessagePart'
|
||||
|
||||
@@ -31,6 +31,7 @@ export const ExplorationGroup = memo(function ExplorationGroup({ parts, ...membe
|
||||
const { preferences } = useSettings()
|
||||
const [expanded, setExpanded] = useState(preferences?.expandToolCalls ?? false)
|
||||
const completed = isExplorationComplete(parts)
|
||||
const failed = completed && explorationFailureCount(parts) > 0
|
||||
|
||||
return (
|
||||
<div className="my-1">
|
||||
@@ -40,7 +41,13 @@ export const ExplorationGroup = memo(function ExplorationGroup({ parts, ...membe
|
||||
aria-expanded={expanded}
|
||||
className="group flex w-full min-w-0 items-center gap-2 py-0.5 text-left text-sm text-muted-foreground hover:text-foreground transition-colors"
|
||||
>
|
||||
{completed ? <span className="shrink-0">→</span> : <Loader2 className="w-3.5 h-3.5 shrink-0 animate-spin" />}
|
||||
{failed ? (
|
||||
<span className="shrink-0 text-destructive">✗</span>
|
||||
) : completed ? (
|
||||
<span className="shrink-0">→</span>
|
||||
) : (
|
||||
<Loader2 className="w-3.5 h-3.5 shrink-0 animate-spin" />
|
||||
)}
|
||||
<span className="truncate">{explorationLabel(parts)}</span>
|
||||
<ChevronRight className={`w-3.5 h-3.5 shrink-0 opacity-0 group-hover:opacity-100 transition-transform ${expanded ? 'rotate-90 opacity-100' : ''}`} />
|
||||
</button>
|
||||
|
||||
@@ -3,6 +3,7 @@ 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 { useComposerDraftStore } from '@/stores/composerDraftStore'
|
||||
import { BUILTIN_COMMANDS } from '@/lib/builtinCommands'
|
||||
import { createCommandActionsMock, stubMatchMedia, createVoiceConversationControllerMock } from '@/test/test-utils'
|
||||
|
||||
@@ -174,6 +175,7 @@ describe('PromptInput command submission', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
useComposerDraftStore.setState({ drafts: {} })
|
||||
mocks.useVoiceConversation.mockReturnValue(createVoiceConversationControllerMock())
|
||||
mocks.runCommand.mockResolvedValue(undefined)
|
||||
mocks.switchSessionModel.mockResolvedValue(undefined)
|
||||
@@ -496,7 +498,7 @@ describe('PromptInput command submission', () => {
|
||||
expect(screen.queryByTestId('composer-mode-badge')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('clears attachments and exits bash mode on Escape while idle', async () => {
|
||||
it('exits bash mode on Escape while idle and keeps the attachments', async () => {
|
||||
const { container } = renderComponent()
|
||||
|
||||
const input = await screen.findByPlaceholderText('Send a message...')
|
||||
@@ -510,7 +512,7 @@ describe('PromptInput command submission', () => {
|
||||
|
||||
expect(input).toHaveValue('')
|
||||
expect(screen.queryByTestId('composer-mode-badge')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('pic.png')).not.toBeInTheDocument()
|
||||
expect(screen.getByText('pic.png')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('keeps attachments and clears only the text when a built-in command is submitted', async () => {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { render, screen, fireEvent, waitFor, within, act } from '@testing-library/react'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import { PromptInput } from './PromptInput'
|
||||
import { useComposerDraftStore } from '@/stores/composerDraftStore'
|
||||
import { useSessionStatus } from '@/stores/sessionStatusStore'
|
||||
import { createCommandActionsMock, createVoiceConversationControllerMock } from '@/test/test-utils'
|
||||
|
||||
@@ -116,6 +117,7 @@ describe('PromptInput composer layout', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
useComposerDraftStore.setState({ drafts: {} })
|
||||
mocks.useVoiceConversation.mockReturnValue(createVoiceConversationControllerMock())
|
||||
mocks.hasPendingPermission.mockReturnValue(false)
|
||||
mocks.useMobile.mockReturnValue(false)
|
||||
|
||||
@@ -0,0 +1,258 @@
|
||||
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 { useComposerDraftStore } from '@/stores/composerDraftStore'
|
||||
import { createCommandActionsMock, createVoiceConversationControllerMock } from '@/test/test-utils'
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
useSTT: vi.fn(),
|
||||
useVoiceConversation: vi.fn(),
|
||||
useMobile: vi.fn(),
|
||||
useCommands: vi.fn(),
|
||||
useCommandHandler: vi.fn(),
|
||||
useFileSearch: vi.fn(),
|
||||
useModelSelection: vi.fn(),
|
||||
useVariants: vi.fn(),
|
||||
useSessionAgent: vi.fn(),
|
||||
useUserBash: vi.fn(),
|
||||
useSessionAgentStore: vi.fn(),
|
||||
useSendErrorStore: vi.fn(),
|
||||
useHasBackgroundActivity: vi.fn(),
|
||||
useSendPrompt: vi.fn(),
|
||||
hasPendingPermission: vi.fn(() => false),
|
||||
setShowDialog: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/hooks/useSTT', () => ({
|
||||
useSTT: mocks.useSTT,
|
||||
useSttAvailability: () => ({ isEnabled: true, isSupported: true }),
|
||||
}))
|
||||
vi.mock('@/hooks/useVoiceConversation', () => ({ useVoiceConversation: mocks.useVoiceConversation }))
|
||||
vi.mock('@/hooks/useMobile', () => ({ useMobile: mocks.useMobile }))
|
||||
vi.mock('@/hooks/useCommands', () => ({ useCommands: mocks.useCommands }))
|
||||
vi.mock('@/hooks/useCommandHandler', () => ({ useCommandHandler: mocks.useCommandHandler }))
|
||||
vi.mock('@/hooks/useFileSearch', () => ({ useFileSearch: mocks.useFileSearch }))
|
||||
vi.mock('@/hooks/useModelSelection', () => ({ useModelSelection: mocks.useModelSelection }))
|
||||
vi.mock('@/hooks/useVariants', () => ({ useVariants: mocks.useVariants }))
|
||||
vi.mock('@/hooks/useSessionAgent', () => ({ useSessionAgent: mocks.useSessionAgent }))
|
||||
vi.mock('@/stores/userBashStore', () => ({ useUserBash: mocks.useUserBash }))
|
||||
vi.mock('@/stores/sessionAgentStore', () => ({ useSessionAgentStore: mocks.useSessionAgentStore }))
|
||||
vi.mock('@/stores/sendErrorStore', () => ({ useSendErrorStore: mocks.useSendErrorStore }))
|
||||
vi.mock('@/stores/sessionStatusStore', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('@/stores/sessionStatusStore')>()
|
||||
return { ...actual, useHasBackgroundActivity: mocks.useHasBackgroundActivity }
|
||||
})
|
||||
vi.mock('@/lib/toast', () => ({
|
||||
showToast: { success: vi.fn(), error: vi.fn(), info: vi.fn(), warning: vi.fn(), loading: vi.fn(), promise: vi.fn(), dismiss: vi.fn() },
|
||||
}))
|
||||
|
||||
vi.mock('@/hooks/useOpenCode', () => ({
|
||||
useSendPrompt: () => ({ mutate: mocks.useSendPrompt, isPending: false }),
|
||||
useInterruptSession: () => ({ mutate: vi.fn() }),
|
||||
useSendShell: () => ({ mutate: vi.fn(), isPending: false }),
|
||||
useAgents: () => ({ data: [] }),
|
||||
useSkills: () => ({ data: [] }),
|
||||
}))
|
||||
|
||||
vi.mock('@/hooks/useProviders', () => ({ useProviders: () => ({ data: undefined }) }))
|
||||
|
||||
vi.mock('@/contexts/EventContext', () => ({
|
||||
usePermissions: () => ({
|
||||
hasForSession: mocks.hasPendingPermission,
|
||||
setShowDialog: mocks.setShowDialog,
|
||||
}),
|
||||
}))
|
||||
|
||||
vi.mock('@/components/agent/AgentQuickSelect', () => ({
|
||||
AgentQuickSelect: () => <div data-testid="agent-quick-select" />,
|
||||
}))
|
||||
|
||||
vi.mock('@/components/model/ModelQuickSelect', () => ({
|
||||
ModelQuickSelect: ({ children }: { children?: React.ReactNode }) => (
|
||||
<div data-testid="model-quick-select">{children}</div>
|
||||
),
|
||||
}))
|
||||
|
||||
vi.mock('@/components/session/PermissionModeToggle', () => ({ PermissionModeToggle: () => null }))
|
||||
vi.mock('@/components/session/SessionSandboxMenu', () => ({ SessionSandboxMenu: () => null }))
|
||||
vi.mock('./ComposerToolsMenu', () => ({ ComposerToolsMenu: () => null }))
|
||||
vi.mock('./PromptSuggestions', () => ({ PromptSuggestions: () => null }))
|
||||
vi.mock('@/hooks/useSessionGoals', () => ({
|
||||
useSessionGoal: () => ({ data: undefined }),
|
||||
useStartSessionGoal: () => ({ mutateAsync: vi.fn(), isPending: false }),
|
||||
}))
|
||||
vi.mock('@/hooks/useSessionPermissionMode', () => ({ useSessionPermissionMode: () => ({ data: undefined }) }))
|
||||
|
||||
const createTestQueryClient = () => new QueryClient({
|
||||
defaultOptions: { queries: { retry: false }, mutations: { retry: false } },
|
||||
})
|
||||
|
||||
const defaultProps = {
|
||||
directory: '/test',
|
||||
sessionID: 'session-a',
|
||||
showScrollButton: false,
|
||||
isSessionActive: false,
|
||||
isStreamingResponse: false,
|
||||
onScrollToBottom: vi.fn(),
|
||||
commandActions: createCommandActionsMock(),
|
||||
onPromptChange: vi.fn(),
|
||||
}
|
||||
|
||||
describe('PromptInput per-session composer draft', () => {
|
||||
const harness = (sessionID: string, overrides: Partial<typeof defaultProps> = {}) => (
|
||||
<QueryClientProvider client={createTestQueryClient()}>
|
||||
<PromptInput key={sessionID} {...defaultProps} {...overrides} sessionID={sessionID} />
|
||||
</QueryClientProvider>
|
||||
)
|
||||
|
||||
const renderSession = (sessionID: string, overrides: Partial<typeof defaultProps> = {}) =>
|
||||
render(harness(sessionID, overrides))
|
||||
|
||||
const promptInput = () => screen.getByPlaceholderText(/Send a message\.\.\.|Enter bash command\.\.\./)
|
||||
|
||||
const attachImage = async (container: HTMLElement) => {
|
||||
const fileInput = container.querySelector('input[type="file"]') as HTMLInputElement
|
||||
fireEvent.change(fileInput, { target: { files: [new File(['img'], 'pic.png', { type: 'image/png' })] } })
|
||||
await screen.findByText('pic.png')
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
useComposerDraftStore.setState({ drafts: {} })
|
||||
mocks.useSendPrompt.mockImplementation((_variables, options) => {
|
||||
options?.onSuccess?.()
|
||||
})
|
||||
mocks.useVoiceConversation.mockReturnValue(createVoiceConversationControllerMock())
|
||||
mocks.hasPendingPermission.mockReturnValue(false)
|
||||
mocks.useMobile.mockReturnValue(false)
|
||||
mocks.useSTT.mockReturnValue({
|
||||
isRecording: false,
|
||||
isProcessing: false,
|
||||
isSupported: false,
|
||||
isEnabled: false,
|
||||
interimTranscript: '',
|
||||
transcript: '',
|
||||
startRecording: vi.fn(),
|
||||
stopRecording: vi.fn(),
|
||||
abortRecording: vi.fn(),
|
||||
reset: vi.fn(),
|
||||
clear: vi.fn(),
|
||||
})
|
||||
mocks.useCommands.mockReturnValue({ searchCommands: () => [], findCommand: () => undefined, recentNames: [] })
|
||||
mocks.useCommandHandler.mockReturnValue({ executeCommand: vi.fn() })
|
||||
mocks.useFileSearch.mockReturnValue({ files: [] })
|
||||
mocks.useModelSelection.mockReturnValue({
|
||||
model: null,
|
||||
modelString: 'test-model',
|
||||
setModel: vi.fn(),
|
||||
setActiveAgent: vi.fn(),
|
||||
recentModels: [],
|
||||
favoriteModels: [],
|
||||
toggleFavorite: vi.fn(),
|
||||
isModelReady: true,
|
||||
})
|
||||
mocks.useVariants.mockReturnValue({ hasVariants: false, currentVariant: null, cycleVariant: vi.fn() })
|
||||
mocks.useSessionAgent.mockReturnValue({ agent: 'default' })
|
||||
mocks.useUserBash.mockImplementation((selector: (state: unknown) => unknown) => selector({ addUserBashCommand: vi.fn() }))
|
||||
mocks.useSessionAgentStore.mockImplementation((selector: (state: unknown) => unknown) => selector({ setAgent: vi.fn() }))
|
||||
mocks.useSendErrorStore.mockImplementation((selector: (state: unknown) => unknown) => selector({ errors: {} }))
|
||||
mocks.useHasBackgroundActivity.mockReturnValue(false)
|
||||
})
|
||||
|
||||
it('keeps the typed draft of each session', () => {
|
||||
const { rerender } = renderSession('session-a')
|
||||
|
||||
fireEvent.change(promptInput(), { target: { value: 'draft for A' } })
|
||||
|
||||
rerender(harness('session-b'))
|
||||
expect(promptInput()).toHaveValue('')
|
||||
|
||||
fireEvent.change(promptInput(), { target: { value: 'draft for B' } })
|
||||
|
||||
rerender(harness('session-a'))
|
||||
expect(promptInput()).toHaveValue('draft for A')
|
||||
|
||||
rerender(harness('session-b'))
|
||||
expect(promptInput()).toHaveValue('draft for B')
|
||||
})
|
||||
|
||||
it('keeps bash mode and attachments of each session', async () => {
|
||||
const { container, rerender } = renderSession('session-a')
|
||||
|
||||
fireEvent.change(promptInput(), { target: { value: '!' } })
|
||||
await attachImage(container)
|
||||
expect(screen.getByTestId('composer-mode-badge')).toHaveTextContent('BASH')
|
||||
|
||||
rerender(harness('session-b'))
|
||||
expect(promptInput()).toHaveValue('')
|
||||
expect(screen.queryByTestId('composer-mode-badge')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('pic.png')).not.toBeInTheDocument()
|
||||
|
||||
rerender(harness('session-a'))
|
||||
expect(promptInput()).toHaveValue('!')
|
||||
expect(screen.getByPlaceholderText('Enter bash command...')).toBeInTheDocument()
|
||||
expect(screen.getByTestId('composer-mode-badge')).toHaveTextContent('BASH')
|
||||
expect(screen.getByText('pic.png')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('sends the restored draft to the session that owns it and clears only that draft', () => {
|
||||
const { rerender } = renderSession('session-a')
|
||||
|
||||
fireEvent.change(promptInput(), { target: { value: 'draft for A' } })
|
||||
|
||||
rerender(harness('session-b'))
|
||||
fireEvent.change(promptInput(), { target: { value: 'draft for B' } })
|
||||
|
||||
rerender(harness('session-a'))
|
||||
fireEvent.click(screen.getByTitle('Send'))
|
||||
|
||||
expect(mocks.useSendPrompt).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ sessionID: 'session-a', text: 'draft for A' }),
|
||||
expect.anything(),
|
||||
)
|
||||
expect(promptInput()).toHaveValue('')
|
||||
|
||||
rerender(harness('session-b'))
|
||||
expect(promptInput()).toHaveValue('draft for B')
|
||||
})
|
||||
|
||||
it('keeps the draft when Escape is pressed while the session is idle', () => {
|
||||
renderSession('session-a')
|
||||
|
||||
fireEvent.change(promptInput(), { target: { value: 'an important draft' } })
|
||||
fireEvent.keyDown(promptInput(), { key: 'Escape' })
|
||||
|
||||
expect(promptInput()).toHaveValue('an important draft')
|
||||
})
|
||||
|
||||
it('reports suggestion list changes instead of clearing on Escape', async () => {
|
||||
const onSuggestionsOpenChange = vi.fn()
|
||||
mocks.useCommands.mockReturnValue({
|
||||
searchCommands: () => [{ item: { name: 'alpha', description: 'Alpha' }, ranges: [] }],
|
||||
findCommand: () => undefined,
|
||||
recentNames: [],
|
||||
})
|
||||
|
||||
renderSession('session-a', { onSuggestionsOpenChange })
|
||||
expect(onSuggestionsOpenChange).toHaveBeenLastCalledWith(false)
|
||||
|
||||
fireEvent.change(promptInput(), { target: { value: '/al', selectionStart: 3 } })
|
||||
|
||||
await waitFor(() => expect(onSuggestionsOpenChange).toHaveBeenLastCalledWith(true))
|
||||
expect(promptInput()).toHaveValue('/al')
|
||||
|
||||
fireEvent.keyDown(promptInput(), { key: 'Escape' })
|
||||
|
||||
await waitFor(() => expect(onSuggestionsOpenChange).toHaveBeenLastCalledWith(false))
|
||||
expect(promptInput()).toHaveValue('/al')
|
||||
})
|
||||
|
||||
it('labels the attachment remove button with the filename', async () => {
|
||||
const { container } = renderSession('session-a')
|
||||
|
||||
await attachImage(container)
|
||||
|
||||
expect(screen.getByRole('button', { name: 'Remove pic.png' })).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
@@ -2,6 +2,7 @@ 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 { useComposerDraftStore } from '@/stores/composerDraftStore'
|
||||
import { createCommandActionsMock, stubMatchMedia, createVoiceConversationControllerMock } from '@/test/test-utils'
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
@@ -164,6 +165,7 @@ describe('PromptInput goal mode', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
useComposerDraftStore.setState({ drafts: {} })
|
||||
mocks.useVoiceConversation.mockReturnValue(createVoiceConversationControllerMock())
|
||||
mocks.useSessionGoal.mockReturnValue({ data: null })
|
||||
mocks.useSessionPermissionMode.mockReturnValue({ data: undefined })
|
||||
|
||||
@@ -2,6 +2,7 @@ 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 { useComposerDraftStore } from '@/stores/composerDraftStore'
|
||||
import { createCommandActionsMock, createVoiceConversationControllerMock } from '@/test/test-utils'
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
@@ -9,7 +10,7 @@ const mocks = vi.hoisted(() => ({
|
||||
switchSessionModel: vi.fn(),
|
||||
switchSessionAgent: vi.fn(),
|
||||
runCommand: vi.fn(),
|
||||
agents: [] as Array<{ name: string; description?: string }>,
|
||||
agents: [] as Array<{ name: string; description?: string; mode?: string; hidden?: boolean }>,
|
||||
skills: [] as Array<{ id: string; name: string; description?: string }>,
|
||||
useSTT: vi.fn(),
|
||||
useVoiceConversation: vi.fn(),
|
||||
@@ -24,7 +25,7 @@ const mocks = vi.hoisted(() => ({
|
||||
useSendErrorStore: vi.fn(),
|
||||
}))
|
||||
|
||||
const suggestionProps = vi.hoisted(() => ({ isOpen: false, selectedIndex: 0 }))
|
||||
const suggestionProps = vi.hoisted(() => ({ isOpen: false, selectedIndex: 0, labels: [] as string[] }))
|
||||
|
||||
vi.mock('@/api/opencode', async () => {
|
||||
const actual = await vi.importActual('@/api/opencode')
|
||||
@@ -95,10 +96,11 @@ vi.mock('@/hooks/useSessionPermissionMode', () => ({
|
||||
}))
|
||||
|
||||
vi.mock('./PromptSuggestions', () => ({
|
||||
PromptSuggestions: (props: { isOpen: boolean; selectedIndex: number }) => {
|
||||
PromptSuggestions: (props: { isOpen: boolean; selectedIndex: number; items: Array<{ label: string }> }) => {
|
||||
if (props.isOpen) {
|
||||
suggestionProps.isOpen = true
|
||||
suggestionProps.selectedIndex = props.selectedIndex
|
||||
suggestionProps.labels = props.items.map((item) => item.label)
|
||||
}
|
||||
return null
|
||||
},
|
||||
@@ -153,6 +155,7 @@ describe('PromptInput agent mention submission', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
useComposerDraftStore.setState({ drafts: {} })
|
||||
mocks.useVoiceConversation.mockReturnValue(createVoiceConversationControllerMock())
|
||||
mocks.sendPrompt.mockResolvedValue({
|
||||
id: 'inbox_1',
|
||||
@@ -199,6 +202,7 @@ describe('PromptInput agent mention submission', () => {
|
||||
mocks.useSessionAgentStore.mockImplementation((selector: (state: unknown) => unknown) => selector({ setAgent: vi.fn() }))
|
||||
suggestionProps.isOpen = false
|
||||
suggestionProps.selectedIndex = 0
|
||||
suggestionProps.labels = []
|
||||
})
|
||||
|
||||
it('sends an @agent mention as an attachment without switching the session agent', async () => {
|
||||
@@ -311,4 +315,23 @@ describe('PromptInput agent mention submission', () => {
|
||||
fireEvent.keyDown(input, { key: 'ArrowDown' })
|
||||
await waitFor(() => expect(suggestionProps.selectedIndex).toBe(1))
|
||||
})
|
||||
|
||||
it('offers only mentionable subagents in the @ list', async () => {
|
||||
mocks.agents = [
|
||||
{ name: 'build', description: 'Build', mode: 'primary', hidden: false },
|
||||
{ name: 'plan', description: 'Plan', mode: 'primary', hidden: false },
|
||||
{ name: 'explore', description: 'Explore', mode: 'subagent', hidden: false },
|
||||
{ name: 'general', description: 'General', mode: 'all', hidden: false },
|
||||
{ name: 'Compaction', description: 'Compaction', mode: 'primary', hidden: true },
|
||||
{ name: 'Title', description: 'Title', mode: 'primary', hidden: true },
|
||||
]
|
||||
mocks.skills = []
|
||||
renderComponent()
|
||||
|
||||
const input = await screen.findByPlaceholderText('Send a message...')
|
||||
fireEvent.change(input, { target: { value: '@', selectionStart: 1 } })
|
||||
|
||||
await waitFor(() => expect(suggestionProps.isOpen).toBe(true))
|
||||
expect(suggestionProps.labels).toEqual(['explore', 'general'])
|
||||
})
|
||||
})
|
||||
@@ -2,6 +2,7 @@ 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 { useComposerDraftStore } from '@/stores/composerDraftStore'
|
||||
import {
|
||||
SessionTranscriptContext,
|
||||
type SessionTranscriptSnapshot,
|
||||
@@ -220,6 +221,7 @@ describe('PromptInput voice conversation', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
useComposerDraftStore.setState({ drafts: {} })
|
||||
mocks.useSendPromptMutate.mockImplementation((_variables, options) => {
|
||||
options?.onSuccess?.()
|
||||
})
|
||||
@@ -423,6 +425,7 @@ describe('PromptInput submission', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
useComposerDraftStore.setState({ drafts: {} })
|
||||
mocks.useSendPromptMutate.mockImplementation((_variables, options) => {
|
||||
options?.onSuccess?.()
|
||||
})
|
||||
|
||||
@@ -11,6 +11,7 @@ import { useSttAvailability } from '@/hooks/useSTT'
|
||||
import { useUserBash } from '@/stores/userBashStore'
|
||||
import { useSessionAgentStore } from '@/stores/sessionAgentStore'
|
||||
import { useSendErrorStore } from '@/stores/sendErrorStore'
|
||||
import { useComposerDraftStore } from '@/stores/composerDraftStore'
|
||||
import { useRecentCommandsStore } from '@/stores/recentCommandsStore'
|
||||
import { useHasBackgroundActivity } from '@/stores/sessionStatusStore'
|
||||
import { useTouchTapSelect } from '@/hooks/useTouchTapSelect'
|
||||
@@ -119,6 +120,7 @@ interface PromptInputProps {
|
||||
directory?: string
|
||||
sessionID: string
|
||||
onVoiceConversationActiveChange?: (active: boolean) => void
|
||||
onSuggestionsOpenChange?: (open: boolean) => void
|
||||
showScrollButton?: boolean
|
||||
isSessionActive?: boolean
|
||||
isStreamingResponse?: boolean
|
||||
@@ -131,6 +133,7 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
|
||||
directory,
|
||||
sessionID,
|
||||
onVoiceConversationActiveChange,
|
||||
onSuggestionsOpenChange,
|
||||
showScrollButton,
|
||||
isSessionActive = false,
|
||||
isStreamingResponse = false,
|
||||
@@ -138,13 +141,14 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
|
||||
commandActions,
|
||||
onPromptChange
|
||||
}, ref) {
|
||||
const [prompt, setPrompt] = useState('')
|
||||
const [isBashMode, setIsBashMode] = useState(false)
|
||||
const [restoredDraft] = useState(() => useComposerDraftStore.getState().getDraft(sessionID))
|
||||
const [prompt, setPrompt] = useState(restoredDraft.prompt)
|
||||
const [isBashMode, setIsBashMode] = useState(restoredDraft.isBashMode)
|
||||
const [isGoalArmed, setIsGoalArmed] = useState(false)
|
||||
const [showSuggestions, setShowSuggestions] = useState(false)
|
||||
const [suggestionQuery, setSuggestionQuery] = useState('')
|
||||
const [attachedFiles, setAttachedFiles] = useState(new Map<string, FileAttachmentInfo>())
|
||||
const [imageAttachments, setImageAttachments] = useState<ImageAttachment[]>([])
|
||||
const [attachedFiles, setAttachedFiles] = useState(restoredDraft.attachedFiles)
|
||||
const [imageAttachments, setImageAttachments] = useState(restoredDraft.imageAttachments)
|
||||
const [isDragging, setIsDragging] = useState(false)
|
||||
const [isModelPickerOpen, setIsModelPickerOpen] = useState(false)
|
||||
const [showMentionSuggestions, setShowMentionSuggestions] = useState(false)
|
||||
@@ -183,6 +187,17 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
|
||||
imageAttachmentsRef.current = imageAttachments
|
||||
}, [attachedFiles, imageAttachments, prompt])
|
||||
|
||||
const saveDraft = useComposerDraftStore((state) => state.saveDraft)
|
||||
const clearDraft = useComposerDraftStore((state) => state.clearDraft)
|
||||
|
||||
useEffect(() => {
|
||||
if (prompt === '' && !isBashMode && attachedFiles.size === 0 && imageAttachments.length === 0) {
|
||||
clearDraft(sessionID)
|
||||
return
|
||||
}
|
||||
saveDraft(sessionID, { prompt, isBashMode, attachedFiles, imageAttachments })
|
||||
}, [sessionID, prompt, isBashMode, attachedFiles, imageAttachments, saveDraft, clearDraft])
|
||||
|
||||
const clearSubmittedPrompt = useCallback((submittedPrompt: string, submittedAttachedFiles: Map<string, FileAttachmentInfo>, submittedImageAttachments: ImageAttachment[], options?: { keepAttachments?: boolean }) => {
|
||||
if (
|
||||
promptRef.current !== submittedPrompt ||
|
||||
@@ -246,6 +261,10 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
|
||||
|
||||
const { data: agents = [] } = useAgents(directory)
|
||||
const { data: skills = [] } = useSkills(directory)
|
||||
const mentionableAgents = useMemo(
|
||||
() => agents.filter((agent) => !agent.hidden && agent.mode !== 'primary'),
|
||||
[agents],
|
||||
)
|
||||
const agentNames = useMemo(() => agents.map((agent) => agent.name), [agents])
|
||||
const skillIds = useMemo(() => skills.map((skill) => skill.id), [skills])
|
||||
const failedPrompt = useSendErrorStore((state) => state.errors[sessionID]?.failedPrompt)
|
||||
@@ -269,7 +288,7 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
|
||||
}, [failedPrompt])
|
||||
|
||||
const mentionSuggestions = useMemo((): PromptSuggestion<MentionItem>[] => {
|
||||
const agentMatches = rankByMatch(agents, mentionQuery, {
|
||||
const agentMatches = rankByMatch(mentionableAgents, mentionQuery, {
|
||||
getName: (agent) => agent.name,
|
||||
getDescription: (agent) => agent.description,
|
||||
}).map(({ item, tier, ranges }) => ({
|
||||
@@ -321,7 +340,7 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
|
||||
return [...agentMatches, ...skillMatches, ...fileMatches]
|
||||
.sort((a, b) => a.tier - b.tier)
|
||||
.map(({ suggestion }) => suggestion)
|
||||
}, [agents, skills, searchResults, mentionQuery])
|
||||
}, [mentionableAgents, skills, searchResults, mentionQuery])
|
||||
|
||||
const commandSuggestions = useMemo((): PromptSuggestion<CommandInfo>[] =>
|
||||
searchCommands(suggestionQuery).map(({ item, ranges }) => ({
|
||||
@@ -735,7 +754,10 @@ if (isIOS && isSecureContext && navigator.clipboard && navigator.clipboard.read)
|
||||
const handleKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {
|
||||
if (isBashMode && e.key === 'Escape') {
|
||||
e.preventDefault()
|
||||
resetPrompt()
|
||||
if (prompt === '!' || prompt === '') {
|
||||
setIsBashMode(false)
|
||||
setPrompt('')
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -815,8 +837,6 @@ if (isIOS && isSecureContext && navigator.clipboard && navigator.clipboard.read)
|
||||
textareaRef.current?.blur()
|
||||
}
|
||||
handleSubmit()
|
||||
} else if (e.key === 'Escape' && !isSessionActive) {
|
||||
resetPrompt()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1063,6 +1083,12 @@ if (isIOS && isSecureContext && navigator.clipboard && navigator.clipboard.read)
|
||||
})
|
||||
const isCommandListOpen = showSuggestions && commandSuggestions.length > 0
|
||||
const isMentionListOpen = showMentionSuggestions && mentionSuggestions.length > 0
|
||||
const isSuggestionListOpen = isCommandListOpen || isMentionListOpen
|
||||
|
||||
useEffect(() => {
|
||||
onSuggestionsOpenChange?.(isSuggestionListOpen)
|
||||
}, [isSuggestionListOpen, onSuggestionsOpenChange])
|
||||
|
||||
const composerMode: ComposerMode | null = isBashMode
|
||||
? 'bash'
|
||||
: isMentionListOpen
|
||||
@@ -1071,7 +1097,7 @@ if (isIOS && isSecureContext && navigator.clipboard && navigator.clipboard.read)
|
||||
? 'command'
|
||||
: null
|
||||
const composerModeStyle = composerMode ? COMPOSER_MODE_STYLES[composerMode] : null
|
||||
const isTakeoverOpen = isMobile && (isCommandListOpen || isMentionListOpen)
|
||||
const isTakeoverOpen = isMobile && isSuggestionListOpen
|
||||
const showStopButton = isSessionActive
|
||||
const showMobileScrollButton = isMobile && showScrollButton
|
||||
const hasOpenGoal = isOpenSessionGoal(sessionGoal)
|
||||
@@ -1279,6 +1305,7 @@ return (
|
||||
<span className="max-w-[120px] truncate">{attachment.filename}</span>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={`Remove ${attachment.filename}`}
|
||||
onClick={() => removeImageAttachment(attachment.id)}
|
||||
className="p-0.5 rounded hover:bg-muted-foreground/20 text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import { TextPart } from './TextPart'
|
||||
|
||||
describe('TextPart code blocks', () => {
|
||||
it('reserves room for the copy button so the first code line is not covered', () => {
|
||||
const { container } = render(<TextPart text={'```ts\nconst answer = 42\n```'} />)
|
||||
|
||||
const pre = container.querySelector('pre')
|
||||
expect(pre).not.toBeNull()
|
||||
expect(pre).toHaveClass('pr-10')
|
||||
expect(screen.getByTitle('Copy code')).toBeInTheDocument()
|
||||
expect(pre?.textContent).toContain('const answer = 42')
|
||||
})
|
||||
})
|
||||
@@ -167,7 +167,7 @@ function CodeBlock({ children, className, ...props }: CodeBlockProps) {
|
||||
|
||||
return (
|
||||
<div className="relative">
|
||||
<pre className={`bg-accent p-1 rounded-lg overflow-x-auto whitespace-pre-wrap break-words border border-border my-4 ${className || ''}`} {...props}>
|
||||
<pre className={`bg-accent py-1 pl-1 pr-10 rounded-lg overflow-x-auto whitespace-pre-wrap break-words border border-border my-4 ${className || ''}`} {...props}>
|
||||
{children}
|
||||
</pre>
|
||||
<CopyButton content={codeContent} title="Copy code" className="absolute top-2 right-2" />
|
||||
|
||||
@@ -292,6 +292,78 @@ describe('ToolCallPart background indicator', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('ToolCallPart shell exit status', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
mocks.useSettings.mockReturnValue({
|
||||
preferences: { expandToolCalls: false },
|
||||
isLoading: false,
|
||||
updateSettings: vi.fn(),
|
||||
isUpdating: false,
|
||||
})
|
||||
mocks.useToolCallPermission.mockReturnValue(null)
|
||||
useUserBash.setState({ userBashCommands: new Map() })
|
||||
})
|
||||
|
||||
const completedShell = (metadata: Record<string, unknown>): SessionMessageAssistantTool => ({
|
||||
type: 'tool',
|
||||
id: 'call_exit',
|
||||
name: 'shell',
|
||||
time: { created: 1, ran: 2, completed: 3 },
|
||||
state: {
|
||||
status: 'completed',
|
||||
input: { command: 'cat does-not-exist.txt' },
|
||||
content: [{ type: 'text', text: 'Exited with code 1' }],
|
||||
metadata,
|
||||
},
|
||||
})
|
||||
|
||||
it('marks a completed shell with a non-zero exit as failed', () => {
|
||||
renderWithProviders(<ToolCallPart part={completedShell({ exit: 1 })} messageID="msg_1" />)
|
||||
|
||||
expect(screen.getByText('exit 1')).toBeInTheDocument()
|
||||
expect(screen.queryByText('completed')).not.toBeInTheDocument()
|
||||
expect(screen.getByText('✗').parentElement).toHaveClass('text-destructive')
|
||||
})
|
||||
|
||||
it('keeps a completed shell with exit code zero successful', () => {
|
||||
renderWithProviders(<ToolCallPart part={completedShell({ exit: 0 })} messageID="msg_1" />)
|
||||
|
||||
expect(screen.getByText('completed')).toBeInTheDocument()
|
||||
expect(screen.getByText('✓').parentElement).toHaveClass('text-success')
|
||||
expect(screen.queryByText('✗')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('keeps a completed shell without an exit code successful', () => {
|
||||
renderWithProviders(<ToolCallPart part={completedShell({})} messageID="msg_1" />)
|
||||
|
||||
expect(screen.getByText('completed')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('does not read an exit code from a non-shell tool', () => {
|
||||
renderWithProviders(
|
||||
<ToolCallPart
|
||||
part={{
|
||||
type: 'tool',
|
||||
id: 'call_fetch',
|
||||
name: 'webfetch',
|
||||
time: { created: 1, ran: 2, completed: 3 },
|
||||
state: {
|
||||
status: 'completed',
|
||||
input: { url: 'https://example.com' },
|
||||
content: [{ type: 'text', text: 'ok' }],
|
||||
metadata: { exit: 1 },
|
||||
},
|
||||
}}
|
||||
messageID="msg_1"
|
||||
/>,
|
||||
)
|
||||
|
||||
expect(screen.getByText('completed')).toBeInTheDocument()
|
||||
expect(screen.queryByText('✗')).not.toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
describe('ToolCallPart execute renderer', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
|
||||
@@ -121,6 +121,12 @@ export const ToolCallPart = memo(function ToolCallPart({ part, messageID, direct
|
||||
return typeof provider === 'string' ? provider : undefined
|
||||
})()
|
||||
const sandboxProviderLabel = sandboxProvider !== undefined && sandboxProvider !== 'ocm' ? sandboxProvider : undefined
|
||||
const foregroundShellExit =
|
||||
part.name === 'shell' && !isBackgroundShell && part.state.status === 'completed'
|
||||
? toolMetadata(part).exit
|
||||
: undefined
|
||||
const failedShellExit =
|
||||
typeof foregroundShellExit === 'number' && foregroundShellExit !== 0 ? foregroundShellExit : undefined
|
||||
const [detailsOpen, setDetailsOpen] = useToolDetailsState(preferences?.expandToolCalls ?? false)
|
||||
|
||||
useEffect(() => {
|
||||
@@ -132,6 +138,7 @@ export const ToolCallPart = memo(function ToolCallPart({ part, messageID, direct
|
||||
|
||||
const getStatusColor = () => {
|
||||
if (isBackgroundShell) return backgroundTaskStatusColor(shellStatus)
|
||||
if (failedShellExit !== undefined) return 'text-destructive'
|
||||
switch (part.state.status) {
|
||||
case 'completed':
|
||||
return 'text-success'
|
||||
@@ -151,6 +158,7 @@ export const ToolCallPart = memo(function ToolCallPart({ part, messageID, direct
|
||||
|
||||
const getStatusIcon = () => {
|
||||
if (isBackgroundShell) return renderShellLifecycleIcon(shellStatus)
|
||||
if (failedShellExit !== undefined) return <span>✗</span>
|
||||
switch (part.state.status) {
|
||||
case 'completed':
|
||||
return <span>✓</span>
|
||||
@@ -294,7 +302,9 @@ export const ToolCallPart = memo(function ToolCallPart({ part, messageID, direct
|
||||
? 'awaiting permission'
|
||||
: isBackgroundShell
|
||||
? lifecycleLabel(shellStatus)
|
||||
: part.state.status
|
||||
: failedShellExit !== undefined
|
||||
? `exit ${failedShellExit}`
|
||||
: part.state.status
|
||||
const commandBlock = (
|
||||
<div className="text-sm">
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
|
||||
@@ -188,6 +188,22 @@ describe('VoiceConversationBar', () => {
|
||||
expect(screen.getByRole('button', { name: 'Sending' })).toHaveAttribute('aria-busy', 'true')
|
||||
})
|
||||
|
||||
it('shows the failure reason and its fix instead of a bare retry', () => {
|
||||
renderBar(
|
||||
buildController({
|
||||
phase: 'paused',
|
||||
label: 'Microphone access denied. Please allow microphone permissions.',
|
||||
hint: 'Allow microphone access, then tap to retry',
|
||||
orbLabel: 'Resume voice conversation',
|
||||
}),
|
||||
)
|
||||
|
||||
expect(
|
||||
screen.getByText('Microphone access denied. Please allow microphone permissions.'),
|
||||
).toBeInTheDocument()
|
||||
expect(screen.getByText('Allow microphone access, then tap to retry')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('shows the notice when there is one and keeps the reserved hint line empty', () => {
|
||||
renderBar(
|
||||
buildController({
|
||||
|
||||
@@ -74,7 +74,14 @@ export function VoiceConversationBar({
|
||||
return (
|
||||
<div className="flex flex-col gap-1 border-t border-border bg-card px-3 pt-2 pb-2">
|
||||
<div role="status" aria-live="polite" className="flex h-5 items-center gap-2">
|
||||
<span className="max-w-[50%] shrink-0 truncate text-xs font-semibold">{label}</span>
|
||||
<span
|
||||
className={cn(
|
||||
'truncate text-xs font-semibold',
|
||||
liveTranscript ? 'max-w-[50%] shrink-0' : 'min-w-0 flex-1',
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
</span>
|
||||
{liveTranscript ? (
|
||||
<span
|
||||
dir="rtl"
|
||||
|
||||
Reference in new issue
Block a user