fix(br-1): cloud never falls back to the stream path; final non-http and retry copy

Orca Cloud counts as no screencast until a probe proves otherwise, so a
sleeping or unreachable sandbox cannot surface 'Cannot reach…' stream notices
(BR-2 closes with this). Non-http pages: 'Orca can't show the sandbox's
browser here yet.' + 'This page can only be viewed in the sandbox.' A failed
open says 'Couldn't open the page. Try again.' (polite live region).
This commit is contained in:
Neil
2026-11-11 02:17:35 -08:00
parent 452556f730
commit ee488d2c8a
5 changed files with 70 additions and 23 deletions
@@ -1,7 +1,7 @@
import { defineFixture } from '../../../component-fixtures/component-fixture'
import { SandboxOnlyBrowserPageState } from './sandbox-only-browser-page-state'
function Pane({ url, error = null }: { url: string; error?: string | null }): React.JSX.Element {
function Pane({ url, error = false }: { url: string; error?: boolean }): React.JSX.Element {
return (
<div className="flex h-[420px] w-[720px] flex-col bg-background text-foreground">
<div className="border-b border-border px-3 py-2 font-mono text-xs text-muted-foreground">
@@ -29,7 +29,5 @@ export const nonHttp = defineFixture({
})
export const openFailed = defineFixture({
width: 740,
render: () => (
<Pane url="https://example.org/" error="Could not open the page on this computer." />
)
render: () => <Pane url="https://example.org/" error />
})
@@ -1,5 +1,6 @@
import { describe, expect, it } from 'vitest'
import { canOpenSandboxPageOnThisComputer } from './sandbox-only-browser-page-state'
import { resolveScreencastSupport } from './use-sandbox-only-browser-page'
describe('canOpenSandboxPageOnThisComputer', () => {
it('offers http(s) pages, including the sandbox localhost', () => {
@@ -15,3 +16,20 @@ describe('canOpenSandboxPageOnThisComputer', () => {
expect(canOpenSandboxPageOnThisComputer('not a url')).toBe(false)
})
})
describe('resolveScreencastSupport', () => {
it('treats a pending or failed probe as no screencast on Orca Cloud', () => {
expect(resolveScreencastSupport('pending', true)).toBe(false)
expect(resolveScreencastSupport('failed', true)).toBe(false)
expect(resolveScreencastSupport(false, true)).toBe(false)
// A future orcad that streams is honoured once proven.
expect(resolveScreencastSupport(true, true)).toBe(true)
})
it('keeps other hosts on the stream path until the probe says otherwise', () => {
expect(resolveScreencastSupport('pending', false)).toBe(null)
expect(resolveScreencastSupport('failed', false)).toBe(null)
expect(resolveScreencastSupport(true, false)).toBe(true)
expect(resolveScreencastSupport(false, false)).toBe(false)
})
})
@@ -24,11 +24,16 @@ export function SandboxOnlyBrowserPageState({
}: {
url: string
opening: boolean
error: string | null
/** The last open attempt failed; the button doubles as the retry. */
error: boolean
onOpenOnThisComputer: () => void
}): React.JSX.Element {
const t = useTranslate()
const canOpen = canOpenSandboxPageOnThisComputer(url)
const cantShow = t(
'auto.components.browser.pane.SandboxOnlyBrowserPage.cantShow',
"Orca can't show the sandbox's browser here yet."
)
return (
<div
data-testid="sandbox-only-browser-page"
@@ -42,10 +47,12 @@ export function SandboxOnlyBrowserPageState({
)}
</div>
<div className="max-w-sm text-xs leading-5 text-muted-foreground">
{t(
'auto.components.browser.pane.SandboxOnlyBrowserPage.body',
"Orca can't show the sandbox's browser here yet. Open the page on this computer to see it. Pages the agent signed in to will open signed out."
)}
{canOpen
? t(
'auto.components.browser.pane.SandboxOnlyBrowserPage.body',
"Orca can't show the sandbox's browser here yet. Open the page on this computer to see it. Pages the agent signed in to will open signed out."
)
: cantShow}
</div>
{canOpen ? (
<Button size="sm" onClick={onOpenOnThisComputer} disabled={opening}>
@@ -59,11 +66,14 @@ export function SandboxOnlyBrowserPageState({
)}
</div>
)}
{error ? (
<div role="alert" className="max-w-sm text-xs leading-5 text-destructive">
{error}
</div>
) : null}
<div role="status" aria-live="polite" className="max-w-sm text-xs leading-5 text-destructive">
{error && canOpen
? t(
'auto.components.browser.pane.SandboxOnlyBrowserPage.openFailed',
"Couldn't open the page. Try again."
)
: null}
</div>
</div>
)
}
@@ -4,15 +4,30 @@ import { BROWSER_SCREENCAST_RUNTIME_CAPABILITY } from '../../../../../shared/bro
import { runtimeEnvironmentSupportsCapability } from '@/runtime/rpc/compatibility/runtime-capability-proof'
import { openWorkspaceBrowserTab } from '@/lib/browser/workspace/workspace-browser-tab-open'
import { resolveBrowserSourceUnifiedTab } from '@/lib/browser/workspace/browser-workspace-source-resolution'
import { isOrcaCloudEnvironmentId } from '@/lib/orca-cloud/orca-cloud-environment-id'
export type SandboxOnlyBrowserPage = {
/** False when the runtime cannot stream (Orca Cloud's orcad); null while unknown, which keeps the stream path. */
screencastSupported: boolean | null
opening: boolean
error: string | null
error: boolean
openOnThisComputer: () => void
}
/**
* Whether the stream path may run. Orca Cloud counts as no screencast until a probe proves it (a sleeping or
* unreachable sandbox must not fall back to "Cannot reach…" notices); other hosts stay unknown (null) until proven.
*/
export function resolveScreencastSupport(
probe: 'pending' | 'failed' | boolean,
isOrcaCloud: boolean
): boolean | null {
if (typeof probe === 'boolean') {
return probe
}
return isOrcaCloud ? false : null
}
/**
* Orca Cloud's orcad hosts agent pages in a headless browser it cannot stream; offer a
* desktop-hosted copy of the page instead.
@@ -24,25 +39,29 @@ export function useSandboxOnlyBrowserPage(input: {
worktreeId: string
}): SandboxOnlyBrowserPage {
const { pageId, url, runtimeEnvironmentId, worktreeId } = input
const [screencastSupported, setScreencastSupported] = useState<boolean | null>(null)
const [probe, setProbe] = useState<'pending' | 'failed' | boolean>('pending')
const [opening, setOpening] = useState(false)
const [error, setError] = useState<string | null>(null)
const [error, setError] = useState(false)
const screencastSupported = resolveScreencastSupport(
probe,
isOrcaCloudEnvironmentId(runtimeEnvironmentId)
)
useEffect(() => {
let cancelled = false
setProbe('pending')
void runtimeEnvironmentSupportsCapability(
runtimeEnvironmentId,
BROWSER_SCREENCAST_RUNTIME_CAPABILITY
)
.then((supported) => {
if (!cancelled) {
setScreencastSupported(supported)
setProbe(supported)
}
})
.catch(() => {
// Unknown support keeps the stream path, which reports its own failures.
if (!cancelled) {
setScreencastSupported(null)
setProbe('failed')
}
})
return () => {
@@ -57,7 +76,7 @@ export function useSandboxOnlyBrowserPage(input: {
worktreeId
)
setOpening(true)
setError(null)
setError(false)
// A new focused desktop-hosted tab beside this one; the sandbox tab stays so the agent's tab id remains valid.
// Desktop-hosted cloud pages tunnel loopback through the sandbox, so localhost reaches the sandbox's server.
void openWorkspaceBrowserTab({
@@ -70,7 +89,7 @@ export function useSandboxOnlyBrowserPage(input: {
expectedRuntimeEnvironmentId: runtimeEnvironmentId,
placementPreference: 'auto'
})
.catch((cause) => setError(cause instanceof Error ? cause.message : String(cause)))
.catch(() => setError(true))
.finally(() => setOpening(false))
}, [pageId, url, runtimeEnvironmentId, worktreeId])
+3 -1
View File
@@ -19011,7 +19011,9 @@
"title": "Your agent opened this page in the sandbox",
"body": "Orca can't show the sandbox's browser here yet. Open the page on this computer to see it. Pages the agent signed in to will open signed out.",
"open": "Open on this computer",
"sandboxOnly": "This page can only be viewed in the sandbox."
"sandboxOnly": "This page can only be viewed in the sandbox.",
"cantShow": "Orca can't show the sandbox's browser here yet.",
"openFailed": "Couldn't open the page. Try again."
}
},
"webauthn": {