fix(w3): W10 round-4 ports polish (one header size, quiet actions, nowrap remap note, dependent settings, aria-describedby, plural connections, announcement template) (#69)

This commit is contained in:
Neil
2026-11-09 06:52:59 -08:00
committed by GitHub
parent b0b224de2b
commit 781fa2a54f
14 changed files with 112 additions and 54 deletions
@@ -122,7 +122,10 @@ function announceMany(environmentId: string, count: number): void {
id: `runtime-port-forward:${environmentId}:many`,
duration: FORWARDED_TOAST_MS,
action: {
label: translate('auto.components.ports.RuntimePortAutoForwarder.openPorts', 'Open Ports'),
label: translate(
'auto.components.ports.RuntimePortAutoForwarder.openPortsPanel',
'Open ports'
),
onClick: () => {
const state = useAppStore.getState()
state.setRightSidebarOpen(true)
@@ -117,7 +117,7 @@ export function HostScopedPortsPanel({
return (
<div className="flex flex-col h-full overflow-y-auto scrollbar-sleek">
<div className="flex items-center justify-between px-3 py-2 border-b border-border">
<span className="text-[11px] font-semibold uppercase tracking-wider text-muted-foreground">
<span className="text-2xs font-semibold uppercase tracking-wider text-muted-foreground">
{t('auto.components.right.sidebar.PortsPanel.6bc058dbe1', 'Ports')}
</span>
<Tooltip>
@@ -114,7 +114,7 @@ export function LocalPortRow({
<div className="group flex items-center gap-2 py-1 px-1 -mx-1 rounded hover:bg-accent/50 transition-colors">
<ContextMenuTrigger asChild>
<div
className="flex min-w-0 flex-1 items-center gap-2 rounded focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring"
className="flex min-w-0 flex-1 items-start gap-2 rounded focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring"
tabIndex={0}
role="group"
aria-label={t(
@@ -52,11 +52,11 @@ export function LocalPortSection({
size={12}
className={cn('shrink-0 transition-transform', !collapsed && 'rotate-90')}
/>
<span className="text-[10px] font-semibold uppercase tracking-wider text-muted-foreground">
<span className="text-2xs font-semibold uppercase tracking-wider text-muted-foreground">
{title}
</span>
{ports.length > 0 && (
<span className="text-[10px] text-muted-foreground/60 ml-1">{ports.length}</span>
<span className="ml-1 text-2xs text-muted-foreground">{ports.length}</span>
)}
</button>
{!collapsed && (
@@ -226,7 +226,7 @@ export function LocalWorkspacePortsPanel({
return (
<div className="flex flex-col h-full overflow-y-auto scrollbar-sleek">
<div className="flex items-center justify-between px-3 py-2 border-b border-border">
<span className="text-[11px] font-semibold uppercase tracking-wider text-muted-foreground">
<span className="text-2xs font-semibold uppercase tracking-wider text-muted-foreground">
{t('auto.components.right.sidebar.PortsPanel.6bc058dbe1', 'Ports')}
</span>
<Tooltip>
@@ -35,10 +35,10 @@ export function RuntimeForwardedPortsSection({
size={12}
className={cn('shrink-0 motion-safe:transition-transform', !collapsed && 'rotate-90')}
/>
<span className="text-3xs font-semibold uppercase tracking-wider text-muted-foreground">
<span className="text-2xs font-semibold uppercase tracking-wider text-muted-foreground">
{t('auto.components.right.sidebar.RuntimeForwardedPorts.title', 'Other forwards')}
</span>
<span className="ml-1 text-3xs text-muted-foreground/60">{forwards.length}</span>
<span className="ml-1 text-2xs text-muted-foreground">{forwards.length}</span>
</button>
{collapsed ? null : (
<div id="runtime-other-forwards">
@@ -58,13 +58,14 @@ function OtherForwardRow({ forward }: { forward: RuntimePortForward }): React.JS
const connections =
forward.openConnections === 0
? null
: forward.openConnections === 1
? t('auto.components.right.sidebar.RuntimeForwardedPorts.oneConnection', '1 connection')
: t(
'auto.components.right.sidebar.RuntimeForwardedPorts.manyConnections',
'{{value0}} connections',
{ value0: forward.openConnections }
)
: t(
'auto.components.right.sidebar.RuntimeForwardedPorts.connectionCount',
'{{count}} connections',
{
count: forward.openConnections,
defaultValue_one: '{{count}} connection'
}
)
const detail = [address, connections].filter(Boolean).join(' · ')
return (
<div className="group -mx-1 flex items-center gap-2 rounded px-1 py-1 hover:bg-accent/50 motion-safe:transition-colors">
@@ -14,7 +14,8 @@ export type RuntimePortForwardRowState =
const FOCUS =
'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring'
const ACTION = 'h-5 px-1 text-xs font-normal text-foreground'
const ACTION =
'h-5 px-1 text-2xs font-normal text-muted-foreground hover:text-foreground [&_svg]:size-3'
/** The line under a remote port: where it lands on this computer, or a control to forward it. */
export function RuntimePortForwardStatus({
@@ -46,11 +47,9 @@ export function RuntimePortForwardStatus({
)
: remapped
? t(
'auto.components.right.sidebar.RuntimePortForward.remappedInUse',
'{{value0}} in use',
{
value0: remotePort
}
'auto.components.right.sidebar.RuntimePortForward.remappedInUseHere',
'({{value0}} in use here)',
{ value0: remotePort }
)
: null
const localAddress = t(
@@ -95,11 +94,11 @@ export function RuntimePortForwardStatus({
{note ? (
<span
className={cn(
'shrink-0 text-2xs',
'shrink-0 whitespace-nowrap text-2xs',
unreachable ? 'text-status-warning-text' : 'text-muted-foreground'
)}
>
· {note}
{note}
</span>
) : null}
{offline && onReconnect ? (
@@ -31,7 +31,10 @@ export function RuntimePortsEmptyText(): React.JSX.Element {
className="rounded-sm text-foreground underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring"
onClick={() => openSettingsTarget({ pane: 'ports', repoId: null })}
>
{t('auto.components.right.sidebar.PortsPanel.portsSettingsLink', 'Ports settings')}
{t(
'auto.components.right.sidebar.PortsPanel.turnOnInSettings',
'Turn on in Ports settings'
)}
</button>
</>
)
@@ -43,10 +43,10 @@ export function SshForwardedPortsSection({
size={12}
className={cn('text-muted-foreground transition-transform', !collapsed && 'rotate-90')}
/>
<span className="text-[10px] font-semibold uppercase tracking-wider text-muted-foreground">
<span className="text-2xs font-semibold uppercase tracking-wider text-muted-foreground">
{t('auto.components.right.sidebar.PortsPanel.ddbe58d74e', 'Forwarded')}
</span>
{count > 0 && <span className="ml-1 text-[10px] text-muted-foreground/60">{count}</span>}
{count > 0 && <span className="ml-1 text-2xs text-muted-foreground">{count}</span>}
</button>
<Button
type="button"
@@ -15,3 +15,20 @@ export const autoForwardOff = defineFixture({
<PortsPane settings={{ ...settings, runtimePortForwarding: { autoForward: false } }} />
)
})
export const invalidRange = defineFixture({
width: 640,
render: () => <PortsPane settings={settings} />,
interact: async (frame) => {
const input = frame.querySelector<HTMLInputElement>('input[aria-label="Lowest port"]')
if (!input) {
return
}
const setValue = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set
setValue?.call(input, '70000')
input.dispatchEvent(new Event('input', { bubbles: true }))
input.focus()
input.blur()
await new Promise((resolve) => requestAnimationFrame(() => resolve(null)))
}
})
@@ -89,6 +89,11 @@ export function PortsPane({ settings }: { settings: GlobalSettings }): React.JSX
[forwarding, updateSettings]
)
const off = !forwarding.autoForward
const needsAutoForward = t(
'auto.components.settings.ports.needsAutoForward',
'Turn on Auto-forward ports to change this.'
)
const rangeErrorId = useId()
const [rangeError, setRangeError] = useState<string | null>(null)
const reportInvalid = useCallback(
(rejected: string | null) =>
@@ -109,8 +114,8 @@ export function PortsPane({ settings }: { settings: GlobalSettings }): React.JSX
<SettingsSwitchRow
label={t('auto.components.settings.ports.autoForward', 'Auto-forward ports')}
description={t(
'auto.components.settings.ports.autoForwardDescription',
'Forward dev servers on remote hosts to localhost here.'
'auto.components.settings.ports.autoForwardDescriptionSandboxes',
'Forward dev servers in sandboxes and on remote hosts to this computer.'
)}
checked={forwarding.autoForward}
onChange={() => update({ autoForward: !forwarding.autoForward })}
@@ -121,7 +126,8 @@ export function PortsPane({ settings }: { settings: GlobalSettings }): React.JSX
'auto.components.settings.ports.exclusiveDescription',
'If the port is taken here, skip it instead of remapping.'
)}
checked={forwarding.exclusive}
// Off reads as off: a dependent switch that cannot act should not look on.
checked={forwarding.exclusive && !off}
onChange={() => update({ exclusive: !forwarding.exclusive })}
disabled={off}
/>
@@ -143,7 +149,7 @@ export function PortsPane({ settings }: { settings: GlobalSettings }): React.JSX
max={forwarding.rangeEnd}
disabled={off}
ariaLabel={t('auto.components.settings.ports.rangeStart', 'Lowest port')}
describedBy={rangeHelpId}
describedBy={rangeError && !off ? `${rangeHelpId} ${rangeErrorId}` : rangeHelpId}
onCommit={(rangeStart) => update({ rangeStart })}
onInvalid={reportInvalid}
/>
@@ -154,17 +160,22 @@ export function PortsPane({ settings }: { settings: GlobalSettings }): React.JSX
max={65_535}
disabled={off}
ariaLabel={t('auto.components.settings.ports.rangeEnd', 'Highest port')}
describedBy={rangeHelpId}
describedBy={rangeError && !off ? `${rangeHelpId} ${rangeErrorId}` : rangeHelpId}
onCommit={(rangeEnd) => update({ rangeEnd })}
onInvalid={reportInvalid}
/>
</div>
}
/>
{rangeError ? <InlineError title={rangeError} className="my-2" /> : null}
{rangeError && !off ? (
<div id={rangeErrorId}>
<InlineError title={rangeError} className="my-2" />
</div>
) : null}
<SettingsSwitchRow
label={t('auto.components.settings.ports.notify', 'Notify when a port is forwarded')}
checked={forwarding.notify}
description={off ? needsAutoForward : undefined}
checked={forwarding.notify && !off}
onChange={() => update({ notify: !forwarding.notify })}
disabled={off}
/>
+4
View File
@@ -408,6 +408,10 @@
"selectedCount_one": "{{count}} selected",
"selectedCount_other": "{{count}} selected"
},
"RuntimeForwardedPorts": {
"connectionCount_one": "{{count}} connection",
"connectionCount_other": "{{count}} connections"
},
"Search": {
"fileCount_one": "{{count}} file",
"fileCount_other": "{{count}} files",
+14 -12
View File
@@ -2159,10 +2159,11 @@
"runtimePortForwards": {
"desktopOnly": "Port forwarding needs the desktop app.",
"forwardedAnnouncement": "Forwarded :{{value0}} to localhost:{{value1}}",
"busyInUse": "localhost:{{value0}} in use",
"updateHost": "Update Orca on this host",
"listenFailedHere": "Could not listen on this computer",
"hostNotReachable": "Host not reachable"
"hostNotReachable": "Host not reachable",
"failedAnnouncement": "Couldn't forward :{{value0}}. {{value1}}",
"busyInUseHere": "localhost:{{value0}} in use on this computer",
"listenFailedRetry": "Couldn't listen on this computer. Retry or pick another port"
}
},
"hooks": {
@@ -14064,7 +14065,6 @@
},
"ports": {
"autoForward": "Auto-forward ports",
"autoForwardDescription": "Forward dev servers on remote hosts to localhost here.",
"exclusive": "Same port number only",
"exclusiveDescription": "If the port is taken here, skip it instead of remapping.",
"range": "Auto-forward port range",
@@ -14081,7 +14081,9 @@
"devServer": "dev server",
"descriptionSandboxes": "Forward dev servers in sandboxes and on remote hosts to this computer."
},
"rangeInvalid": "\"{{value0}}\" isn't a usable port. Use a port from 1 to 65535, lowest first."
"rangeInvalid": "\"{{value0}}\" isn't a usable port. Use a port from 1 to 65535, lowest first.",
"needsAutoForward": "Turn on Auto-forward ports to change this.",
"autoForwardDescriptionSandboxes": "Forward dev servers in sandboxes and on remote hosts to this computer."
}
},
"right": {
@@ -14314,7 +14316,7 @@
"localPortRequiresPrivileges": "Port {{port}} requires elevated privileges. Use a local port ≥ 1024.",
"remoteEmpty": "No ports yet. Dev servers started here are forwarded to localhost.",
"remoteEmptyOff": "No ports yet. Auto-forward is off.",
"portsSettingsLink": "Ports settings"
"turnOnInSettings": "Turn on in Ports settings"
},
"Search": {
"1abfb25a66": "Type to search in files",
@@ -15642,8 +15644,8 @@
"ssh": "SSH access",
"stopped": "stopped",
"stopLabel": "Stop forwarding port {{value0}}",
"oneConnection": "1 connection",
"manyConnections": "{{value0}} connections"
"connectionCount_one": "{{count}} connection",
"connectionCount_other": "{{count}} connections"
},
"RuntimePortForward": {
"pending": "Forwarding…",
@@ -15655,12 +15657,12 @@
"stopForwarding": "Stop forwarding",
"hostOfflineNote": "Host offline",
"notAnswering": "Nothing answering on :{{value0}} yet",
"remappedInUse": "{{value0}} in use",
"forwardedToLabel": "Port {{value0}} is forwarded to {{value1}}. Open in browser",
"reconnect": "Reconnect",
"actionLabel": "{{value0}} for port {{value1}}",
"copyLocalUrl": "Copy local URL",
"stopAndSkip": "Stop and don't auto-forward :{{value0}}"
"stopAndSkip": "Stop and don't auto-forward :{{value0}}",
"remappedInUseHere": "({{value0}} in use here)"
},
"CloudShare": {
"alreadyShared": "Already shared",
@@ -19989,8 +19991,8 @@
"forwarded": "Forwarded :{{value0}} to localhost:{{value1}}",
"remappedInUse": "{{value0}} · {{value1}} in use on this computer",
"many": "{{value0}} ports forwarded",
"openPorts": "Open Ports",
"busyInUse": "localhost:{{value0}} in use on this computer"
"busyInUse": "localhost:{{value0}} in use on this computer",
"openPortsPanel": "Open ports"
}
}
},
@@ -67,7 +67,14 @@ export function runtimePortForwardingAvailable(): boolean {
return typeof bridge()?.openPortForward === 'function'
}
let announcementRepeat = 0
function emit(next: ForwardState): void {
if (next.announcement && next.announcement === state.announcement.replace(/\u00a0+$/, '')) {
// Live regions only speak changed text; a trailing no-break space marks a repeat.
announcementRepeat = (announcementRepeat + 1) % 2
next = { ...next, announcement: next.announcement + '\u00a0'.repeat(announcementRepeat + 1) }
}
state = next
for (const listener of listeners) {
listener()
@@ -189,10 +196,17 @@ export async function openRuntimePortForward(
'Forwarded :{{value0}} to localhost:{{value1}}',
{ value0: request.remotePort, value1: result.forward.localPort }
)
: `:${request.remotePort} ${runtimePortForwardFailureText({
code: result.code,
localPort: request.localPort ?? request.remotePort
})}`
: translate(
'auto.lib.runtimePortForwards.failedAnnouncement',
"Couldn't forward :{{value0}}. {{value1}}",
{
value0: request.remotePort,
value1: runtimePortForwardFailureText({
code: result.code,
localPort: request.localPort ?? request.remotePort
})
}
)
})
return result
}
@@ -219,16 +233,20 @@ export async function closeRuntimePortForward(
export function runtimePortForwardFailureText(failure: RuntimePortForwardFailure): string {
switch (failure.code) {
case 'port_busy':
return translate('auto.lib.runtimePortForwards.busyInUse', 'localhost:{{value0}} in use', {
value0: failure.localPort
})
return translate(
'auto.lib.runtimePortForwards.busyInUseHere',
'localhost:{{value0}} in use on this computer',
{
value0: failure.localPort
}
)
case 'host_unsupported':
return translate('auto.lib.runtimePortForwards.updateHost', 'Update Orca on this host')
case 'invalid_request':
case 'listen_failed':
return translate(
'auto.lib.runtimePortForwards.listenFailedHere',
'Could not listen on this computer'
'auto.lib.runtimePortForwards.listenFailedRetry',
"Couldn't listen on this computer. Retry or pick another port"
)
case 'tunnel_failed':
return translate('auto.lib.runtimePortForwards.hostNotReachable', 'Host not reachable')