Skip to content

Commit 008d428

Browse files
Desel72Zephyroambytecii
authored
feat: Set Success Rate as - while waiting for execution (eigent-ai#1424)
Co-authored-by: Xiangyu Shi <sxyu.shi@gmail.com> Co-authored-by: bytecii <994513625@qq.com>
1 parent 4476409 commit 008d428

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

‎src/components/Trigger/ExecutionLogs.tsx‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ export interface TriggerExecutionData {
5050
logs: ExecutionLogEntry[];
5151
}
5252

53+
// Success rate thresholds for color coding (percentage)
54+
const SUCCESS_CRITERIA_EXCELLENT = 90;
55+
const SUCCESS_CRITERIA_ACCEPTABLE = 70;
56+
5357
// Helper function to map ExecutionStatus to display status
5458
const mapExecutionStatus = (
5559
status: ExecutionStatus
@@ -164,6 +168,13 @@ const getStatusColor = (status: ExecutionLogEntry['status']) => {
164168
}
165169
};
166170

171+
const getSuccessRateColorClass = (rate: number | null): string => {
172+
if (rate === null) return 'text-text-label';
173+
if (rate >= SUCCESS_CRITERIA_EXCELLENT) return 'text-icon-success';
174+
if (rate >= SUCCESS_CRITERIA_ACCEPTABLE) return 'text-icon-warning';
175+
return 'text-icon-caution';
176+
};
177+
167178
interface ExecutionLogsProps {
168179
triggerId: number;
169180
}
@@ -275,12 +286,12 @@ export function ExecutionLogs({ triggerId }: ExecutionLogsProps) {
275286
const successfulExecutions = Array.isArray(executions)
276287
? executions.filter((e) => e.status === ExecutionStatus.Completed)
277288
: [];
278-
const successRate =
289+
const successRate: number | null =
279290
completedExecutions.length > 0
280291
? Math.round(
281292
(successfulExecutions.length / completedExecutions.length) * 100
282293
)
283-
: 0;
294+
: null;
284295

285296
return (
286297
<div className="flex h-full flex-col">
@@ -314,9 +325,9 @@ export function ExecutionLogs({ triggerId }: ExecutionLogsProps) {
314325
</div>
315326
<div className="border-r-1 mr-4 flex flex-col border-y-0 border-l-0 border-solid border-border-tertiary pr-4">
316327
<span
317-
className={`text-label-sm font-medium ${successRate >= 90 ? 'text-icon-success' : successRate >= 70 ? 'text-icon-warning' : 'text-icon-cuation'}`}
328+
className={`text-label-sm font-medium ${getSuccessRateColorClass(successRate)}`}
318329
>
319-
{successRate}%
330+
{successRate !== null ? `${successRate}%` : '-'}
320331
</span>
321332
<span className="text-label-xs text-text-label">
322333
{t('triggers.success-rate')}

‎tailwind.config.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ module.exports = {
528528
'icon-information': 'var(--icon-information)',
529529
'icon-success': 'var(--icon-success)',
530530
'icon-warning': 'var(--icon-warning)',
531+
'icon-caution': 'var(--icon-cuation)',
531532
'icon-cuation': 'var(--icon-cuation)',
532533
'icon-action-hover': 'var(--icon-action-hover)',
533534
'icon-multimodal': 'var(--icon-multimodal)',

0 commit comments

Comments
 (0)