同步:完善质量分析工作台并更新主题字体

同步已上线的智能分析执行协议、来源查询、图表报告与管理页面配套代码。
补齐数据库迁移、运行依赖和回归测试,保留原有指标计算口径。
统一午夜黑及其他主题的控件细节、中文和业务数字字体。
排除本地业务数据、凭据、预览、发布与验收产物。

验证:生产构建通过,320项前端回归通过;本轮仅同步Git,不再次部署。
This commit is contained in:
2026-10-30 22:40:58 +08:00
parent edef747e3b
commit ff7bbe3e46
393 changed files with 62999 additions and 1783 deletions
+76
View File
@@ -0,0 +1,76 @@
export type ModelThinking = { id: string; model: string; phase: string; status: string; text: string; version: number; source: 'api'; streaming: boolean; truncated: boolean; recovering?: boolean; finishReason?: string; at?: string; startedAt?: string; finishedAt?: string };
/** Reveal only received text, catching up within 100ms without splitting a UTF-16 pair. */
export function thinkingTextFrame(from: string, target: string, elapsedMs: number): string {
if (!target.startsWith(from) || elapsedMs >= 100) return target;
let end = from.length + Math.ceil((target.length - from.length) * Math.max(0, elapsedMs) / 100);
if (end < target.length && end > 0 && /[\uD800-\uDBFF]/.test(target[end - 1])) end--;
return target.slice(0, end);
}
const object = (value: unknown): Record<string, unknown> => value && typeof value === 'object' && !Array.isArray(value) ? value as Record<string, unknown> : {};
export function mergeModelThinking(existing: unknown, update: unknown): ModelThinking[] {
let rows: ModelThinking[] = Array.isArray(existing) ? existing.map(value => ({ ...object(value) }) as ModelThinking) : [];
const next = object(update);
if (typeof next.id !== 'string' || next.source !== 'api' || typeof next.version !== 'number') return rows;
const prior = rows.find(row => row.id === next.id);
if (prior && prior.version >= next.version) return rows;
if (next.reset === true && !prior) rows = [];
let text: string;
let recovering = false;
if (typeof next.text === 'string') text = next.text;
else if (typeof next.delta === 'string' && !prior?.recovering && (prior?.version || 0) === next.baseVersion) text = (prior?.text || '') + next.delta;
else { text = prior?.text || ''; recovering = true; }
const row = { ...prior, ...next, text, recovering } as ModelThinking;
const index = rows.findIndex(item => item.id === next.id);
if (index < 0) rows.push(row); else rows[index] = row;
return rows;
}
export function modelThinkingEntries(turn: Record<string, unknown>): ModelThinking[] {
const plan = object(turn.plan || object(turn.result).plan);
let rows: ModelThinking[] = [];
for (const source of [plan.modelThinking, turn.modelThinking]) {
if (Array.isArray(source)) for (const block of source) rows = mergeModelThinking(rows, block);
}
return rows;
}
export function thinkingStatus(entry: ModelThinking, running: boolean): string {
if (entry.recovering) return '正在恢复完整文本…';
if (entry.finishReason === 'length') return '达到模型输出上限,保留已返回文本';
if (entry.status === 'interrupted' && !entry.text) return '调用已中断,未收到思考文本';
if (entry.status === 'not_returned') return '接口未返回思考文本';
if (entry.status === 'interrupted' || entry.status === 'running' && !running) return '已中断,保留已返回文本';
if (entry.status === 'running') return entry.text ? '正在输出' : '等待接口返回…';
return '已返回';
}
/** Merge only recorded provider text and recorded analysis events, ordered by their actual timestamps. */
export function orderedAnalysisProcess(turn: Record<string, unknown>, timeline: Record<string, unknown>[]): Record<string, unknown>[] {
const thoughts = modelThinkingEntries(turn).filter(entry => entry.text).map(entry => ({ ...entry, kind: 'thinking', key: `thinking:${entry.id}` }));
const events = timeline.map((entry, index) => ({ ...entry, key: `event:${entry.sequence ?? index}` }));
const rows: Record<string, unknown>[] = [...thoughts, ...events];
const time = (entry: Record<string, unknown>) => {
const stamp = Date.parse(String(entry.at || entry.startedAt || ''));
return Number.isFinite(stamp) ? stamp : Number.NEGATIVE_INFINITY;
};
// Stable ordering preserves source order for old records without timestamps. Never invent historical times.
return rows.sort((a, b) => { const left=time(a), right=time(b); return left === right ? 0 : left < right ? -1 : 1; });
}
/** Adjacent provider calls read as one uninterrupted thought, without extra phase/model headings. */
export function groupAdjacentThinking(events: Record<string, unknown>[]): Record<string, unknown>[] {
const grouped: Record<string, unknown>[] = [];
for (const event of events) {
const previous = grouped.at(-1);
if (event.kind === 'thinking' && previous?.kind === 'thinking') {
previous.text = `${String(previous.text || '')}\n\n${String(event.text || '')}`;
previous.status = previous.status === 'running' || event.status === 'running' ? 'running' : event.status;
previous.truncated = Boolean(previous.truncated || event.truncated);
} else grouped.push({ ...event });
}
return grouped;
}