feat: add session status store with optimistic active state and SSE polling (#272)

* feat: add session status store with optimistic active state and SSE polling

- Adds sessionStatusStore with setOptimisticActive (auto-timeout), statusCache deduplication, and replaceStatuses/clearStatus

- Integrates store in useSendPrompt (set optimistic on send, clear on error)

- Adds session.status SSE event handling in useSSE with 5s polling fallback

- Refactors test to mock the store instead of using real store instance

- Fixes repoId null check in useRepoActivity

* feat: replace event-source-polyfill with native SSE for PromptInput

* fix: keep stop button visible and hide clear prompt button during active session

* feat: restore failed queued prompts and preserve optimistic active status during poll

* test: add MessageThread tests for optimistic editing state and resend flow

* fix: handle queued prompt edge cases during pending submission and SSE errors
This commit is contained in:
Chris Scott authored and GitHub committed 2026-06-10 08:35:19 -04:00
1 parent 931f1215e6
commit 4e32fd5b00
16 files changed
+833 -61

No files matched your search

@@ -5,6 +5,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { RepoQuickSwitchSheet } from './RepoQuickSwitchSheet'
import { listRepos } from '@/api/repos'
import { useMobileTabBar } from '@/hooks/useMobileTabBar'
import { ASSISTANT_REPO_ID } from '@opencode-manager/shared/utils'
vi.mock('@/api/repos')
@@ -109,6 +110,42 @@ describe('RepoQuickSwitchSheet', () => {
})
})
it('does not show assistant as a repo option', async () => {
vi.mocked(listRepos).mockResolvedValue([
{
id: ASSISTANT_REPO_ID,
repoUrl: 'Assistant',
localPath: '/assistant',
sourcePath: null,
currentBranch: null,
isLocal: true,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
},
{
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(),
},
])
const handleClose = vi.fn()
render(
<RepoQuickSwitchSheet isOpen onClose={handleClose} />,
{ wrapper: createWrapper() },
)
await waitFor(() => {
expect(screen.getByText('repo1')).toBeInTheDocument()
})
expect(screen.queryByText('Assistant')).not.toBeInTheDocument()
})
it('navigates on repo click and closes sheet', async () => {
vi.mocked(listRepos).mockResolvedValue([
{
@@ -10,6 +10,7 @@ import { AddRepoDialog } from '@/components/repo/AddRepoDialog'
import { FolderGit2, Check, Plus, House } from 'lucide-react'
import { useUrlParams } from '@/hooks/useUrlParams'
import { ASSISTANT_REPO_ID } from '@opencode-manager/shared/utils'
import { getAssistantPath, isAssistantPath } from '@/lib/navigation'
interface RepoQuickSwitchSheetProps {
isOpen: boolean
@@ -24,6 +25,7 @@ export function RepoQuickSwitchSheet({ isOpen, onClose }: RepoQuickSwitchSheetPr
const [addRepoOpen, setAddRepoOpen] = useState(false)
const activeRepoId = useMemo(() => {
if (isAssistantPath(location.pathname)) return null
const match = location.pathname.match(/^\/repos\/(\d+)/)
return match ? Number(match[1]) : null
}, [location.pathname])
@@ -59,6 +61,11 @@ export function RepoQuickSwitchSheet({ isOpen, onClose }: RepoQuickSwitchSheetPr
}
const handleClick = (id: number) => {
if (searchParams.get('mobileTabAction') === 'assistant') {
navigateAndClose(getAssistantPath(), { replace: true })
return
}
if (id === activeRepoId) {
onClose()
return