From 6dcdc507a35f7d400042ca1883cd3744d37d8585 Mon Sep 17 00:00:00 2001 From: Zakk Date: Tue, 29 Sep 2026 17:26:03 +1000 Subject: [PATCH] fix(connections): disable close on kernel-forwarded connections with the reason --- e2e/connections.spec.ts | 10 +++++++--- src/features/connections/Connections.tsx | 9 ++++++--- src/features/connections/view.ts | 2 ++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/e2e/connections.spec.ts b/e2e/connections.spec.ts index e9d32f15..303e7bed 100644 --- a/e2e/connections.spec.ts +++ b/e2e/connections.spec.ts @@ -395,10 +395,14 @@ test('closing a connection removes it from the list and clears the selection', a await expect(page.locator('.rp-toast.positive')).toContainText('Closed api.telegram.org'); await expect(page).toHaveURL(/#\/connections$/); await expect(page.locator('.rp-table [data-key="c-0001"]')).toHaveCount(0); - // A kernel-observed connection is refused by the backend, and the row stays. + // A kernel-forwarded connection has no userspace transport to cancel, so Close says why before it is pressed. await page.goto('/#/connections?id=c-0002'); - await panel.getByRole('button', {name: 'Close connection', exact: true}).click(); - await expect(page.locator('.rp-toast.negative')).toContainText('cannot be closed'); + const reason = + 'The backend has no userspace transfer to interrupt, so this connection cannot be closed. Connections the kernel forwards directly are of this kind.'; + const close = panel.getByRole('button', {name: 'Close connection', exact: true}); + await expect(close).toBeDisabled(); + await expect(close).toHaveAccessibleDescription(reason); + await expect(panel.getByText(reason)).toBeVisible(); await expect(page.locator('.rp-table [data-key="c-0002"]')).toHaveCount(1); }); diff --git a/src/features/connections/Connections.tsx b/src/features/connections/Connections.tsx index f86876d5..3f0633cd 100644 --- a/src/features/connections/Connections.tsx +++ b/src/features/connections/Connections.tsx @@ -1,4 +1,5 @@ import { + ActionHelp, Badge, Button, ConfirmButton, @@ -120,9 +121,11 @@ export function Connections(props: PageProps) { {cur.source && } {vm.canClose && cur.closable && ( - + + + )} diff --git a/src/features/connections/view.ts b/src/features/connections/view.ts index 774150bc..3fa98093 100644 --- a/src/features/connections/view.ts +++ b/src/features/connections/view.ts @@ -360,6 +360,8 @@ export function connectionDetail( : null, source: current.src ? (sourceIp(current.src) ?? current.src) : null, closable: current.state === 'active' || current.state === 'dialing' || current.state === 'routing', + // An ebpf-only observation is kernel-forwarded: the backend has no userspace transport to cancel. + closeReason: current.observed_by === 'ebpf' ? t('conn.notClosable') : null, stateHelp: connectionStateHelp(current.state, t) } : null;