diff --git a/src/renderer/src/components/right-sidebar/local-workspace-port-sections.test.ts b/src/renderer/src/components/right-sidebar/local-workspace-port-sections.test.ts index 8cb8520514e..48a93d140a8 100644 --- a/src/renderer/src/components/right-sidebar/local-workspace-port-sections.test.ts +++ b/src/renderer/src/components/right-sidebar/local-workspace-port-sections.test.ts @@ -1,6 +1,9 @@ import { describe, expect, it } from 'vitest' import type { WorkspacePort } from '../../../../shared/workspace-ports' -import { getLocalWorkspacePortSections } from './local-workspace-port-sections' +import { + getLocalWorkspacePortSections, + shouldShowCenteredPortsEmpty +} from './local-workspace-port-sections' const external = ( port: number, @@ -36,3 +39,26 @@ describe('getLocalWorkspacePortSections', () => { expect(sections.externalPorts.map((port) => port.port)).toEqual([6768, 23456, 5432, 8123]) }) }) + +describe('shouldShowCenteredPortsEmpty', () => { + const none = { + activePorts: [], + otherWorkspacePorts: [], + externalPorts: [], + remoteOnlyForwards: [], + hasFooter: false + } + + it('centers the empty message only when the panel has no group at all', () => { + expect(shouldShowCenteredPortsEmpty({}, none)).toBe(true) + // Orca Cloud: Shared links is a group, so the inline line under Active Workspace stays. + expect(shouldShowCenteredPortsEmpty({}, { ...none, hasFooter: true })).toBe(false) + expect(shouldShowCenteredPortsEmpty({}, { ...none, remoteOnlyForwards: [1] })).toBe(false) + expect(shouldShowCenteredPortsEmpty({}, { ...none, externalPorts: [1] })).toBe(false) + }) + + it('keeps the inline Scanning line before the first scan and hides on scan errors', () => { + expect(shouldShowCenteredPortsEmpty(null, none)).toBe(false) + expect(shouldShowCenteredPortsEmpty({ unavailableReason: 'x' }, none)).toBe(false) + }) +}) diff --git a/src/renderer/src/components/right-sidebar/local-workspace-port-sections.ts b/src/renderer/src/components/right-sidebar/local-workspace-port-sections.ts index 3aefcbecda9..5e2603921ce 100644 --- a/src/renderer/src/components/right-sidebar/local-workspace-port-sections.ts +++ b/src/renderer/src/components/right-sidebar/local-workspace-port-sections.ts @@ -50,6 +50,31 @@ export function shouldShowLocalWorkspacePortSections( ) } +/** + * The panel says "no ports" once: centered when it would show no group at all, otherwise inline + * under Active Workspace (e.g. above Orca Cloud's Shared links, or beside remote-only forwards). + */ +export function shouldShowCenteredPortsEmpty( + scan: { unavailableReason?: string } | null | undefined, + sections: { + activePorts: unknown[] + otherWorkspacePorts: unknown[] + externalPorts: unknown[] + remoteOnlyForwards: unknown[] + hasFooter: boolean + } +): boolean { + return ( + Boolean(scan) && + !scan?.unavailableReason && + sections.activePorts.length === 0 && + sections.otherWorkspacePorts.length === 0 && + sections.externalPorts.length === 0 && + sections.remoteOnlyForwards.length === 0 && + !sections.hasFooter + ) +} + function workspacePortAsExternal(port: WorkspacePort & { kind: 'workspace' }): WorkspacePort { return { id: port.id, diff --git a/src/renderer/src/components/right-sidebar/local-workspace-ports-panel.tsx b/src/renderer/src/components/right-sidebar/local-workspace-ports-panel.tsx index 702a42cf5ee..97a6d7ee62c 100644 --- a/src/renderer/src/components/right-sidebar/local-workspace-ports-panel.tsx +++ b/src/renderer/src/components/right-sidebar/local-workspace-ports-panel.tsx @@ -22,6 +22,7 @@ import { translate } from '@/i18n/i18n' import { useTranslate } from '@/i18n/use-translate' import { getLocalWorkspacePortSections, + shouldShowCenteredPortsEmpty, shouldShowLocalWorkspacePortSections } from './local-workspace-port-sections' import { LocalPortSection } from './local-port-section' @@ -222,6 +223,17 @@ export function LocalWorkspacePortsPanel({ otherWorkspacePorts, externalPorts }) + const remoteOnlyForwards = + runtimeForwarding?.forwards.filter( + (forward) => !displayScan?.ports.some((port) => port.port === forward.remotePort) + ) ?? [] + const showCenteredEmpty = shouldShowCenteredPortsEmpty(displayScan, { + activePorts, + otherWorkspacePorts, + externalPorts, + remoteOnlyForwards, + hasFooter: Boolean(footer) + }) if (!activeRepoId) { return ( @@ -280,7 +292,7 @@ export function LocalWorkspacePortsPanel({ )} - {showPortSections && ( + {showPortSections && !showCenteredEmpty && ( <> )} - {runtimeForwarding && ( - !displayScan?.ports.some((port) => port.port === forward.remotePort) - )} - /> - )} + {runtimeForwarding && } - {!displayScan?.unavailableReason && - displayScan && - activePorts.length === 0 && - otherWorkspacePorts.length === 0 && - externalPorts.length === 0 && ( -
- -

- {runtimeForwarding ? ( - - ) : ( - t('auto.components.right.sidebar.PortsPanel.a2a9fc6899', 'No local ports detected') - )} -

-
- )} + {showCenteredEmpty && ( +
+ +

+ {runtimeForwarding ? ( + + ) : ( + t('auto.components.right.sidebar.PortsPanel.a2a9fc6899', 'No local ports detected') + )} +

+
+ )} {footer?.(activePorts)} diff --git a/src/renderer/src/components/right-sidebar/runtime-port-forward-status.fixture.tsx b/src/renderer/src/components/right-sidebar/runtime-port-forward-status.fixture.tsx index 0d6702e63a8..33c82b4597d 100644 --- a/src/renderer/src/components/right-sidebar/runtime-port-forward-status.fixture.tsx +++ b/src/renderer/src/components/right-sidebar/runtime-port-forward-status.fixture.tsx @@ -3,6 +3,7 @@ import type { WorkspacePort } from '../../../../shared/workspace-ports' import type { RuntimePortForward } from '../../../../shared/runtime-port-forwards' import { LocalPortSection } from './local-port-section' import { RuntimeForwardedPortsSection } from './runtime-forwarded-ports-section' +import { SharedLinksList } from './cloud-share/shared-links-list' import { RuntimePortForwardStatus, type RuntimePortForwardRowState @@ -112,6 +113,25 @@ function Panel({ empty = false }: { empty?: boolean }): React.JSX.Element { export const allStates = defineFixture({ width: 300, render: () => }) export const noPorts = defineFixture({ width: 300, render: () => }) +/** Orca Cloud with no ports: one inline empty line under Active Workspace, then Shared links; no centered empty state. */ +export const cloudNoPorts = defineFixture({ + width: 300, + render: () => ( +
+ + {}} + onRetry={() => {}} + onCopy={async () => true} + onOpen={() => {}} + onRevoke={async () => true} + /> +
+ ) +}) export const hostOffline = defineFixture({ width: 300, render: () => (