fix: follow live request results and prioritize usable groups
Publish Docker image (Multi-arch) / Build & push (amd64) (push) Failing after 1m59s
Release (Linux, macOS, Windows) / Linux Release (push) Failing after 4m32s
Publish Docker image (Multi-arch) / Build & push (arm64) (push) Canceled after 0s
Release (Linux, macOS, Windows) / macOS Release (push) Canceled after 0s
Release (Linux, macOS, Windows) / Windows Release (push) Canceled after 0s
Publish Docker image (Multi-arch) / Create multi-arch manifests (push) Canceled after 0s

This commit is contained in:
cneicy committed 2026-09-26 14:49:12 +08:00
1 parent a2d17be0c4
commit d2e03ab7e8
12 files changed
+257 -86

No files matched your search

@@ -194,9 +194,20 @@ it('keeps non-Astra groups compact and puts Astra groups first', async () => {
data: [
{
categoryName: 'Groups',
monitors: [
{ name: 'Failed Astra', status: 0, uptime: 0, models: ['gpt-6-astra'] },
{ name: 'Luna only', status: 1, uptime: 1, models: ['gpt-6-luna'] },
monitors: [
{
name: 'Failed Astra',
status: 0,
uptime: 0,
models: ['gpt-6-astra'],
},
{ name: 'Luna only', status: 1, uptime: 1, models: ['gpt-6-luna'] },
{
name: 'Degraded Astra',
status: 2,
uptime: 0.8,
models: ['gpt-6-astra'],
},
{
name: 'Astra group',
status: 1,
@@ -214,12 +225,12 @@ it('keeps non-Astra groups compact and puts Astra groups first', async () => {
screen
.getAllByRole('heading', { level: 2 })
.map((heading) => heading.textContent)
).toEqual(['Astra group', 'Luna only', 'Failed Astra'])
expect(screen.getAllByText(t('Recent pelican works'))).toHaveLength(2)
expect(screen.getAllByText(t('Model fingerprint'))).toHaveLength(2)
).toEqual(['Degraded Astra', 'Astra group', 'Luna only', 'Failed Astra'])
expect(screen.getAllByText(t('Recent pelican works'))).toHaveLength(3)
expect(screen.getAllByText(t('Model fingerprint'))).toHaveLength(3)
expect(
screen.getAllByRole('region', { name: t('Availability history') })
).toHaveLength(3)
).toHaveLength(4)
})
it('keeps the main-site group status link on the original internal route', () => {
@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest'
import {
cacheHitRates,
compareStatusMonitors,
formatCacheHitRate,
getOverallStatus,
getProbeInterval,
@@ -9,6 +10,32 @@ import {
} from '../lib/status'
describe('group status mapping', () => {
it('prioritizes normal and degraded groups together, then Astra', () => {
const rows = [
{ name: 'down-astra', status: 0, uptime: 0, models: ['gpt-6-astra'] },
{ name: 'normal-luna', status: 1, uptime: 1, models: ['gpt-6-luna'] },
{
name: 'partial-astra',
status: 2,
uptime: 0.8,
models: ['gpt-6-astra'],
},
{ name: 'normal-astra', status: 1, uptime: 1, models: ['gpt-6-astra'] },
{ name: 'degraded-luna', status: 3, uptime: 0.8, models: ['gpt-6-luna'] },
{ name: 'unknown-luna', status: -1, uptime: 0, models: ['gpt-6-luna'] },
]
expect(
[...rows].sort(compareStatusMonitors).map((row) => row.name)
).toEqual([
'partial-astra',
'normal-astra',
'normal-luna',
'degraded-luna',
'down-astra',
'unknown-luna',
])
})
it('maps down monitors to error', () => {
expect(statusKind(0)).toBe('error')
})
+14 -2
View File
@@ -6,8 +6,20 @@ export function supportsAstra(monitor: UptimeMonitor): boolean {
return monitor.models?.includes('gpt-6-astra') ?? false
}
export function compareStatusMonitors(a: UptimeMonitor, b: UptimeMonitor): number {
return Number(b.status === 1) - Number(a.status === 1) || Number(supportsAstra(b)) - Number(supportsAstra(a))
export function compareStatusMonitors(
a: UptimeMonitor,
b: UptimeMonitor
): number {
const aUsable =
statusKind(a.status) === 'operational' ||
statusKind(a.status) === 'degraded'
const bUsable =
statusKind(b.status) === 'operational' ||
statusKind(b.status) === 'degraded'
return (
Number(bUsable) - Number(aUsable) ||
Number(supportsAstra(b)) - Number(supportsAstra(a))
)
}
export function statusKind(status: number): GroupStatusKind {