refactor(frontend): rework speech-to-text to tap-first interaction (#207)

* refactor(frontend): extract VoiceStatusOverlay component and improve swipe tracking

- Extract voice status overlay to dedicated VoiceStatusOverlay.tsx component
- Move pointer event handlers from button to container for larger swipe surface area
- Users can now initiate swipe gesture from anywhere in the container, not just the button

* refactor(frontend): add SSE delta support and improve status synchronization

- Add SSEMessagePartDeltaEvent type for streaming delta updates
- Add SSESessionCreatedEvent type for session creation events
- Implement directory filtering for SSE events to prevent cross-contamination
- Add version tracking for status snapshots to ignore stale responses
- Replace individual status updates with atomic replaceStatuses operation
- Refactor parts batcher to use unified operation queue with delta support
- Clear stale statuses on initial snapshot and directory changes
- Add tests for status snapshot clearing and stale response handling

* refactor: remove auto-restart from assistant mode and fix mobile sheet close behavior

Stop restarting OpenCode after assistant mode initialization since the
startup error logic is no longer needed. Also fix the repo quick switch
sheet to stay open when launched from the mobile tab bar, preventing
unwanted navigation away from the sheet.

* refactor(frontend): improve speech-to-text UI
This commit is contained in:
Chris Scott authored and GitHub committed 2026-04-29 12:26:41 -04:00
1 parent 04400c91cc
commit f0c87ffa5d
11 files changed
+525 -270

No files matched your search

@@ -4,6 +4,7 @@ import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { RepoQuickSwitchSheet } from './RepoQuickSwitchSheet'
import { listRepos } from '@/api/repos'
import { useMobileTabBar } from '@/hooks/useMobileTabBar'
vi.mock('@/api/repos')
@@ -29,6 +30,16 @@ function LocationSpy() {
return <div data-testid="location">{`${pathname}${search}`}</div>
}
function MobileSheetHarness() {
const { close } = useMobileTabBar()
return (
<>
<RepoQuickSwitchSheet isOpen onClose={close} />
<LocationSpy />
</>
)
}
describe('RepoQuickSwitchSheet', () => {
beforeEach(() => {
vi.clearAllMocks()
@@ -162,7 +173,7 @@ describe('RepoQuickSwitchSheet', () => {
fireEvent.click(screen.getByText('repo1'))
expect(screen.getByTestId('location')).toHaveTextContent('/repos/1/assistant')
expect(handleClose).toHaveBeenCalled()
expect(handleClose).not.toHaveBeenCalled()
})
it('navigates from assistant to repo detail when clicking active repo', async () => {
@@ -206,4 +217,47 @@ describe('RepoQuickSwitchSheet', () => {
expect(screen.getByTestId('location')).toHaveTextContent('/repos/1')
expect(handleClose).not.toHaveBeenCalled()
})
it('switches repos from the mobile repos sheet without navigating back to the previous repo', async () => {
vi.mocked(listRepos).mockResolvedValue([
{
id: 1,
repoUrl: 'https://github.com/test/repo1.git',
localPath: '/path/to/repo1',
sourcePath: null,
currentBranch: 'main',
isLocal: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
},
{
id: 2,
repoUrl: 'https://github.com/test/repo2.git',
localPath: '/path/to/repo2',
sourcePath: null,
currentBranch: 'main',
isLocal: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
},
])
render(
<QueryClientProvider client={new QueryClient()}>
<MemoryRouter initialEntries={['/repos/1?mobileTab=repos']}>
<Routes>
<Route path="*" element={<MobileSheetHarness />} />
</Routes>
</MemoryRouter>
</QueryClientProvider>,
)
await waitFor(() => {
expect(screen.getByText('repo2')).toBeInTheDocument()
})
fireEvent.click(screen.getByText('repo2'))
expect(screen.getByTestId('location')).toHaveTextContent('/repos/2')
})
})
@@ -38,18 +38,26 @@ export function RepoQuickSwitchSheet({ isOpen, onClose }: RepoQuickSwitchSheetPr
)
}, [repos, searchQuery])
const isUrlControlledSheet = new URLSearchParams(location.search).get('mobileTab') === 'repos'
const navigateAndClose = (path: string, options?: { replace?: boolean }) => {
navigate(path, options)
if (!isUrlControlledSheet) {
onClose()
}
}
const handleClick = (id: number) => {
const pendingAction = new URLSearchParams(location.search).get('mobileTabAction')
if (pendingAction === 'assistant') {
navigate(`/repos/${id}/assistant`)
onClose()
navigateAndClose(`/repos/${id}/assistant`)
return
}
const isAssistantRoute = location.pathname === `/repos/${id}/assistant`
if (id === activeRepoId) {
if (isAssistantRoute) {
navigate(`/repos/${id}`, { replace: true })
navigateAndClose(`/repos/${id}`, { replace: true })
return
}
@@ -57,8 +65,7 @@ export function RepoQuickSwitchSheet({ isOpen, onClose }: RepoQuickSwitchSheetPr
return
}
navigate(`/repos/${id}`, { replace: true })
onClose()
navigateAndClose(`/repos/${id}`, { replace: true })
}
return (