fix(admin-ui): stale-data notice, request timeout and dedupe, hash and format edge cases

Show a persistent notice when a refresh fails while old data is on screen.
Add retry to the Targets and Access Matrix error states.
Give tables names, skeletons a status role and CSV export a live region.
Abort admin requests after 15 seconds and share concurrent identical GETs.
Show a reload prompt when a lazy page chunk fails to load.
Ignore prototype keys in the location hash.
Stop formatContextWindow emitting 1000k, round latency before the 1s cutoff,
and treat NaN as not enough data in the month projection.
Regenerate admin_assets_gen.go.
This commit is contained in:
2026-11-08 01:59:34 +00:00
parent 5f5efa5a8d
commit fcfb298077
31 changed files with 421 additions and 180 deletions
+33
View File
@@ -0,0 +1,33 @@
import { describe, expect, it } from 'vitest'
import { loadState } from './load-state'
import { staleNotice } from './stale-notice'
const at = new Date('2026-11-08T10:11:12Z')
describe('staleNotice', () => {
it.each([
{ name: 'no data, error', hasData: false, error: 'boom', want: null },
{ name: 'data, no error', hasData: true, error: '', want: null },
{ name: 'no data, no error', hasData: false, error: '', want: null },
])('is null: $name', ({ hasData, error, want }) => {
expect(staleNotice(hasData, error, at)).toBe(want)
})
it('names the error and the data age when data is shown and refresh fails', () => {
const msg = staleNotice(true, 'HTTP 503', at)
expect(msg).toContain('HTTP 503')
expect(msg).toContain(at.toLocaleTimeString())
})
it('omits the age when lastUpdated is unknown', () => {
expect(staleNotice(true, 'x', null)).toBe('Refresh failing: x.')
})
// Lean gate Gateway.Ui.Stale.no_silent_stale: ready + error always has a notice.
it.each([true, false])('never silent when ready with error (loading=%s)', (loading) => {
const state = loadState({ loading, hasData: true, error: 'e' })
expect(state).toBe('ready')
expect(staleNotice(true, 'e', at)).not.toBeNull()
})
})