import type { ReactNode } from 'react'
import { useLocation } from 'wouter'
import { IconFolderOff } from '@tabler/icons-react'
import { workspaceProviderIcon } from '@/client/components/shared/workspace-icon'
import { Button } from '@/client/components/ui/button'
import { Spinner } from '@/client/components/ui/spinner'
import { useRemoveWorkspace } from '@/client/features/home/api'
import type { HarnessAvailability, WorkspaceType } from '@/lib/types'
type RecoveryRetryProps = {
retrying: boolean
onRetry: () => void
}
type WorkspaceCheckFailedStateProps = RecoveryRetryProps
export function WorkspaceCheckFailedState(props: WorkspaceCheckFailedStateProps) {
return (
Could not check this workspace’s agent. Try again.
)
}
type WorkspaceMissingStateProps = {
workspaceId: string
}
export function WorkspaceMissingState({ workspaceId }: WorkspaceMissingStateProps) {
const [, navigate] = useLocation()
const remove = useRemoveWorkspace()
return (
The workspace folder is missing
{remove.error && (
{remove.error.message}
)}
)
}
type HarnessUnavailableStateProps = RecoveryRetryProps & {
type: WorkspaceType
availability: Exclude
}
export function HarnessUnavailableState({
type,
availability,
...retry
}: HarnessUnavailableStateProps) {
const needsTerminalLogin = availability.status === 'login-required'
return (
{availability.reason}
{needsTerminalLogin && (
<>
Complete sign-in in your agent’s terminal, then try again.
>
)}
)
}
export function WorkspaceLoadingState() {
return (
)
}
type RecoveryMessageProps = RecoveryRetryProps & {
title: string
type?: WorkspaceType
children: ReactNode
}
function RecoveryMessage({ title, type, children, retrying, onRetry }: RecoveryMessageProps) {
return (
{type &&

}
{title}
)
}