feat(windows): port the Capacity Dock to the macOS design

The Windows dock now mirrors CapacityDockView.swift at the mac's 0.6 default
scale: the graphite gradient surface with the concave edge flare, a provider
glyph inside a recessed ring, severity colours (green, yellow from 50, orange
from 75, red from 90) on ring, percent and bars, warm off-white text, and the
tailed detail bubble with the mac typography. This also settles the open
severity-colour question in favour of the mac behaviour.

Interaction follows CapacityDockController and CapacityDockInteractionState:
the resting rail shows the preferred provider; hovering expands it after 80 ms
and collapses 180 ms after leaving; hovering a row shows its bubble after
180 ms and dismisses it 240 ms after the row unless the pointer is on the
bubble; clicking a row pins the rail and makes that provider the preferred
one, persisted in windows-dock.json; Escape dismisses; right-click opens a
native menu with Refresh and Hide Capacity Dock.

One transparent window hosts both rail and bubble. dock.rs owns the geometry
as a pure layout function with unit tests, applies size and position in a
single SetWindowPos so the rail never flashes between two updates, and
returns window-relative frames the page paints into after measuring the
bubble's natural height. Every window metric stays a whole pixel.

Out of scope for v1, as before: dragging, edge choice and scale.
This commit is contained in:
iamtoruk 2026-09-01 15:30:12 -07:00
parent 004d736f8d
commit a80bee7965
6 changed files with 1282 additions and 240 deletions

View file

