Feat/perf dashboard (#770)

This commit is contained in:
paisley
2026-04-07 11:04:57 +08:00
committed by GitHub
Unverified
parent 413244522e
commit d8750e135b
9 changed files with 135 additions and 39 deletions

View File

@@ -6,8 +6,9 @@ import {
deleteChannelConfig,
cleanupDanglingWeChatPluginState,
getChannelFormValues,
listConfiguredChannelAccounts,
listConfiguredChannelAccountsFromConfig,
listConfiguredChannels,
listConfiguredChannelsFromConfig,
readOpenClawConfig,
saveChannelConfig,
setChannelDefaultAccount,
@@ -20,6 +21,7 @@ import {
clearAllBindingsForChannel,
clearChannelBinding,
listAgentsSnapshot,
listAgentsSnapshotFromConfig,
} from '../../utils/agent-config';
import {
ensureDingTalkPluginInstalled,
@@ -344,16 +346,21 @@ const CHANNEL_TARGET_CACHE_ENABLED = process.env.VITEST !== 'true';
const channelTargetCache = new Map<string, { expiresAt: number; targets: ChannelTargetOptionView[] }>();
async function buildChannelAccountsView(ctx: HostApiContext): Promise<ChannelAccountsView[]> {
const [configuredChannels, configuredAccounts, openClawConfig, agentsSnapshot] = await Promise.all([
listConfiguredChannels(),
listConfiguredChannelAccounts(),
readOpenClawConfig(),
listAgentsSnapshot(),
// Read config once and share across all sub-calls (was 5 readFile calls before).
const openClawConfig = await readOpenClawConfig();
const [configuredChannels, configuredAccounts, agentsSnapshot] = await Promise.all([
listConfiguredChannelsFromConfig(openClawConfig),
Promise.resolve(listConfiguredChannelAccountsFromConfig(openClawConfig)),
listAgentsSnapshotFromConfig(openClawConfig),
]);
let gatewayStatus: GatewayChannelStatusPayload | null;
try {
gatewayStatus = await ctx.gatewayManager.rpc<GatewayChannelStatusPayload>('channels.status', { probe: true });
// probe: false — use cached runtime state instead of active network probes
// per channel. Real-time status updates arrive via channel.status events.
// 8s timeout — fail fast when Gateway is busy with AI tasks.
gatewayStatus = await ctx.gatewayManager.rpc<GatewayChannelStatusPayload>('channels.status', { probe: false }, 8000);
} catch {
gatewayStatus = null;
}