feat(webui): report account storage update progress
Surface account storage preparation and background history progress through the existing live connection status channel. Clearly distinguish unavailable accounts from accounts that remain fully usable during maintenance. Show processed totals, completion percentage, estimated remaining time, and retry states in both the global notice and account overview. Preserve existing connection update filtering to avoid unnecessary refreshes.
This commit is contained in:
7 files changed
+202
-27
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import type { AccountConnections } from '@snowluma/onebot/manager';
|
||||
|
||||
export function comparableConnectionSnapshot(snapshot: unknown): unknown {
|
||||
if (!Array.isArray(snapshot)) return snapshot;
|
||||
return (snapshot as AccountConnections[]).map((account) => ({
|
||||
uin: account.uin,
|
||||
nickname: account.nickname,
|
||||
adapters: Array.isArray(account.adapters)
|
||||
? account.adapters.map((adapter) => ({
|
||||
name: adapter.name,
|
||||
kind: adapter.kind,
|
||||
status: adapter.status,
|
||||
lastErrorAt: adapter.lastErrorAt,
|
||||
}))
|
||||
: [],
|
||||
databaseMigration: account.databaseMigration
|
||||
? {
|
||||
phase: account.databaseMigration.phase,
|
||||
usable: account.databaseMigration.usable,
|
||||
processed: account.databaseMigration.processed,
|
||||
total: account.databaseMigration.total,
|
||||
progress: account.databaseMigration.progress,
|
||||
estimatedRemainingSeconds: account.databaseMigration.estimatedRemainingSeconds,
|
||||
error: account.databaseMigration.error,
|
||||
}
|
||||
: undefined,
|
||||
}));
|
||||
}
|
||||
@@ -49,6 +49,7 @@ import { sseResponse } from './sse-response';
|
||||
import { bindStateStream } from './state-stream';
|
||||
import type { StateBus, StateResource } from './state-bus';
|
||||
import { startConnectionDiffLoop } from './connection-diff-loop';
|
||||
import { comparableConnectionSnapshot } from './connection-snapshot';
|
||||
import { describeTrustProxy, makeClientIpResolver, parseTrustProxy } from './client-ip';
|
||||
import { findAvailablePort } from './port';
|
||||
import {
|
||||
@@ -467,22 +468,7 @@ export async function initWebUI(
|
||||
startConnectionDiffLoop({
|
||||
bus: listener.stateBus,
|
||||
getSnapshot: () => oneBotManager.getConnectionStatuses(),
|
||||
pickComparable: (snap) => {
|
||||
if (!Array.isArray(snap)) return snap;
|
||||
return (snap as Array<{ uin: string; nickname?: string; adapters?: unknown[] }>).map((acc) => ({
|
||||
uin: acc.uin,
|
||||
nickname: acc.nickname,
|
||||
// Empty fallback when `adapters` is not an array — never the
|
||||
// raw value, which could re-introduce volatile fields verbatim
|
||||
// if the snapshot shape ever drifts.
|
||||
adapters: Array.isArray(acc.adapters)
|
||||
? acc.adapters.map((a: unknown) => {
|
||||
const o = a as { name?: string; kind?: string; status?: string; lastErrorAt?: number };
|
||||
return { name: o.name, kind: o.kind, status: o.status, lastErrorAt: o.lastErrorAt };
|
||||
})
|
||||
: [],
|
||||
}));
|
||||
},
|
||||
pickComparable: comparableConnectionSnapshot,
|
||||
intervalMs: 500,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user