ai-battery 0.1.13 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,14 @@ property refreshTimer : missing value
9
9
  property titleCommand : ""
10
10
  property detailCommand : ""
11
11
  property tooltipCommand : ""
12
+ property stateCommand : ""
12
13
  property refreshInterval : 10
14
+ property activeRefreshInterval : 10
15
+ property readyRefreshInterval : 10
16
+ property idleRefreshInterval : 30
17
+ property fastRefreshInterval : 2
18
+ property fastUntilDate : missing value
19
+ property lastHudState : ""
13
20
 
14
21
  on run argv
15
22
  if (count of argv) < 2 then error "ai-battery macOS status item requires title and detail commands"
@@ -22,6 +29,7 @@ on run argv
22
29
  try
23
30
  set refreshInterval to (item 4 of argv) as real
24
31
  end try
32
+ if (count of argv) is greater than or equal to 5 then set stateCommand to item 5 of argv
25
33
  else
26
34
  if (count of argv) is greater than or equal to 3 then
27
35
  try
@@ -29,6 +37,7 @@ on run argv
29
37
  end try
30
38
  end if
31
39
  end if
40
+ my configureIntervals_()
32
41
 
33
42
  current application's NSApplication's sharedApplication()
34
43
  current application's NSApp's setActivationPolicy:(current application's NSApplicationActivationPolicyAccessory)
@@ -39,6 +48,7 @@ on run argv
39
48
  statusItem's button()'s setToolTip:"AI Battery"
40
49
 
41
50
  set statusMenu to current application's NSMenu's alloc()'s initWithTitle:"AI Battery"
51
+ statusMenu's setDelegate:me
42
52
  set detailItem to current application's NSMenuItem's alloc()'s initWithTitle:"Loading..." action:(missing value) keyEquivalent:""
43
53
  detailItem's setEnabled:false
44
54
  statusMenu's addItem:detailItem
@@ -54,16 +64,76 @@ on run argv
54
64
 
55
65
  statusItem's setMenu:statusMenu
56
66
  my refresh_(missing value)
57
-
58
- set refreshTimer to current application's NSTimer's scheduledTimerWithTimeInterval:refreshInterval target:me selector:"refresh:" userInfo:(missing value) repeats:true
59
- current application's NSRunLoop's currentRunLoop()'s addTimer:refreshTimer forMode:(current application's NSRunLoopCommonModes)
60
67
  current application's NSApp's |run|()
61
68
  end run
62
69
 
