|
10 | 10 | const global = $derived(metrics.current.global) |
11 | 11 | const transactionStatus = $derived(global.transaction_status) |
12 | 12 | const commitProgress = $derived(global.commit_progress) |
| 13 | + const transactionId = $derived(global.transaction_id) |
13 | 14 |
|
14 | 15 | const total = $derived( |
15 | 16 | commitProgress |
|
32 | 33 | ? ((commitProgress.completed + commitProgress.in_progress * inProgressFraction) / total) * 100 |
33 | 34 | : null |
34 | 35 | ) |
| 36 | +
|
| 37 | + // Disable the smooth progress bar transition when the transaction changes so |
| 38 | + // the bar jumps immediately to the new value rather than animating. |
| 39 | + let disableTransition = $state(false) |
| 40 | + let prevTransactionId = transactionId |
| 41 | +
|
| 42 | + $effect(() => { |
| 43 | + const currentId = transactionId |
| 44 | + if (currentId !== prevTransactionId) { |
| 45 | + prevTransactionId = currentId |
| 46 | + disableTransition = true |
| 47 | + requestAnimationFrame(() => { |
| 48 | + disableTransition = false |
| 49 | + }) |
| 50 | + } |
| 51 | + }) |
35 | 52 | </script> |
36 | 53 |
|
37 | 54 | {#if transactionStatus !== 'NoTransaction'} |
38 | 55 | <div class="flex flex-wrap items-center gap-x-8 gap-y-2 {_class}" transition:slide> |
39 | | - <div class="flex w-28 flex-col items-center"> |
| 56 | + <div class="flex w-28 flex-col items-center mr-14"> |
40 | 57 | <div class="text-sm text-nowrap">Transaction status</div> |
41 | | - <div class="pt-2"> |
| 58 | + <div class="pt-2 flex flex-nowrap justify-center items-center gap-2"> |
| 59 | + <div></div> |
42 | 60 | {#if transactionStatus === 'TransactionInProgress'} |
43 | 61 | <div class="pointer-events-none chip bg-tertiary-50-950 uppercase">Started</div> |
44 | 62 | {:else if transactionStatus === 'CommitInProgress'} |
45 | 63 | <div class="pointer-events-none chip bg-warning-200-800 uppercase">Committing</div> |
46 | 64 | {/if} |
| 65 | + <div class="font-dm-mono text-sm w-0 text-nowrap"><span class="select-none">ID:</span>{transactionId}</div> |
47 | 66 | </div> |
48 | 67 | </div> |
49 | 68 |
|
|
66 | 85 | <div class="relative"> |
67 | 86 | <Progress class="h-2" value={combinedPercent} max={100}> |
68 | 87 | <Progress.Track class="bg-surface-600-400"> |
69 | | - <Progress.Range class="bg-yellow-500 duration-2000 ease-linear" /> |
| 88 | + <Progress.Range |
| 89 | + class="bg-yellow-500 {disableTransition ? 'duration-0' : 'duration-2000 ease-linear'}" |
| 90 | + /> |
70 | 91 | </Progress.Track> |
71 | 92 | </Progress> |
72 | 93 | <Progress class="absolute inset-x-0 bottom-0 h-2" value={completedPercent} max={100}> |
73 | 94 | <Progress.Track class="opacity-0"></Progress.Track> |
74 | 95 | <Progress.Range |
75 | | - class="absolute inset-y-0 left-0 bg-success-500 duration-2000 ease-linear" |
| 96 | + class="absolute inset-y-0 left-0 bg-success-500 {disableTransition |
| 97 | + ? 'duration-0' |
| 98 | + : 'duration-2000 ease-linear'}" |
76 | 99 | /> |
77 | 100 | </Progress> |
78 | 101 | </div> |
|
0 commit comments