mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
fix(cloud): another team's cloud workspace is neither a Run on target nor announced as reconnecting, same scope as the sidebar (STALE-RUN-TARGET) (#722)
This commit is contained in:
+40
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import type { AppState } from '@/store/types'
|
||||
|
||||
vi.mock('../../../../../lib/workspace/ownership/workspace-runtime-environment', () => ({
|
||||
selectWorkspaceRuntimeEnvironmentId: (_state: unknown, worktreeId: string | null) =>
|
||||
worktreeId === 'wt-pick' ? 'pick' : null
|
||||
}))
|
||||
vi.mock('@/runtime/hosts/connections/runtime-host-connection-state', () => ({
|
||||
runtimeHostConnectionStateForEntry: (entry: { reconnecting?: boolean } | undefined) =>
|
||||
entry?.reconnecting ? 'reconnecting' : 'connected'
|
||||
}))
|
||||
|
||||
import { selectRetryingOutageEnvironmentId } from './remote-server-outage'
|
||||
|
||||
function state(activeOrgId: string): AppState {
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the selectors read only these fields.
|
||||
return {
|
||||
runtimeEnvironments: [
|
||||
{
|
||||
id: 'pick',
|
||||
name: 'endpass-pick (cloud)',
|
||||
orcaCloudPaired: true,
|
||||
orcaCloudPairedAccountId: 'org:eval'
|
||||
}
|
||||
],
|
||||
cloudAccountIdByEnvironmentId: {},
|
||||
orcaProfileAuthStatus: { cloud: { userId: 'u1', activeOrgId } },
|
||||
runtimeStatusByEnvironmentId: new Map([['pick', { reconnecting: true }]])
|
||||
} as unknown as AppState
|
||||
}
|
||||
|
||||
describe('reconnect banner scope (STALE-RUN-TARGET)', () => {
|
||||
it("announces the active team's cloud workspace reconnecting", () => {
|
||||
expect(selectRetryingOutageEnvironmentId(state('eval'), 'wt-pick')).toBe('pick')
|
||||
})
|
||||
|
||||
it("stays quiet for another team's cloud workspace, which the sidebar hides too", () => {
|
||||
expect(selectRetryingOutageEnvironmentId(state('noplan'), 'wt-pick')).toBeNull()
|
||||
})
|
||||
})
|
||||
+7
-1
@@ -6,6 +6,7 @@ import { tailscaleHostOfEndpoint } from '../../../../../../../shared/remote-runt
|
||||
import { selectExecutionHostDisplayLabel } from '@/runtime/hosts/display/execution-host-display-label'
|
||||
import { runtimeHostConnectionStateForEntry } from '@/runtime/hosts/connections/runtime-host-connection-state'
|
||||
import type { RemoteRuntimeRecoveryCause } from '../../remote-runtime/recovery/remote-runtime-recovery-copy'
|
||||
import { selectOrcaCloudHiddenHostIds } from '@/lib/orca-cloud/use-sidebar-hidden-checkouts'
|
||||
|
||||
/** Read shared server reconnection once so individual panes do not announce the same outage. */
|
||||
export function selectRetryingOutageEnvironmentId(
|
||||
@@ -13,7 +14,12 @@ export function selectRetryingOutageEnvironmentId(
|
||||
worktreeId: string | null | undefined
|
||||
): string | null {
|
||||
const environmentId = selectWorkspaceRuntimeEnvironmentId(state, worktreeId)
|
||||
if (!environmentId) {
|
||||
// STALE-RUN-TARGET: another team's cloud workspace is out of scope here (same rule as the
|
||||
// sidebar), so its dropped connection is not announced; it is checked again on its own team.
|
||||
if (
|
||||
!environmentId ||
|
||||
selectOrcaCloudHiddenHostIds(state).has(toRuntimeExecutionHostId(environmentId))
|
||||
) {
|
||||
return null
|
||||
}
|
||||
// Only reconnecting proves transport loss; checking or failed probes over a live socket do not.
|
||||
|
||||
@@ -14,6 +14,7 @@ import type { ComposerDecisions } from './composer-decisions'
|
||||
import type { WorkspaceCreationTargetHint } from '@/lib/workspace/creation/project-host-workspace-target'
|
||||
import { selectWorktreesByRepo } from '@/store/workspaces/catalog/workspace-record-fields'
|
||||
import { selectAllKnownWorkspaceStatuses } from '@/store/workspaces/status/host-workspace-status-columns'
|
||||
import { selectOrcaCloudHiddenHostIds } from '@/lib/orca-cloud/use-sidebar-hidden-checkouts'
|
||||
|
||||
export type ComposerStateInput = {
|
||||
initialRepoId?: string
|
||||
@@ -129,6 +130,9 @@ export function useComposerTargetStore(options: ComposerStateInput, decisions: C
|
||||
|
||||
const eligibleRepos = useMemo(() => getNewWorkspaceDialogEligibleRepos(repos), [repos])
|
||||
|
||||
// STALE-RUN-TARGET: another team's cloud workspace isn't a place to run (same rule as the sidebar).
|
||||
const hiddenCloudHostIds = useAppStore(selectOrcaCloudHiddenHostIds)
|
||||
|
||||
const hostOptions = useMemo(
|
||||
() =>
|
||||
buildExecutionHostRegistry({
|
||||
@@ -140,8 +144,9 @@ export function useComposerTargetStore(options: ComposerStateInput, decisions: C
|
||||
runtimeEnvironments,
|
||||
runtimeStatusByEnvironmentId,
|
||||
hostLabelOverrides: getHostDisplayLabelOverrides(settings)
|
||||
}),
|
||||
}).filter((host) => !hiddenCloudHostIds.has(host.id)),
|
||||
[
|
||||
hiddenCloudHostIds,
|
||||
repos,
|
||||
settings,
|
||||
sshConnectionStates,
|
||||
|
||||
@@ -4,6 +4,7 @@ import { EMPTY_PENDING_VM_CHECKOUT_INDEX } from '../../../../shared/pending-vm-c
|
||||
import { withOrcaCloudHosts } from '@/runtime/ephemeral-vm/vm-create-hidden-checkouts'
|
||||
import {
|
||||
parseOrcaCloudHostScopeKey,
|
||||
selectOrcaCloudHiddenHostIds,
|
||||
selectOrcaCloudHostScopeKey,
|
||||
withoutHiddenHostRepos
|
||||
} from './use-sidebar-hidden-checkouts'
|
||||
@@ -151,3 +152,35 @@ describe('GH-CREATE-NO-ROW hand-off', () => {
|
||||
expect(hidden(pairing('runtime:p'))).toEqual(['runtime:p'])
|
||||
})
|
||||
})
|
||||
|
||||
describe('hidden cloud hosts for Run on and the reconnect banner (STALE-RUN-TARGET)', () => {
|
||||
const state = (activeOrgId: string) => {
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the selector reads only these fields.
|
||||
return {
|
||||
runtimeEnvironments: [
|
||||
{
|
||||
id: 'pick',
|
||||
name: 'endpass-pick (cloud)',
|
||||
orcaCloudPaired: true,
|
||||
orcaCloudPairedAccountId: 'org:eval'
|
||||
}
|
||||
],
|
||||
cloudAccountIdByEnvironmentId: {},
|
||||
orcaProfileAuthStatus: { cloud: { userId: 'u1', activeOrgId } }
|
||||
} as unknown as Pick<AppState, 'runtimeEnvironments'>
|
||||
}
|
||||
|
||||
it("names another team's paired workspace, the same host the sidebar hides", () => {
|
||||
expect([...selectOrcaCloudHiddenHostIds(state('noplan'))]).toEqual(['runtime:pick'])
|
||||
})
|
||||
|
||||
it("keeps the active team's paired workspace", () => {
|
||||
expect(selectOrcaCloudHiddenHostIds(state('eval')).size).toBe(0)
|
||||
})
|
||||
|
||||
it('answers the same set while nothing changed, so store subscribers do not re-render', () => {
|
||||
expect(selectOrcaCloudHiddenHostIds(state('noplan'))).toBe(
|
||||
selectOrcaCloudHiddenHostIds(state('noplan'))
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -73,6 +73,21 @@ export function parseOrcaCloudHostScopeKey(key: string): {
|
||||
return { primaryHostIds, pairedHostIds, hiddenHostIds }
|
||||
}
|
||||
|
||||
let hiddenCache: { key: string; ids: ReadonlySet<string> } | null = null
|
||||
|
||||
/**
|
||||
* STALE-RUN-TARGET: the Orca Cloud hosts the sidebar scopes out (another team's sandbox, owned or
|
||||
* PAIRED). Run on and the reconnect banner use the same rule, so a team switch never leaves another
|
||||
* team's workspace listed as a place to run, or announced as reconnecting, where it can't be used.
|
||||
*/
|
||||
export function selectOrcaCloudHiddenHostIds(state: CloudScopeState): ReadonlySet<string> {
|
||||
const key = selectOrcaCloudHostScopeKey(state)
|
||||
if (hiddenCache?.key !== key) {
|
||||
hiddenCache = { key, ids: parseOrcaCloudHostScopeKey(key).hiddenHostIds }
|
||||
}
|
||||
return hiddenCache.ids
|
||||
}
|
||||
|
||||
/**
|
||||
* What sidebar lists hide: VM checkouts whose create is in progress, an Orca Cloud clone beside its
|
||||
* listed workspace, and every row of another team's sandbox.
|
||||
|
||||
Reference in New Issue
Block a user