fix: reduce status flapping, add IPv6 ping, color manual web services
Addresses three reports from issue #196: - Ping now sends 2 probes with a ~2s timeout (was 1 probe / 1s) so a single dropped packet or a slow IoT/ESPHome device no longer flaps a node offline (#196.1, #196.2). - IPv6-only devices (e.g. Alexa) are now pinged over IPv6: ping6 on macOS, -6 flag on Linux/Windows, detected via inet_pton (#196.3). - Manually-added services carry no category and so always rendered grey even when they were reachable HTTP/HTTPS. A resolvable web URL now falls back to the web colour (#196.9). ha-relevant: yes
This commit is contained in:
@@ -675,7 +675,9 @@ const CATEGORY_COLORS: Record<string, string> = {
|
||||
|
||||
function ServiceBadge({ svc, host, onEdit, onRemove }: { svc: ServiceInfo; host?: string; onEdit: () => void; onRemove: () => void }) {
|
||||
const url = getServiceUrl(svc, host)
|
||||
const color = CATEGORY_COLORS[svc.category ?? ''] ?? '#8b949e'
|
||||
// Manually-added services carry no category, so they fell back to grey even
|
||||
// when they're reachable HTTP/HTTPS. Treat any resolvable web URL as `web`.
|
||||
const color = CATEGORY_COLORS[svc.category ?? ''] ?? (url ? CATEGORY_COLORS.web : '#8b949e')
|
||||
const pathLabel = svc.path?.trim() ? svc.path.trim() : ''
|
||||
|
||||
return (
|
||||
|
||||
@@ -502,6 +502,25 @@ describe('DetailPanel', () => {
|
||||
render(<DetailPanel onEdit={vi.fn()} />)
|
||||
expect(screen.getByText('health').tagName).not.toBe('A')
|
||||
})
|
||||
|
||||
it('colors a categoryless but reachable web service blue, not grey', () => {
|
||||
setupStore({ ip: '192.168.1.10', services: [{ port: 8080, protocol: 'tcp', service_name: 'nginx', path: '' }] })
|
||||
render(<DetailPanel onEdit={vi.fn()} />)
|
||||
const link = screen.getByRole('link', { name: 'nginx' })
|
||||
expect(link.style.color).toBe('rgb(0, 212, 255)') // #00d4ff (web)
|
||||
})
|
||||
|
||||
it('keeps a categoryless unreachable service grey', () => {
|
||||
setupStore({ ip: undefined, services: [{ protocol: 'tcp', service_name: 'health', path: '' }] })
|
||||
render(<DetailPanel onEdit={vi.fn()} />)
|
||||
expect(screen.getByText('health').style.color).toBe('rgb(139, 148, 158)') // #8b949e
|
||||
})
|
||||
|
||||
it('respects an explicit category over the url fallback', () => {
|
||||
setupStore({ ip: '192.168.1.10', services: [{ port: 5432, protocol: 'tcp', service_name: 'pg', category: 'database', path: '' }] })
|
||||
render(<DetailPanel onEdit={vi.fn()} />)
|
||||
expect(screen.getByText('pg').style.color).toBe('rgb(168, 85, 247)') // #a855f7 (database)
|
||||
})
|
||||
})
|
||||
|
||||
describe('Last Seen formatting', () => {
|
||||
|
||||
Reference in New Issue
Block a user