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): shared types and IPC channels for Claude usage indicator

eneseb85090114f1
diff --git a/src/shared/ipc.ts b/src/shared/ipc.ts
index cc7d30f65..6477acf52 100644
--- a/src/shared/ipc.ts
+++ b/src/shared/ipc.ts
@@ -25,6 +25,9 @@ export const IPC = {
appUpdateDownloaded: 'app:update-downloaded',
appRestartToUpdate: 'app:restart-to-update',
announcementsFetch: 'announcements:fetch',
+ usageFetch: 'usage:fetch',
+ usageRefresh: 'usage:refresh',
+ usageUpdate: 'usage:update',
// Events broadcast from main to the renderer (sessionId is appended to the channel name).
ptyData: (sessionId: string) => `pty:data:${sessionId}`,
ptyExit: (sessionId: string) => `pty:exit:${sessionId}`,
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 94a42662b..eeff60a4e 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -384,6 +384,38 @@ export interface BridgeApi {
onMessage(listener: (m: BridgeMessage) => void): () => void
}
+/** One usage window (5h session or 7d weekly) as shown in the indicator. */
+export interface ClaudeUsageWindow {
+ /** 0–100; remaining quota. Drives the bar fill (REF shows "remaining"). */
+ leftPercent: number
+ /** Unix ms when this window resets, or null if unknown. */
+ resetsAt: number | null
+}
+
+/** Claude Code subscription usage snapshot for the bottom-left indicator. */
+export interface ClaudeUsage {
+ session: ClaudeUsageWindow | null
+ weekly: ClaudeUsageWindow | null
+ /** Signed-in account email, read-only and best-effort (null if unknown). */
+ email: string | null
+ /** Unix ms when this snapshot was produced. */
+ updatedAt: number
+ /**
+ * 'unavailable' = no OAuth subscription token (API-key billing / logged out) → hide pill.
+ * 'fetching' = request in flight. 'ok' = windows present. 'error' = fetch failed.
+ */
+ status: 'unavailable' | 'fetching' | 'ok' | 'error'
+}
+
+export interface UsageApi {
+ /** Returns the latest snapshot (cached if fresh, else a fresh fetch). */
+ fetch(): Promise<ClaudeUsage>
+ /** Forces a fresh fetch, bypassing the focus debounce. */
+ refresh(): Promise<ClaudeUsage>
+ /** Fires whenever main pushes a new snapshot (poll/refresh). Returns unsubscribe. */
+ onUpdate(listener: (usage: ClaudeUsage) => void): () => void
+}
+
export interface NodeTerminalApi {
pty: PtyApi
workspace: WorkspaceApi
@@ -396,6 +428,7 @@ export interface NodeTerminalApi {
updates: UpdateApi
announcements: AnnouncementsApi
bridge: BridgeApi
+ usage: UsageApi
/** Fires when the user presses Cmd/Ctrl+M (toggle markdown view). Returns unsubscribe. */
onMarkdownToggle(listener: () => void): () => void
/** Fires when the user presses Cmd/Ctrl+W (close selected node). Returns unsubscribe. */