70
+ on configureIntervals_()
71
+ set activeRefreshInterval to refreshInterval
72
+ if activeRefreshInterval is greater than 10 then set activeRefreshInterval to 10
73
+
74
+ set readyRefreshInterval to refreshInterval
75
+ if readyRefreshInterval is less than 10 then set readyRefreshInterval to 10
76
+ if readyRefreshInterval is greater than 15 then set readyRefreshInterval to 15
77
+
78
+ set idleRefreshInterval to refreshInterval * 3
79
+ if idleRefreshInterval is less than 30 then set idleRefreshInterval to 30
80
+ if idleRefreshInterval is greater than 60 then set idleRefreshInterval to 60
81
+
82
+ set fastRefreshInterval to 2
83
+ if refreshInterval is less than 2 then set fastRefreshInterval to refreshInterval
84
+ end configureIntervals_
85
+
86
+ on scheduleRefresh_(secondsUntilRefresh)
87
+ try
88
+ refreshTimer's invalidate()
89
+ end try
90
+ set refreshTimer to current application's NSTimer's scheduledTimerWithTimeInterval:secondsUntilRefresh target:me selector:"refresh:" userInfo:(missing value) repeats:false
91
+ current application's NSRunLoop's currentRunLoop()'s addTimer:refreshTimer forMode:(current application's NSRunLoopCommonModes)
92
+ end scheduleRefresh_
93
+
94
+ on fastWindowActive_()
95
+ if fastUntilDate is missing value then return false
96
+ try
97
+ set secondsLeft to (fastUntilDate's timeIntervalSinceNow()) as real
98
+ if secondsLeft is greater than 0 then return true
99
+ end try
100
+ return false
101
+ end fastWindowActive_
102
+
103
+ on startFastWindow_(secondsToRun)
104
+ set fastUntilDate to current application's NSDate's dateWithTimeIntervalSinceNow:(secondsToRun)
105
+ end startFastWindow_
106
+
107
+ on refreshIntervalForState_(hudState)
108
+ if (my fastWindowActive_()) then return fastRefreshInterval
109
+ if hudState is "background-running" then return fastRefreshInterval
110
+ if hudState is "foreground-running" then return activeRefreshInterval
111
+ if hudState is "background-ready" then return readyRefreshInterval
112
+ return idleRefreshInterval
113
+ end refreshIntervalForState_
114
+
115
+ on updateFastWindowForState_(hudState)
116
+ if hudState is "" then return
117
+ if lastHudState is "" then
118
+ set lastHudState to hudState
119
+ return
120
+ end if
121
+ if hudState is not lastHudState then
122
+ set lastHudState to hudState
123
+ my startFastWindow_(45)
124
+ end if
125
+ end updateFastWindowForState_
126
+
127
+ on menuWillOpen_(sender)
128
+ my startFastWindow_(30)
129
+ my refresh_(missing value)
130
+ end menuWillOpen_
131
+
63
132
  on refresh_(sender)
64
133
  set titleText to "AI --"
65
134
  set detailText to "AI Battery unavailable"
66
135
  set tooltipText to "AI Battery unavailable"
136
+ set hudState to ""
67
137
  set imagePath to ""
68
138
  set menuImage to missing value
69
139
  set detailImage to missing value
@@ -80,6 +150,12 @@ on refresh_(sender)
80
150
  set tooltipText to (do shell script (tooltipCommand as text))
81
151
  end try
82
152
 
153
+ if stateCommand is not "" then
154
+ try
155
+ set hudState to (do shell script (stateCommand as text))
156
+ end try
157
+ end if
158
+
83
159
  if imagePath is "" then set imagePath to "AI --"
84
160
  if detailText is "" then set detailText to "AI Battery unavailable"
85
161
  if tooltipText is "" then set tooltipText to detailText
@@ -123,6 +199,8 @@ on refresh_(sender)
123
199
  end if
124
200
 
125
201
  statusItem's button()'s setToolTip:tooltipText
202
+ my updateFastWindowForState_(hudState)
203
+ my scheduleRefresh_(my refreshIntervalForState_(hudState))
126
204
  end refresh_
127
205
 
128
206
  on quit_(sender)
package/bin/ai-battery.js CHANGED
@@ -16,6 +16,7 @@ const CLAUDE_LIMIT_HIT_TAIL_BYTES = 256 * 1024;
16
16
  const CLAUDE_LIMIT_HIT_MAX_FILES = 80;
17
17
  const CLAUDE_CODEX_CACHE_SECONDS = 60;
18
18
  const CLAUDE_CODEX_FALLBACK_CACHE_SECONDS = 15;
19
+ const BACKGROUND_USAGE_RUNNING_SECONDS = 5 * 60;
19
20
  const DIVIDER = "│";
20
21
  const PROVIDER_DIVIDER = "┃";
21
22
  const ANSI_RE = /\u001b\[[0-?]*[ -/]*[@-~]/g;
@@ -48,6 +49,8 @@ const MENU_BAR_WARNING = "#FF9F0A";
48
49
  const MENU_BAR_DANGER = "#FF453A";
49
50
  const MENU_BAR_OUTLINE_OPACITY = "0.42";
50
51
  const MENU_DETAIL_OUTLINE_OPACITY = "0.14";
52
+ const MENU_DIM_TEXT = "#A1A1AA";
53
+ const MENU_DIM_OUTLINE_OPACITY = "0.24";
51
54
 
52
55
  function parseArgs(argv) {
53
56
  const args = {
@@ -65,6 +68,7 @@ function parseArgs(argv) {
65
68
  menuBar: false,
66
69
  menuBarImage: false,
67
70
  menuDetailImage: false,
71
+ hudState: false,
68
72
  silent: false,
69
73
  force: false,
70
74
  header: true,
@@ -129,6 +133,9 @@ function parseArgs(argv) {
129
133
  } else if (arg === "--menu-detail-image") {
130
134
  args.menuDetailImage = true;
131
135
  args.style = "plain";
136
+ } else if (arg === "--hud-state") {
137
+ args.hudState = true;
138
+ args.style = "plain";
132
139
  } else if (arg === "--version" || arg === "-v") {
133
140
  args.version = true;
134
141
  } else if (arg === "--help" || arg === "-h") {
@@ -2029,6 +2036,28 @@ function codexSessionMeta(filePath) {
2029
2036
  }
2030
2037
  }
2031
2038
 
2039
+ function codexUsageLooksBackground(meta) {
2040
+ if (!meta) return false;
2041
+ const text = [
2042
+ meta.originator,
2043
+ meta.source,
2044
+ meta.client?.name,
2045
+ meta.clientInfo?.name,
2046
+ meta.client_info?.name
2047
+ ].filter(Boolean).join(" ").toLowerCase();
2048
+ if (!text) return false;
2049
+ if (text.includes("codex-tui") || /\bcli\b/.test(text)) return false;
2050
+ return (
2051
+ text.includes("remote")
2052
+ || text.includes("mobile")
2053
+ || text.includes("desktop")
2054
+ || text.includes("codex app")
2055
+ || text.includes("codex_app")
2056
+ || text.includes("vscode")
2057
+ || text.includes("vs code")
2058
+ );
2059
+ }
2060
+
2032
2061
  function sameOrNestedPath(a, b) {
2033
2062
  if (!a || !b) return false;
2034
2063
  const left = path.resolve(a);
@@ -2245,6 +2274,21 @@ function claudeCommandIsBackground(cmdline) {
2245
2274
  || cmdline.includes("--bg-spare");
2246
2275
  }
2247
2276
 
2277
+ function codexCommandIsBackground(cmdline) {
2278
+ const tokens = commandLineTokens(cmdline);
2279
+ if (!tokens.length) return false;
2280
+
2281
+ let commandIndex = -1;
2282
+ const firstBase = commandTokenBasename(tokens[0]).toLowerCase();
2283
+ if (tokenMatchesProviderExecutable(tokens[0], "codex")) {
2284
+ commandIndex = 0;
2285
+ } else if (/^node(?:\.exe)?$/i.test(firstBase) && tokenMatchesProviderExecutable(tokens[1], "codex")) {
2286
+ commandIndex = 1;
2287
+ }
2288
+
2289
+ return commandIndex >= 0 && tokens[commandIndex + 1] === "app-server";
2290
+ }
2291
+
2248
2292
  function commandLineTokens(cmdline) {
2249
2293
  return (String(cmdline || "").match(/"(?:(?:\\.|[^"\\])*)"|'[^']*'|\S+/g) || [])
2250
2294
  .map((token) => token.replace(/^"(.*)"$/s, "$1").replace(/^'(.*)'$/s, "$1").replace(/\\"/g, "\""))
@@ -2297,6 +2341,7 @@ function aiBatteryRunnerCommandTokens(tokens) {
2297
2341
 
2298
2342
  function commandMatchesProvider(cmdline, provider) {
2299
2343
  const text = String(cmdline || "");
2344
+ if (provider === "codex" && codexCommandIsBackground(text)) return false;
2300
2345
  if (provider === "claude" && claudeCommandIsBackground(text)) return false;
2301
2346
  if (
2302
2347
  text.includes("ai-battery.js")
@@ -2476,6 +2521,10 @@ function isProviderRunning(provider) {
2476
2521
  return providerRunningInProcesses(provider, scanProcessCommands());
2477
2522
  }
2478
2523
 
2524
+ function codexBackgroundReadyInProcesses(processes) {
2525
+ return processes.some((proc) => codexCommandIsBackground(proc.cmdline));
2526
+ }
2527
+
2479
2528
  function readStdin() {
2480
2529
  return new Promise((resolve, reject) => {
2481
2530
  let input = "";
@@ -2987,14 +3036,18 @@ function readCodex(options = {}) {
2987
3036
  writeScanCache("codex-status", scan);
2988
3037
  }
2989
3038
 
3039
+ const processes = options.includeRunning === false ? null : scanProcessCommands();
2990
3040
  const running = typeof options.runningOverride === "boolean"
2991
3041
  ? options.runningOverride
2992
3042
  : (
2993
3043
  options.includeRunning === false
2994
3044
  ? Boolean(scan.running)
2995
- : isProviderRunning("codex")
3045
+ : providerRunningInProcesses("codex", processes)
2996
3046
  );
2997
- const result = { ...scan, running };
3047
+ const backgroundReady = processes
3048
+ ? codexBackgroundReadyInProcesses(processes)
3049
+ : Boolean(scan.backgroundReady);
3050
+ const result = { ...scan, running, backgroundReady };
2998
3051
  if (result.ok) result.ageSeconds = cacheAgeSeconds(result.timestamp ?? null);
2999
3052
  return result;
3000
3053
  }
@@ -3057,18 +3110,24 @@ function scanCodexStatus() {
3057
3110
 
3058
3111
  const primary = normalizeLimit(rateLimits.primary);
3059
3112
  const secondary = normalizeLimit(rateLimits.secondary);
3113
+ const sessionMeta = codexSessionMeta(match.file);
3114
+ const timestamp = match.json.timestamp ?? null;
3060
3115
 
3061
3116
  return {
3062
3117
  provider: "codex",
3063
3118
  ok: true,
3064
3119
  planType: rateLimits.plan_type ?? null,
3065
3120
  limitId: rateLimits.limit_id ?? null,
3066
- timestamp: match.json.timestamp ?? null,
3121
+ timestamp,
3067
3122
  source: match.file,
3068
3123
  percentRemaining: primary?.remainingPercent ?? null,
3069
3124
  percentUsed: primary?.usedPercent ?? null,
3070
3125
  primary,
3071
3126
  secondary,
3127
+ usageUpdate: {
3128
+ timestamp,
3129
+ background: codexUsageLooksBackground(sessionMeta)
3130
+ },
3072
3131
  approvalPolicy,
3073
3132
  sandboxMode,
3074
3133
  collaborationMode,
@@ -3741,6 +3800,14 @@ function renderMenuBar(snapshot) {
3741
3800
  return parts.length ? parts.join(" ") : "AI --";
3742
3801
  }
3743
3802
 
3803
+ function renderHudState(snapshot) {
3804
+ const results = snapshot.results.filter(Boolean);
3805
+ if (results.some((result) => result.running === true)) return "foreground-running";
3806
+ if (results.some(codexBackgroundUsageRunning)) return "background-running";
3807
+ if (results.some((result) => result.provider === "codex" && result.backgroundReady === true)) return "background-ready";
3808
+ return "idle";
3809
+ }
3810
+
3744
3811
  function svgEscape(value) {
3745
3812
  return String(value)
3746
3813
  .replace(/&/g, "&amp;")
@@ -3923,17 +3990,11 @@ function imageDataUri(filePath) {
3923
3990
  return `data:${mime};base64,${fs.readFileSync(filePath).toString("base64")}`;
3924
3991
  }
3925
3992
 
3926
- function menuBarBatteryColor(percent) {
3993
+ function menuBatteryColor(percent, running = true) {
3994
+ if (!running) return MENU_DIM_TEXT;
3927
3995
  if (typeof percent !== "number") return MENU_BAR_WHITE;
3928
3996
  if (percent <= 20) return MENU_BAR_DANGER;
3929
3997
  if (percent <= 40) return MENU_BAR_WARNING;
3930
- return MENU_BAR_WHITE;
3931
- }
3932
-
3933
- function menuDetailBatteryColor(percent) {
3934
- if (typeof percent !== "number") return "none";
3935
- if (percent <= 20) return MENU_BAR_DANGER;
3936
- if (percent <= 40) return MENU_BAR_WARNING;
3937
3998
  return MENU_DETAIL_GREEN;
3938
3999
  }
3939
4000
 
@@ -3980,6 +4041,7 @@ function renderMenuBarImage(snapshot) {
3980
4041
 
3981
4042
  visibleResults.forEach((result, index) => {
3982
4043
  const x = startX + (index * providerWidth);
4044
+ const running = result.running === true;
3983
4045
  const percent = typeof result.percentRemaining === "number" ? clamp(result.percentRemaining, 0, 100) : null;
3984
4046
  const meterX = x + 23;
3985
4047
  const meterY = 3;
@@ -3991,16 +4053,18 @@ function renderMenuBarImage(snapshot) {
3991
4053
  const meterInnerWidth = meterWidth - 4;
3992
4054
  const meterInnerHeight = meterHeight - 3.4;
3993
4055
  const fillWidth = percent === null ? 0 : Math.max(percent > 0 ? 2 : 0, Math.round((percent / 100) * meterInnerWidth));
3994
- const fill = menuBarBatteryColor(percent);
4056
+ const fill = menuBatteryColor(percent, running);
3995
4057
  const label = percent === null ? "--" : `${Math.round(percent)}%`;
3996
4058
  const labelX = meterX + (meterWidth / 2);
4059
+ const textFill = running ? MENU_BAR_WHITE : MENU_DIM_TEXT;
4060
+ const outlineOpacity = running ? MENU_BAR_OUTLINE_OPACITY : MENU_DIM_OUTLINE_OPACITY;
3997
4061
 
3998
4062
  items.push(menuBarImageIcon(result.provider, x, 3));
3999
- items.push(`<rect x="${meterX}" y="${meterY}" width="${meterWidth}" height="${meterHeight}" rx="2.5" fill="none" stroke="${MENU_BAR_WHITE}" stroke-opacity="${MENU_BAR_OUTLINE_OPACITY}" stroke-width="${meterStroke}"/>`);
4063
+ items.push(`<rect x="${meterX}" y="${meterY}" width="${meterWidth}" height="${meterHeight}" rx="2.5" fill="none" stroke="${MENU_BAR_WHITE}" stroke-opacity="${outlineOpacity}" stroke-width="${meterStroke}"/>`);
4000
4064
  if (fillWidth > 0) {
4001
4065
  items.push(`<rect x="${meterInnerX}" y="${meterInnerY}" width="${fillWidth}" height="${meterInnerHeight}" rx="0.8" fill="${fill}"/>`);
4002
4066
  }
4003
- items.push(`<text x="${labelX}" y="21" text-anchor="middle" font-family="-apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif" font-size="9.5" font-weight="650" fill="${MENU_BAR_WHITE}">${svgEscape(label)}</text>`);
4067
+ items.push(`<text x="${labelX}" y="21" text-anchor="middle" font-family="-apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif" font-size="9.5" font-weight="650" fill="${textFill}">${svgEscape(label)}</text>`);
4004
4068
  });
4005
4069
 
4006
4070
  if (!items.length) {
@@ -4043,11 +4107,44 @@ function menuDetailMetaText(result) {
4043
4107
  return parts.join(" · ");
4044
4108
  }
4045
4109
 
4110
+ function shortAgeText(timestamp) {
4111
+ const seconds = cacheAgeSeconds(timestamp);
4112
+ if (typeof seconds !== "number") return null;
4113
+ if (seconds < 60) return `${seconds}s ago`;
4114
+ const minutes = Math.floor(seconds / 60);
4115
+ if (minutes < 60) return `${minutes}m ago`;
4116
+ const hours = Math.floor(minutes / 60);
4117
+ if (hours < 24) return `${hours}h ago`;
4118
+ const days = Math.floor(hours / 24);
4119
+ if (days < 7) return `${days}d ago`;
4120
+ return new Date(timestamp).toISOString().slice(0, 10);
4121
+ }
4122
+
4123
+ function codexBackgroundUsageRunning(result) {
4124
+ if (result?.provider !== "codex" || result.running === true) return false;
4125
+ if (result.usageUpdate?.background !== true) return false;
4126
+ const seconds = cacheAgeSeconds(result.usageUpdate?.timestamp ?? result.timestamp ?? null);
4127
+ return typeof seconds === "number" && seconds <= BACKGROUND_USAGE_RUNNING_SECONDS;
4128
+ }
4129
+
4130
+ function menuDetailUsageUpdateText(result) {
4131
+ if (result.provider !== "codex" || result.running === true) return null;
4132
+ if (codexBackgroundUsageRunning(result)) {
4133
+ const timestamp = result.usageUpdate?.timestamp ?? result.timestamp ?? null;
4134
+ const age = shortAgeText(timestamp);
4135
+ if (age) return `local idle · background running · updated ${age}`;
4136
+ }
4137
+ if (result.backgroundReady === true) return "local idle · background ready";
4138
+ return null;
4139
+ }
4140
+
4046
4141
  function renderMenuDetailImage(snapshot) {
4047
4142
  const visibleResults = snapshot.results.filter(Boolean);
4048
4143
  const rows = visibleResults.length ? visibleResults : [{ provider: "ai", ok: false }];
4049
4144
  const width = 392;
4050
- const rowHeight = 36;
4145
+ const usageTexts = rows.map(menuDetailUsageUpdateText);
4146
+ const hasUsageText = usageTexts.some(Boolean);
4147
+ const rowHeight = hasUsageText ? 46 : 36;
4051
4148
  const verticalPadding = 8;
4052
4149
  const height = (rows.length * rowHeight) + (verticalPadding * 2);
4053
4150
  const barX = 86;
@@ -4057,23 +4154,33 @@ function renderMenuDetailImage(snapshot) {
4057
4154
 
4058
4155
  rows.forEach((result, index) => {
4059
4156
  const y = verticalPadding + (index * rowHeight);
4060
- const baseline = y + 22;
4157
+ const baseline = y + (hasUsageText ? 19 : 22);
4158
+ const usageBaseline = y + 38;
4159
+ const usageText = usageTexts[index];
4061
4160
  const provider = result.provider === "codex" ? "Codex" : result.provider === "claude" ? "Claude" : "AI";
4161
+ const running = result.running === true;
4062
4162
  const percent = typeof result.percentRemaining === "number" ? clamp(result.percentRemaining, 0, 100) : null;
4063
4163
  const fillWidth = percent === null ? 0 : Math.max(percent > 0 ? 3 : 0, Math.round((percent / 100) * barWidth));
4064
- const fill = menuDetailBatteryColor(percent);
4164
+ const fill = menuBatteryColor(percent, running);
4065
4165
  const percentText = percent === null ? "--%" : `${Math.round(percent)}%`;
4066
4166
  const metaText = result.ok ? menuDetailMetaText(result) : "unavailable";
4067
4167
  const barY = baseline - barHeight;
4168
+ const primaryFill = running ? "#F5F5F7" : MENU_DIM_TEXT;
4169
+ const metaFill = running ? MENU_DIM_TEXT : "#8E8E93";
4170
+ const trackOpacity = running ? "0.10" : "0.06";
4171
+ const outlineOpacity = running ? MENU_DETAIL_OUTLINE_OPACITY : MENU_DIM_OUTLINE_OPACITY;
4068
4172
 
4069
- items.push(`<text x="14" y="${baseline}" font-family="-apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif" font-size="13" font-weight="650" fill="#F5F5F7">${svgEscape(provider)}</text>`);
4070
- items.push(`<rect x="${barX}" y="${barY}" width="${barWidth}" height="${barHeight}" rx="4" fill="#FFFFFF" fill-opacity="0.10" stroke="#FFFFFF" stroke-opacity="${MENU_DETAIL_OUTLINE_OPACITY}" stroke-width="1"/>`);
4173
+ items.push(`<text x="14" y="${baseline}" font-family="-apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif" font-size="13" font-weight="650" fill="${primaryFill}">${svgEscape(provider)}</text>`);
4174
+ items.push(`<rect x="${barX}" y="${barY}" width="${barWidth}" height="${barHeight}" rx="4" fill="#FFFFFF" fill-opacity="${trackOpacity}" stroke="#FFFFFF" stroke-opacity="${outlineOpacity}" stroke-width="1"/>`);
4071
4175
  if (fillWidth > 0) {
4072
4176
  items.push(`<rect x="${barX}" y="${barY}" width="${fillWidth}" height="${barHeight}" rx="4" fill="${fill}"/>`);
4073
4177
  }
4074
- items.push(`<text x="${barX + barWidth + 12}" y="${baseline}" font-family="-apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif" font-size="13" font-weight="700" fill="#F5F5F7">${svgEscape(percentText)}</text>`);
4178
+ items.push(`<text x="${barX + barWidth + 12}" y="${baseline}" font-family="-apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif" font-size="13" font-weight="700" fill="${primaryFill}">${svgEscape(percentText)}</text>`);
4075
4179
  if (metaText) {
4076
- items.push(`<text x="${width - 14}" y="${baseline}" text-anchor="end" font-family="-apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif" font-size="13" font-weight="550" fill="#A1A1AA">${svgEscape(metaText)}</text>`);
4180
+ items.push(`<text x="${width - 14}" y="${baseline}" text-anchor="end" font-family="-apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif" font-size="13" font-weight="550" fill="${metaFill}">${svgEscape(metaText)}</text>`);
4181
+ }
4182
+ if (usageText) {
4183
+ items.push(`<text x="${width - 14}" y="${usageBaseline}" text-anchor="end" font-family="-apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif" font-size="10.5" font-weight="500" fill="#8E8E93">${svgEscape(usageText)}</text>`);
4077
4184
  }
4078
4185
  });
4079
4186
 
@@ -4109,6 +4216,7 @@ function applyLeftPadding(output, args) {
4109
4216
 
4110
4217
  function render(snapshot, args) {
4111
4218
  if (args.json) return JSON.stringify(snapshot, null, 2);
4219
+ if (args.hudState) return renderHudState(snapshot);
4112
4220
  if (args.menuBarImage) return renderMenuBarImage(snapshot);
4113
4221
  if (args.menuDetailImage) return renderMenuDetailImage(snapshot);
4114
4222
  if (args.menuBar) return renderMenuBar(snapshot);
@@ -4469,6 +4577,7 @@ export {
4469
4577
  bar,
4470
4578
  claudeHeader,
4471
4579
  commandMatchesProvider,
4580
+ codexBackgroundReadyInProcesses,
4472
4581
  codexStatusLineMatches,
4473
4582
  codexWrapperScript,
4474
4583
  firstPercentValue,
@@ -4486,6 +4595,9 @@ export {
4486
4595
  removeAiBatteryShellPathBlock,
4487
4596
  percentValue,
4488
4597
  providerRunningInProcesses,
4598
+ renderHudState,
4599
+ renderMenuBarImage,
4600
+ renderMenuDetailImage,
4489
4601
  rowptyDiagnostic,
4490
4602
  sameFilePath,
4491
4603
  visibleWidth,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-battery",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "Tiny terminal battery meter for local Codex and Claude Code usage.",
5
5
  "type": "module",
6
6
  "keywords": [