diff --git a/config/react-compiler-bailout-baseline.txt b/config/react-compiler-bailout-baseline.txt index c4cd51da520..6e8b9e879a5 100644 --- a/config/react-compiler-bailout-baseline.txt +++ b/config/react-compiler-bailout-baseline.txt @@ -558,8 +558,6 @@ 1 src/renderer/src/components/stats/ShareUsageButton.tsx 2 src/renderer/src/components/status-bar/ClaudeSwitcherForOwner.tsx 1 src/renderer/src/components/status-bar/PortsStatusSegment.tsx -1 src/renderer/src/components/status-bar/RuntimeHostStatusRow.tsx -2 src/renderer/src/components/status-bar/SshTargetStatusRow.tsx 1 src/renderer/src/components/status-bar/icons.tsx 3 src/renderer/src/components/status-bar/status-bar-density.ts 2 src/renderer/src/components/status-bar/use-codex-switcher-controller.ts diff --git a/src/renderer/src/components/status-bar/SshStatusSegment.large-host-list.test.tsx b/src/renderer/src/components/status-bar/SshStatusSegment.large-host-list.test.tsx index d2ea5dcbd15..ebb97e2740c 100644 --- a/src/renderer/src/components/status-bar/SshStatusSegment.large-host-list.test.tsx +++ b/src/renderer/src/components/status-bar/SshStatusSegment.large-host-list.test.tsx @@ -110,6 +110,37 @@ function connectionState(targetId: string, status: SshConnectionStatus): SshConn return { targetId, status, error: null, reconnectAttempt: 0 } } +function addStoppedServer() { + state.runtimeEnvironments = [ + { + id: 'server', + name: 'Server', + createdAt: 0, + updatedAt: 0, + lastUsedAt: null, + runtimeId: null, + source: 'manual', + preferredEndpointId: 'direct', + endpoints: [ + { id: 'direct', kind: 'websocket', label: 'Direct', endpoint: 'ws://127.0.0.1:1' } + ] + } + ] + state.runtimeStatusByEnvironmentId.set('server', { + status: null, + checkedAt: 0, + remoteControl: { + state: 'closed', + reconnectAttempt: 7, + pendingRequestCount: 0, + subscriptionCount: 0, + lastConnectedAt: null, + lastClose: null, + lastError: null + } + }) +} + beforeEach(() => { vi.clearAllMocks() state.runtimeEnvironments = [] @@ -191,6 +222,80 @@ describe('the status menu with a very large imported SSH host list', () => { } ) + it.each([13_692, 136_920])( + 'splits %i SSH hosts only when SSH inputs change during actions', + async (count) => { + state.sshTargetLabels = new Map( + Array.from({ length: count }, (_, index) => [`ssh-${index}`, `node-${index}`]) + ) + const retryId = `ssh-${count - 1}` + state.sshConnectionStates = new Map([ + ['ssh-0', connectionState('ssh-0', 'connected')], + [retryId, { ...connectionState(retryId, 'reconnecting'), reconnectAttempt: 2 }] + ]) + addStoppedServer() + let settleDisconnect: () => void = () => undefined + let settleSsh: () => void = () => undefined + let settleRuntime: (value: boolean) => void = () => undefined + const disconnectRequest = new Promise((resolve) => { + settleDisconnect = resolve + }) + const sshRequest = new Promise((resolve) => { + settleSsh = resolve + }) + const runtimeRequest = new Promise((resolve) => { + settleRuntime = resolve + }) + const disconnect = vi.fn(() => disconnectRequest) + vi.stubGlobal('api', { ssh: { connect: vi.fn(() => sshRequest), disconnect } }) + vi.mocked(connectRuntimeHostAndReloadProjects).mockImplementationOnce(() => runtimeRequest) + inventoryVisits.registry = inventoryVisits.split = inventoryVisits.overall = 0 + const view = render( + + + + ) + expect(inventoryVisits).toEqual({ registry: count, split: count, overall: count }) + + await act(async () => + fireEvent.click(screen.getByRole('button', { name: 'Disconnect node-0' })) + ) + expect(disconnect).toHaveBeenCalledWith({ targetId: 'ssh-0' }) + expect(inventoryVisits).toEqual({ registry: count, split: count, overall: count }) + await act(async () => settleDisconnect()) + expect(inventoryVisits).toEqual({ registry: count, split: count, overall: count }) + + // A real SSH pending input changes the cap projection once, without rebuilding its inventory. + await act(async () => fireEvent.click(screen.getByRole('menuitem', { name: 'Retry now' }))) + expect(screen.getByRole('button', { name: `Stop node-${count - 1}` })).toBeTruthy() + expect(inventoryVisits).toEqual({ registry: count, split: count * 2, overall: count }) + // Runtime start and settlement leave this nonempty SSH selection unchanged. + await act(async () => fireEvent.click(screen.getByRole('button', { name: 'Connect Server' }))) + expect(screen.getByRole('button', { name: 'Stop Server' })).toBeTruthy() + expect(inventoryVisits).toEqual({ registry: count, split: count * 2, overall: count }) + await act(async () => settleRuntime(true)) + expect(screen.getByRole('button', { name: 'Connect Server' })).toBeTruthy() + expect(inventoryVisits).toEqual({ registry: count, split: count * 2, overall: count }) + + // A separate backend publication legitimately changes inventory, but cannot drop the pending row. + state.sshConnectionStates = new Map(state.sshConnectionStates).set( + retryId, + connectionState(retryId, 'disconnected') + ) + view.rerender( + + + + ) + expect(screen.getByRole('button', { name: `Stop node-${count - 1}` })).toBeTruthy() + expect(inventoryVisits).toEqual({ registry: count * 2, split: count * 3, overall: count * 2 }) + await act(async () => settleSsh()) + expect(screen.queryByText(`node-${count - 1}`)).toBeNull() + expect(inventoryVisits).toEqual({ registry: count * 2, split: count * 4, overall: count * 2 }) + vi.unstubAllGlobals() + } + ) + it('renders a bounded number of idle host rows instead of one per imported host', () => { render( @@ -277,34 +382,7 @@ describe('the status menu with a very large imported SSH host list', () => { ) state.sshTargetLabels = new Map() state.sshConnectionStates = new Map() - state.runtimeEnvironments = [ - { - id: 'server', - name: 'Server', - createdAt: 0, - updatedAt: 0, - lastUsedAt: null, - runtimeId: null, - source: 'manual', - preferredEndpointId: 'direct', - endpoints: [ - { id: 'direct', kind: 'websocket', label: 'Direct', endpoint: 'ws://127.0.0.1:1' } - ] - } - ] - state.runtimeStatusByEnvironmentId.set('server', { - status: null, - checkedAt: 0, - remoteControl: { - state: 'closed', - reconnectAttempt: 7, - pendingRequestCount: 0, - subscriptionCount: 0, - lastConnectedAt: null, - lastClose: null, - lastError: null - } - }) + addStoppedServer() render( diff --git a/src/renderer/src/components/status-bar/SshStatusSegment.tsx b/src/renderer/src/components/status-bar/SshStatusSegment.tsx index 8cebe3b9b72..3ef9009c1f4 100644 --- a/src/renderer/src/components/status-bar/SshStatusSegment.tsx +++ b/src/renderer/src/components/status-bar/SshStatusSegment.tsx @@ -1,4 +1,5 @@ import React, { useCallback, useMemo, useRef, useState } from 'react' +import { useShallow } from 'zustand/react/shallow' import { MonitorSmartphone, Server } from 'lucide-react' import { toast } from 'sonner' import { @@ -104,20 +105,25 @@ export function SshStatusSegment({ ) const menu = useRemoteHostMenuState(menuOpen, hostExists) const { connect: trackConnect, cancel: cancelConnect } = menu + const selectPendingSshTargets = useShallow((pending: ReadonlySet) => { + const targetIds = new Set() + for (const id of pending) { + const host = parseExecutionHostId(id) + if (host?.kind === 'ssh') { + targetIds.add(host.targetId) + } + } + return targetIds + }) + const pendingTargetIds = selectPendingSshTargets(menu.pending) const { connected: connectedTargets, inactive: disconnectedTargets, hiddenIdleCount - } = useMemo(() => { - const pendingTargetIds = new Set() - for (const id of menu.pending) { - const host = parseExecutionHostId(id) - if (host?.kind === 'ssh') { - pendingTargetIds.add(host.targetId) - } - } - return splitSshStatusMenuRows(targets, { projectHostIds, pendingTargetIds }) - }, [targets, projectHostIds, menu.pending]) + } = useMemo( + () => splitSshStatusMenuRows(targets, { projectHostIds, pendingTargetIds }), + [targets, projectHostIds, pendingTargetIds] + ) const displayedTargets = [...connectedTargets, ...disconnectedTargets] const displayedHosts = [...connectedRuntimeHosts, ...inactiveRuntimeHosts] menu.observe([ diff --git a/src/renderer/src/components/status-bar/use-remote-host-menu-state.ts b/src/renderer/src/components/status-bar/use-remote-host-menu-state.ts index f2162c1bdb3..b5a6af1cbdf 100644 --- a/src/renderer/src/components/status-bar/use-remote-host-menu-state.ts +++ b/src/renderer/src/components/status-bar/use-remote-host-menu-state.ts @@ -61,7 +61,11 @@ export function useRemoteHostMenuState(open: boolean, hostExists: (id: string) = [mounted] ) const cancel = useCallback((id: string) => { - controllers.current.get(id)?.abort() + const controller = controllers.current.get(id) + if (!controller) { + return + } + controller.abort() controllers.current.delete(id) setPending(new Set(controllers.current.keys())) }, []) diff --git a/src/renderer/src/i18n/locales/de.json b/src/renderer/src/i18n/locales/de.json index b497ab40827..ad1e2f531bf 100644 --- a/src/renderer/src/i18n/locales/de.json +++ b/src/renderer/src/i18n/locales/de.json @@ -4910,7 +4910,7 @@ "access_revoked_explanation": "Mit einem neuen Kopplungslink vom Server erneut koppeln, um die Verbindung wiederherzustellen.", "managed_access_revoked_explanation": "Orca konnte sich über SSH nicht erneut koppeln; verbinde dich, um es noch einmal zu versuchen.", "connect_access_revoked_explanation": "Verbinden, um es erneut zu versuchen.", - "server_replaced_explanation": "Wähle in Einstellungen › Remote-Orca-Server für diesen Server Vergessen… und verbinde dann den SSH-Host, um ihn mit seinem aktuellen Server zu koppeln.", + "server_replaced_explanation": "Wähle in Einstellungen › Entfernte Orca-Server für diesen Server Vergessen… und verbinde dann den SSH-Host, um ihn mit seinem aktuellen Server zu koppeln.", "update_required_explanation": "Orca auf diesem Computer oder auf dem Server aktualisieren und anschließend erneut verbinden." }, "NativeChatResumeStatusSegment": { diff --git a/src/renderer/src/i18n/locales/ja.json b/src/renderer/src/i18n/locales/ja.json index 2b48d7c1089..a6d5cf8973e 100644 --- a/src/renderer/src/i18n/locales/ja.json +++ b/src/renderer/src/i18n/locales/ja.json @@ -4357,7 +4357,7 @@ "access_revoked_explanation": "サーバーで発行した新規ペアリングリンクで再度ペアリングし、接続し直してください。", "managed_access_revoked_explanation": "Orca は SSH 経由で再ペアリングできなかったため、接続して再試行してください。", "connect_access_revoked_explanation": "接続してもう一度お試しください。", - "server_replaced_explanation": "設定 › リモート Orca サーバーでこのサーバーの「削除…」を選択し、SSH ホストに接続して現在のサーバーとペアリングしてください。", + "server_replaced_explanation": "設定 › リモート Orca サーバーでこのサーバーの「登録を解除…」を選択し、SSH ホストに接続して現在のサーバーとペアリングしてください。", "update_required_explanation": "このコンピュータまたはサーバーの Orca を更新してから、再度接続してください。" }, "NativeChatResumeStatusSegment": {