fix: 日志三段式——开始+进度(原地更新)+完成,各一条
- logInfo 开始 → resetVideoProgress 进度 → updateVideoProgress 更新 → logSuccess 完成 - 进度条目保留最后帧数不动,完成后新加 success 条目
This commit is contained in:
@@ -19,7 +19,7 @@ import { runAgentLoop } from '../services/agent-engine.js';
|
||||
import { estimateTokens } from '../services/context-manager.js';
|
||||
import { searchMemories, buildMemoryContext, markMemoryUsed, extractMemoriesFromConversation, isMemoryEnabled } from '../services/memory-manager.js';
|
||||
import { showToolConfirm } from './tool-confirm-modal.js';
|
||||
import { logInfo, logStream, logError, logSuccess, logWarn, resetVideoProgress, updateVideoProgress, finishVideoProgress } from '../services/log-service.js';
|
||||
import { logInfo, logStream, logError, logSuccess, logWarn, resetVideoProgress, updateVideoProgress } from '../services/log-service.js';
|
||||
import type { ChatSession, ChatMessage, OllamaStreamChunk, FileContent, ChatFile, ToolCallRecord } from '../types.js';
|
||||
|
||||
let chatInputEl: HTMLTextAreaElement;
|
||||
@@ -252,7 +252,8 @@ async function handleVideoPath(filePath: string): Promise<void> {
|
||||
|
||||
const name = filePath.split(/[/\\]/).pop() || filePath;
|
||||
|
||||
// 先显示提取中的预览卡片 + 日志进度条目
|
||||
// 日志:开始 → 进度(原地更新) → 完成
|
||||
logInfo('🎬 正在提取视频帧', name);
|
||||
pendingVideoMeta = { fileName: name, duration: 0, width: 0, height: 0 };
|
||||
renderVideoPreview();
|
||||
resetVideoProgress(name);
|
||||
@@ -280,8 +281,8 @@ async function handleVideoPath(filePath: string): Promise<void> {
|
||||
pendingVideoFrames = result.frames!;
|
||||
pendingVideoMeta = { fileName: name, ...result.videoInfo! };
|
||||
|
||||
// 完成:日志条目原地更新为 success(不新增)
|
||||
finishVideoProgress(name, pendingVideoFrames.length, pendingVideoMeta.duration);
|
||||
// 完成:新加一条 success 日志,进度条目保留原地
|
||||
logSuccess('✅ 视频帧提取完成', `${pendingVideoFrames.length} 帧 / ${pendingVideoMeta.duration.toFixed(1)}s (1fps)`);
|
||||
renderVideoPreview();
|
||||
} catch (err) {
|
||||
bridge.video.removeProgressListener();
|
||||
|
||||
@@ -214,21 +214,6 @@ export function updateVideoProgress(current: number): void {
|
||||
}
|
||||
}
|
||||
|
||||
/** 视频提取完成:将进度条目原地更新为完成状态 */
|
||||
export function finishVideoProgress(fileName: string, frameCount: number, duration: number): void {
|
||||
const all = logBodyEl?.querySelectorAll?.('.log-video-progress');
|
||||
if (all && all.length > 0) {
|
||||
const latest = all[all.length - 1] as HTMLElement;
|
||||
latest.className = 'log-entry log-success';
|
||||
const icon = latest.querySelector('.log-icon');
|
||||
const msg = latest.querySelector('.log-msg');
|
||||
const detail = latest.querySelector('.log-detail');
|
||||
if (icon) icon.textContent = '✅';
|
||||
if (msg) msg.textContent = `视频帧提取完成: ${escapeHtml(fileName)}`;
|
||||
if (detail) detail.textContent = `${frameCount} 帧 / ${duration.toFixed(1)}s (1fps)`;
|
||||
}
|
||||
}
|
||||
|
||||
export function logAgentLoop(iteration: number, maxLoops: number): void { addLog('info', `Loop #${iteration}/${maxLoops}`); }
|
||||
export function logModelResponse(contentLen: number, toolCalls: number): void { addLog('stream', `响应: ${contentLen}字, ${toolCalls}工具`); }
|
||||
export function logConnection(status: string, detail?: string): void { addLog(status === 'connected' ? 'success' : 'warn', `连接: ${status}`, detail); }
|
||||
|
||||
Reference in New Issue
Block a user