fix(cloud): hide Orca Cloud sandbox clones from the sidebar; no Tailscale hint for cloud hosts

Each Orca Cloud workspace is its own sandbox host whose clone is registered
as the project there (orca-worktree mode, hosted-sandbox-driver.ts), with
the workspace as a worktree beside it. The clone was listed as a primary
row, so every cloud workspace added another identical
'master [primary] · Orca Cloud' row under its project. Sidebar lists and
the jump palette now hide primary checkouts on Orca Cloud hosts, reusing
the VM-create hidden-checkout filter.

An unreachable Orca Cloud sandbox (asleep, gone, or another team's) was
classified as a network host and got the 'connect both devices to
Tailscale' hint; cloud hosts now keep the plain message.
This commit is contained in:
Neil
2026-11-10 15:28:46 -08:00
parent 240e764ebd
commit c66cb01cf3
10 changed files with 197 additions and 34 deletions
@@ -5,7 +5,8 @@ import { withRuntimeUnreachableHint } from './runtime-environment-unreachable-hi
export function withTailscaleHintForResponse<TResult>(
response: RuntimeRpcResponse<TResult>,
endpoint: string,
environment: Pick<KnownRuntimeEnvironment, 'orcadDeployment' | 'sshAccess'>
environment: Pick<KnownRuntimeEnvironment, 'orcadDeployment' | 'sshAccess'> &
Partial<Pick<KnownRuntimeEnvironment, 'name' | 'source'>>
): RuntimeRpcResponse<TResult> {
if (response.ok === true) {
return response
@@ -0,0 +1,21 @@
import { describe, expect, it } from 'vitest'
import { withRuntimeUnreachableHint } from './runtime-environment-unreachable-hint'
const FAILURE = 'Could not connect to the remote Orca runtime: socket closed.'
const ENDPOINT = 'wss://203.0.113.7:6768'
describe('withRuntimeUnreachableHint', () => {
it('hints Tailscale for a paired server on another network', () => {
expect(
withRuntimeUnreachableHint({ name: 'desk', source: 'manual' }, FAILURE, ENDPOINT)
).toMatch(/Tailscale/)
})
it('leaves an Orca Cloud sandbox failure without a Tailscale hint', () => {
const cloud = {
name: 'orca-sandbox-push-test sandbox 1a2b3c4d',
source: 'ephemeral-vm' as const
}
expect(withRuntimeUnreachableHint(cloud, FAILURE, ENDPOINT)).toBe(FAILURE)
})
})
@@ -1,15 +1,22 @@
import { withRemoteRuntimeTailscaleHint } from '../../../shared/remote-runtime/remote-runtime-tailscale-hint'
import { classifyRuntimeEnvironmentHost } from '../../../shared/remote-runtime/host-catalog/runtime-environment-host-kind'
import type { KnownRuntimeEnvironment } from '../../../shared/remote-runtime/host-catalog/runtime-environments'
import { isOrcaCloudRuntimeEnvironment } from '../../../shared/remote-runtime/host-catalog/orca-cloud-environment-name'
const UNREACHABLE_RE =
/could not connect to the remote orca runtime|remote orca runtime closed the connection|timed out (?:waiting for|while connecting to) the remote orca runtime/i
export function withRuntimeUnreachableHint(
environment: Pick<KnownRuntimeEnvironment, 'orcadDeployment' | 'sshAccess'>,
environment: Pick<KnownRuntimeEnvironment, 'orcadDeployment' | 'sshAccess'> &
Partial<Pick<KnownRuntimeEnvironment, 'name' | 'source'>>,
message: string,
endpoint: string | null | undefined
): string {
// Orca Cloud sandboxes are reached through Orca Cloud, not the user's network: one that does not
// answer is asleep, gone, or another team's, and a Tailscale hint sends the user the wrong way.
if (isOrcaCloudRuntimeEnvironment(environment)) {
return message
}
const host = classifyRuntimeEnvironmentHost(environment)
switch (host.kind) {
case 'network':
@@ -9,11 +9,8 @@ import {
} from '@/lib/sidebar-pending-layer'
import { useSidebarListSession } from '@/lib/sidebar-list-session'
import { readEndedCreations, subscribeEndedCreations } from '@/lib/sidebar-ended-creations'
import {
readHiddenVmCheckouts,
subscribeHiddenVmCheckouts,
withoutHiddenVmCheckouts
} from '@/lib/vm-create-hidden-checkouts'
import { withoutHiddenVmCheckouts } from '@/lib/vm-create-hidden-checkouts'
import { useSidebarHiddenCheckouts } from '@/lib/orca-cloud/use-sidebar-hidden-checkouts'
import '../../../../../../shared/folder-workspaces/folder-workspace-execution-host'
import { getFolderWorkspaceHostId } from '../../../../../../shared/folder-workspaces/folder-workspace-host-id'
import type { FolderWorkspace } from '../../../../../../shared/folder-workspaces/folder-workspace-types'
@@ -78,7 +75,7 @@ export function useMainSidebarListModel(args: SidebarListModelArgs): SidebarList
const feed = useDesktopSidebarFeed()
const pending = useSyncExternalStore(subscribeSidebarPendingLayer, readSidebarPendingLayer)
const endedCreationIds = useSyncExternalStore(subscribeEndedCreations, readEndedCreations)
const hiddenVmCheckouts = useSyncExternalStore(subscribeHiddenVmCheckouts, readHiddenVmCheckouts)
const hiddenVmCheckouts = useSidebarHiddenCheckouts()
const pendingCreationKeys = useAppStore(
useShallow((s) => selectPendingWorktreeCreationKeys(s.pendingWorktreeCreations))
)
@@ -1,5 +1,5 @@
import { selectSidebarLineageParentIdentities } from '@/store/slices/worktrees/metadata/cross-store-lineage-parents'
import { useMemo, useState, useSyncExternalStore } from 'react'
import { useMemo, useState } from 'react'
import { shallow } from 'zustand/shallow'
import type { AppState } from '@/store/types'
import { useAppStore } from '@/store'
@@ -24,11 +24,8 @@ import type { SidebarWorktreeFilters } from './use-filters'
import { useReusedArrayIdentity } from './use-reused-array-identity'
import { useSleepingSweepRetention } from './use-sleeping-sweep-retention'
import { selectWorktreesByRepo } from '@/store/workspaces/catalog/workspace-record-fields'
import {
readHiddenVmCheckouts,
subscribeHiddenVmCheckouts,
withoutHiddenVmWorktrees
} from '@/lib/vm-create-hidden-checkouts'
import { withoutHiddenVmWorktrees } from '@/lib/vm-create-hidden-checkouts'
import { useSidebarHiddenCheckouts } from '@/lib/orca-cloud/use-sidebar-hidden-checkouts'
const EMPTY_WORKTREE_ID_SET: ReadonlySet<string> = new Set()
@@ -123,7 +120,7 @@ export function useVisibleSidebarWorktrees(args: {
worktreeIdsWithStructuredChat
})
const hiddenVmCheckouts = useSyncExternalStore(subscribeHiddenVmCheckouts, readHiddenVmCheckouts)
const hiddenVmCheckouts = useSidebarHiddenCheckouts()
const recomputedVisibleWorktrees = useMemo(() => {
const visible = computeVisibleWorktrees(worktreesByRepo, sortedIds, {
filterRepoIds,
@@ -1,4 +1,4 @@
import { useMemo, useSyncExternalStore } from 'react'
import { useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import { useShallow } from 'zustand/react/shallow'
import { useAppStore } from '@/store/index'
@@ -6,11 +6,8 @@ import { usePluginCommands } from '@/store/plugins/catalog/plugin-contribution-c
import { usePluginNewFiles } from '@/store/plugins/file-creation/plugin-new-files'
import { useSettingsNavigationMetadata } from '@/hooks/useSettingsNavigationMetadata'
import { dedupePaletteWorktrees } from '@/lib/workspace/search/palette-repo-resolution'
import {
readHiddenVmCheckouts,
subscribeHiddenVmCheckouts,
withoutHiddenVmWorktreesByRepo
} from '@/lib/vm-create-hidden-checkouts'
import { withoutHiddenVmWorktreesByRepo } from '@/lib/vm-create-hidden-checkouts'
import { useSidebarHiddenCheckouts } from '@/lib/orca-cloud/use-sidebar-hidden-checkouts'
import {
selectPaletteIndexStatusSnapshot,
selectPaletteStatusInputs
@@ -42,8 +39,8 @@ export function useWorktreeJumpPaletteStoreState({
const recordFeatureInteraction = useAppStore((state) => state.recordFeatureInteraction)
const revealSidebarRow = useAppStore((state) => state.revealSidebarRow)
const storedWorktreesByRepo = useAppStore((state) => selectWorktreesByRepo(state))
const hiddenVmCheckouts = useSyncExternalStore(subscribeHiddenVmCheckouts, readHiddenVmCheckouts)
// Why: a VM create's checkout is not a workspace until the create adopts it.
const hiddenVmCheckouts = useSidebarHiddenCheckouts()
// Why: a VM create's checkout is not a workspace until the create adopts it; an Orca Cloud clone never is.
const worktreesByRepo = useMemo(
() => withoutHiddenVmWorktreesByRepo(storedWorktreesByRepo, hiddenVmCheckouts),
[storedWorktreesByRepo, hiddenVmCheckouts]
@@ -0,0 +1,18 @@
import { describe, expect, it } from 'vitest'
import type { AppState } from '@/store/types'
import { selectOrcaCloudHostIdsKey } from './use-sidebar-hidden-checkouts'
describe('selectOrcaCloudHostIdsKey', () => {
it('names only Orca Cloud sandbox servers', () => {
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the selector reads only id, name and source.
const state = {
runtimeEnvironments: [
{ id: 'a', name: 'orca-sandbox-push-test sandbox 1a2b3c4d', source: 'ephemeral-vm' },
{ id: 'b', name: 'orca-sandbox-push-test sandbox 5e6f7a8b', source: 'ephemeral-vm' },
{ id: 'vm', name: 'my recipe VM', source: 'ephemeral-vm' },
{ id: 'manual', name: 'orca-sandbox-push-test sandbox 1a2b3c4d', source: 'manual' }
]
} as unknown as Pick<AppState, 'runtimeEnvironments'>
expect(selectOrcaCloudHostIdsKey(state).split('\n')).toEqual(['runtime:a', 'runtime:b'])
})
})
@@ -0,0 +1,33 @@
import { useMemo, useSyncExternalStore } from 'react'
import { useAppStore } from '@/store'
import type { AppState } from '@/store/types'
import {
readHiddenVmCheckouts,
subscribeHiddenVmCheckouts,
withOrcaCloudPrimaryHosts,
type HiddenVmCheckouts
} from '@/lib/vm-create-hidden-checkouts'
import { toRuntimeExecutionHostId } from '../../../../shared/execution-host'
import { isOrcaCloudRuntimeEnvironment } from '../../../../shared/remote-runtime/host-catalog/orca-cloud-environment-name'
/** Orca Cloud sandbox hosts, newline-joined so the selector result compares by value. */
export function selectOrcaCloudHostIdsKey(state: Pick<AppState, 'runtimeEnvironments'>): string {
return (state.runtimeEnvironments ?? [])
.filter((environment) => isOrcaCloudRuntimeEnvironment(environment))
.map((environment) => toRuntimeExecutionHostId(environment.id))
.join('\n')
}
/** What sidebar lists hide: VM checkouts whose create is in progress, and every Orca Cloud clone. */
export function useSidebarHiddenCheckouts(): HiddenVmCheckouts {
const pending = useSyncExternalStore(subscribeHiddenVmCheckouts, readHiddenVmCheckouts)
const cloudHostIdsKey = useAppStore(selectOrcaCloudHostIdsKey)
return useMemo(
() =>
withOrcaCloudPrimaryHosts(
pending,
new Set(cloudHostIdsKey ? cloudHostIdsKey.split('\n') : [])
),
[pending, cloudHostIdsKey]
)
}
@@ -1,13 +1,16 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
import { EMPTY_SIDEBAR_FEED_DOMAINS } from '../../../shared/sidebar-feed-client/sidebar-feed-snapshot'
import type { SidebarFeedDomains } from '../../../shared/sidebar-list/sidebar-feed-domains'
import { composeWorktreeHostIdentity } from '../../../shared/worktree/host-qualified-identity'
import {
hideVmCreateCheckout,
readHiddenVmCheckouts,
releaseVmCreateCheckout,
settleVmCreateCheckoutAfterCleanup,
withOrcaCloudPrimaryHosts,
withoutHiddenVmCheckouts,
withoutHiddenVmWorktrees
withoutHiddenVmWorktrees,
withoutHiddenVmWorktreesByRepo
} from './vm-create-hidden-checkouts'
type Row = { repoId: string; path: string; isMainWorktree?: boolean }
@@ -78,3 +81,54 @@ describe('hidden VM checkout lifecycle', () => {
expect(isListed('vm')).toBe(true)
})
})
describe('Orca Cloud sandbox primaries', () => {
// Two cloud workspaces of one project: each sandbox lists its clone (master) as primary.
const hostA = 'runtime:sandbox-a'
const hostB = 'runtime:sandbox-b'
const cloudHosts = new Set([hostA, hostB])
const cloneA = {
repoId: 'r',
path: '/vercel/sandbox/project',
isMainWorktree: true,
hostId: hostA
}
const cloneB = { ...cloneA, hostId: hostB }
const sockeye = { repoId: 'r', path: '/w/sockeye', isMainWorktree: false, hostId: hostA }
const otter = { repoId: 'r', path: '/w/otter', isMainWorktree: false, hostId: hostB }
const local = { repoId: 'r', path: '/Users/me/repo', isMainWorktree: true, hostId: 'local' }
it('lists neither clone as a row, keeping the cloud workspaces and the local primary', () => {
const hidden = withOrcaCloudPrimaryHosts(readHiddenVmCheckouts(), cloudHosts)
const rows = [local, cloneA, cloneB, sockeye, otter]
expect(withoutHiddenVmWorktrees(rows, hidden)).toEqual([local, sockeye, otter])
expect(withoutHiddenVmWorktreesByRepo({ r: rows }, hidden)).toEqual({
r: [local, sockeye, otter]
})
})
it("reads a paired-server row's host from its host-qualified key", () => {
const { hostId: _a, ...rowA } = cloneA
const { hostId: _b, ...rowB } = cloneB
const { hostId: _s, ...rowS } = sockeye
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the filter reads only repoId, path, isMainWorktree and the key.
const domains = {
...EMPTY_SIDEBAR_FEED_DOMAINS,
pairedServerRows: new Map([
[composeWorktreeHostIdentity(hostA, 'r::/vercel/sandbox/project'), rowA],
[composeWorktreeHostIdentity(hostB, 'r::/vercel/sandbox/project'), rowB],
[composeWorktreeHostIdentity(hostA, 'r::/w/sockeye'), rowS]
])
} as unknown as SidebarFeedDomains
const hidden = withOrcaCloudPrimaryHosts(readHiddenVmCheckouts(), cloudHosts)
expect([...withoutHiddenVmCheckouts(domains, hidden).pairedServerRows.values()]).toEqual([rowS])
})
it('leaves lists untouched when no Orca Cloud host is known', () => {
const rows = [local, cloneA]
const hidden = withOrcaCloudPrimaryHosts(readHiddenVmCheckouts(), new Set())
expect(withoutHiddenVmWorktrees(rows, hidden)).toBe(rows)
})
})
@@ -1,4 +1,5 @@
import type { SidebarFeedDomains } from '../../../shared/sidebar-list/sidebar-feed-domains'
import { getExecutionHostIdFromWorktreeHostIdentity } from '../../../shared/worktree/host-qualified-identity'
import {
indexPendingVmCheckouts,
isPendingVmCheckout,
@@ -8,10 +9,43 @@ import {
/** A VM's primary checkout, registered on its host before the create that owns it finishes. */
export type HiddenVmCheckout = PendingVmCheckout
type CheckoutRow = { repoId: string; path: string; isMainWorktree?: boolean }
type CheckoutRow = { repoId: string; path: string; isMainWorktree?: boolean; hostId?: string }
/** What lists filter by: this window's pending VM checkouts and every other window's. */
export type HiddenVmCheckouts = PendingVmCheckoutIndex
/**
* What lists filter by: this window's pending VM checkouts and every other window's, plus the hosts
* whose primary checkout is never a workspace (withOrcaCloudPrimaryHosts).
*/
export type HiddenVmCheckouts = PendingVmCheckoutIndex & {
readonly primaryHostIds?: ReadonlySet<string>
}
/**
* Why: each Orca Cloud workspace is its own sandbox whose clone is registered as the project there,
* and the workspace is a worktree beside it (orca-worktree mode). That clone is scaffolding, not a
* workspace: listed, every cloud workspace added another identical "<default branch> primary ·
* Orca Cloud" row to its project.
*/
export function withOrcaCloudPrimaryHosts(
checkouts: HiddenVmCheckouts,
hostIds: ReadonlySet<string>
): HiddenVmCheckouts {
return hostIds.size === 0 ? checkouts : { ...checkouts, primaryHostIds: hostIds }
}
function hidesNothing(checkouts: HiddenVmCheckouts): boolean {
return checkouts.keys.size === 0 && !checkouts.primaryHostIds?.size
}
function isHiddenCheckout(
checkouts: HiddenVmCheckouts,
row: CheckoutRow,
hostId: string | undefined = row.hostId
): boolean {
if (row.isMainWorktree === true && hostId && checkouts.primaryHostIds?.has(hostId)) {
return true
}
return checkouts.keys.size > 0 && isPendingVmCheckout(checkouts, row)
}
// Upper bound for a cleaned-up VM's rows to leave the lists (its host is retired asynchronously).
const HIDDEN_AFTER_CLEANUP_MS = 60_000
@@ -136,10 +170,10 @@ export function withoutHiddenVmWorktrees<W extends CheckoutRow>(
worktrees: W[],
checkouts: HiddenVmCheckouts
): W[] {
if (checkouts.keys.size === 0) {
if (hidesNothing(checkouts)) {
return worktrees
}
const kept = worktrees.filter((worktree) => !isPendingVmCheckout(checkouts, worktree))
const kept = worktrees.filter((worktree) => !isHiddenCheckout(checkouts, worktree))
return kept.length === worktrees.length ? worktrees : kept
}
@@ -148,11 +182,13 @@ export function withoutHiddenVmWorktreesByRepo<W extends CheckoutRow>(
worktreesByRepo: Record<string, W[]>,
checkouts: HiddenVmCheckouts
): Record<string, W[]> {
if (checkouts.keys.size === 0) {
if (hidesNothing(checkouts)) {
return worktreesByRepo
}
let next: Record<string, W[]> | null = null
for (const repoId of checkouts.repoIds) {
// Host-hidden primaries can sit under any repo; pending checkouts only under theirs.
const repoIds = checkouts.primaryHostIds?.size ? Object.keys(worktreesByRepo) : checkouts.repoIds
for (const repoId of repoIds) {
const list = worktreesByRepo[repoId]
if (!list) {
continue
@@ -166,13 +202,15 @@ export function withoutHiddenVmWorktreesByRepo<W extends CheckoutRow>(
return next ?? worktreesByRepo
}
function withoutHiddenRows<K, V extends CheckoutRow>(
function withoutHiddenRows<K extends string, V extends CheckoutRow>(
rows: ReadonlyMap<K, V>,
checkouts: HiddenVmCheckouts
): ReadonlyMap<K, V> {
let kept: Map<K, V> | null = null
for (const [key, row] of rows) {
if (isPendingVmCheckout(checkouts, row)) {
// Paired-server rows carry their host only in the host-qualified key.
const hostId = row.hostId ?? getExecutionHostIdFromWorktreeHostIdentity(key)
if (isHiddenCheckout(checkouts, row, hostId)) {
kept ??= new Map(rows)
kept.delete(key)
}
@@ -185,7 +223,7 @@ export function withoutHiddenVmCheckouts(
domains: SidebarFeedDomains,
checkouts: HiddenVmCheckouts
): SidebarFeedDomains {
if (checkouts.keys.size === 0) {
if (hidesNothing(checkouts)) {
return domains
}
const workspaces = withoutHiddenRows(domains.workspaces, checkouts)