Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

feat(usage): bottom-left Claude usage pill and popover

enesbf579200fe90
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index d1a58197f..551801b24 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -54,6 +54,7 @@ import { AnnouncementBanner } from '../components/AnnouncementBanner'
import { ConfirmDialog } from '../components/ConfirmDialog'
import { NotifyConsentDialog } from '../components/NotifyConsentDialog'
import { ExplorerPanel } from '../components/ExplorerPanel'
+import { UsageIndicator } from '../components/UsageIndicator'
import { transport } from '../terminal/local-transport'
import { useProjects } from '../state/projects'
import { useClaudeStatus } from '../state/claudeStatus'
@@ -1498,6 +1499,7 @@ export function Canvas() {
color="#4a4a4a"
/>
<Controls showInteractive={false} position="bottom-left" />
+ <UsageIndicator />
<MiniMap
className="minimap"
position="bottom-right"
diff --git a/src/renderer/components/UsageIndicator.tsx b/src/renderer/components/UsageIndicator.tsx
new file mode 100644
index 000000000..f3e611a04
--- /dev/null
+++ b/src/renderer/components/UsageIndicator.tsx
@@ -0,0 +1,135 @@
+import { useEffect, useRef, useState } from 'react'
+import type { ClaudeUsage, ClaudeUsageWindow } from '@shared/types'
+import { barColor, formatResetCountdown, formatTimeAgo } from '../lib/usageFormat'
+
+const SESSION_LABEL = '5h'
+const WEEKLY_LABEL = 'wk'
+
+/** A single window row in the popover: label, bar, "% left", reset countdown. */
+function WindowRow({ title, label, w }: { title: string; label: string; w: ClaudeUsageWindow }) {
+ const left = Math.round(w.leftPercent)
+ return (
+ <div className="usage-row">
+ <div className="usage-row__title">{title}</div>
+ <div className="usage-bar">
+ <div className="usage-bar__fill" style={{ width: `${w.leftPercent}%`, background: barColor(w.leftPercent) }} />
+ </div>
+ <div className="usage-row__meta">
+ <span>{left}% left</span>
+ <span>{formatResetCountdown(w.resetsAt)}</span>
+ </div>
+ <span className="usage-row__hidden-label">{label}</span>
+ </div>
+ )
+}
+
+/**
+ * Bottom-left Claude usage pill + popover. Renders to the right of the React Flow Controls.
+ * Mirrors REF: hidden when 'unavailable'; '···' while first-fetching; '⚠' on error w/o data;
+ * last-known data shown on stale/error. Compact pill = mini-bar + "62% 5h · 76% wk".
+ */
+export function UsageIndicator(): JSX.Element | null {
+ const [usage, setUsage] = useState<ClaudeUsage | null>(null)
+ const [open, setOpen] = useState(false)
+ const [refreshing, setRefreshing] = useState(false)
+ const popRef = useRef<HTMLDivElement>(null)
+
+ useEffect(() => {
+ void window.nodeTerminal.usage.fetch().then(setUsage)
+ return window.nodeTerminal.usage.onUpdate(setUsage)
+ }, [])
+
+ // Close the popover on an outside click.
+ useEffect(() => {
+ if (!open) return
+ const onDown = (e: MouseEvent): void => {
+ if (popRef.current && !popRef.current.contains(e.target as Node)) setOpen(false)
+ }
+ window.addEventListener('mousedown', onDown)
+ return () => window.removeEventListener('mousedown', onDown)
+ }, [open])
+
+ if (!usage || usage.status === 'unavailable') return null
+
+ const { session, weekly, status } = usage
+ const hasData = !!session || !!weekly
+ const fetching = status === 'fetching' || refreshing
+ const isError = status === 'error'
+
+ const refresh = async (e: React.MouseEvent): Promise<void> => {
+ e.stopPropagation()
+ if (refreshing) return
+ setRefreshing(true)
+ try {
+ setUsage(await window.nodeTerminal.usage.refresh())
+ } finally {
+ setRefreshing(false)
+ }
+ }
+
+ let pillBody: JSX.Element
+ if (!hasData && fetching) {
+ pillBody = <span className="usage-pill__dim usage-pill__pulse">···</span>
+ } else if (!hasData && isError) {
+ pillBody = <span className="usage-pill__dim">⚠</span>
+ } else {
+ pillBody = (
+ <>
+ {session && (
+ <span className="usage-pill__minibar" aria-hidden>
+ <span
+ className="usage-pill__minibar-fill"
+ style={{ width: `${session.leftPercent}%`, background: barColor(session.leftPercent) }}
+ />
+ </span>
+ )}
+ {session && (
+ <span className="usage-pill__num">
+ {Math.round(session.leftPercent)}% {SESSION_LABEL}
+ </span>
+ )}
+ {session && weekly && <span className="usage-pill__sep">·</span>}
+ {weekly && (
+ <span className="usage-pill__num">
+ {Math.round(weekly.leftPercent)}% {WEEKLY_LABEL}
+ </span>
+ )}
+ {isError && hasData && <span className="usage-pill__dim">⚠</span>}
+ </>
+ )
+ }
+
+ return (
+ <div className="usage-indicator" ref={popRef}>
+ {open && (
+ <div className="usage-popover">
+ <div className="usage-popover__head">
+ <span className="usage-popover__title">✦ Claude</span>
+ <span className="usage-popover__ago">Updated {formatTimeAgo(usage.updatedAt)}</span>
+ </div>
+ {session && <WindowRow title="Session" label={SESSION_LABEL} w={session} />}
+ {weekly && <WindowRow title="Weekly" label={WEEKLY_LABEL} w={weekly} />}
+ {!hasData && <div className="usage-popover__empty">No usage data.</div>}
+ {usage.email && (
+ <div className="usage-account">
+ <div className="usage-account__label">Claude Account</div>
+ <div className="usage-account__email">{usage.email}</div>
+ </div>
+ )}
+ </div>
+ )}
+ <button className="usage-pill" onClick={() => setOpen((v) => !v)} title="Claude usage">
+ <span className="usage-pill__icon">✦</span>
+ {pillBody}
+ </button>
+ <button
+ className={`usage-refresh${fetching ? ' spin' : ''}`}
+ onClick={refresh}
+ disabled={refreshing}
+ title="Refresh usage"
+ >
+ ⟳
+ </button>
+ </div>
+ )
+}
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 308b81f2f..6e3c9947d 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -2916,3 +2916,107 @@ body,
.react-flow__controls-button:hover {
background: var(--panel-header);
}
+
+/* ---- Claude usage indicator (bottom-left, right of React Flow Controls) ---- */
+.usage-indicator {
+ position: absolute;
+ left: 60px; /* clear the React Flow Controls column */
+ bottom: 18px;
+ z-index: 5;
+ display: flex;
+ align-items: center;
+ gap: 4px;
+}
+.usage-pill {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ height: 26px;
+ padding: 0 9px;
+ border-radius: 13px;
+ background: rgba(28, 28, 30, 0.92);
+ border: 1px solid rgba(255, 255, 255, 0.08);
+ color: var(--label, #fff);
+ font-size: 12px;
+ font-variant-numeric: tabular-nums;
+ cursor: pointer;
+}
+.usage-pill:hover { background: rgba(44, 44, 46, 0.95); }
+.usage-pill__icon { color: #d97757; font-size: 13px; }
+.usage-pill__minibar {
+ display: inline-block;
+ width: 42px;
+ height: 6px;
+ border-radius: 3px;
+ background: rgba(255, 255, 255, 0.14);
+ overflow: hidden;
+}
+.usage-pill__minibar-fill { display: block; height: 100%; border-radius: 3px; }
+.usage-pill__num { color: var(--label, #fff); }
+.usage-pill__sep { color: rgba(255, 255, 255, 0.4); }
+.usage-pill__dim { color: rgba(255, 255, 255, 0.5); }
+.usage-pill__pulse { animation: usage-pulse 1.2s ease-in-out infinite; }
+@keyframes usage-pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
+
+.usage-refresh {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ width: 24px;
+ height: 24px;
+ border-radius: 12px;
+ background: rgba(28, 28, 30, 0.92);
+ border: 1px solid rgba(255, 255, 255, 0.08);
+ color: rgba(255, 255, 255, 0.7);
+ font-size: 13px;
+ cursor: pointer;
+}
+.usage-refresh:hover { color: #fff; }
+.usage-refresh:disabled { opacity: 0.4; cursor: default; }
+.usage-refresh.spin { animation: usage-spin 0.9s linear infinite; }
+@keyframes usage-spin { to { transform: rotate(360deg); } }
+
+.usage-popover {
+ position: absolute;
+ bottom: 34px;
+ left: 0;
+ width: 280px;
+ padding: 14px 16px;
+ border-radius: 12px;
+ background: rgba(20, 20, 22, 0.98);
+ border: 1px solid rgba(255, 255, 255, 0.1);
+ box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
+ color: var(--label, #fff);
+}
+.usage-popover__head { margin-bottom: 12px; }
+.usage-popover__title { display: block; font-size: 15px; font-weight: 600; }
+.usage-popover__ago { font-size: 12px; color: rgba(255, 255, 255, 0.5); }
+.usage-popover__empty { font-size: 13px; color: rgba(255, 255, 255, 0.5); }
+.usage-row { margin-top: 14px; }
+.usage-row__title { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
+.usage-bar {
+ height: 8px;
+ border-radius: 4px;
+ background: rgba(255, 255, 255, 0.12);
+ overflow: hidden;
+}
+.usage-bar__fill { height: 100%; border-radius: 4px; }
+.usage-row__meta {
+ display: flex;
+ justify-content: space-between;
+ margin-top: 6px;
+ font-size: 13px;
+ color: rgba(255, 255, 255, 0.65);
+}
+.usage-row__hidden-label { display: none; }
+.usage-account {
+ margin-top: 14px;
+ padding-top: 12px;
+ border-top: 1px solid rgba(255, 255, 255, 0.1);
+}
+.usage-account__label {
+ font-size: 12px;
+ color: rgba(255, 255, 255, 0.45);
+ margin-bottom: 4px;
+}
+.usage-account__email { font-size: 13px; }