diff options
| author | Adam Malczewski <[email protected]> | 2026-06-02 14:39:24 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-02 14:39:24 +0900 |
| commit | f0207a7f000257e6c459db7053edbae4d68fcf3f (patch) | |
| tree | 414d3748a0fcda7ff6400729f83b4b64a924ee67 /packages | |
| parent | 2756730aeba633c3cc331500bcfb9a67d85dc892 (diff) | |
| parent | 3f0bfe76ceabd1cb53727f1d9ae84d7494054d7f (diff) | |
| download | dispatch-f0207a7f000257e6c459db7053edbae4d68fcf3f.tar.gz dispatch-f0207a7f000257e6c459db7053edbae4d68fcf3f.zip | |
Merge branch 'dev' into sb/status-bar
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/frontend/src/lib/components/CacheRatePanel.svelte | 7 | ||||
| -rw-r--r-- | packages/frontend/src/lib/components/KeyUsage.svelte | 21 |
2 files changed, 17 insertions, 11 deletions
diff --git a/packages/frontend/src/lib/components/CacheRatePanel.svelte b/packages/frontend/src/lib/components/CacheRatePanel.svelte index c35cbb5..88985a0 100644 --- a/packages/frontend/src/lib/components/CacheRatePanel.svelte +++ b/packages/frontend/src/lib/components/CacheRatePanel.svelte @@ -55,7 +55,7 @@ const lastHitPct = $derived( {#if tabTitle} <span class="badge badge-xs badge-ghost">{tabTitle}</span> {/if} - <span class="badge badge-xs ml-auto">{cacheStats.requests} req</span> + <span class="badge badge-xs ml-auto whitespace-nowrap">{cacheStats.requests} req</span> </div> <!-- Headline cumulative hit rate --> @@ -120,10 +120,5 @@ const lastHitPct = $derived( </div> </div> </div> - - <p class="text-xs text-base-content/40"> - Cache reads cost ~10% of fresh input; writes cost ~25% more. A high hit - rate after the first turn means caching is working. Resets on reload. - </p> {/if} </div> diff --git a/packages/frontend/src/lib/components/KeyUsage.svelte b/packages/frontend/src/lib/components/KeyUsage.svelte index 00d179e..7c0cadc 100644 --- a/packages/frontend/src/lib/components/KeyUsage.svelte +++ b/packages/frontend/src/lib/components/KeyUsage.svelte @@ -131,6 +131,17 @@ function progressClass(utilization: number): string { return "progress-success"; } +// Pace-aware coloring for cycle bars that show a "time dot" (elapsed % of the +// reset window). Red once usage hits 90%, otherwise green when usage is at or +// behind the dot and orange when it has run ahead of it. Falls back to the +// plain threshold coloring when no dot is present (elapsedPct < 0). +function pacedProgressClass(percentUsed: number, elapsedPct: number): string { + if (percentUsed >= 90) return "progress-error"; + if (elapsedPct < 0) return progressClass(percentUsed / 100); + if (percentUsed <= elapsedPct) return "progress-success"; + return "progress-warning"; +} + function formatDate(ts: number): string { const diff = ts - Date.now(); const days = Math.floor(diff / 86400000); @@ -245,7 +256,7 @@ function hasBucketData(bucket: UsageBucket | undefined): boolean { <span class="text-xs font-mono">{p}%</span> </div> <div class="relative w-full h-2"> - <progress class="progress w-full h-2 {progressClass(u)} absolute inset-0" value={p} max="100"></progress> + <progress class="progress w-full h-2 {pacedProgressClass(p, tp)} absolute inset-0" value={p} max="100"></progress> {#if tp >= 0} <div class="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-2 h-2 rounded-full border border-info bg-info-content pointer-events-none box-border" style="left: {tp}%"></div> {/if} @@ -266,7 +277,7 @@ function hasBucketData(bucket: UsageBucket | undefined): boolean { <span class="text-xs font-mono">{p}%</span> </div> <div class="relative w-full h-2"> - <progress class="progress w-full h-2 {progressClass(u)} absolute inset-0" value={p} max="100"></progress> + <progress class="progress w-full h-2 {pacedProgressClass(p, tp)} absolute inset-0" value={p} max="100"></progress> {#if tp >= 0} <div class="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-2 h-2 rounded-full border border-info bg-info-content pointer-events-none box-border" style="left: {tp}%"></div> {/if} @@ -330,7 +341,7 @@ function hasBucketData(bucket: UsageBucket | undefined): boolean { <span class="text-xs font-mono">{p}%</span> </div> <div class="relative w-full h-2"> - <progress class="progress w-full h-2 {progressClass(u)} absolute inset-0" value={p} max="100"></progress> + <progress class="progress w-full h-2 {pacedProgressClass(p, tp)} absolute inset-0" value={p} max="100"></progress> {#if tp >= 0} <div class="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-2 h-2 rounded-full border border-info bg-info-content pointer-events-none box-border" style="left: {tp}%"></div> {/if} @@ -351,7 +362,7 @@ function hasBucketData(bucket: UsageBucket | undefined): boolean { <span class="text-xs font-mono">{p}%</span> </div> <div class="relative w-full h-2"> - <progress class="progress w-full h-2 {progressClass(u)} absolute inset-0" value={p} max="100"></progress> + <progress class="progress w-full h-2 {pacedProgressClass(p, tp)} absolute inset-0" value={p} max="100"></progress> {#if tp >= 0} <div class="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-2 h-2 rounded-full border border-info bg-info-content pointer-events-none box-border" style="left: {tp}%"></div> {/if} @@ -372,7 +383,7 @@ function hasBucketData(bucket: UsageBucket | undefined): boolean { <span class="text-xs font-mono">{p}%</span> </div> <div class="relative w-full h-2"> - <progress class="progress w-full h-2 {progressClass(u)} absolute inset-0" value={p} max="100"></progress> + <progress class="progress w-full h-2 {pacedProgressClass(p, tp)} absolute inset-0" value={p} max="100"></progress> {#if tp >= 0} <div class="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-2 h-2 rounded-full border border-info bg-info-content pointer-events-none box-border" style="left: {tp}%"></div> {/if} |
