mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-17 08:20:12 +00:00
feat: show long step durations in hours and minutes on run timelines (#12437)
* feat: show long step durations in hours and minutes on run timelines Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: keep the wait label on a queued step with no execution bar yet Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
df0e5cf4c2
commit
c6955ed445
@@ -25,7 +25,13 @@
|
||||
import Tabs from './common/tabs/Tabs.svelte'
|
||||
import { type DurationStatus, type FlowStatusViewerContext, type GraphModuleState } from './graph'
|
||||
import ModuleStatus from './ModuleStatus.svelte'
|
||||
import { clone, isScriptPreview, msToSec, readFieldsRecursively, truncateRev } from '$lib/utils'
|
||||
import {
|
||||
clone,
|
||||
isScriptPreview,
|
||||
msToCompactDuration,
|
||||
readFieldsRecursively,
|
||||
truncateRev
|
||||
} from '$lib/utils'
|
||||
import { downloadViaClient, shouldDownloadViaClient } from '$lib/utils/downloadFile'
|
||||
import { appendViewToken } from '$lib/viewToken'
|
||||
import JobArgs from './JobArgs.svelte'
|
||||
@@ -2289,7 +2295,7 @@
|
||||
{#if node.duration_ms}
|
||||
<Badge>
|
||||
<Hourglass class="mr-2" size={10} />
|
||||
{msToSec(node.duration_ms)} s
|
||||
{msToCompactDuration(node.duration_ms)}
|
||||
</Badge>
|
||||
{/if}
|
||||
{#if node.job_id && !isReplay}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { displayDate, msToSec } from '$lib/utils'
|
||||
import { displayDate, msToCompactDuration } from '$lib/utils'
|
||||
import { Loader2 } from 'lucide-svelte'
|
||||
import TimelineBar from './TimelineBar.svelte'
|
||||
import WaitTimeWarning from './common/waitTimeWarning/WaitTimeWarning.svelte'
|
||||
@@ -167,10 +167,10 @@
|
||||
</div>
|
||||
{/if}
|
||||
{#if max && min}
|
||||
<span class="font-mono">{msToSec(max - min, 1)}s</span>
|
||||
<span class="font-mono">{msToCompactDuration(max - min, 1)}</span>
|
||||
{/if}
|
||||
{#if !max && min}{#if now}
|
||||
<span class="font-mono">{msToSec(now - min, 1)}s</span>
|
||||
<span class="font-mono">{msToCompactDuration(now - min, 1)}</span>
|
||||
{/if}<Loader2 size={14} class="animate-spin" />{/if}
|
||||
</div>
|
||||
</div>
|
||||
@@ -213,7 +213,7 @@
|
||||
</span>
|
||||
{:else if compact && subItems?.[0]?.duration_ms != undefined}
|
||||
<span class="text-2xs text-secondary font-mono">
|
||||
{msToSec(subItems[0].duration_ms, 1)}s
|
||||
{msToCompactDuration(subItems[0].duration_ms, 1)}
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -272,7 +272,7 @@
|
||||
{compact}
|
||||
concat
|
||||
colorClass="bg-purple-400/80"
|
||||
tooltip={`Waiting for approval — ${msToSec(aw.len, 1)}s`}
|
||||
tooltip={`Waiting for approval — ${msToCompactDuration(aw.len, 1)}`}
|
||||
started_at={aw.start}
|
||||
len={aw.len}
|
||||
running={aw.running}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { msToSec } from '$lib/utils'
|
||||
import { msToCompactDuration, msToReadableTime } from '$lib/utils'
|
||||
import { ExternalLink } from 'lucide-svelte'
|
||||
import Popover from './Popover.svelte'
|
||||
|
||||
@@ -73,15 +73,17 @@
|
||||
{@const narrow = len / total < 0.09}
|
||||
{@const endPos =
|
||||
started_at != undefined && min != undefined ? (started_at - min + len) / total : 1}
|
||||
{@const nearStart = endPos < 0.15}
|
||||
<span
|
||||
class={narrow
|
||||
? nearStart
|
||||
? 'absolute left-full ml-2 text-primary font-mono'
|
||||
: 'absolute right-full mr-1 text-primary font-mono'
|
||||
: 'font-mono'}
|
||||
>{#if len}{msToSec(len, 1)}s{/if}</span
|
||||
>
|
||||
<!-- Once the job has started, a narrow wait bar is directly followed by its execution bar, whose label would collide. -->
|
||||
{#if !(narrow && gray && !running)}
|
||||
<span
|
||||
title={msToReadableTime(len, 1)}
|
||||
class={narrow
|
||||
? endPos > 0.85
|
||||
? 'absolute right-full mr-1 text-primary font-mono'
|
||||
: 'absolute left-full ml-2 text-primary font-mono'
|
||||
: 'font-mono truncate px-1'}>{msToCompactDuration(len, 1)}</span
|
||||
>
|
||||
{/if}
|
||||
{/if}
|
||||
</Popover>
|
||||
{/if}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { displayDate, msToSec, emptyString } from '$lib/utils'
|
||||
import { displayDate, msToCompactDuration, emptyString } from '$lib/utils'
|
||||
import { onDestroy } from 'svelte'
|
||||
import { getDbClockNow } from '$lib/forLater'
|
||||
import { ChevronDown, ChevronRight, Loader2, Moon, ShieldCheck } from 'lucide-svelte'
|
||||
@@ -179,13 +179,13 @@
|
||||
<div class="col-span-11 pt-1 px-2 flex text-2xs text-secondary justify-between">
|
||||
<div>{min ? displayDate(new Date(min), true) : ''}</div>
|
||||
{#if max && min}
|
||||
<div class="hidden lg:block">{msToSec(max - min)}s</div>
|
||||
<div class="hidden lg:block">{msToCompactDuration(max - min, 1)}</div>
|
||||
{/if}
|
||||
<div class="flex gap-1 items-center font-mono">
|
||||
{max ? displayDate(new Date(max), true) : ''}
|
||||
{#if !max && min}
|
||||
{#if now}
|
||||
{msToSec(now - min, 3)}s
|
||||
{msToCompactDuration(now - min, 1)}
|
||||
{/if}
|
||||
<Loader2 size={14} class="animate-spin" />
|
||||
{/if}
|
||||
@@ -264,7 +264,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
{:else}
|
||||
<span class="text-tertiary">{msToSec(v.duration_ms ?? 0)}s</span>
|
||||
<span class="text-tertiary">{msToCompactDuration(v.duration_ms ?? 0)}</span>
|
||||
{/if}
|
||||
</div>
|
||||
{#if canApprove && selfApprovalDisabled && actingUser?.is_admin}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import FlowModuleSchemaItem from './FlowModuleSchemaItem.svelte'
|
||||
import FlowModuleIcon from '../FlowModuleIcon.svelte'
|
||||
import { prettyLanguage } from '$lib/common'
|
||||
import { msToSec, type Item } from '$lib/utils'
|
||||
import { msToCompactDuration, type Item } from '$lib/utils'
|
||||
import FlowJobsMenu from './FlowJobsMenu.svelte'
|
||||
import { type OnSelectedIteration } from '$lib/components/graph/graphBuilder.svelte'
|
||||
import { describeStepSettings } from '$lib/components/flows/flowStepSettings'
|
||||
@@ -150,7 +150,7 @@
|
||||
editMode ? 'text-gray-400 dark:text-gray-500 text-2xs font-normal mr-2 right-16' : ''
|
||||
)}
|
||||
>
|
||||
{msToSec(duration_ms)}s
|
||||
{msToCompactDuration(duration_ms)}
|
||||
</div>
|
||||
{/if}
|
||||
{#if sideAnnotation && sideAnnotation != ''}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import Tooltip from '$lib/components/meltComponents/Tooltip.svelte'
|
||||
import type { FailureModuleN } from '../../graphBuilder.svelte'
|
||||
import { getNodeColorClasses, NODE } from '$lib/components/graph'
|
||||
import { msToSec } from '$lib/utils'
|
||||
import { msToCompactDuration } from '$lib/utils'
|
||||
import { getFlowRunStatusContext } from '../../flowRunStatus.svelte'
|
||||
|
||||
interface Props {
|
||||
@@ -24,7 +24,7 @@
|
||||
<div
|
||||
class="absolute z-5 right-0 -top-4 mr-2 center-center text-2xs font-normal text-gray-400 dark:text-gray-500"
|
||||
>
|
||||
{msToSec(state.duration_ms)}s
|
||||
{msToCompactDuration(state.duration_ms)}
|
||||
</div>
|
||||
{/if}
|
||||
<div
|
||||
|
||||
@@ -10,9 +10,20 @@ import {
|
||||
getQueryStmtCountHeuristic,
|
||||
isJobResolvable,
|
||||
parseDbInputFromAssetSyntax,
|
||||
apiErrorMessage
|
||||
apiErrorMessage,
|
||||
msToCompactDuration
|
||||
} from './utils'
|
||||
|
||||
describe('msToCompactDuration', () => {
|
||||
it('keeps the two largest units and drops a zero second unit', () => {
|
||||
expect(msToCompactDuration(12_345, 1)).toBe('12.3s')
|
||||
expect(msToCompactDuration(65_000)).toBe('1m 5s')
|
||||
expect(msToCompactDuration(3 * 3_600_000 + 12 * 60_000 + 59_000)).toBe('3h 12m')
|
||||
expect(msToCompactDuration(2 * 3_600_000)).toBe('2h')
|
||||
expect(msToCompactDuration(26 * 3_600_000 + 5 * 60_000)).toBe('1d 2h')
|
||||
})
|
||||
})
|
||||
|
||||
// Mirrors the backend invariant that only failed or canceled rows can carry a resolution;
|
||||
// offering the action anywhere else would send ids the API then silently skips.
|
||||
describe('isJobResolvable', () => {
|
||||
|
||||
@@ -252,6 +252,29 @@ export function msToReadableTime(ms: number | undefined, maximumFractionDigits?:
|
||||
}
|
||||
}
|
||||
|
||||
/** A duration in its two largest units (`12.3s`, `4m 5s`, `3h 12m`, `2d 3h`), short enough for a
|
||||
* label beside a bar; use msToReadableTime where the exact value is wanted. */
|
||||
export function msToCompactDuration(
|
||||
ms: number | undefined,
|
||||
maximumFractionDigits?: number
|
||||
): string {
|
||||
if (ms === undefined) return '?'
|
||||
if (ms < 60_000) return `${msToSec(ms, maximumFractionDigits)}s`
|
||||
|
||||
const seconds = Math.floor(ms / 1000)
|
||||
const minutes = Math.floor(seconds / 60)
|
||||
const hours = Math.floor(minutes / 60)
|
||||
const days = Math.floor(hours / 24)
|
||||
|
||||
const [major, minor] =
|
||||
days > 0
|
||||
? [`${days}d`, hours % 24 ? `${hours % 24}h` : '']
|
||||
: hours > 0
|
||||
? [`${hours}h`, minutes % 60 ? `${minutes % 60}m` : '']
|
||||
: [`${minutes}m`, seconds % 60 ? `${seconds % 60}s` : '']
|
||||
return minor ? `${major} ${minor}` : major
|
||||
}
|
||||
|
||||
export function msToReadableTimeShort(
|
||||
ms: number | undefined,
|
||||
maximumFractionDigits?: number
|
||||
|
||||
Reference in New Issue
Block a user