feat: Allow specifying a custom time for progress logs and add type assertion for new findings.
Build and Push CodeReview / build (push) Waiting to run
Details
Build and Push CodeReview / build (push) Waiting to run
Details
This commit is contained in:
parent
62c42341c4
commit
310750c366
|
|
@ -49,7 +49,7 @@ function agentAuditReducer(state: AgentAuditState, action: AgentAuditAction): Ag
|
|||
if (newFinding.id && existingIds.has(newFinding.id)) {
|
||||
return state; // 已存在,不添加
|
||||
}
|
||||
return { ...state, findings: [...state.findings, newFinding] };
|
||||
return { ...state, findings: [...state.findings, newFinding as AgentFinding] };
|
||||
}
|
||||
|
||||
case 'SET_AGENT_TREE':
|
||||
|
|
@ -99,19 +99,21 @@ function agentAuditReducer(state: AgentAuditState, action: AgentAuditAction): Ag
|
|||
}
|
||||
|
||||
case 'UPDATE_OR_ADD_PROGRESS_LOG': {
|
||||
const { progressKey, title, agentName } = action.payload;
|
||||
const { progressKey, title, agentName, time } = action.payload;
|
||||
// 查找是否已存在相同 progressKey 的进度日志
|
||||
const existingIndex = state.logs.findIndex(
|
||||
log => log.type === 'progress' && log.progressKey === progressKey
|
||||
);
|
||||
|
||||
const logTime = time || new Date().toLocaleTimeString('en-US', { hour12: false });
|
||||
|
||||
if (existingIndex >= 0) {
|
||||
// 更新现有日志的 title 和 time
|
||||
const updatedLogs = [...state.logs];
|
||||
updatedLogs[existingIndex] = {
|
||||
...updatedLogs[existingIndex],
|
||||
title,
|
||||
time: new Date().toLocaleTimeString('en-US', { hour12: false }),
|
||||
time: logTime,
|
||||
};
|
||||
return { ...state, logs: updatedLogs };
|
||||
} else {
|
||||
|
|
@ -121,6 +123,7 @@ function agentAuditReducer(state: AgentAuditState, action: AgentAuditAction): Ag
|
|||
title,
|
||||
progressKey,
|
||||
agentName,
|
||||
time: logTime,
|
||||
});
|
||||
return { ...state, logs: [...state.logs, newLog] };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ export type AgentAuditAction =
|
|||
| { type: 'SET_LOGS'; payload: LogItem[] }
|
||||
| { type: 'ADD_LOG'; payload: Omit<LogItem, 'id' | 'time'> & { id?: string; time?: string } }
|
||||
| { type: 'UPDATE_LOG'; payload: { id: string; updates: Partial<LogItem> } }
|
||||
| { type: 'UPDATE_OR_ADD_PROGRESS_LOG'; payload: { progressKey: string; title: string; agentName?: string } }
|
||||
| { type: 'UPDATE_OR_ADD_PROGRESS_LOG'; payload: { progressKey: string; title: string; agentName?: string; time?: string } }
|
||||
| { type: 'COMPLETE_TOOL_LOG'; payload: { toolName: string; output: string; duration: number } }
|
||||
| { type: 'REMOVE_LOG'; payload: string }
|
||||
| { type: 'SELECT_AGENT'; payload: string | null }
|
||||
|
|
|
|||
Loading…
Reference in New Issue