mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 19:34:29 +00:00
fix(cloud): a team switch moves off the old team's paired cloud workspace, and the status bar counts only this team's hosts (TEAM-SWITCH-STALE-PANE) (#726)
The team-switch leave fired only for an owned workspace's host going from the team's (+) to hidden (-); a paired one's host is ~ since #690, so the main pane kept showing another team's workspace after the switch (n57). It leaves for ~ to - too. The status bar's host list and count now drop another team's cloud servers, the same scope as the sidebar (#722).
This commit is contained in:
@@ -9,6 +9,10 @@ import {
|
||||
DropdownMenuTrigger
|
||||
} from '@/components/ui/dropdown-menu'
|
||||
import { useAppStore } from '../../store/index'
|
||||
import {
|
||||
selectOrcaCloudHiddenHostIds,
|
||||
withoutHiddenHostEnvironments
|
||||
} from '@/lib/orca-cloud/use-sidebar-hidden-checkouts'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import { useTranslate } from '@/i18n/use-translate'
|
||||
import { getHostDisplayLabelOverrides } from '../../../../shared/host-setting-overrides'
|
||||
@@ -58,6 +62,8 @@ export function SshStatusSegment({
|
||||
const settings = useAppStore((s) => s.settings)
|
||||
const runtimeEnvironments = useAppStore((s) => s.runtimeEnvironments)
|
||||
const runtimeStatusByEnvironmentId = useAppStore((s) => s.runtimeStatusByEnvironmentId)
|
||||
// Another team's cloud sandboxes are not this team's hosts (same scope as the sidebar, #722).
|
||||
const hiddenCloudHostIds = useAppStore(selectOrcaCloudHiddenHostIds)
|
||||
const readRuntimeHostStatusSnapshots = useAppStore((s) => s.readRuntimeHostStatusSnapshots)
|
||||
const hydrateRuntimeEnvironmentStatuses = useAppStore((s) => s.hydrateRuntimeEnvironmentStatuses)
|
||||
const setActiveView = useAppStore((s) => s.setActiveView)
|
||||
@@ -73,7 +79,10 @@ export function SshStatusSegment({
|
||||
[repos]
|
||||
)
|
||||
const hostLabelOverrides = useMemo(() => getHostDisplayLabelOverrides(settings), [settings])
|
||||
const userManagedEnvironments = runtimeEnvironments.filter(isListedRemoteServer)
|
||||
const userManagedEnvironments = withoutHiddenHostEnvironments(
|
||||
runtimeEnvironments.filter(isListedRemoteServer),
|
||||
hiddenCloudHostIds
|
||||
)
|
||||
// Why the registry: a managed server and its SSH host are one machine, shown on its active route.
|
||||
const visibleHosts = new Map(
|
||||
pickerExecutionHosts(
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import type { AppState } from '@/store/types'
|
||||
import { installLeaveOutOfTeamCloudWorkspace } from './leave-out-of-team-cloud-workspace'
|
||||
import {
|
||||
activeCloudWorkspaceLeftTeam,
|
||||
installLeaveOutOfTeamCloudWorkspace
|
||||
} from './leave-out-of-team-cloud-workspace'
|
||||
|
||||
const environments = [
|
||||
{ id: 'cusk', name: 'push-test sandbox 1a2b3c4d', source: 'ephemeral-vm' },
|
||||
@@ -88,3 +91,20 @@ describe('leaving an out-of-team cloud workspace', () => {
|
||||
expect(h.active()).toBe('repo::/w/cusk')
|
||||
})
|
||||
})
|
||||
|
||||
describe('a paired cloud workspace of the team switched away (TEAM-SWITCH-STALE-PANE)', () => {
|
||||
it('leaves it: the paired host went from the team (~) to hidden (-)', () => {
|
||||
expect(activeCloudWorkspaceLeftTeam('~runtime:eval', '-runtime:eval', 'runtime:eval')).toBe(
|
||||
true
|
||||
)
|
||||
})
|
||||
|
||||
it('stays when the paired host is still the team scope, or the host is another one', () => {
|
||||
expect(
|
||||
activeCloudWorkspaceLeftTeam('~runtime:eval', '~runtime:eval\n-runtime:x', 'runtime:eval')
|
||||
).toBe(false)
|
||||
expect(activeCloudWorkspaceLeftTeam('~runtime:eval', '-runtime:eval', 'runtime:other')).toBe(
|
||||
false
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -38,8 +38,11 @@ export function activeCloudWorkspaceLeftTeam(
|
||||
if (!hostId || previousScopeKey === nextScopeKey) {
|
||||
return false
|
||||
}
|
||||
const previous = parseOrcaCloudHostScopeKey(previousScopeKey)
|
||||
// TEAM-SWITCH-STALE-PANE: a paired cloud workspace of the team (`~host`, since #690) leaves too,
|
||||
// or another team's workspace stayed open in the main pane after the switch (n57).
|
||||
return (
|
||||
parseOrcaCloudHostScopeKey(previousScopeKey).primaryHostIds.has(hostId) &&
|
||||
(previous.primaryHostIds.has(hostId) || previous.pairedHostIds.has(hostId)) &&
|
||||
parseOrcaCloudHostScopeKey(nextScopeKey).hiddenHostIds.has(hostId)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
parseOrcaCloudHostScopeKey,
|
||||
selectOrcaCloudHiddenHostIds,
|
||||
selectOrcaCloudHostScopeKey,
|
||||
withoutHiddenHostEnvironments,
|
||||
withoutHiddenHostRepos
|
||||
} from './use-sidebar-hidden-checkouts'
|
||||
|
||||
@@ -184,3 +185,14 @@ describe('hidden cloud hosts for Run on and the reconnect banner (STALE-RUN-TARG
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('the status bar host list after a team switch (TEAM-SWITCH-STALE-PANE)', () => {
|
||||
it("drops another team's cloud servers and keeps the rest", () => {
|
||||
const envs = [{ id: 'eval' }, { id: 'acme' }, { id: 'ssh-box' }]
|
||||
expect(withoutHiddenHostEnvironments(envs, new Set(['runtime:eval']))).toEqual([
|
||||
{ id: 'acme' },
|
||||
{ id: 'ssh-box' }
|
||||
])
|
||||
expect(withoutHiddenHostEnvironments(envs, new Set())).toBe(envs)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -101,6 +101,23 @@ export function useSidebarHiddenCheckouts(): HiddenVmCheckouts {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* TEAM-SWITCH-STALE-PANE: runtime servers without another team's cloud sandboxes, so the status bar's
|
||||
* host list and count follow the same team scope as the sidebar (n57: "3 hosts" after the switch).
|
||||
*/
|
||||
export function withoutHiddenHostEnvironments<E extends { id: string }>(
|
||||
environments: readonly E[],
|
||||
hiddenHostIds: ReadonlySet<string>
|
||||
): readonly E[] {
|
||||
if (hiddenHostIds.size === 0) {
|
||||
return environments
|
||||
}
|
||||
const kept = environments.filter(
|
||||
(environment) => !hiddenHostIds.has(toRuntimeExecutionHostId(environment.id))
|
||||
)
|
||||
return kept.length === environments.length ? environments : kept
|
||||
}
|
||||
|
||||
/** Repos without another team's sandbox projects, so none surfaces as its own project header. */
|
||||
export function withoutHiddenHostRepos<R extends Pick<Repo, 'connectionId' | 'executionHostId'>>(
|
||||
repos: readonly R[],
|
||||
|
||||
Reference in New Issue
Block a user