Skip to content

The agent that grows with you

fix(desktop): a gateway address the Web Access pane cannot parse no longer breaks the pane

emozilla087dd2f4d0dc
diff --git a/apps/desktop/src/app/settings/web-access-settings.test.tsx b/apps/desktop/src/app/settings/web-access-settings.test.tsx
index 0f7c8d99a89..5369300e80e 100644
--- a/apps/desktop/src/app/settings/web-access-settings.test.tsx
+++ b/apps/desktop/src/app/settings/web-access-settings.test.tsx
@@ -161,4 +161,11 @@ describe('WebAccessSettings', () => {
expect(mocked.getWebAccessStatus).not.toHaveBeenCalled()
expect(screen.queryByRole('button', { name: 'Start' })).toBeNull()
})
+
+ it('treats a gateway address it cannot parse as not serving this config', async () => {
+ // The gateway reports its own URL; a malformed one must not take the pane down.
+ renderPane({ ...OFF, enabled: true, gateway: { reason: null, state: 'serving', url: 'http://[::1' }, mode: 'lan' })
+
+ expect(await screen.findByText('Restart needed')).toBeTruthy()
+ })
})
diff --git a/apps/desktop/src/app/settings/web-access-settings.tsx b/apps/desktop/src/app/settings/web-access-settings.tsx
index 7ffa588af11..1ea313a08d8 100644
--- a/apps/desktop/src/app/settings/web-access-settings.tsx
+++ b/apps/desktop/src/app/settings/web-access-settings.tsx
@@ -41,7 +41,16 @@ type Busy = 'restart' | 'start' | 'stop' | null
function servesConfig(status: WebAccessStatus): boolean {
const { state, url } = status.gateway
- return status.enabled && state === 'serving' && url !== null && new URL(url).port === String(status.port)
+ if (!status.enabled || state !== 'serving' || url === null) {
+ return false
+ }
+
+ try {
+ return new URL(url).port === String(status.port)
+ } catch {
+ // An address the pane cannot read is not one it can confirm.
+ return false
+ }
}
function phaseOf(status: WebAccessStatus): Phase {