@ -1,24 +1,185 @@
//! The Capacity Dock: a slim quota rail docked to the right screen edge, the Windows twin of
//! the macOS Capacity Dock. The window is created on demand and closed again when the dock is
//! switched off, so a disabled dock leaves no webview resident.
//!
//! One window hosts both the rail and the hover bubble. This module owns the geometry the mac
//! app splits across CapacityDockPlacement and CapacityDockController: it turns a row count,
//! the hover state and the measured bubble height into a window rectangle plus the
//! window-relative frames the page paints into.
use std::fs;
use std::path::PathBuf;
use anyhow::Result;
use serde::{Deserialize, Serialize};
use tauri::{AppHandle, Manager, WebviewUrl, WebviewWindowBuilder};
pub const DOCK_LABEL: &str = "dock";
/// Whole-point metrics at the macOS dock's default 0.6 scale: its 88pt rail lands on 53, which
/// `layout.activityBarWidth` in tokens.json already rounds to 56 for this frontend. Fractional
/// sizes cost the mac app 5-7% idle CPU by making the hosting view re-lay itself out forever,
/// so every value here stays an integer.
const RAIL_WIDTH: f64 = 56.0;
const ROW_HEIGHT: f64 = 50.0;
const ROW_SPACING: f64 = 7.0;
const RAIL_PAD: f64 = 12.0;
const DETAIL_WIDTH: f64 = 300.0;
/// Whole-point metrics at the macOS dock's default 0.6 scale, the same numbers as
/// `src/dockGeometry.ts`. Fractional sizes cost the mac app 5-7% idle CPU by making the
/// hosting view re-lay itself out forever, so every value here stays an integer.
const RAIL_WIDTH: i32 = 53;
const ROW_HEIGHT: i32 = 50;
const ROW_SPACING: i32 = 7;
/// 12 of padding plus 60% of the 31 shoulder depth, so content never crowds the concave flare.
const RAIL_ALONG_PAD: i32 = 31;
const DETAIL_WIDTH: i32 = 315;
const DETAIL_GAP: i32 = 10;
const DETAIL_INSET: i32 = 8;
/// The rail's resting top edge sits this far below the top of the work area.
const DEFAULT_TOP_OFFSET: i32 = 156;
const VERTICAL_INSET: i32 = 12;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize)]
pub struct Rect {
pub x: i32,
pub y: i32,
pub w: i32,
pub h: i32,
}
impl Rect {
fn right(&self) -> i32 {
self.x + self.w
}
fn bottom(&self) -> i32 {
self.y + self.h
}
fn union(&self, other: &Rect) -> Rect {
let x = self.x.min(other.x);
let y = self.y.min(other.y);
Rect {
x,
y,
w: self.right().max(other.right()) - x,
h: self.bottom().max(other.bottom()) - y,
}
}
fn offset(&self, dx: i32, dy: i32) -> Rect {
Rect {
x: self.x + dx,
y: self.y + dy,
..*self
}
}
}
#[derive(Clone, Copy, Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DetailRequest {
/// Index of the hovered row, counted from the top of the rail.
pub row: u32,
pub height: i32,
}
#[derive(Clone, Copy, Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LayoutRequest {
pub rows: u32,
pub expanded: bool,
pub detail: Option<DetailRequest>,
}
/// Which end of the rail stays put while it grows: the resting rail keeps its top and grows
/// downward unless there is more room above it.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum Anchor {
Start,
End,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DetailFrame {
pub x: i32,
pub y: i32,
pub w: i32,
pub h: i32,
/// Where the tail points, in the bubble's own coordinates.
pub tail_y: i32,
}
/// Everything the page needs to paint: frames are relative to the window's top-left corner.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DockFrame {
#[serde(skip)]
pub window: Rect,
pub rail: Rect,
pub anchor: Anchor,
pub detail: Option<DetailFrame>,
}
fn rail_height(rows: u32) -> i32 {
let rows = rows.max(1) as i32;
RAIL_ALONG_PAD * 2 + rows * ROW_HEIGHT + (rows - 1) * ROW_SPACING
}
/// Pure layout in logical pixels. `area` is the monitor work area.
pub fn layout(area: Rect, request: &LayoutRequest) -> DockFrame {
let rest_h = rail_height(1);
let rail_h = if request.expanded {
rail_height(request.rows)
} else {
rest_h
};
let lowest_top = area.y + VERTICAL_INSET;
let clamp_top = |top: i32, h: i32| top.clamp(lowest_top, (area.bottom() - VERTICAL_INSET - h).max(lowest_top));
let rest_top = clamp_top(area.y + DEFAULT_TOP_OFFSET, rest_h);
let room_below = area.bottom() - (rest_top + rest_h);
let room_above = rest_top - area.y;
let anchor = if room_below >= room_above {
Anchor::Start
} else {
Anchor::End
};
let rail_top = match anchor {
Anchor::Start => clamp_top(rest_top, rail_h),
Anchor::End => clamp_top(rest_top + rest_h - rail_h, rail_h),
};
let rail = Rect {
x: area.right() - RAIL_WIDTH,
y: rail_top,
w: RAIL_WIDTH,
h: rail_h,
};
let detail = request.detail.map(|d| {
let w = DETAIL_WIDTH.min((area.w - DETAIL_INSET * 2).max(0));
let h = d.height.max(1).min((area.h - DETAIL_INSET * 2).max(1));
let row_mid = rail.y + RAIL_ALONG_PAD + d.row as i32 * (ROW_HEIGHT + ROW_SPACING) + ROW_HEIGHT / 2;
let min_x = area.x + DETAIL_INSET;
let max_x = (area.right() - DETAIL_INSET - w).max(min_x);
let min_y = area.y + DETAIL_INSET;
let max_y = (area.bottom() - DETAIL_INSET - h).max(min_y);
let x = (rail.x - DETAIL_GAP - w).clamp(min_x, max_x);
let y = (row_mid - h / 2).clamp(min_y, max_y);
(Rect { x, y, w, h }, row_mid - y)
});
let window = match &detail {
Some((rect, _)) => rail.union(rect),
None => rail,
};
DockFrame {
window,
rail: rail.offset(-window.x, -window.y),
anchor,
detail: detail.map(|(rect, tail_y)| {
let local = rect.offset(-window.x, -window.y);
DetailFrame {
x: local.x,
y: local.y,
w: local.w,
h: local.h,
tail_y,
}
}),
}
}
fn state_path() -> PathBuf {
dirs::home_dir()
@ -27,55 +188,104 @@ fn state_path() -> PathBuf {
.join("windows-dock.json")
}
pub fn is_enabled() -> bool {
fn read_state() -> serde_json::Map<String, serde_json::Value> {
fs::read(state_path())
.ok()
.and_then(|bytes| serde_json::from_slice::<serde_json::Value>(&bytes).ok())
.and_then(|value| value.get("enabled").and_then(serde_json::Value::as_bool))
.unwrap_or(false)
.and_then(|value| value.as_object().cloned())
.unwrap_or_default()
}
pub fn set_enabled(enabled: bool) -> Result<()> {
fn write_state(state: &serde_json::Map<String, serde_json::Value>) -> Result<()> {
let path = state_path();
if let Some(parent) = path.parent() {
fs::create_dir_all(parent)?;
}
let body = serde_json::to_vec_pretty(&serde_json::json!({ "enabled": enabled }))?;
fs::write(&path, body)?;
fs::write(&path, serde_json::to_vec_pretty(state)?)?;
Ok(())
}
fn logical_height(rows: u32) -> f64 {
let rows = rows.max(1) as f64;
RAIL_PAD * 2.0 + rows * ROW_HEIGHT + (rows - 1.0) * ROW_SPACING
pub fn is_enabled() -> bool {
read_state()
.get("enabled")
.and_then(serde_json::Value::as_bool)
.unwrap_or(false)
}
/// Right edge, vertically centred, sized to the provider count. Expanding keeps the right edge
/// flush and grows leftwards, so the rail never moves under the pointer.
pub fn apply_layout(window: &tauri::WebviewWindow, rows: u32, expanded: bool) {
let Ok(Some(monitor)) = window.primary_monitor() else {
return;
};
let scale = monitor.scale_factor();
let width = if expanded {
RAIL_WIDTH + DETAIL_WIDTH
} else {
RAIL_WIDTH
};
let w = (width * scale).round() as i32;
let h = (logical_height(rows) * scale).round() as i32;
pub fn set_enabled(enabled: bool) -> Result<()> {
let mut state = read_state();
state.insert("enabled".into(), serde_json::Value::Bool(enabled));
write_state(&state)
}
/// The provider the resting rail shows. A click on another row makes it the preferred one,
/// as on the mac.
pub fn preferred_provider() -> Option<String> {
read_state()
.get("preferred")
.and_then(serde_json::Value::as_str)
.map(str::to_owned)
}
pub fn set_preferred_provider(id: &str) -> Result<()> {
let mut state = read_state();
state.insert("preferred".into(), serde_json::Value::String(id.to_owned()));
write_state(&state)
}
/// Sizes and moves the window in one step and returns the frames the page paints into.
pub fn apply_layout(window: &tauri::WebviewWindow, request: &LayoutRequest) -> Option<DockFrame> {
let monitor = window.primary_monitor().ok().flatten()?;
let scale = monitor.scale_factor();
let area = monitor.work_area();
let x = area.position.x + area.size.width as i32 - w;
let y = area.position.y + ((area.size.height as i32 - h) / 2).max(0);
let logical = |v: i32| (v as f64 / scale).round() as i32;
let area = Rect {
x: logical(area.position.x),
y: logical(area.position.y),
w: logical(area.size.width as i32),
h: logical(area.size.height as i32),
};
let frame = layout(area, request);
let physical = |v: i32| (v as f64 * scale).round() as i32;
let target = Rect {
x: physical(frame.window.x),
y: physical(frame.window.y),
w: physical(frame.window.w).max(1),
h: physical(frame.window.h).max(1),
};
#[cfg(debug_assertions)]
eprintln!(
"codeburn dock: scale={scale} work_area={},{} {}x{} -> pos {x},{y} size {w}x{h}",
area.position.x, area.position.y, area.size.width, area.size.height
"codeburn dock: scale={scale} work_area={},{} {}x{} -> pos {},{} size {}x{}",
area.x, area.y, area.w, area.h, target.x, target.y, target.w, target.h
);
let _ = window.set_size(tauri::PhysicalSize::new(w.max(1) as u32, h.max(1) as u32));
let _ = window.set_position(tauri::PhysicalPosition::new(x, y));
move_and_resize(window, target);
Some(frame)
}
/// Size and position change together: two separate calls repaint twice, and between them the
/// rail would flash at the wrong offset inside the window.
#[cfg(target_os = "windows")]
fn move_and_resize(window: &tauri::WebviewWindow, target: Rect) {
use windows_sys::Win32::UI::WindowsAndMessaging::{SetWindowPos, SWP_NOACTIVATE, SWP_NOZORDER};
let Ok(hwnd) = window.hwnd() else { return };
unsafe {
SetWindowPos(
hwnd.0 as _,
std::ptr::null_mut(),
target.x,
target.y,
target.w,
target.h,
SWP_NOZORDER | SWP_NOACTIVATE,
);
}
}
#[cfg(not(target_os = "windows"))]
fn move_and_resize(window: &tauri::WebviewWindow, target: Rect) {
let _ = window.set_size(tauri::PhysicalSize::new(target.w as u32, target.h as u32));
let _ = window.set_position(tauri::PhysicalPosition::new(target.x, target.y));
}
pub fn show(app: &AppHandle) -> tauri::Result<()> {
@ -86,7 +296,7 @@ pub fn show(app: &AppHandle) -> tauri::Result<()> {
let builder = WebviewWindowBuilder::new(app, DOCK_LABEL, WebviewUrl::default())
.title("CodeBurn Capacity Dock")
.inner_size(RAIL_WIDTH, logical_height(1))
.inner_size(RAIL_WIDTH as f64, rail_height(1) as f64)
.decorations(false)
.resizable(false)
.always_on_top(true)
@ -95,14 +305,21 @@ pub fn show(app: &AppHandle) -> tauri::Result<()> {
.shadow(false)
.visible(false);
// The page draws its own rounded card, so the window behind it has to be see-through.
// The page draws its own card shapes, so the window behind them has to be see-through.
// `transparent` is only compiled in off macOS, where it needs the private-API feature.
#[cfg(not(target_os = "macos"))]
let builder = builder.transparent(true);
let window = builder.build()?;
apply_layout(&window, 1, false);
apply_layout(
&window,
&LayoutRequest {
rows: 1,
expanded: false,
detail: None,
},
);
window.show()?;
#[cfg(debug_assertions)]
{
@ -121,3 +338,78 @@ pub fn hide(app: &AppHandle) {
let _ = window.close();
}
}
/// The rail's right-click menu, the mac dock's context menu minus the edge choices v1 does
/// not offer. Menu events arrive in `lib.rs` under the `dock_` ids.
pub fn popup_context_menu(app: &AppHandle) -> tauri::Result<()> {
use tauri::menu::{ContextMenu, Menu, MenuItem};
let Some(window) = app.get_webview_window(DOCK_LABEL) else {
return Ok(());
};
let refresh = MenuItem::with_id(app, "dock_refresh", "Refresh", true, None::<&str>)?;
let hide = MenuItem::with_id(app, "dock_hide", "Hide Capacity Dock", true, None::<&str>)?;
let menu = Menu::with_items(app, &[&refresh, &hide])?;
menu.popup(window.as_ref().window())
}
#[cfg(test)]
mod tests {
use super::*;
const AREA: Rect = Rect { x: 0, y: 0, w: 1600, h: 852 };
fn request(rows: u32, expanded: bool, detail: Option<DetailRequest>) -> LayoutRequest {
LayoutRequest { rows, expanded, detail }
}
#[test]
fn resting_rail_hugs_the_right_edge_below_the_default_offset() {
let frame = layout(AREA, &request(1, false, None));
assert_eq!(frame.window, Rect { x: 1600 - RAIL_WIDTH, y: 156, w: RAIL_WIDTH, h: 112 });
assert_eq!(frame.rail, Rect { x: 0, y: 0, w: RAIL_WIDTH, h: 112 });
assert_eq!(frame.anchor, Anchor::Start);
assert!(frame.detail.is_none());
}
#[test]
fn expansion_keeps_the_top_and_grows_downward() {
let rest = layout(AREA, &request(1, false, None));
let expanded = layout(AREA, &request(3, true, None));
assert_eq!(expanded.window.y, rest.window.y);
assert_eq!(expanded.window.h, 31 * 2 + 3 * 50 + 2 * 7);
}
#[test]
fn a_short_work_area_anchors_at_the_end_and_grows_upward() {
let area = Rect { x: 0, y: 0, w: 1280, h: 400 };
let rest = layout(area, &request(1, false, None));
let expanded = layout(area, &request(3, true, None));
assert_eq!(rest.anchor, Anchor::End);
assert_eq!(expanded.window.bottom(), rest.window.bottom());
assert!(expanded.window.y >= area.y + VERTICAL_INSET);
// A rail taller than the room above it is pushed down rather than off the screen.
let oversized = layout(area, &request(6, true, None));
assert_eq!(oversized.window.y, area.y + VERTICAL_INSET);
}
#[test]
fn detail_sits_left_of_the_rail_centred_on_its_row() {
let frame = layout(AREA, &request(2, true, Some(DetailRequest { row: 1, height: 160 })));
let detail = frame.detail.expect("detail frame");
let rail_x = 1600 - RAIL_WIDTH;
assert_eq!(frame.window.x, rail_x - DETAIL_GAP - DETAIL_WIDTH);
assert_eq!(detail.w, DETAIL_WIDTH);
assert_eq!(detail.h, 160);
let row_mid = RAIL_ALONG_PAD + (ROW_HEIGHT + ROW_SPACING) + ROW_HEIGHT / 2;
assert_eq!(detail.tail_y, row_mid - (detail.y - frame.rail.y));
assert_eq!(frame.rail.x, DETAIL_WIDTH + DETAIL_GAP);
}
#[test]
fn detail_is_clamped_inside_the_work_area() {
let frame = layout(AREA, &request(1, true, Some(DetailRequest { row: 0, height: 900 })));
let detail = frame.detail.expect("detail frame");
assert_eq!(detail.h, AREA.h - DETAIL_INSET * 2);
assert_eq!(frame.window.y + detail.y, DETAIL_INSET);
}
}

View file

@ -93,6 +93,17 @@ pub fn run() {
Ok(())
})
// The dock's right-click menu pops up from `dock::popup_context_menu`; its items report
// here rather than to the tray handler.
.on_menu_event(|app, event| match event.id.as_ref() {
"dock_refresh" => {
if let Some(window) = app.get_webview_window(dock::DOCK_LABEL) {
let _ = window.emit("codeburn://dock-refresh", ());
}
}
"dock_hide" => set_dock_enabled(app, false),
_ => {}
})
.on_window_event(|window, event| {
// The dock is a persistent rail: it owns its own lifecycle and must survive both
// the hide-on-blur and the hide-on-close that keep the popover alive.
@ -128,6 +139,9 @@ pub fn run() {
commands::set_launch_at_login,
commands::dock_quota,
commands::dock_set_layout,
commands::dock_preferred,
commands::dock_set_preferred,
commands::dock_context_menu,
])
.build(tauri::generate_context!())
.expect("error while running tauri application")
@ -620,12 +634,32 @@ mod commands {
Ok(cli.fetch_quota().await)
}
/// The rail only knows its own provider count and hover state; the geometry that turns
/// those into a window lives in `dock`.
/// The page only knows its row count, hover state and the bubble's measured height; the
/// geometry that turns those into a window lives in `dock`. Synchronous on purpose: the
/// replies must arrive in request order or a stale frame could land after a newer one.
#[tauri::command]
pub fn dock_set_layout(app: AppHandle, rows: u32, expanded: bool) {
if let Some(window) = app.get_webview_window(crate::dock::DOCK_LABEL) {
crate::dock::apply_layout(&window, rows, expanded);
}
pub fn dock_set_layout(
app: AppHandle,
request: crate::dock::LayoutRequest,
) -> Result<crate::dock::DockFrame, String> {
let window = app
.get_webview_window(crate::dock::DOCK_LABEL)
.ok_or_else(|| "dock window is not open".to_string())?;
crate::dock::apply_layout(&window, &request).ok_or_else(|| "no primary monitor".to_string())
}
#[tauri::command]
pub fn dock_preferred() -> Option<String> {
crate::dock::preferred_provider()
}
#[tauri::command]
pub fn dock_set_preferred(id: String) -> Result<(), String> {
crate::dock::set_preferred_provider(&id).map_err(|e| e.to_string())
}
#[tauri::command]
pub fn dock_context_menu(app: AppHandle) -> Result<(), String> {
crate::dock::popup_context_menu(&app).map_err(|e| e.to_string())
}
}

View file

@ -1,14 +1,35 @@
import { useCallback, useEffect, useRef, useState } from 'react'
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
import { invoke } from '@tauri-apps/api/core'
import { listen } from '@tauri-apps/api/event'
import { ProviderGlyph } from './providerIcons'
import {
DETAIL_INSETS,
M,
MOTION,
bezier,
bubblePath,
displayLabel,
headlineWindow,
pct,
railHeight,
railPath,
resetsIn,
severity,
type QuotaWindow,
type Severity,
} from './dockGeometry'
import './dock.css'
const REFRESH_MS = 5 * 60 * 1000
const HOVER_CLOSE_MS = 180
const MAX_DETAIL_ROWS = 5
type QuotaWindow = {
label: string
usedPct: number
resetsAt?: string
const PROVIDER_NAMES: Record<string, string> = {
claude: 'Claude',
codex: 'Codex',
gemini: 'Gemini',
copilot: 'GitHub Copilot',
antigravity: 'Antigravity',
kimi: 'Kimi',
}
type Provider = {
@ -25,105 +46,238 @@ type DockQuota =
| { state: 'cliOutdated' }
| { state: 'unavailable'; message: string }
const RING_SIZE = 32
const RING_STROKE = 3
const RADIUS = (RING_SIZE - RING_STROKE) / 2
const CIRCUMFERENCE = 2 * Math.PI * RADIUS
function headline(provider: Provider): QuotaWindow | null {
if (provider.windows.length === 0) return null
return provider.windows.reduce((worst, row) => (row.usedPct > worst.usedPct ? row : worst))
type Rect = { x: number; y: number; w: number; h: number }
type DockFrame = {
rail: Rect
anchor: 'start' | 'end'
detail: (Rect & { tailY: number }) | null
}
// Whole percentage points, matching the mac dock's rounded metrics.
function pct(value: number): number {
return Math.min(100, Math.max(0, Math.round(value)))
/// Port of CapacityDockInteractionState: the immediate truth that decides whether a delayed
/// hover action is still valid when its timer fires.
type Interaction = {
railHovered: boolean
detailHovered: boolean
pinned: boolean
collapseGrace: boolean
}
const REST: Interaction = { railHovered: false, detailHovered: false, pinned: false, collapseGrace: false }
const isExpanded = (i: Interaction) => i.pinned || i.railHovered || i.detailHovered || i.collapseGrace
const canCollapse = (i: Interaction) => !i.pinned && !i.railHovered && !i.detailHovered && !i.collapseGrace
type DetailPhase = 'entering' | 'shown' | 'dismissing'
function useTimers() {
const timers = useRef<Record<string, number>>({})
const cancel = useCallback((name: string) => {
window.clearTimeout(timers.current[name])
delete timers.current[name]
}, [])
const schedule = useCallback(
(name: string, ms: number, fn: () => void) => {
cancel(name)
timers.current[name] = window.setTimeout(() => {
delete timers.current[name]
fn()
}, ms)
},
[cancel]
)
useEffect(() => {
const all = timers.current
return () => Object.values(all).forEach((id) => window.clearTimeout(id))
}, [])
return { schedule, cancel }
}
function resetsIn(iso?: string): string {
if (!iso) return ''
const seconds = (new Date(iso).getTime() - Date.now()) / 1000
if (Number.isNaN(seconds)) return ''
if (seconds < 60) return 'now'
const minutes = Math.floor(seconds / 60)
const hours = Math.floor(minutes / 60)
const days = Math.floor(hours / 24)
if (days > 0) return `${days}d ${hours % 24}h`
if (hours > 0) return `${hours}h ${minutes % 60}m`
return `${minutes}m`
/// The rail's presentation progress, 0 at rest and 1 expanded, eased with the mac's rail
/// curves. A reversal restarts from the current value so a quick exit never snaps.
function useRailProgress(target: 0 | 1, onSettled: (value: 0 | 1) => void): number {
const [progress, setProgress] = useState<number>(target)
const live = useRef<{ value: number; raf: number }>({ value: target, raf: 0 })
const settled = useRef(onSettled)
settled.current = onSettled
useEffect(() => {
const from = live.current.value
if (from === target) return
const motion = target === 1 ? MOTION.railExpand : MOTION.railCollapse
const start = performance.now()
const step = (now: number) => {
const linear = Math.min(1, (now - start) / motion.duration)
const value = from + (target - from) * bezier(motion.curve, linear)
live.current.value = value
setProgress(value)
if (linear < 1) {
live.current.raf = requestAnimationFrame(step)
} else {
settled.current(target)
}
}
cancelAnimationFrame(live.current.raf)
live.current.raf = requestAnimationFrame(step)
return () => cancelAnimationFrame(live.current.raf)
}, [target])
return progress
}
function Ring({ provider }: { provider: Provider }) {
const top = headline(provider)
const used = top ? pct(top.usedPct) : 0
const RING_COLORS: Record<Severity, string> = {
normal: '#30D158',
warning: '#FFD60A',
critical: '#FF9F0A',
danger: '#FF453A',
}
function Ring({ percent }: { percent: number | null }) {
const size = M.ringSize
const stroke = M.ringStroke
// Strokes are centred on the ring's circle like SwiftUI's, so the box gets a margin for them.
const margin = 3
const box = size + margin * 2
const c = box / 2
const r = size / 2
const circumference = 2 * Math.PI * r
const amount = percent === null ? 0 : Math.min(1, Math.max(0, percent / 100))
return (
<div className="dock-row" data-provider={provider.id} title={provider.name}>
<svg className="dock-ring" width={RING_SIZE} height={RING_SIZE} viewBox={`0 0 ${RING_SIZE} ${RING_SIZE}`}>
<circle
className="dock-ring-track"
cx={RING_SIZE / 2}
cy={RING_SIZE / 2}
r={RADIUS}
strokeWidth={RING_STROKE}
/>
<svg className="dock-ring" width={box} height={box} viewBox={`0 0 ${box} ${box}`} aria-hidden="true">
<defs>
<linearGradient id="dock-ring-sheen" x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stopColor="#fff" stopOpacity="0.16" />
<stop offset="0.5" stopColor="#fff" stopOpacity="0.07" />
<stop offset="1" stopColor="#fff" stopOpacity="0.12" />
</linearGradient>
</defs>
<circle cx={c} cy={c} r={r} fill="none" stroke="rgba(0,0,0,0.74)" strokeWidth={stroke + 1.2} />
<circle cx={c} cy={c} r={r} fill="none" stroke="url(#dock-ring-sheen)" strokeWidth={stroke + 0.36} />
{percent === null ? (
<circle cx={c} cy={c} r={r} fill="none" stroke="rgba(255,255,255,0.24)" strokeWidth={1.2} strokeDasharray="1.8 2.4" />
) : (
<circle
cx={c}
cy={c}
r={r}
fill="none"
stroke={RING_COLORS[severity(percent)]}
strokeWidth={stroke}
strokeLinecap="round"
strokeDasharray={`${circumference * amount} ${circumference}`}
transform={`rotate(-90 ${c} ${c})`}
className="dock-ring-arc"
cx={RING_SIZE / 2}
cy={RING_SIZE / 2}
r={RADIUS}
strokeWidth={RING_STROKE}
strokeDasharray={CIRCUMFERENCE}
strokeDashoffset={CIRCUMFERENCE * (1 - used / 100)}
/>
</svg>
<span className={`dock-pct${used >= 90 ? ' is-spent' : ''}`}>{top ? `${used}%` : '--'}</span>
</div>
)}
</svg>
)
}
function notice(quota: DockQuota | null, providers: Provider[]): string | null {
if (quota?.state === 'cliOutdated') return 'CLI update needed for live quota. Run npm install -g codeburn.'
if (quota?.state === 'unavailable') return 'Quota is unavailable right now.'
if (quota?.state === 'ready' && providers.length === 0) return 'No signed in providers to show.'
return null
type RowProps = {
provider: Provider
loading: boolean
opacity: number
offset: number
onEnter: () => void
onLeave: () => void
onClick: () => void
}
function Detail({ providers, message }: { providers: Provider[]; message: string | null }) {
function Row({ provider, loading, opacity, offset, onEnter, onLeave, onClick }: RowProps) {
const headline = provider.available ? headlineWindow(provider.windows) : null
const percent = headline ? pct(headline.usedPct) : null
const sev = percent === null ? null : severity(percent)
return (
<div className="dock-detail">
{message ? <p className="dock-notice">{message}</p> : null}
{providers.map((provider) => (
<section className="dock-detail-card" key={provider.id} data-provider={provider.id}>
<header className="dock-detail-head">
<span className="dock-detail-name">{provider.name}</span>
{provider.plan ? <span className="dock-detail-plan">{provider.plan}</span> : null}
</header>
{provider.windows.map((row) => {
<button
type="button"
className="dock-row"
style={{ opacity, transform: `translateY(${offset}px)` }}
onMouseEnter={onEnter}
onMouseLeave={onLeave}
onClick={onClick}
aria-label={`${provider.name} usage`}
>
<span className="dock-gauge">
<Ring percent={percent} />
<span className={`dock-glyph${loading ? ' is-loading' : ''}`}>
<ProviderGlyph id={provider.id} size={M.providerIconSize} />
</span>
{provider.error ? <span className="dock-row-alert" /> : null}
</span>
<span className={`dock-pct${sev ? ` is-${sev}` : ' is-empty'}`}>{percent === null ? '--' : `${percent}%`}</span>
</button>
)
}
function instruction(provider: Provider, quota: DockQuota | null): string {
if (quota?.state === 'cliOutdated') return 'CLI update needed for live quota. Run npm install -g codeburn.'
if (quota?.state === 'unavailable') return quota.message || 'Quota is unavailable right now.'
return `Sign in with the ${provider.name} app or CLI. The dock checks again every five minutes.`
}
function Detail({ provider, quota, loading }: { provider: Provider; quota: DockQuota | null; loading: boolean }) {
const windows = provider.windows.slice(0, MAX_DETAIL_ROWS)
return (
<div className="dock-detail-body">
<header className="dock-detail-head">
<span className="dock-detail-glyph">
<ProviderGlyph id={provider.id} size={Math.round(24 * 0.9)} />
</span>
<span className="dock-detail-title">{provider.name} Usage</span>
{provider.plan ? <span className="dock-detail-plan">{provider.plan}</span> : null}
</header>
{loading ? <p className="dock-conn is-loading">Refreshing…</p> : null}
{!loading && provider.error ? (
<div className="dock-conn-block">
<p className="dock-conn is-failed">Reconnect required</p>
<p className="dock-conn-reason">{provider.error}</p>
<p className="dock-conn-hint">{instruction(provider, quota)}</p>
</div>
) : null}
{!loading && !provider.error && !provider.available ? (
<div className="dock-conn-block">
<p className="dock-conn is-disconnected">Not connected</p>
<p className="dock-conn-instruction">{instruction(provider, quota)}</p>
</div>
) : null}
{provider.available
? windows.map((row) => {
const used = pct(row.usedPct)
const resets = resetsIn(row.resetsAt)
return (
<div className="dock-window" key={`${provider.id}-${row.label}`}>
<div className="dock-window-top">
<span className="dock-window-label">{row.label}</span>
<span className="dock-window-label">{displayLabel(row.label)}</span>
<span className="dock-window-pct">{used}%</span>
</div>
<div className="dock-track">
<div className="dock-fill" style={{ width: `${used}%` }} />
<div className={`dock-fill is-${severity(used)}`} style={{ width: `max(2px, ${used}%)` }} />
</div>
{resets ? <span className="dock-window-resets">Resets in {resets}</span> : null}
</div>
)
})}
</section>
))}
})
: null}
</div>
)
}
export function Dock() {
const [quota, setQuota] = useState<DockQuota | null>(null)
const [expanded, setExpanded] = useState(false)
const closeTimer = useRef<number | undefined>(undefined)
const [preferredId, setPreferredId] = useState<string | null>(null)
const [interaction, setInteraction] = useState<Interaction>(REST)
const [presentationExpanded, setPresentationExpanded] = useState(false)
const [hovered, setHovered] = useState<string | null>(null)
const [detailPhase, setDetailPhase] = useState<DetailPhase>('entering')
const [detailHeight, setDetailHeight] = useState(0)
const [frame, setFrame] = useState<DockFrame | null>(null)
const { schedule, cancel } = useTimers()
const interactionRef = useRef(interaction)
interactionRef.current = interaction
const hoveredRef = useRef(hovered)
hoveredRef.current = hovered
const phaseRef = useRef(detailPhase)
phaseRef.current = detailPhase
const pointerInsideRail = useRef(false)
const detailRef = useRef<HTMLDivElement>(null)
const load = useCallback(async () => {
try {
@ -135,47 +289,265 @@ export function Dock() {
useEffect(() => {
void load()
void invoke<string | null>('dock_preferred').then((id) => setPreferredId(id ?? null))
const timer = window.setInterval(() => void load(), REFRESH_MS)
return () => window.clearInterval(timer)
const unlisten = listen('codeburn://dock-refresh', () => void load())
return () => {
window.clearInterval(timer)
void unlisten.then((f) => f())
}
}, [load])
const providers =
quota?.state === 'ready' ? quota.providers.filter((provider) => provider.available) : []
const rows = Math.max(providers.length, 1)
// Providers: the ones the CLI reports signed in, else the preferred one as a dashed stand-in.
const all = quota?.state === 'ready' ? quota.providers : []
const available = all.filter((p) => p.available)
const resolvedPreferredId = preferredId ?? available[0]?.id ?? all[0]?.id ?? 'claude'
const preferred: Provider = all.find((p) => p.id === resolvedPreferredId) ?? {
id: resolvedPreferredId,
name: PROVIDER_NAMES[resolvedPreferredId] ?? resolvedPreferredId,
available: false,
windows: [],
}
const selected = available.length > 0 ? available : [preferred]
const displayed = presentationExpanded
? [preferred, ...selected.filter((p) => p.id !== preferred.id)]
: [preferred]
const anchor = frame?.anchor ?? 'start'
const ordered = anchor === 'end' ? [...displayed].reverse() : displayed
const loading = quota === null
const expanded = isExpanded(interaction)
useEffect(() => {
if (expanded) setPresentationExpanded(true)
}, [expanded])
const progress = useRailProgress(expanded ? 1 : 0, (value) => {
if (value === 0) setPresentationExpanded(false)
})
// Detail lifecycle, port of showDetail / hideDetail / dismissDetail.
const showDetail = useCallback(
(id: string) => {
cancel('detailDismiss')
if (hoveredRef.current === id) {
if (phaseRef.current === 'dismissing') setDetailPhase('shown')
return
}
setHovered(id)
setDetailPhase(hoveredRef.current && phaseRef.current === 'shown' ? 'shown' : 'entering')
},
[cancel]
)
const hideDetail = useCallback(() => {
if (!hoveredRef.current) return
setDetailPhase('dismissing')
schedule('detailDismiss', MOTION.detailDismiss.duration, () => {
setHovered(null)
setDetailPhase('entering')
})
}, [schedule])
const scheduleCollapse = useCallback(() => {
schedule('collapse', MOTION.railHoverCloseDelay, () => {
setInteraction((i) => ({ ...i, collapseGrace: false }))
const next = { ...interactionRef.current, collapseGrace: false }
if (canCollapse(next)) hideDetail()
})
}, [schedule, hideDetail])
const onRailEnter = () => {
pointerInsideRail.current = true
cancel('expand')
cancel('collapse')
schedule('expand', MOTION.railHoverOpenDelay, () => {
if (!pointerInsideRail.current) return
setInteraction((i) => ({ ...i, railHovered: true, collapseGrace: false }))
})
}
const onRailLeave = () => {
pointerInsideRail.current = false
cancel('expand')
setInteraction((i) => ({ ...i, railHovered: false, collapseGrace: true }))
scheduleCollapse()
}
const onRowEnter = (id: string) => {
cancel('detailShow')
cancel('detailExit')
// Re-entering a row aborts a pending collapse; a row exit must not touch it.
cancel('collapse')
schedule('detailShow', MOTION.detailShowDelay, () => showDetail(id))
}
const onRowLeave = (id: string) => {
cancel('detailShow')
if (hoveredRef.current !== id) return
// Enough time to cross the transparent gap into the bubble.
schedule('detailExit', MOTION.detailExitDelay, () => {
if (interactionRef.current.detailHovered) return
hideDetail()
scheduleCollapse()
})
}
const onDetailEnter = () => {
cancel('collapse')
cancel('detailExit')
setInteraction((i) => ({ ...i, detailHovered: true }))
if (phaseRef.current === 'dismissing') {
cancel('detailDismiss')
setDetailPhase('shown')
}
}
const onDetailLeave = () => {
setInteraction((i) => ({ ...i, detailHovered: false }))
scheduleCollapse()
}
const onRowClick = (provider: Provider) => {
cancel('expand')
cancel('collapse')
if (provider.id !== resolvedPreferredId) {
setPreferredId(provider.id)
void invoke('dock_set_preferred', { id: provider.id })
setInteraction((i) => (i.pinned ? i : { ...i, pinned: true }))
} else {
setInteraction((i) => ({ ...i, pinned: !i.pinned }))
}
showDetail(provider.id)
}
const dismiss = useCallback(() => {
;['expand', 'collapse', 'detailShow', 'detailExit'].forEach(cancel)
setInteraction(REST)
hideDetail()
}, [cancel, hideDetail])
useEffect(() => {
void invoke('dock_set_layout', { rows, expanded })
}, [rows, expanded])
const onKey = (event: KeyboardEvent) => {
if (event.key === 'Escape' && isExpanded(interactionRef.current)) dismiss()
}
window.addEventListener('keydown', onKey)
return () => window.removeEventListener('keydown', onKey)
}, [dismiss])
useEffect(() => () => window.clearTimeout(closeTimer.current), [])
// The bubble is laid out at its natural height first; the window is sized from that.
useLayoutEffect(() => {
if (!hovered) {
setDetailHeight(0)
return
}
const el = detailRef.current
if (el) setDetailHeight(Math.ceil(el.offsetHeight))
}, [hovered, quota])
const message = notice(quota, providers)
const rows = ordered.length
const detailRow = hovered ? ordered.findIndex((p) => p.id === hovered) : -1
const detailRequest = hovered && detailHeight > 0 && detailRow >= 0 ? { row: detailRow, height: detailHeight } : null
useEffect(() => {
let stale = false
void invoke<DockFrame>('dock_set_layout', {
request: { rows, expanded: presentationExpanded, detail: detailRequest },
}).then((next) => {
if (!stale) setFrame(next)
})
return () => {
stale = true
}
// detailRequest is derived from the two scalars below.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [rows, presentationExpanded, detailRow, detailHeight])
const open = () => {
window.clearTimeout(closeTimer.current)
if (providers.length > 0 || message) setExpanded(true)
}
// Entering: the card is placed while invisible, then slides in on the next frame.
const detailPlaced = frame?.detail != null && detailRequest != null
useEffect(() => {
if (detailPhase !== 'entering' || !detailPlaced) return
const raf = requestAnimationFrame(() => setDetailPhase('shown'))
return () => cancelAnimationFrame(raf)
}, [detailPhase, detailPlaced])
// A short grace period keeps the panel from flickering shut as the pointer crosses the
// seam between the rail and the panel.
const close = () => {
window.clearTimeout(closeTimer.current)
closeTimer.current = window.setTimeout(() => setExpanded(false), HOVER_CLOSE_MS)
}
const restLength = railHeight(1)
const targetLength = railHeight(rows)
const bodyLength = Math.round(restLength + (targetLength - restLength) * progress)
const railRect = frame?.rail ?? { x: 0, y: 0, w: M.railWidth, h: restLength }
const railTop = anchor === 'end' ? railRect.y + railRect.h - bodyLength : railRect.y
const shape = railPath(M.railWidth, bodyLength)
const hoveredProvider = hovered ? (ordered.find((p) => p.id === hovered) ?? null) : null
const detailFrame = frame?.detail ?? null
const detailW = M.detailWidth
const detailH = detailHeight
const tailY = detailFrame ? detailFrame.tailY : detailH / 2
return (
<div className="dock" onMouseEnter={open} onMouseLeave={close}>
{expanded ? <Detail providers={providers} message={message} /> : null}
<div className="dock-rail" onDoubleClick={() => void load()}>
{providers.map((provider) => (
<Ring provider={provider} key={provider.id} />
))}
{providers.length === 0 ? (
<div className="dock-row">
<span className="dock-quiet">{quota?.state === 'cliOutdated' ? 'CLI' : '--'}</span>
</div>
) : null}
<div className="dock" onContextMenu={(e) => { e.preventDefault(); void invoke('dock_context_menu') }}>
<div
className="dock-rail"
style={{ top: railTop, width: M.railWidth, height: bodyLength, clipPath: `path('${shape}')` }}
onMouseEnter={onRailEnter}
onMouseLeave={onRailLeave}
>
<svg className="dock-surface" width={M.railWidth} height={bodyLength} viewBox={`0 0 ${M.railWidth} ${bodyLength}`} aria-hidden="true">
<defs>
<linearGradient id="dock-rail-fill" x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stopColor="#131416" />
<stop offset="0.46" stopColor="#09090A" />
<stop offset="1" stopColor="#030304" />
</linearGradient>
<radialGradient id="dock-rail-glow" cx="0" cy="0" r="180" gradientUnits="userSpaceOnUse">
<stop offset="0" stopColor="#fff" stopOpacity="0.055" />
<stop offset="1" stopColor="#fff" stopOpacity="0" />
</radialGradient>
<linearGradient id="dock-rail-edge" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stopColor="#fff" stopOpacity="0.05" />
<stop offset="0.55" stopColor="#fff" stopOpacity="0.09" />
<stop offset="0.86" stopColor="#fff" stopOpacity="0.14" />
<stop offset="1" stopColor="#fff" stopOpacity="0.08" />
</linearGradient>
</defs>
<path d={shape} fill="url(#dock-rail-fill)" />
<path d={shape} fill="url(#dock-rail-glow)" />
<path d={shape} fill="none" stroke="url(#dock-rail-edge)" strokeWidth="0.6" />
</svg>
<div
className="dock-rows"
style={anchor === 'end' ? { bottom: M.railAlongPad } : { top: M.railAlongPad }}
>
{ordered.map((provider) => {
const isPreferred = provider.id === preferred.id
return (
<Row
key={provider.id}
provider={provider}
loading={loading}
opacity={isPreferred ? 1 : progress}
offset={isPreferred ? 0 : M.rowReveal * (1 - progress)}
onEnter={() => onRowEnter(provider.id)}
onLeave={() => onRowLeave(provider.id)}
onClick={() => onRowClick(provider)}
/>
)
})}
</div>
</div>
{hoveredProvider ? (
<div
ref={detailRef}
className={`dock-detail is-${detailPhase}${detailPlaced ? '' : ' is-measuring'}`}
style={{
left: detailFrame?.x ?? 0,
top: detailFrame?.y ?? 0,
width: detailW,
paddingRight: DETAIL_INSETS.horizontal + DETAIL_INSETS.tail,
}}
onMouseEnter={onDetailEnter}
onMouseLeave={onDetailLeave}
>
{detailH > 0 ? (
<svg className="dock-surface" width={detailW} height={detailH} viewBox={`0 0 ${detailW} ${detailH}`} aria-hidden="true">
<path d={bubblePath(detailW, detailH, tailY)} fill="url(#dock-rail-fill)" />
<path d={bubblePath(detailW, detailH, tailY)} fill="url(#dock-rail-glow)" />
<path d={bubblePath(detailW, detailH, tailY)} fill="none" stroke="rgba(255,255,255,0.09)" strokeWidth="0.9" />
</svg>
) : null}
<Detail provider={hoveredProvider} quota={quota} loading={loading} />
</div>
) : null}
</div>
)
}

View file

@ -1,170 +1,289 @@
/* Capacity Dock rail. Metrics are the macOS dock's whole-point values at its default 0.6
scale (mac/Sources/CodeBurnMenubar/Views/CapacityDockView.swift); the window that holds
them is sized in src-tauri/src/dock.rs and the two must stay in step. */
/* Capacity Dock, the Windows twin of mac/Sources/CodeBurnMenubar/Views/CapacityDockView.swift.
Metrics come from src/dockGeometry.ts (the mac values at its 0.6 default scale) and the
window that holds them is sized in src-tauri/src/dock.rs; all three stay in step. The dock is
always the mac's dark graphite surface, whichever theme the popover is in. */
:root {
--dock-rail-w: 56px;
--dock-row-h: 50px;
--dock-row-gap: 7px;
--dock-pad: 12px;
--dock-detail-w: 300px;
--dock-radius: 10px;
/* claude, codex and copilot are tokens.json color.categorical; the remaining three keep
the ring colours the macOS Capacity Dock already gives them. */
--dock-claude: #C9521D;
--dock-codex: #5C7CA3;
--dock-copilot: #B8944C;
--dock-gemini: #478CFA;
--dock-kimi: #E6F014;
--dock-antigravity: #FF7A45;
/* Warm off-white: a mild orange tint so bright labels on the dark card read softer. */
--dock-text: #FAF2E6;
--dock-green: #30D158;
--dock-yellow: #FFD60A;
--dock-orange: #FF9F0A;
--dock-red: #FF453A;
--dock-rail-expand: cubic-bezier(0.22, 1, 0.36, 1);
--dock-detail-present: cubic-bezier(0.16, 1, 0.3, 1);
--dock-detail-follow: cubic-bezier(0.25, 0.1, 0.25, 1);
--dock-detail-dismiss: cubic-bezier(0.4, 0, 1, 1);
}
.dock {
display: flex;
justify-content: flex-end;
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
font-family: var(--font-sans);
color: var(--dock-text);
user-select: none;
-webkit-user-select: none;
}
.dock-surface {
position: absolute;
inset: 0;
display: block;
pointer-events: none;
}
/* Rail */
.dock-rail {
flex: 0 0 var(--dock-rail-w);
position: absolute;
right: 0;
box-sizing: border-box;
}
.dock-rows {
position: absolute;
left: 0;
right: 0;
display: flex;
flex-direction: column;
gap: var(--dock-row-gap);
padding: var(--dock-pad) 0;
background: var(--surface);
border-radius: var(--dock-radius) 0 0 var(--dock-radius);
border: 1px solid var(--separator);
border-right: none;
box-shadow: var(--menu-shadow);
gap: 7px;
}
.dock-row {
height: var(--dock-row-h);
appearance: none;
border: 0;
margin: 0;
padding: 0;
background: none;
color: inherit;
font: inherit;
cursor: default;
height: 50px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 2px;
gap: 4px;
}
.dock-row:focus-visible {
outline: none;
}
.dock-gauge {
position: relative;
width: 31px;
height: 31px;
display: grid;
place-items: center;
}
.dock-ring {
transform: rotate(-90deg);
}
.dock-ring-track {
fill: none;
stroke: var(--fill-12);
position: absolute;
top: -3px;
left: -3px;
overflow: visible;
}
.dock-ring-arc {
fill: none;
stroke: var(--dock-accent, var(--label-2));
stroke-linecap: round;
transition: stroke-dashoffset 240ms var(--ease-ui);
transition: stroke-dasharray 240ms var(--ease-ui), stroke 240ms var(--ease-ui);
}
.dock-glyph {
position: relative;
display: grid;
place-items: center;
color: #fff;
}
.dock-glyph.is-loading {
opacity: 0.6;
}
.dock-row-alert {
position: absolute;
top: -3px;
right: -3px;
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--dock-red);
box-shadow: 0 0 0 1.5px #000;
}
.dock-pct {
font-size: 10px;
font-weight: 500;
line-height: 12px;
font-variant-numeric: tabular-nums;
color: var(--label-2);
color: var(--dock-text);
}
.dock-pct.is-spent {
color: var(--danger);
}
.dock-pct.is-empty { color: rgba(250, 242, 230, 0.72); }
.dock-pct.is-warning { color: var(--dock-yellow); }
.dock-pct.is-critical { color: var(--dock-orange); }
.dock-pct.is-danger { color: var(--dock-red); }
.dock-quiet {
font-size: 10px;
color: var(--label-3);
}
/* Detail bubble */
.dock-detail {
flex: 0 0 var(--dock-detail-w);
overflow-y: auto;
padding: var(--dock-pad);
position: absolute;
box-sizing: border-box;
padding: 14px 20px;
transition:
transform 200ms var(--dock-detail-present),
opacity 200ms var(--dock-detail-present),
top 220ms var(--dock-detail-follow),
left 220ms var(--dock-detail-follow);
}
/* Measured before it is placed: laid out at full size, but neither seen nor hit. */
.dock-detail.is-measuring {
visibility: hidden;
pointer-events: none;
}
/* Starts a step toward the rail so the bubble emerges from the dock. */
.dock-detail.is-entering {
transform: translateX(10px);
opacity: 0;
transition: none;
}
.dock-detail.is-dismissing {
transform: translateX(6px);
opacity: 0;
pointer-events: none;
transition:
transform 140ms var(--dock-detail-dismiss),
opacity 140ms var(--dock-detail-dismiss);
}
.dock-detail-body {
position: relative;
display: flex;
flex-direction: column;
gap: 10px;
background: var(--surface);
border-radius: var(--dock-radius) 0 0 var(--dock-radius);
border: 1px solid var(--separator);
border-right: none;
box-shadow: var(--menu-shadow);
}
.dock-notice {
margin: 0;
font-size: 11px;
color: var(--label-2);
}
.dock-detail-card {
display: flex;
flex-direction: column;
gap: 6px;
}
.dock-detail-head {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 8px;
align-items: center;
gap: 7px;
}
.dock-detail-name {
font-size: 12px;
.dock-detail-glyph {
display: grid;
place-items: center;
color: var(--dock-text);
flex: 0 0 auto;
}
.dock-detail-title {
font-size: 17px;
font-weight: 600;
color: var(--label);
line-height: 1.2;
white-space: nowrap;
}
.dock-detail-plan {
margin-left: auto;
font-size: 10px;
color: var(--label-2);
font-weight: 500;
color: rgba(250, 242, 230, 0.62);
white-space: nowrap;
}
.dock-window {
.dock-conn,
.dock-conn-reason,
.dock-conn-hint,
.dock-conn-instruction {
margin: 0;
}
.dock-conn-block {
display: flex;
flex-direction: column;
gap: 3px;
}
.dock-conn.is-loading {
font-size: 10px;
color: rgba(250, 242, 230, 0.52);
}
.dock-conn.is-disconnected {
font-size: 11px;
color: rgba(250, 242, 230, 0.6);
}
.dock-conn.is-failed {
font-size: 11px;
font-weight: 600;
color: var(--dock-red);
}
.dock-conn-reason {
font-size: 10px;
color: rgba(250, 242, 230, 0.58);
}
.dock-conn-hint {
font-size: 10px;
color: rgba(250, 242, 230, 0.72);
}
.dock-conn-instruction {
font-size: 12px;
color: rgba(250, 242, 230, 0.62);
}
.dock-window {
display: flex;
flex-direction: column;
gap: 5px;
}
.dock-window-top {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 8px;
font-size: 11px;
color: var(--label-2);
gap: 7px;
font-size: 12px;
font-weight: 500;
}
.dock-window-label {
color: rgba(250, 242, 230, 0.82);
}
.dock-window-pct {
font-variant-numeric: tabular-nums;
color: var(--label);
color: var(--dock-text);
}
.dock-track {
height: 4px;
border-radius: var(--radius-bar);
background: var(--fill-12);
height: 5px;
border-radius: 999px;
background: rgba(250, 242, 230, 0.14);
overflow: hidden;
}
.dock-fill {
height: 100%;
border-radius: var(--radius-bar);
background: var(--dock-accent, var(--label-2));
border-radius: 999px;
background: var(--dock-green);
}
.dock-fill.is-warning { background: var(--dock-yellow); }
.dock-fill.is-critical { background: var(--dock-orange); }
.dock-fill.is-danger { background: var(--dock-red); }
.dock-window-resets {
align-self: flex-end;
font-size: 10px;
color: var(--label-3);
font-variant-numeric: tabular-nums;
color: rgba(250, 242, 230, 0.5);
}
[data-provider='claude'] { --dock-accent: var(--dock-claude); }
[data-provider='codex'] { --dock-accent: var(--dock-codex); }
[data-provider='copilot'] { --dock-accent: var(--dock-copilot); }
[data-provider='gemini'] { --dock-accent: var(--dock-gemini); }
[data-provider='kimi'] { --dock-accent: var(--dock-kimi); }
[data-provider='antigravity'] { --dock-accent: var(--dock-antigravity); }

172
windows/src/dockGeometry.ts Normal file
View file

@ -0,0 +1,172 @@
/// Pure geometry and presentation rules for the Capacity Dock, ported from
/// mac/Sources/CodeBurnMenubar/Views/CapacityDockView.swift, CapacityDockMotion.swift and
/// Data/QuotaSummary.swift. Every metric is the mac value at its default 0.6 scale, rounded to a
/// whole pixel the way CapacityDockMetrics.points does; src-tauri/src/dock.rs sizes the window
/// from the same numbers and the two must stay in step.
export const SCALE = 0.6
export const DETAIL_SCALE = 0.9
function points(base: number, scale = SCALE): number {
return Math.max(1, Math.round(base * scale))
}
export const M = {
railWidth: points(88),
rowHeight: points(84),
rowSpacing: points(12),
// Docked rails add 60% of the shoulder depth so content never crowds the concave flare.
railAlongPad: points(20) + Math.round(points(52) * 0.6),
railCrossPad: points(12),
shoulderDepth: points(52),
ringSize: points(52),
ringStroke: points(4),
ringLabelSpacing: points(6),
providerIconSize: points(26),
percentTextSize: points(17),
detailWidth: points(350, DETAIL_SCALE),
detailGap: 10,
rowReveal: -8 * SCALE,
} as const
export function railHeight(rows: number): number {
const count = Math.max(rows, 1)
return M.railAlongPad * 2 + count * M.rowHeight + (count - 1) * M.rowSpacing
}
/// Motion: durations in ms and cubic-bezier control points, verbatim from CapacityDockMotion.
export const MOTION = {
railExpand: { duration: 520, curve: [0.22, 1, 0.36, 1] as const },
railCollapse: { duration: 440, curve: [0.32, 0, 0.2, 1] as const },
detailPresent: { duration: 200, curve: [0.16, 1, 0.3, 1] as const },
detailFollow: { duration: 220, curve: [0.25, 0.1, 0.25, 1] as const },
detailDismiss: { duration: 140, curve: [0.4, 0, 1, 1] as const },
railHoverOpenDelay: 80,
railHoverCloseDelay: 180,
detailShowDelay: 180,
detailExitDelay: 240,
detailAppearOffset: 10,
} as const
export function cssCurve(curve: readonly [number, number, number, number]): string {
return `cubic-bezier(${curve.join(', ')})`
}
/// Cubic bezier easing solved by Newton iteration, matching CapacityDockMotion.cubicBezier.
export function bezier(curve: readonly [number, number, number, number], x: number): number {
const [p1x, p1y, p2x, p2y] = curve
const sampleX = (t: number) => ((1 - 3 * p2x + 3 * p1x) * t + (3 * p2x - 6 * p1x)) * t * t + 3 * p1x * t
const sampleY = (t: number) => ((1 - 3 * p2y + 3 * p1y) * t + (3 * p2y - 6 * p1y)) * t * t + 3 * p1y * t
const sampleDx = (t: number) => (3 * (1 - 3 * p2x + 3 * p1x) * t + 2 * (3 * p2x - 6 * p1x)) * t + 3 * p1x
if (x <= 0) return 0
if (x >= 1) return 1
let t = x
for (let i = 0; i < 8; i += 1) {
const dx = sampleX(t) - x
if (Math.abs(dx) < 1e-5) break
const d = sampleDx(t)
if (Math.abs(d) < 1e-6) break
t -= dx / d
}
return sampleY(Math.min(1, Math.max(0, t)))
}
export type Severity = 'normal' | 'warning' | 'critical' | 'danger'
/// Four tiers, from QuotaSummary.severity: below 50% is headroom, then yellow, orange, red.
export function severity(percent: number): Severity {
if (percent >= 90) return 'danger'
if (percent >= 75) return 'critical'
if (percent >= 50) return 'warning'
return 'normal'
}
export type QuotaWindow = { label: string; usedPct: number; resetsAt?: string }
/// The glance value: every provider on the same billing horizon, weekly if there is one, else
/// monthly, else the window nearest exhaustion. Empty stays null rather than posing as 0%.
export function headlineWindow(windows: QuotaWindow[]): QuotaWindow | null {
const find = (needle: string) => windows.find((row) => row.label.toLowerCase().includes(needle))
return (
find('week') ??
find('month') ??
windows.reduce<QuotaWindow | null>((worst, row) => (worst && worst.usedPct >= row.usedPct ? worst : row), null)
)
}
export function pct(value: number): number {
return Math.min(100, Math.max(0, Math.round(value)))
}
export function resetsIn(iso: string | undefined, now = Date.now()): string {
if (!iso) return ''
const seconds = (new Date(iso).getTime() - now) / 1000
if (Number.isNaN(seconds)) return ''
if (seconds < 60) return 'now'
const minutes = Math.floor(seconds / 60)
const hours = Math.floor(minutes / 60)
const days = Math.floor(hours / 24)
if (days > 0) return `${days}d ${hours % 24}h`
if (hours > 0) return `${hours}h ${minutes % 60}m`
return `${minutes}m`
}
export function displayLabel(label: string): string {
return label
.replace(/Claude and GPT models/i, 'Claude + GPT')
.replace(/Gemini Models/i, 'Gemini')
.replace(/Five-hour/i, '5-hour')
}
/// The docked rail outline (CapacityDockRailShape.rightFlarePath at full attachment): convex
/// corners on the free left side, concave shoulders necking into the flush right edge, the
/// system-notch technique. Coordinates are local to a w by h box.
export function railPath(w: number, h: number): string {
const freeR = Math.min(22, h / 2, w * 0.45)
const contactR = Math.min(M.shoulderDepth * 0.6, h * 0.22, Math.max(0, h / 2 - freeR))
const f = (n: number) => n.toFixed(2)
return [
`M ${f(w)} 0`,
`Q ${f(w)} ${f(contactR)} ${f(w - contactR)} ${f(contactR)}`,
`L ${f(freeR)} ${f(contactR)}`,
`Q 0 ${f(contactR)} 0 ${f(contactR + freeR)}`,
`L 0 ${f(h - contactR - freeR)}`,
`Q 0 ${f(h - contactR)} ${f(freeR)} ${f(h - contactR)}`,
`L ${f(w - contactR)} ${f(h - contactR)}`,
`Q ${f(w)} ${f(h - contactR)} ${f(w)} ${f(h)}`,
'Z',
].join(' ')
}
/// Detail bubble with a tail on its right edge pointing at the hovered row
/// (CapacityDockBubbleShape.rightTailPath). tailY is in local pixels.
export function bubblePath(w: number, h: number, tailY: number): string {
const tailWidth = Math.min(22, Math.max(14, w * 0.055))
const bodyRight = w - tailWidth
const radius = Math.min(20, h * 0.18)
const midY = h * Math.min(Math.max(tailY / Math.max(h, 1), 0.18), 0.82)
const neck = Math.min(32, h * 0.19)
const f = (n: number) => n.toFixed(2)
return [
`M ${f(radius)} 0`,
`L ${f(bodyRight - radius)} 0`,
`Q ${f(bodyRight)} 0 ${f(bodyRight)} ${f(radius)}`,
`L ${f(bodyRight)} ${f(midY - neck)}`,
`C ${f(bodyRight)} ${f(midY - neck * 0.55)} ${f(w)} ${f(midY - tailWidth * 0.42)} ${f(w)} ${f(midY)}`,
`C ${f(w)} ${f(midY + tailWidth * 0.42)} ${f(bodyRight)} ${f(midY + neck * 0.55)} ${f(bodyRight)} ${f(midY + neck)}`,
`L ${f(bodyRight)} ${f(h - radius)}`,
`Q ${f(bodyRight)} ${f(h)} ${f(bodyRight - radius)} ${f(h)}`,
`L ${f(radius)} ${f(h)}`,
`Q 0 ${f(h)} 0 ${f(h - radius)}`,
`L 0 ${f(radius)}`,
`Q 0 0 ${f(radius)} 0`,
'Z',
].join(' ')
}
/// Trailing inset of the bubble content: the regular inset plus room for the tail.
export const DETAIL_INSETS = {
horizontal: Math.round(22 * DETAIL_SCALE),
vertical: Math.round(16 * DETAIL_SCALE),
tail: Math.round(18 * DETAIL_SCALE),
} as const

View file

@ -0,0 +1,53 @@
/// Provider glyphs for the Capacity Dock, the same vector marks the mac app ships under
/// Resources/ProviderIcons. They render as template images: one path, filled with currentColor.
type Glyph = { viewBox: string; d: string; transform?: string }
const GLYPHS: Record<string, Glyph> = {
claude: {
viewBox: '0 0 100 100',
d: 'M25.7146 63.2153L41.4393 54.3917L41.7025 53.6226L41.4393 53.1976H40.6705L38.0394 53.0359L29.054 52.7929L21.2624 52.4691L13.7134 52.0644L11.8111 51.6594L10.0303 49.3118L10.2123 48.138L11.8111 47.0657L14.0981 47.2681L19.1574 47.6119L26.7467 48.138L32.2516 48.4618L40.4073 49.3118H41.7025L41.8846 48.7857L41.4393 48.4618L41.0955 48.138L33.243 42.8155L24.7432 37.1894L20.2909 33.9513L17.8824 32.3119L16.6684 30.774L16.1422 27.4147L18.328 25.0062L21.2624 25.2088L22.0112 25.4112L24.9861 27.6979L31.3407 32.616L39.6381 38.7273L40.8525 39.7391L41.3381 39.395L41.399 39.1523L40.8525 38.2415L36.3394 30.0858L31.5227 21.7883L29.3775 18.3478L28.811 16.2837C28.6087 15.4334 28.4669 14.7252 28.4669 13.8549L30.9563 10.4753L32.3321 10.0303L35.6515 10.4756L37.0479 11.6897L39.112 16.4052L42.4513 23.8327L47.6321 33.9313L49.15 36.9265L49.9594 39.6991L50.2632 40.5491H50.7894V40.0632L51.2141 34.3766L52.0035 27.3944L52.7726 18.4087L53.0358 15.8793L54.2905 12.8435L56.7795 11.2041L58.7224 12.135L60.3212 14.422L60.0986 15.899L59.1474 22.0718L57.2857 31.7458L56.0713 38.2218H56.7795L57.5892 37.4121L60.8677 33.061L66.3723 26.18L68.801 23.448L71.6342 20.4325L73.4556 18.9957H76.8962L79.4255 22.7601L78.2926 26.6456L74.7509 31.1384L71.8163 34.943L67.607 40.6097L64.9758 45.1431L65.2188 45.5072L65.8464 45.4466L75.358 43.4228L80.4984 42.4917L86.6304 41.4393L89.4033 42.7346L89.7065 44.0502L88.6135 46.7419L82.0566 48.3607L74.3662 49.8989L62.9118 52.6109L62.77 52.7121L62.9321 52.9144L68.0925 53.4L70.2987 53.5214H75.7021L85.7601 54.2702L88.3912 56.0108L89.9697 58.1358L89.7065 59.7545L85.6589 61.8189L80.1949 60.5236L67.4452 57.4881L63.0735 56.3952H62.4665V56.7596L66.1093 60.3213L72.7877 66.3523L81.1461 74.1236L81.5707 76.0462L80.4984 77.5638L79.3649 77.4021L72.0186 71.8772L69.1854 69.3879L62.77 63.9844H62.3453V64.5509L63.8223 66.7164L71.6342 78.4544L72.0389 82.0567L71.4725 83.2308L69.4487 83.939L67.2222 83.534L62.6485 77.1189L57.9333 69.8937L54.1284 63.4177L53.6631 63.6809L51.4167 87.8651L50.3644 89.0995L47.9356 90.0303L45.9121 88.4924L44.8392 86.0031L45.9118 81.0852L47.2071 74.6701L48.2594 69.5699L49.2106 63.2356L49.7773 61.131L49.7367 60.9892L49.2715 61.0498L44.4954 67.607L37.23 77.4224L31.4825 83.5746L30.1063 84.1211L27.7181 82.8864L27.9408 80.6805L29.2763 78.7177L37.2297 68.5988L42.026 62.3248L45.1227 58.7025L45.1024 58.176H44.9204L23.7917 71.8975L20.0274 72.3831L18.4083 70.8655L18.6106 68.3761L19.3798 67.5664L25.7343 63.195L25.7146 63.2153Z',
},
codex: {
viewBox: '0 0 100 100',
d: 'M83.7733 42.8087C84.6678 40.1149 84.9771 37.2613 84.6807 34.4385C84.3843 31.6156 83.489 28.8885 82.0544 26.4394C77.6908 18.8436 68.9203 14.9365 60.3548 16.7725C57.9831 14.1344 54.9591 12.1668 51.5864 11.0673C48.2137 9.96772 44.611 9.77498 41.1402 10.5084C37.6694 11.2418 34.4527 12.8755 31.8132 15.2455C29.1736 17.6155 27.204 20.6383 26.1024 24.0103C23.3212 24.5806 20.6938 25.738 18.3958 27.405C16.0977 29.0721 14.1819 31.2104 12.7765 33.6772C8.36538 41.2609 9.3669 50.8267 15.2527 57.3327C14.3549 60.0251 14.0424 62.8782 14.3361 65.7012C14.6298 68.5241 15.523 71.2518 16.9558 73.7017C21.325 81.3002 30.1011 85.207 38.6712 83.3686C40.5554 85.4904 42.8707 87.1858 45.4623 88.3416C48.0539 89.4975 50.8622 90.0871 53.6999 90.0713C62.4793 90.079 70.2575 84.4114 72.9393 76.0515C75.7201 75.4802 78.347 74.3225 80.6449 72.6555C82.9427 70.9886 84.8587 68.8507 86.2649 66.3846C90.6227 58.8145 89.6172 49.3005 83.7733 42.8087ZM53.6999 84.8356C50.1955 84.8411 46.801 83.6129 44.1116 81.3661L44.5848 81.098L60.5123 71.9043C60.9087 71.6718 61.2379 71.3402 61.4674 70.942C61.6969 70.5439 61.8189 70.0929 61.8215 69.6333V47.1769L68.5553 51.072C68.6225 51.1063 68.6694 51.1707 68.6814 51.2456V69.854C68.6641 78.1208 61.9667 84.8183 53.6999 84.8356ZM21.4977 71.0843C19.7402 68.0497 19.1092 64.4925 19.7156 61.0386L20.1885 61.3225L36.1321 70.5165C36.5266 70.748 36.9757 70.87 37.4331 70.87C37.8905 70.87 38.3396 70.748 38.7341 70.5165L58.21 59.2883V67.0628C58.2081 67.1031 58.1973 67.1424 58.1782 67.1779C58.1591 67.2134 58.1322 67.2441 58.0996 67.2678L41.9671 76.5722C34.798 80.7022 25.6388 78.2463 21.4977 71.0843ZM17.3026 36.3898C19.0723 33.3357 21.8655 31.0062 25.1878 29.8138V48.7376C25.1818 49.1949 25.2986 49.6453 25.5261 50.042C25.7535 50.4387 26.0833 50.7671 26.4809 50.9928L45.8622 62.1739L39.1283 66.069C39.0919 66.0883 39.0513 66.0984 39.0101 66.0984C38.9689 66.0984 38.9283 66.0883 38.8919 66.069L22.7908 56.7809C15.6359 52.6337 13.1822 43.4816 17.3026 36.3112V36.3898ZM72.624 49.2426L53.1792 37.9512L59.8976 34.0718C59.9341 34.0524 59.9747 34.0423 60.016 34.0423C60.0573 34.0423 60.0979 34.0524 60.1344 34.0718L76.2355 43.3761C78.6973 44.7966 80.7043 46.8882 82.0221 49.4065C83.3398 51.9249 83.914 54.7661 83.6775 57.5985C83.4411 60.431 82.4038 63.1377 80.6867 65.4027C78.9696 67.6677 76.6436 69.3975 73.9803 70.3901V51.466C73.9663 51.0096 73.834 50.5647 73.5962 50.1749C73.3584 49.7851 73.0234 49.4638 72.624 49.2426ZM79.3261 39.1657L78.8529 38.8815L62.9411 29.6089C62.5442 29.376 62.0924 29.2532 61.6322 29.2532C61.172 29.2532 60.7202 29.376 60.3233 29.6089L40.8629 40.8374V33.0628C40.8587 33.0233 40.8654 32.9834 40.882 32.9473C40.8987 32.9113 40.9248 32.8803 40.9575 32.8579L57.0586 23.5692C59.5263 22.1476 62.3478 21.458 65.193 21.5811C68.0382 21.7042 70.7896 22.6348 73.1253 24.2642C75.461 25.8936 77.2845 28.1543 78.3825 30.782C79.4806 33.4097 79.8077 36.2957 79.3257 39.1025V39.1657H79.3261ZM37.1888 52.9484L30.455 49.069C30.4213 49.0487 30.3925 49.0212 30.3707 48.9884C30.3488 48.9557 30.3345 48.9186 30.3286 48.8797V30.3188C30.3323 27.4714 31.1466 24.6839 32.6761 22.2822C34.2057 19.8805 36.3874 17.9639 38.9661 16.7564C41.5448 15.549 44.4139 15.1005 47.2381 15.4636C50.0622 15.8267 52.7247 16.9862 54.9141 18.8067L54.4409 19.0748L38.5134 28.2686C38.117 28.5011 37.7879 28.8327 37.5584 29.2308C37.329 29.629 37.207 30.0799 37.2045 30.5395L37.1888 52.9487V52.9484ZM40.8472 45.0632L49.5209 40.0643L58.21 45.0635V55.0615L49.5523 60.0608L40.8632 55.0615L40.8472 45.0632Z',
},
gemini: {
viewBox: '0 0 100 100',
d: 'M48.217 10.7381C48.8274 9.07596 51.1705 9.10263 51.7434 10.7779L53.3442 15.4571C55.7354 22.447 59.6489 28.8096 64.7979 34.079C69.947 39.3483 76.2012 43.3909 83.1024 45.9106L88.2657 47.7954C89.9088 48.3953 89.9123 50.7344 88.2711 51.3392L83.0955 53.2469C76.3818 55.7214 70.2839 59.6393 65.2262 64.728C60.1684 69.8168 56.2722 75.9542 53.8085 82.7134L51.783 88.2704C51.1836 89.915 48.8758 89.9193 48.2703 88.2772L46.1551 82.5404C43.6813 75.8303 39.7939 69.7395 34.7602 64.6867C29.7265 59.6339 23.6659 55.739 16.9952 53.2698L11.7265 51.3198C10.0944 50.7155 10.0901 48.3924 11.7198 47.7822L17.0915 45.7707C23.7343 43.2834 29.7654 39.3804 34.7722 34.3288C39.7791 29.2771 43.6435 23.196 46.1013 16.5012L48.217 10.7381Z',
},
copilot: {
viewBox: '0 0 100 100',
d: 'M79.7057 21.6044C85.0857 27.2967 87.3915 35.1429 88.3522 46.0659C90.8885 46.0659 93.2711 46.6428 94.8851 48.8352L97.8826 52.9121C98.728 54.0659 99.1892 55.4505 99.1892 56.9121V67.9505C99.1833 68.6605 99.0137 69.3596 98.6938 69.9934C98.3739 70.6271 97.9122 71.1784 97.3446 71.6044C83.7791 81.5275 67.0241 89.5275 50 89.5275C31.1698 89.5275 12.2627 78.6428 2.65542 71.6044C2.08785 71.1784 1.62614 70.6271 1.30621 69.9934C0.986278 69.3596 0.816752 68.6605 0.810822 67.9505L0.810822 56.9121C0.810822 55.4505 1.27197 54.0659 2.11741 52.8736L5.11488 48.8352C6.7289 46.6428 9.1115 46.0659 11.6478 46.0659C12.6085 35.1429 14.8759 27.2967 20.2944 21.6044C30.5165 10.7582 44.0819 9.52747 49.8463 9.52747H50C55.6491 9.52747 69.3683 10.6429 79.7057 21.6044ZM50 39.7967C48.8471 39.7967 47.5021 39.8736 46.0418 40.0275C45.678 41.7486 44.8848 43.3496 43.7361 44.6813C42.1163 46.2842 40.1962 47.5511 38.0858 48.4092C35.9755 49.2672 33.7165 49.6995 31.4388 49.6813C28.8256 49.6813 26.0971 49.1044 23.8683 47.6813C21.7547 48.4121 19.7179 49.4121 19.5642 51.9121C19.3721 56.6044 19.3336 61.3352 19.3336 66.0659C19.3336 68.4121 19.3336 70.7967 19.2568 73.1813C19.2568 74.5659 20.1022 75.8352 21.3704 76.4121C31.5156 81.0275 41.1613 83.3736 50 83.3736C58.8387 83.3736 68.446 81.0659 78.6297 76.4121C79.2511 76.1286 79.7794 75.6746 80.1535 75.1028C80.5276 74.531 80.7321 73.8647 80.7432 73.1813C80.8585 66.1044 80.7432 58.9505 80.4358 51.9121C80.2821 49.3736 78.2454 48.4121 76.1318 47.6813C73.9029 49.1044 71.136 49.6429 68.5612 49.6429C66.2861 49.6662 64.0288 49.2399 61.9186 48.3885C59.8084 47.5371 57.8868 46.2773 56.2639 44.6813C55.1153 43.3496 54.322 41.7486 53.9582 40.0275C52.6516 39.8736 51.3066 39.8352 50 39.7967ZM39.6242 56.7198C41.853 56.7198 43.6592 58.489 43.6592 60.7198V68.1044C43.6592 69.1653 43.2381 70.1827 42.4886 70.9328C41.7391 71.683 40.7226 72.1044 39.6626 72.1044C38.6026 72.1044 37.5861 71.683 36.8366 70.9328C36.087 70.1827 35.666 69.1653 35.666 68.1044V60.6813C35.666 58.4505 37.4337 56.6813 39.6626 56.6813L39.6242 56.7198ZM60.1453 56.7198C62.3742 56.7198 64.1419 58.489 64.1419 60.7198V68.1044C64.1419 69.1653 63.7208 70.1827 62.9713 70.9328C62.2218 71.683 61.2052 72.1044 60.1453 72.1044C59.0853 72.1044 58.0688 71.683 57.3192 70.9328C56.5697 70.1827 56.1487 69.1653 56.1487 68.1044V60.6813C56.1487 58.4505 57.9548 56.6813 60.1453 56.6813V56.7198ZM32.0921 20.4121C27.788 20.8352 24.1757 22.2582 22.3311 24.2582C18.3345 28.6044 19.1799 39.6813 21.4857 42.0275C23.7655 43.9275 26.6682 44.9142 29.6326 44.7967C32.2458 44.7967 37.1647 44.2198 41.1998 40.1044C43.0059 38.3736 44.0819 34.0659 43.9666 29.7198C43.8514 26.2198 42.8522 23.2967 41.3919 22.0659C39.7779 20.6813 36.1655 20.0659 32.0921 20.4121ZM58.6081 22.0659C57.1478 23.2967 56.1487 26.2198 56.0334 29.7198C55.9181 34.0659 56.9941 38.3736 58.8003 40.1044C60.3121 41.6165 62.111 42.8106 64.0909 43.6164C66.0708 44.4223 68.1918 44.8236 70.329 44.7967C73.7492 44.7967 76.8619 43.6813 78.5144 42.0275C80.8201 39.6813 81.6655 28.6044 77.6689 24.2198C75.8243 22.2967 72.212 20.8352 67.9079 20.4121C63.8345 20.0275 60.2221 20.6813 58.6081 22.0659ZM50 31.0659C49.0009 31.0659 47.848 31.1429 46.5414 31.2582C46.6951 31.9121 46.7335 32.6813 46.8104 33.4505C46.8104 34.0275 46.8104 34.6044 46.7335 35.1813C47.9633 35.0659 49.0393 35.0659 50 35.0659C50.9992 35.0659 52.0367 35.0659 53.2665 35.1813C53.1896 34.5659 53.1896 34.0275 53.1896 33.4505C53.2665 32.6813 53.3049 31.9121 53.4586 31.2582C52.152 31.1429 50.9992 31.0659 50 31.0659Z',
},
kimi: {
viewBox: '0 0 24 24',
transform: 'translate(0 -0.56)',
d: 'M21.7202 0.939941C22.9502 0.939941 23.9502 1.93994 23.9502 3.16994C23.9502 4.39994 22.9502 5.39994 21.7202 5.39994H19.7502C19.6002 5.39994 19.4902 5.27994 19.4902 5.13994V3.16994C19.4902 1.93994 20.4902 0.939941 21.7202 0.939941ZM9.39 13.9501L17.82 5.59012C17.98 5.43012 17.89 5.12012 17.68 5.12012H13.14C13.14 5.12012 13.04 5.14012 13 5.18012L3.92 14.1901C3.78 14.3301 3.57 14.2101 3.57 13.9801V5.39012C3.57 5.24012 3.47 5.12012 3.35 5.12012H0.219999C0.0999993 5.12012 0 5.24012 0 5.39012V23.9201C0 24.0701 0.0999993 24.1901 0.219999 24.1901H3.35C3.47 24.1901 3.57 24.0701 3.57 23.9201V20.1401C3.57 20.0601 3.6 19.9801 3.65 19.9301L6.47 17.1401C6.54 17.0701 6.63 17.0601 6.71 17.1101L14.24 22.6501C15.47 23.4801 16.85 23.9901 18.25 24.1401C18.37 24.1501 18.48 24.0301 18.48 23.8701V20.3101C18.48 20.1701 18.4 20.0601 18.29 20.0501C17.47 19.9201 16.66 19.6001 15.94 19.1101L9.42 14.3901C9.28 14.3001 9.27 14.0701 9.39 13.9501Z',
},
antigravity: {
viewBox: '0 0 100 100',
d: 'M85.2843 88.0301C90.1329 91.6664 97.4057 89.2422 90.7389 82.5755C70.7389 63.1816 74.9813 9.84827 50.1329 9.84827C25.2843 9.84827 29.5267 63.1816 9.52673 82.5755C2.25402 89.8483 10.1328 91.6664 14.9813 88.0301C33.7692 75.3028 32.5571 52.8786 50.1329 52.8786C67.7086 52.8786 66.4965 75.3028 85.2843 88.0301Z',
},
}
export function hasProviderGlyph(id: string): boolean {
return id in GLYPHS
}
export function ProviderGlyph({ id, size }: { id: string; size: number }) {
const glyph = GLYPHS[id]
if (!glyph) {
// A dotted circle stands in for providers without a curated mark, as on the mac.
return (
<svg width={size} height={size} viewBox="0 0 24 24" aria-hidden="true">
<circle cx="12" cy="12" r="9" fill="none" stroke="currentColor" strokeWidth="2" strokeDasharray="2.4 2.6" />
</svg>
)
}
return (
<svg width={size} height={size} viewBox={glyph.viewBox} aria-hidden="true">
<path d={glyph.d} transform={glyph.transform} fill="currentColor" fillRule="evenodd" />
</svg>
)
}