mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-31 19:45:15 +02:00
feat(run-details-panel): enhance run details display and error handling
- Improved the layout and readability of the run details panel by restructuring sections and adding collapsible error views. - Introduced a new `RunErrorSection` component to present run-level errors more clearly, allowing users to toggle raw error details. - Updated the handling of run outputs, step results, and artifacts for better user experience. - Refactored duration calculation in `RunRow` to utilize a dedicated `formatDuration` function for consistency. - Added a new `RunStepResult` interface to improve type safety and clarity in handling step results.
This commit is contained in:
parent
cb2e33e083
commit
fade9d1b9d
5 changed files with 268 additions and 44 deletions
19
surfsense_web/lib/automations/run-duration.ts
Normal file
19
surfsense_web/lib/automations/run-duration.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* Format the wall-clock duration between a run/step's start and finish
|
||||
* timestamps into a compact, human-readable label (e.g. `850ms`, `4.2s`,
|
||||
* `1m 30s`). Returns `null` when either bound is missing or the delta is
|
||||
* negative/non-finite, so callers can simply omit the label.
|
||||
*/
|
||||
export function formatDuration(
|
||||
started: string | null | undefined,
|
||||
finished: string | null | undefined
|
||||
): string | null {
|
||||
if (!started || !finished) return null;
|
||||
const ms = new Date(finished).getTime() - new Date(started).getTime();
|
||||
if (!Number.isFinite(ms) || ms < 0) return null;
|
||||
if (ms < 1000) return `${ms}ms`;
|
||||
if (ms < 60_000) return `${(ms / 1000).toFixed(1)}s`;
|
||||
const minutes = Math.floor(ms / 60_000);
|
||||
const seconds = Math.floor((ms % 60_000) / 1000);
|
||||
return `${minutes}m ${seconds}s`;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue