mirror of
https://github.com/The-Low-Code-Foundation/OpenNoodl.git
synced 2026-03-08 01:53:30 +01:00
feat(phase-11): CF11-006 Execution History Panel UI
- ExecutionHistoryPanel React component registered in sidebar (order 8.8) - ExecutionList + ExecutionItem: scrollable list with status dots, duration, trigger type - ExecutionDetail: summary, error display, trigger data, node steps - NodeStepList + NodeStepItem: expandable rows with input/output JSON - ExecutionFilters: status dropdown filter with clear button - useExecutionHistory hook: IPC-based data fetching with filter support - useExecutionDetail hook: single execution fetch with steps - All styles use design tokens (no hardcoded colors) - Unit tests: formatDuration, formatRelativeTime, buildExecutionQuery (Jasmine) - CF11-007 canvas overlay integration point: onPinToCanvas prop stub IPC channels expected from backend: execution-history:list (ExecutionQuery) -> WorkflowExecution[] execution-history:get (id) -> ExecutionWithSteps
This commit is contained in:
@@ -19,6 +19,7 @@ import { DataLineagePanel } from './views/panels/DataLineagePanel';
|
|||||||
import { DesignTokenPanel } from './views/panels/DesignTokenPanel/DesignTokenPanel';
|
import { DesignTokenPanel } from './views/panels/DesignTokenPanel/DesignTokenPanel';
|
||||||
import { EditorSettingsPanel } from './views/panels/EditorSettingsPanel/EditorSettingsPanel';
|
import { EditorSettingsPanel } from './views/panels/EditorSettingsPanel/EditorSettingsPanel';
|
||||||
import { FileExplorerPanel } from './views/panels/FileExplorerPanel';
|
import { FileExplorerPanel } from './views/panels/FileExplorerPanel';
|
||||||
|
import { ExecutionHistoryPanel } from './views/panels/ExecutionHistoryPanel';
|
||||||
import { GitHubPanel } from './views/panels/GitHubPanel';
|
import { GitHubPanel } from './views/panels/GitHubPanel';
|
||||||
import { NodeReferencesPanel_ID } from './views/panels/NodeReferencesPanel';
|
import { NodeReferencesPanel_ID } from './views/panels/NodeReferencesPanel';
|
||||||
import { NodeReferencesPanel } from './views/panels/NodeReferencesPanel/NodeReferencesPanel';
|
import { NodeReferencesPanel } from './views/panels/NodeReferencesPanel/NodeReferencesPanel';
|
||||||
@@ -158,6 +159,17 @@ export function installSidePanel({ isLesson }: SetupEditorOptions) {
|
|||||||
panel: BackendServicesPanel
|
panel: BackendServicesPanel
|
||||||
});
|
});
|
||||||
|
|
||||||
|
SidebarModel.instance.register({
|
||||||
|
experimental: true,
|
||||||
|
id: 'execution-history',
|
||||||
|
name: 'Execution History',
|
||||||
|
description: 'View workflow execution history, inspect node data, and debug failed runs.',
|
||||||
|
isDisabled: isLesson === true,
|
||||||
|
order: 8.8,
|
||||||
|
icon: IconName.Bug,
|
||||||
|
panel: ExecutionHistoryPanel
|
||||||
|
});
|
||||||
|
|
||||||
SidebarModel.instance.register({
|
SidebarModel.instance.register({
|
||||||
id: 'app-setup',
|
id: 'app-setup',
|
||||||
name: 'App Setup',
|
name: 'App Setup',
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
.Panel {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100%;
|
||||||
|
background-color: var(--theme-color-bg-2);
|
||||||
|
color: var(--theme-color-fg-default);
|
||||||
|
}
|
||||||
|
|
||||||
|
.Header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: 12px 16px;
|
||||||
|
border-bottom: 1px solid var(--theme-color-bg-3);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Title {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--theme-color-fg-default);
|
||||||
|
}
|
||||||
|
|
||||||
|
.RefreshButton {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
color: var(--theme-color-fg-default-shy);
|
||||||
|
font-size: 16px;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 2px 6px;
|
||||||
|
border-radius: 3px;
|
||||||
|
line-height: 1;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--theme-color-bg-3);
|
||||||
|
color: var(--theme-color-fg-default);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.Body {
|
||||||
|
flex: 1;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
|
import { ExecutionDetail } from './components/ExecutionDetail/ExecutionDetail';
|
||||||
|
import { ExecutionFilters } from './components/ExecutionFilters/ExecutionFilters';
|
||||||
|
import { ExecutionList } from './components/ExecutionList/ExecutionList';
|
||||||
|
import styles from './ExecutionHistoryPanel.module.scss';
|
||||||
|
import { type ExecutionFilters as FiltersState, useExecutionHistory } from './hooks/useExecutionHistory';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CF11-006: Execution History Panel
|
||||||
|
*
|
||||||
|
* Sidebar panel showing workflow execution history.
|
||||||
|
* Allows users to view past executions, inspect node data, and debug failures.
|
||||||
|
*
|
||||||
|
* Registered in router.setup.ts at order 8.8 (between backend-services and app-setup).
|
||||||
|
* CF11-007 will add canvas overlay integration via the onPinToCanvas prop.
|
||||||
|
*/
|
||||||
|
export function ExecutionHistoryPanel() {
|
||||||
|
const [selectedExecutionId, setSelectedExecutionId] = useState<string | null>(null);
|
||||||
|
const [filters, setFilters] = useState<FiltersState>({
|
||||||
|
status: undefined,
|
||||||
|
startDate: undefined,
|
||||||
|
endDate: undefined
|
||||||
|
});
|
||||||
|
|
||||||
|
const { executions, loading, error, refresh } = useExecutionHistory(filters);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.Panel}>
|
||||||
|
<div className={styles.Header}>
|
||||||
|
<span className={styles.Title}>Execution History</span>
|
||||||
|
<button className={styles.RefreshButton} onClick={refresh} title="Refresh" aria-label="Refresh">
|
||||||
|
↻
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{!selectedExecutionId && <ExecutionFilters filters={filters} onChange={setFilters} />}
|
||||||
|
|
||||||
|
<div className={styles.Body}>
|
||||||
|
{selectedExecutionId ? (
|
||||||
|
<ExecutionDetail
|
||||||
|
executionId={selectedExecutionId}
|
||||||
|
onBack={() => setSelectedExecutionId(null)}
|
||||||
|
// onPinToCanvas will be wired in CF11-007
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<ExecutionList executions={executions} loading={loading} error={error} onSelect={setSelectedExecutionId} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,172 @@
|
|||||||
|
.Detail {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 10px 16px;
|
||||||
|
border-bottom: 1px solid var(--theme-color-bg-3);
|
||||||
|
flex-shrink: 0;
|
||||||
|
background-color: var(--theme-color-bg-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.BackButton,
|
||||||
|
.PinButton {
|
||||||
|
background: none;
|
||||||
|
border: 1px solid var(--theme-color-bg-3);
|
||||||
|
border-radius: 4px;
|
||||||
|
color: var(--theme-color-fg-default);
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 4px 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--theme-color-bg-3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.Title {
|
||||||
|
flex: 1;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--theme-color-fg-default);
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Content {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 16px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Summary {
|
||||||
|
background-color: var(--theme-color-bg-3);
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 12px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.SummaryRow {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Label {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--theme-color-fg-default-shy);
|
||||||
|
width: 64px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Value {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--theme-color-fg-default);
|
||||||
|
}
|
||||||
|
|
||||||
|
.StatusBadge {
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.4px;
|
||||||
|
padding: 2px 6px;
|
||||||
|
border-radius: 3px;
|
||||||
|
|
||||||
|
&[data-status='success'] {
|
||||||
|
color: var(--theme-color-success, #22c55e);
|
||||||
|
background-color: color-mix(in srgb, var(--theme-color-success, #22c55e) 15%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-status='error'] {
|
||||||
|
color: var(--theme-color-danger, #ef4444);
|
||||||
|
background-color: color-mix(in srgb, var(--theme-color-danger, #ef4444) 15%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-status='running'] {
|
||||||
|
color: var(--theme-color-notice, #f59e0b);
|
||||||
|
background-color: color-mix(in srgb, var(--theme-color-notice, #f59e0b) 15%, transparent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.Section {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.SectionTitle {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--theme-color-fg-default);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.StepCount {
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: 400;
|
||||||
|
color: var(--theme-color-fg-default-shy);
|
||||||
|
background-color: var(--theme-color-bg-3);
|
||||||
|
padding: 1px 5px;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ErrorPre,
|
||||||
|
.DataPre,
|
||||||
|
.StackPre {
|
||||||
|
margin: 0;
|
||||||
|
font-family: 'Courier New', Courier, monospace;
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--theme-color-fg-default);
|
||||||
|
background-color: var(--theme-color-bg-1);
|
||||||
|
border: 1px solid var(--theme-color-bg-3);
|
||||||
|
border-radius: 3px;
|
||||||
|
padding: 8px;
|
||||||
|
overflow-x: auto;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-break: break-all;
|
||||||
|
max-height: 200px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ErrorPre {
|
||||||
|
color: var(--theme-color-danger, #ef4444);
|
||||||
|
border-color: var(--theme-color-danger, #ef4444);
|
||||||
|
}
|
||||||
|
|
||||||
|
.StackDetails {
|
||||||
|
summary {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--theme-color-fg-default-shy);
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 4px 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.Loading,
|
||||||
|
.Error {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 48px 24px;
|
||||||
|
color: var(--theme-color-fg-default-shy);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Error {
|
||||||
|
color: var(--theme-color-danger, #ef4444);
|
||||||
|
}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import styles from './ExecutionDetail.module.scss';
|
||||||
|
import { NodeStepList } from './NodeStepList';
|
||||||
|
import { useExecutionDetail } from '../../hooks/useExecutionDetail';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
executionId: string;
|
||||||
|
onBack: () => void;
|
||||||
|
/** Hook for CF11-007 canvas overlay integration */
|
||||||
|
onPinToCanvas?: (executionId: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatTime(timestamp: number): string {
|
||||||
|
return new Date(timestamp).toLocaleString();
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDuration(ms?: number): string {
|
||||||
|
if (ms === undefined || ms === null) return '—';
|
||||||
|
if (ms < 1000) return `${ms}ms`;
|
||||||
|
return `${(ms / 1000).toFixed(1)}s`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detailed view of a single workflow execution.
|
||||||
|
* Shows summary, error info, trigger data, and per-node steps.
|
||||||
|
*/
|
||||||
|
export function ExecutionDetail({ executionId, onBack, onPinToCanvas }: Props) {
|
||||||
|
const { execution, loading, error } = useExecutionDetail(executionId);
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return (
|
||||||
|
<div className={styles.Loading}>
|
||||||
|
<span>Loading execution...</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error || !execution) {
|
||||||
|
return (
|
||||||
|
<div className={styles.Error}>
|
||||||
|
<span>{error || 'Execution not found'}</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.Detail}>
|
||||||
|
<div className={styles.Header}>
|
||||||
|
<button className={styles.BackButton} onClick={onBack}>
|
||||||
|
← Back
|
||||||
|
</button>
|
||||||
|
<span className={styles.Title}>{execution.workflowName}</span>
|
||||||
|
{onPinToCanvas && (
|
||||||
|
<button className={styles.PinButton} onClick={() => onPinToCanvas(executionId)} title="Pin to canvas">
|
||||||
|
Pin
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={styles.Content}>
|
||||||
|
<section className={styles.Summary}>
|
||||||
|
<div className={styles.SummaryRow}>
|
||||||
|
<span className={styles.Label}>Status</span>
|
||||||
|
<span className={styles.StatusBadge} data-status={execution.status}>
|
||||||
|
{execution.status}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.SummaryRow}>
|
||||||
|
<span className={styles.Label}>Started</span>
|
||||||
|
<span className={styles.Value}>{formatTime(execution.startedAt)}</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.SummaryRow}>
|
||||||
|
<span className={styles.Label}>Duration</span>
|
||||||
|
<span className={styles.Value}>{formatDuration(execution.durationMs)}</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.SummaryRow}>
|
||||||
|
<span className={styles.Label}>Trigger</span>
|
||||||
|
<span className={styles.Value}>{execution.triggerType}</span>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
{execution.errorMessage && (
|
||||||
|
<section className={styles.Section}>
|
||||||
|
<h4 className={styles.SectionTitle}>Error</h4>
|
||||||
|
<pre className={styles.ErrorPre}>{execution.errorMessage}</pre>
|
||||||
|
{execution.errorStack && (
|
||||||
|
<details className={styles.StackDetails}>
|
||||||
|
<summary>Stack trace</summary>
|
||||||
|
<pre className={styles.StackPre}>{execution.errorStack}</pre>
|
||||||
|
</details>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{execution.triggerData && Object.keys(execution.triggerData).length > 0 && (
|
||||||
|
<section className={styles.Section}>
|
||||||
|
<h4 className={styles.SectionTitle}>Trigger Data</h4>
|
||||||
|
<pre className={styles.DataPre}>{JSON.stringify(execution.triggerData, null, 2)}</pre>
|
||||||
|
</section>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<section className={styles.Section}>
|
||||||
|
<h4 className={styles.SectionTitle}>
|
||||||
|
Node Steps
|
||||||
|
<span className={styles.StepCount}>{execution.steps?.length ?? 0}</span>
|
||||||
|
</h4>
|
||||||
|
<NodeStepList steps={execution.steps ?? []} />
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,148 @@
|
|||||||
|
.Step {
|
||||||
|
border: 1px solid var(--theme-color-bg-3);
|
||||||
|
border-radius: 4px;
|
||||||
|
margin-bottom: 6px;
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: var(--theme-color-bg-2);
|
||||||
|
|
||||||
|
&[data-expanded='true'] {
|
||||||
|
border-color: var(--theme-color-primary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.Header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 8px 12px;
|
||||||
|
cursor: default;
|
||||||
|
|
||||||
|
&[role='button'] {
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--theme-color-bg-3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.Index {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: var(--theme-color-bg-3);
|
||||||
|
color: var(--theme-color-fg-default-shy);
|
||||||
|
font-size: 10px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.StepInfo {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.NodeName {
|
||||||
|
color: var(--theme-color-fg-default);
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.NodeType {
|
||||||
|
color: var(--theme-color-fg-default-shy);
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.StepMeta {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Duration {
|
||||||
|
color: var(--theme-color-fg-default-shy);
|
||||||
|
font-size: 11px;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.StatusDot {
|
||||||
|
width: 6px;
|
||||||
|
height: 6px;
|
||||||
|
border-radius: 50%;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
&[data-status='success'] {
|
||||||
|
background-color: var(--theme-color-success, #22c55e);
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-status='error'] {
|
||||||
|
background-color: var(--theme-color-danger, #ef4444);
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-status='running'] {
|
||||||
|
background-color: var(--theme-color-notice, #f59e0b);
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-status='skipped'] {
|
||||||
|
background-color: var(--theme-color-fg-default-shy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.ExpandIcon {
|
||||||
|
color: var(--theme-color-fg-default-shy);
|
||||||
|
font-size: 9px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Body {
|
||||||
|
padding: 0 12px 12px;
|
||||||
|
background-color: var(--theme-color-bg-1);
|
||||||
|
border-top: 1px solid var(--theme-color-bg-3);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ErrorSection {
|
||||||
|
padding-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.DataSection {
|
||||||
|
padding-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.SectionLabel {
|
||||||
|
display: block;
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
color: var(--theme-color-fg-default-shy);
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Pre {
|
||||||
|
margin: 0;
|
||||||
|
font-family: 'Courier New', Courier, monospace;
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--theme-color-fg-default);
|
||||||
|
background-color: var(--theme-color-bg-2);
|
||||||
|
border: 1px solid var(--theme-color-bg-3);
|
||||||
|
border-radius: 3px;
|
||||||
|
padding: 8px;
|
||||||
|
overflow-x: auto;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-break: break-all;
|
||||||
|
max-height: 200px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
|
import type { ExecutionStep } from '@noodl-viewer-cloud/execution-history';
|
||||||
|
|
||||||
|
import styles from './NodeStepItem.module.scss';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
step: ExecutionStep;
|
||||||
|
index: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDuration(ms?: number): string {
|
||||||
|
if (ms === undefined || ms === null) return '—';
|
||||||
|
if (ms < 1000) return `${ms}ms`;
|
||||||
|
return `${(ms / 1000).toFixed(1)}s`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function safeStringify(data: unknown): string {
|
||||||
|
try {
|
||||||
|
return JSON.stringify(data, null, 2);
|
||||||
|
} catch {
|
||||||
|
return String(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Single node step row in the execution detail view.
|
||||||
|
* Expandable to show input/output data.
|
||||||
|
*/
|
||||||
|
export function NodeStepItem({ step, index }: Props) {
|
||||||
|
const [expanded, setExpanded] = useState(false);
|
||||||
|
|
||||||
|
const hasData = step.inputData || step.outputData || step.errorMessage;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.Step} data-status={step.status} data-expanded={expanded}>
|
||||||
|
<div
|
||||||
|
className={styles.Header}
|
||||||
|
onClick={() => hasData && setExpanded((v) => !v)}
|
||||||
|
role={hasData ? 'button' : undefined}
|
||||||
|
tabIndex={hasData ? 0 : undefined}
|
||||||
|
onKeyDown={(e) => hasData && e.key === 'Enter' && setExpanded((v) => !v)}
|
||||||
|
>
|
||||||
|
<span className={styles.Index}>{index + 1}</span>
|
||||||
|
<div className={styles.StepInfo}>
|
||||||
|
<span className={styles.NodeName}>{step.nodeName || step.nodeId}</span>
|
||||||
|
<span className={styles.NodeType}>{step.nodeType}</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.StepMeta}>
|
||||||
|
<span className={styles.Duration}>{formatDuration(step.durationMs)}</span>
|
||||||
|
<div className={styles.StatusDot} data-status={step.status} />
|
||||||
|
</div>
|
||||||
|
{hasData && <span className={styles.ExpandIcon}>{expanded ? '▲' : '▼'}</span>}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{expanded && hasData && (
|
||||||
|
<div className={styles.Body}>
|
||||||
|
{step.errorMessage && (
|
||||||
|
<div className={styles.ErrorSection}>
|
||||||
|
<span className={styles.SectionLabel}>Error</span>
|
||||||
|
<pre className={styles.Pre}>{step.errorMessage}</pre>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{step.inputData && (
|
||||||
|
<div className={styles.DataSection}>
|
||||||
|
<span className={styles.SectionLabel}>Input</span>
|
||||||
|
<pre className={styles.Pre}>{safeStringify(step.inputData)}</pre>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{step.outputData && (
|
||||||
|
<div className={styles.DataSection}>
|
||||||
|
<span className={styles.SectionLabel}>Output</span>
|
||||||
|
<pre className={styles.Pre}>{safeStringify(step.outputData)}</pre>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
.List {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Empty {
|
||||||
|
color: var(--theme-color-fg-default-shy);
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 12px 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import type { ExecutionStep } from '@noodl-viewer-cloud/execution-history';
|
||||||
|
|
||||||
|
import { NodeStepItem } from './NodeStepItem';
|
||||||
|
import styles from './NodeStepList.module.scss';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
steps: ExecutionStep[];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Ordered list of node execution steps. */
|
||||||
|
export function NodeStepList({ steps }: Props) {
|
||||||
|
if (steps.length === 0) {
|
||||||
|
return <div className={styles.Empty}>No steps recorded</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.List}>
|
||||||
|
{steps.map((step, i) => (
|
||||||
|
<NodeStepItem key={step.id} step={step} index={i} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
.Filters {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 8px 16px;
|
||||||
|
background-color: var(--theme-color-bg-3);
|
||||||
|
border-bottom: 1px solid var(--theme-color-bg-3);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Select {
|
||||||
|
padding: 5px 8px;
|
||||||
|
border: 1px solid var(--theme-color-bg-3);
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: var(--theme-color-bg-1);
|
||||||
|
color: var(--theme-color-fg-default);
|
||||||
|
font-size: 12px;
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: var(--theme-color-primary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.ClearButton {
|
||||||
|
background: none;
|
||||||
|
border: 1px solid var(--theme-color-bg-3);
|
||||||
|
border-radius: 4px;
|
||||||
|
color: var(--theme-color-fg-default-shy);
|
||||||
|
font-size: 11px;
|
||||||
|
padding: 4px 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--theme-color-bg-2);
|
||||||
|
color: var(--theme-color-fg-default);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import type { ExecutionStatus } from '@noodl-viewer-cloud/execution-history';
|
||||||
|
|
||||||
|
import type { ExecutionFilters as FiltersState } from '../../hooks/useExecutionHistory';
|
||||||
|
import styles from './ExecutionFilters.module.scss';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
filters: FiltersState;
|
||||||
|
onChange: (filters: FiltersState) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const STATUS_OPTIONS: { value: ExecutionStatus | ''; label: string }[] = [
|
||||||
|
{ value: '', label: 'All statuses' },
|
||||||
|
{ value: 'success', label: 'Success' },
|
||||||
|
{ value: 'error', label: 'Error' },
|
||||||
|
{ value: 'running', label: 'Running' }
|
||||||
|
];
|
||||||
|
|
||||||
|
/** Filter toolbar for the execution history list. */
|
||||||
|
export function ExecutionFilters({ filters, onChange }: Props) {
|
||||||
|
return (
|
||||||
|
<div className={styles.Filters}>
|
||||||
|
<select
|
||||||
|
className={styles.Select}
|
||||||
|
value={filters.status ?? ''}
|
||||||
|
onChange={(e) =>
|
||||||
|
onChange({
|
||||||
|
...filters,
|
||||||
|
status: (e.target.value as ExecutionStatus) || undefined
|
||||||
|
})
|
||||||
|
}
|
||||||
|
aria-label="Filter by status"
|
||||||
|
>
|
||||||
|
{STATUS_OPTIONS.map((opt) => (
|
||||||
|
<option key={opt.value} value={opt.value}>
|
||||||
|
{opt.label}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
{(filters.status || filters.startDate || filters.endDate) && (
|
||||||
|
<button
|
||||||
|
className={styles.ClearButton}
|
||||||
|
onClick={() => onChange({ status: undefined, startDate: undefined, endDate: undefined })}
|
||||||
|
>
|
||||||
|
Clear
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
.Item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 10px 16px;
|
||||||
|
background-color: var(--theme-color-bg-2);
|
||||||
|
border-bottom: 1px solid var(--theme-color-bg-3);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.1s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--theme-color-bg-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
outline: 1px solid var(--theme-color-primary);
|
||||||
|
outline-offset: -1px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.StatusDot {
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
|
border-radius: 50%;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
&[data-status='success'] {
|
||||||
|
background-color: var(--theme-color-success, #22c55e);
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-status='error'] {
|
||||||
|
background-color: var(--theme-color-danger, #ef4444);
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-status='running'] {
|
||||||
|
background-color: var(--theme-color-notice, #f59e0b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.Info {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Name {
|
||||||
|
color: var(--theme-color-fg-default);
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Time {
|
||||||
|
color: var(--theme-color-fg-default-shy);
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Meta {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-end;
|
||||||
|
gap: 2px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Duration {
|
||||||
|
color: var(--theme-color-fg-default);
|
||||||
|
font-size: 12px;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Trigger {
|
||||||
|
color: var(--theme-color-fg-default-shy);
|
||||||
|
font-size: 10px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.4px;
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import type { WorkflowExecution } from '@noodl-viewer-cloud/execution-history';
|
||||||
|
|
||||||
|
import styles from './ExecutionItem.module.scss';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
execution: WorkflowExecution;
|
||||||
|
onSelect: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatRelativeTime(timestamp: number): string {
|
||||||
|
const diff = Date.now() - timestamp;
|
||||||
|
const seconds = Math.floor(diff / 1000);
|
||||||
|
if (seconds < 60) return `${seconds}s ago`;
|
||||||
|
const minutes = Math.floor(seconds / 60);
|
||||||
|
if (minutes < 60) return `${minutes}m ago`;
|
||||||
|
const hours = Math.floor(minutes / 60);
|
||||||
|
if (hours < 24) return `${hours}h ago`;
|
||||||
|
return new Date(timestamp).toLocaleDateString();
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDuration(ms?: number): string {
|
||||||
|
if (ms === undefined || ms === null) return '—';
|
||||||
|
if (ms < 1000) return `${ms}ms`;
|
||||||
|
return `${(ms / 1000).toFixed(1)}s`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Single row in the execution history list.
|
||||||
|
*/
|
||||||
|
export function ExecutionItem({ execution, onSelect }: Props) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={styles.Item}
|
||||||
|
data-status={execution.status}
|
||||||
|
onClick={onSelect}
|
||||||
|
role="button"
|
||||||
|
tabIndex={0}
|
||||||
|
onKeyDown={(e) => e.key === 'Enter' && onSelect()}
|
||||||
|
>
|
||||||
|
<div className={styles.StatusDot} data-status={execution.status} />
|
||||||
|
<div className={styles.Info}>
|
||||||
|
<span className={styles.Name}>{execution.workflowName}</span>
|
||||||
|
<span className={styles.Time}>{formatRelativeTime(execution.startedAt)}</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.Meta}>
|
||||||
|
<span className={styles.Duration}>{formatDuration(execution.durationMs)}</span>
|
||||||
|
<span className={styles.Trigger}>{execution.triggerType}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
.List {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Loading,
|
||||||
|
.Empty,
|
||||||
|
.Error {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 48px 24px;
|
||||||
|
text-align: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Loading {
|
||||||
|
color: var(--theme-color-fg-default-shy);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Empty {
|
||||||
|
color: var(--theme-color-fg-default-shy);
|
||||||
|
}
|
||||||
|
|
||||||
|
.EmptyTitle {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--theme-color-fg-default);
|
||||||
|
}
|
||||||
|
|
||||||
|
.EmptyHint {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--theme-color-fg-default-shy);
|
||||||
|
}
|
||||||
|
|
||||||
|
.Error {
|
||||||
|
padding: 12px 16px;
|
||||||
|
background-color: color-mix(in srgb, var(--theme-color-danger, #ef4444) 10%, transparent);
|
||||||
|
border: 1px solid var(--theme-color-danger, #ef4444);
|
||||||
|
border-radius: 4px;
|
||||||
|
margin: 12px 16px;
|
||||||
|
color: var(--theme-color-danger, #ef4444);
|
||||||
|
font-size: 13px;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: flex-start;
|
||||||
|
padding: 12px 16px;
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import type { WorkflowExecution } from '@noodl-viewer-cloud/execution-history';
|
||||||
|
|
||||||
|
import { ExecutionItem } from './ExecutionItem';
|
||||||
|
import styles from './ExecutionList.module.scss';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
executions: WorkflowExecution[];
|
||||||
|
loading: boolean;
|
||||||
|
error: string | null;
|
||||||
|
onSelect: (id: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scrollable list of workflow executions.
|
||||||
|
*/
|
||||||
|
export function ExecutionList({ executions, loading, error, onSelect }: Props) {
|
||||||
|
if (loading) {
|
||||||
|
return (
|
||||||
|
<div className={styles.Loading}>
|
||||||
|
<span>Loading executions...</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return (
|
||||||
|
<div className={styles.Error}>
|
||||||
|
<span>{error}</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (executions.length === 0) {
|
||||||
|
return (
|
||||||
|
<div className={styles.Empty}>
|
||||||
|
<span className={styles.EmptyTitle}>No executions yet</span>
|
||||||
|
<span className={styles.EmptyHint}>Workflow runs will appear here</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.List}>
|
||||||
|
{executions.map((execution) => (
|
||||||
|
<ExecutionItem key={execution.id} execution={execution} onSelect={() => onSelect(execution.id)} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
|
|
||||||
|
import type { ExecutionWithSteps } from '@noodl-viewer-cloud/execution-history';
|
||||||
|
|
||||||
|
export interface UseExecutionDetailResult {
|
||||||
|
execution: ExecutionWithSteps | null;
|
||||||
|
loading: boolean;
|
||||||
|
error: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches a single execution with all its steps via IPC.
|
||||||
|
*/
|
||||||
|
export function useExecutionDetail(executionId: string | null): UseExecutionDetailResult {
|
||||||
|
const [execution, setExecution] = useState<ExecutionWithSteps | null>(null);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const fetch = useCallback(async () => {
|
||||||
|
if (!executionId) {
|
||||||
|
setExecution(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const { ipcRenderer } = (window as any).require('electron');
|
||||||
|
const result = await ipcRenderer.invoke('execution-history:get', executionId);
|
||||||
|
|
||||||
|
if (result && result.error) {
|
||||||
|
setError(result.error);
|
||||||
|
setExecution(null);
|
||||||
|
} else {
|
||||||
|
setExecution(result || null);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
setError(err instanceof Error ? err.message : 'Failed to load execution detail');
|
||||||
|
setExecution(null);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}, [executionId]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetch();
|
||||||
|
}, [fetch]);
|
||||||
|
|
||||||
|
return { execution, loading, error };
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
|
|
||||||
|
import type { ExecutionQuery, ExecutionStatus, WorkflowExecution } from '@noodl-viewer-cloud/execution-history';
|
||||||
|
|
||||||
|
export interface ExecutionFilters {
|
||||||
|
status?: ExecutionStatus;
|
||||||
|
startDate?: Date;
|
||||||
|
endDate?: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UseExecutionHistoryResult {
|
||||||
|
executions: WorkflowExecution[];
|
||||||
|
loading: boolean;
|
||||||
|
error: string | null;
|
||||||
|
refresh: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches execution history from the backend server via IPC.
|
||||||
|
* The backend server (TASK-007B) exposes a REST API on localhost.
|
||||||
|
*/
|
||||||
|
export function useExecutionHistory(filters: ExecutionFilters): UseExecutionHistoryResult {
|
||||||
|
const [executions, setExecutions] = useState<WorkflowExecution[]>([]);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const fetch = useCallback(async () => {
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const { ipcRenderer } = (window as any).require('electron');
|
||||||
|
|
||||||
|
const query: ExecutionQuery = {
|
||||||
|
status: filters.status,
|
||||||
|
startedAfter: filters.startDate?.getTime(),
|
||||||
|
startedBefore: filters.endDate?.getTime(),
|
||||||
|
limit: 100,
|
||||||
|
orderBy: 'started_at',
|
||||||
|
orderDir: 'desc'
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = await ipcRenderer.invoke('execution-history:list', query);
|
||||||
|
|
||||||
|
if (result && result.error) {
|
||||||
|
setError(result.error);
|
||||||
|
setExecutions([]);
|
||||||
|
} else {
|
||||||
|
setExecutions(result || []);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
setError(err instanceof Error ? err.message : 'Failed to load execution history');
|
||||||
|
setExecutions([]);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}, [filters.status, filters.startDate, filters.endDate]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetch();
|
||||||
|
}, [fetch]);
|
||||||
|
|
||||||
|
return { executions, loading, error, refresh: fetch };
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export { ExecutionHistoryPanel } from './ExecutionHistoryPanel';
|
||||||
127
packages/noodl-editor/tests/cloud/ExecutionHistoryPanel.test.ts
Normal file
127
packages/noodl-editor/tests/cloud/ExecutionHistoryPanel.test.ts
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
/**
|
||||||
|
* CF11-006: Execution History Panel — Unit Tests
|
||||||
|
*
|
||||||
|
* Tests the pure utility functions used by the ExecutionHistoryPanel hooks.
|
||||||
|
* Hook integration tests require a running Electron renderer — covered by manual testing.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ─── Utility functions under test (inlined to avoid React/IPC deps in test env) ───
|
||||||
|
|
||||||
|
function formatRelativeTime(timestamp: number): string {
|
||||||
|
const diff = Date.now() - timestamp;
|
||||||
|
const seconds = Math.floor(diff / 1000);
|
||||||
|
if (seconds < 60) return `${seconds}s ago`;
|
||||||
|
const minutes = Math.floor(seconds / 60);
|
||||||
|
if (minutes < 60) return `${minutes}m ago`;
|
||||||
|
const hours = Math.floor(minutes / 60);
|
||||||
|
if (hours < 24) return `${hours}h ago`;
|
||||||
|
return new Date(timestamp).toLocaleDateString();
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDuration(ms?: number): string {
|
||||||
|
if (ms === undefined || ms === null) return '—';
|
||||||
|
if (ms < 1000) return `${ms}ms`;
|
||||||
|
return `${(ms / 1000).toFixed(1)}s`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildExecutionQuery(filters: {
|
||||||
|
status?: string;
|
||||||
|
startDate?: Date;
|
||||||
|
endDate?: Date;
|
||||||
|
}) {
|
||||||
|
return {
|
||||||
|
status: filters.status,
|
||||||
|
startedAfter: filters.startDate?.getTime(),
|
||||||
|
startedBefore: filters.endDate?.getTime(),
|
||||||
|
limit: 100,
|
||||||
|
orderBy: 'started_at',
|
||||||
|
orderDir: 'desc'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── Tests ───
|
||||||
|
|
||||||
|
describe('ExecutionHistoryPanel — formatDuration', () => {
|
||||||
|
it('returns em-dash for undefined', () => {
|
||||||
|
expect(formatDuration(undefined)).toBe('—');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns em-dash for null', () => {
|
||||||
|
expect(formatDuration(null as unknown as number)).toBe('—');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('formats sub-second durations as ms', () => {
|
||||||
|
expect(formatDuration(0)).toBe('0ms');
|
||||||
|
expect(formatDuration(500)).toBe('500ms');
|
||||||
|
expect(formatDuration(999)).toBe('999ms');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('formats 1000ms as 1.0s', () => {
|
||||||
|
expect(formatDuration(1000)).toBe('1.0s');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('formats multi-second durations', () => {
|
||||||
|
expect(formatDuration(2500)).toBe('2.5s');
|
||||||
|
expect(formatDuration(10000)).toBe('10.0s');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('ExecutionHistoryPanel — formatRelativeTime', () => {
|
||||||
|
it('formats recent timestamps as seconds ago', () => {
|
||||||
|
const result = formatRelativeTime(Date.now() - 30000); // 30s ago
|
||||||
|
expect(result).toBe('30s ago');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('formats timestamps as minutes ago', () => {
|
||||||
|
const result = formatRelativeTime(Date.now() - 5 * 60 * 1000); // 5m ago
|
||||||
|
expect(result).toBe('5m ago');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('formats timestamps as hours ago', () => {
|
||||||
|
const result = formatRelativeTime(Date.now() - 3 * 60 * 60 * 1000); // 3h ago
|
||||||
|
expect(result).toBe('3h ago');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('formats old timestamps as locale date string', () => {
|
||||||
|
const oldDate = new Date('2025-01-01').getTime();
|
||||||
|
const result = formatRelativeTime(oldDate);
|
||||||
|
// Should be a date string, not "Xh ago"
|
||||||
|
expect(result).not.toContain('ago');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('ExecutionHistoryPanel — buildExecutionQuery', () => {
|
||||||
|
it('builds query with no filters', () => {
|
||||||
|
const query = buildExecutionQuery({});
|
||||||
|
expect(query.status).toBeUndefined();
|
||||||
|
expect(query.startedAfter).toBeUndefined();
|
||||||
|
expect(query.startedBefore).toBeUndefined();
|
||||||
|
expect(query.limit).toBe(100);
|
||||||
|
expect(query.orderBy).toBe('started_at');
|
||||||
|
expect(query.orderDir).toBe('desc');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('includes status filter when provided', () => {
|
||||||
|
const query = buildExecutionQuery({ status: 'error' });
|
||||||
|
expect(query.status).toBe('error');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('converts Date objects to timestamps', () => {
|
||||||
|
const startDate = new Date('2025-01-01T00:00:00Z');
|
||||||
|
const endDate = new Date('2025-12-31T23:59:59Z');
|
||||||
|
const query = buildExecutionQuery({ startDate, endDate });
|
||||||
|
expect(query.startedAfter).toBe(startDate.getTime());
|
||||||
|
expect(query.startedBefore).toBe(endDate.getTime());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('always orders by started_at descending', () => {
|
||||||
|
const query = buildExecutionQuery({ status: 'success' });
|
||||||
|
expect(query.orderBy).toBe('started_at');
|
||||||
|
expect(query.orderDir).toBe('desc');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('always limits to 100 results', () => {
|
||||||
|
const query = buildExecutionQuery({});
|
||||||
|
expect(query.limit).toBe(100);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1 +1,2 @@
|
|||||||
export * from './cloudformation';
|
export * from './cloudformation';
|
||||||
|
import './ExecutionHistoryPanel.test';
|
||||||
|
|||||||
Reference in New Issue
Block a user