ai-battery 0.1.29 → 0.2.0
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.
- package/README.md +82 -325
- package/bin/ai-battery-run +8 -6
- package/docs/REFERENCE.md +78 -0
- package/docs/RELEASING.md +18 -7
- package/docs/antigravity-icon.svg +76 -0
- package/docs/claude-statusline-preview.svg +1 -2
- package/docs/hud-preview.svg +144 -0
- package/docs/terminal-preview.svg +54 -44
- package/lib/cli.js +198 -88
- package/lib/core/cli-help.js +38 -24
- package/lib/core/cli-output.js +24 -4
- package/lib/core/config-editor.js +135 -0
- package/lib/core/display-config.js +29 -0
- package/lib/core/statusline-git.js +47 -0
- package/lib/core/uninstall.js +3 -3
- package/lib/platforms/linux/hud.js +3 -2
- package/lib/platforms/macos/hud.js +3 -2
- package/lib/platforms/process-scanner.js +2 -1
- package/lib/platforms/ui-language.js +41 -0
- package/lib/platforms/windows/codex-runner.js +7 -6
- package/lib/platforms/windows/hud/controls.ps1 +95 -73
- package/lib/platforms/windows/hud/main.ps1 +74 -55
- package/lib/platforms/windows/hud/rendering.ps1 +6 -1
- package/lib/platforms/windows/hud/snapshot.ps1 +23 -0
- package/lib/providers/antigravity.js +167 -0
- package/package.json +4 -2
- package/lib/README.md +0 -23
|
@@ -1,12 +1,24 @@
|
|
|
1
|
+
function Set-HudControlVisible($Control, [bool]$Visible) {
|
|
2
|
+
# Visible reads false when a parent is hidden; Tag records the intended state.
|
|
3
|
+
if ($Control.Tag -ne $Visible) {
|
|
4
|
+
$Control.Visible = $Visible
|
|
5
|
+
$Control.Tag = $Visible
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
1
9
|
function Set-HudBatteryImage($Box, [Nullable[int]]$Percent, [bool]$Running) {
|
|
2
|
-
$
|
|
3
|
-
$
|
|
4
|
-
$Box.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
if (-not $script:hudBatteryRenderKeys) { $script:hudBatteryRenderKeys = @{} }
|
|
11
|
+
$key = "$Percent|$Running|$script:hudScale|$script:hudDarkText"
|
|
12
|
+
if (-not $Box.Image -or $script:hudBatteryRenderKeys[$Box] -ne $key) {
|
|
13
|
+
$image = New-BatteryImage $Percent $Running 36 16 $false
|
|
14
|
+
$oldImage = $Box.Image
|
|
15
|
+
$Box.AccessibleName = if ($null -eq $Percent) { "--" } else { [string][int]$Percent }
|
|
16
|
+
$Box.ForeColor = Get-HudBatteryTextColor $Running
|
|
17
|
+
$Box.Image = $image
|
|
18
|
+
$script:hudBatteryRenderKeys[$Box] = $key
|
|
19
|
+
if ($oldImage) { $oldImage.Dispose() }
|
|
20
|
+
}
|
|
21
|
+
Set-HudControlVisible $Box $true
|
|
10
22
|
}
|
|
11
23
|
|
|
12
24
|
function New-HudGlyphImage([string]$Kind, [System.Drawing.Color]$Color, [int]$Width = 21, [int]$Height = 18) {
|
|
@@ -147,28 +159,24 @@ function Set-HudMetricLabel($Label, [string]$Value, [System.Drawing.Color]$Color
|
|
|
147
159
|
$Label.ForeColor = $Color
|
|
148
160
|
if ([string]::IsNullOrWhiteSpace($Value)) {
|
|
149
161
|
$Label.Width = 0
|
|
150
|
-
$Label
|
|
151
|
-
$Label.Tag = $false
|
|
162
|
+
Set-HudControlVisible $Label $false
|
|
152
163
|
} else {
|
|
153
164
|
$Label.Width = if ($null -ne $FixedWidth -and $FixedWidth -gt 0) {
|
|
154
165
|
[int]$FixedWidth
|
|
155
166
|
} else {
|
|
156
167
|
(Get-LabelTextWidth $Label) + (Scale-HudValue 1)
|
|
157
168
|
}
|
|
158
|
-
$Label
|
|
159
|
-
$Label.Tag = $true
|
|
169
|
+
Set-HudControlVisible $Label $true
|
|
160
170
|
}
|
|
161
171
|
}
|
|
162
172
|
|
|
163
173
|
function Set-HudDivider($Divider, [string]$Value) {
|
|
164
174
|
if ([string]::IsNullOrWhiteSpace($Value)) {
|
|
165
|
-
$Divider
|
|
175
|
+
Set-HudControlVisible $Divider $false
|
|
166
176
|
$Divider.Width = 0
|
|
167
|
-
$Divider.Tag = $false
|
|
168
177
|
} else {
|
|
169
|
-
$Divider
|
|
178
|
+
Set-HudControlVisible $Divider $true
|
|
170
179
|
$Divider.Width = Scale-HudValue 1
|
|
171
|
-
$Divider.Tag = $true
|
|
172
180
|
}
|
|
173
181
|
}
|
|
174
182
|
|
|
@@ -190,12 +198,12 @@ function Get-SharedHudColumnWidth([string[]]$Values, [int]$Minimum = 0) {
|
|
|
190
198
|
return [int]$width
|
|
191
199
|
}
|
|
192
200
|
|
|
193
|
-
function Set-HudParts($Parts, $PrefixLabel, $BatteryBox, $Divider1, $ResetLabel, $Divider2, $WeekLabel, $ExtraLabel, [Nullable[int]]$ResetWidth = $null, [Nullable[int]]$WeekWidth = $null) {
|
|
201
|
+
function Set-HudParts($Parts, $PrefixLabel, $BatteryBox, $Divider1, $ResetLabel, $Divider2, $WeekLabel, $ExtraLabel, [Nullable[int]]$ResetWidth = $null, [Nullable[int]]$WeekWidth = $null, [Nullable[int]]$PrefixWidth = $null) {
|
|
194
202
|
$PrefixLabel.Text = $Parts.Prefix
|
|
195
203
|
$PrefixLabel.ForeColor = $Parts.TextColor
|
|
196
|
-
$PrefixLabel.Width = Scale-HudValue 48
|
|
197
|
-
$PrefixLabel
|
|
198
|
-
$
|
|
204
|
+
$PrefixLabel.Width = if ($null -ne $PrefixWidth) { [int]$PrefixWidth } else { [math]::Max((Scale-HudValue 48), (Get-LabelTextWidth $PrefixLabel) + (Scale-HudValue 1)) }
|
|
205
|
+
Set-HudControlVisible $PrefixLabel $true
|
|
206
|
+
$BatteryBox.Width = Scale-HudValue 42
|
|
199
207
|
Set-HudBatteryImage $BatteryBox $Parts.Percent $Parts.Running
|
|
200
208
|
Set-HudDivider $Divider1 $Parts.ResetValue
|
|
201
209
|
Set-HudMetricLabel $ResetLabel $Parts.ResetValue $Parts.TextColor $ResetWidth
|
|
@@ -206,8 +214,7 @@ function Set-HudParts($Parts, $PrefixLabel, $BatteryBox, $Divider1, $ResetLabel,
|
|
|
206
214
|
|
|
207
215
|
function Set-HudControlsVisible($Controls, [bool]$Visible) {
|
|
208
216
|
foreach ($control in $Controls) {
|
|
209
|
-
$control
|
|
210
|
-
$control.Tag = $Visible
|
|
217
|
+
Set-HudControlVisible $control $Visible
|
|
211
218
|
}
|
|
212
219
|
}
|
|
213
220
|
|
|
@@ -242,39 +249,30 @@ function Resize-HudToContent {
|
|
|
242
249
|
|
|
243
250
|
$oldRight = $form.Left + $form.Width
|
|
244
251
|
$oldBottom = $form.Top + $form.Height
|
|
245
|
-
$
|
|
246
|
-
|
|
247
|
-
$bothRows = $script:codexRowVisible -and $script:claudeRowVisible
|
|
248
|
-
if ($providerDivider) {
|
|
249
|
-
$providerDivider.Visible = $bothRows
|
|
250
|
-
$providerDivider.Tag = $bothRows
|
|
251
|
-
}
|
|
252
|
+
$visibleCount = @($script:hudVisibleProviders).Count
|
|
253
|
+
if ($providerDivider) { $providerDivider.Visible = $false; $providerDivider.Tag = $false }
|
|
252
254
|
if ($script:dockTuiStatusline) {
|
|
253
255
|
Set-DockedTuiWindowRegion
|
|
254
256
|
Sync-HitFormBounds
|
|
255
257
|
return
|
|
256
258
|
}
|
|
257
|
-
$contentWidth =
|
|
258
|
-
|
|
259
|
-
$contentWidth
|
|
260
|
-
|
|
261
|
-
$desiredWidth = [math]::Max((Scale-HudValue 150),
|
|
262
|
-
|
|
263
|
-
$desiredHeight = [
|
|
264
|
-
|
|
265
|
-
$
|
|
266
|
-
$
|
|
267
|
-
|
|
268
|
-
$
|
|
269
|
-
|
|
270
|
-
} else {
|
|
271
|
-
$panel.RowStyles[0] = [System.Windows.Forms.RowStyle]::new([System.Windows.Forms.SizeType]::Percent, 100)
|
|
272
|
-
$panel.RowStyles[1] = [System.Windows.Forms.RowStyle]::new([System.Windows.Forms.SizeType]::Absolute, 0)
|
|
259
|
+
$contentWidth = 0
|
|
260
|
+
foreach ($name in $script:hudVisibleProviders) {
|
|
261
|
+
$contentWidth = [math]::Max($contentWidth, (Get-HudControlsWidth $script:hudProviderRows[$name].Controls))
|
|
262
|
+
}
|
|
263
|
+
$desiredWidth = [math]::Max((Scale-HudValue 150), $panel.Padding.Left + $panel.Padding.Right + $contentWidth + (Scale-HudValue 1))
|
|
264
|
+
$rowHeight = $script:hudTwoRowHeight - $script:hudOneRowHeight
|
|
265
|
+
$desiredHeight = $script:hudOneRowHeight + [math]::Max(0, $visibleCount - 1) * $rowHeight
|
|
266
|
+
for ($i = 0; $i -lt 3; $i += 1) {
|
|
267
|
+
$sizeType = if ($i -lt $visibleCount) { [System.Windows.Forms.SizeType]::Percent } else { [System.Windows.Forms.SizeType]::Absolute }
|
|
268
|
+
$height = if ($i -lt $visibleCount) { 100 / [math]::Max(1, $visibleCount) } else { 0 }
|
|
269
|
+
$style = $panel.RowStyles[$i]
|
|
270
|
+
if ($style.SizeType -ne $sizeType) { $style.SizeType = $sizeType }
|
|
271
|
+
if ([math]::Abs($style.Height - $height) -gt 0.01) { $style.Height = $height }
|
|
273
272
|
}
|
|
274
273
|
|
|
275
274
|
if (([math]::Abs($form.Width - $desiredWidth) -gt 1) -or ($form.Height -ne $desiredHeight)) {
|
|
276
|
-
$form.
|
|
277
|
-
$form.Height = $desiredHeight
|
|
275
|
+
$form.Size = [System.Drawing.Size]::new($desiredWidth, $desiredHeight)
|
|
278
276
|
$newX = if ($script:hudAnchorX -eq "right") { $oldRight - $form.Width } else { $form.Left }
|
|
279
277
|
$newY = if ($script:hudAnchorY -eq "bottom") { $oldBottom - $form.Height } else { $form.Top }
|
|
280
278
|
$form.Location = [System.Drawing.Point]::new([int]$newX, [int]$newY)
|
|
@@ -284,6 +282,9 @@ function Resize-HudToContent {
|
|
|
284
282
|
}
|
|
285
283
|
|
|
286
284
|
function Show-HudMessage([string]$Message) {
|
|
285
|
+
$key = "message:$Message|$script:hudScale|$script:hudDarkText"
|
|
286
|
+
if ($script:hudVisualKey -eq $key) { return }
|
|
287
|
+
$script:hudVisualKey = $null
|
|
287
288
|
$codexPrefixLabel.Text = $Message
|
|
288
289
|
$codexPrefixLabel.ForeColor = Get-HudMutedTextColor
|
|
289
290
|
$codexPrefixLabel.Width = (Get-LabelTextWidth $codexPrefixLabel) + (Scale-HudValue 1)
|
|
@@ -308,9 +309,14 @@ function Show-HudMessage([string]$Message) {
|
|
|
308
309
|
if ($oldImage) { $oldImage.Dispose() }
|
|
309
310
|
$script:codexRowVisible = $true
|
|
310
311
|
$script:claudeRowVisible = $false
|
|
311
|
-
$codexRow
|
|
312
|
-
$claudeRow
|
|
312
|
+
Set-HudControlVisible $codexRow $true
|
|
313
|
+
Set-HudControlVisible $claudeRow $false
|
|
314
|
+
Set-HudControlVisible $antigravityRow $false
|
|
315
|
+
Set-HudControlsVisible $antigravityHudControls $false
|
|
316
|
+
$script:hudVisibleProviders = @("codex")
|
|
317
|
+
if (-not $script:dockTuiStatusline -and $panel.GetRow($codexRow) -ne 0) { $panel.SetRow($codexRow, 0) }
|
|
313
318
|
Resize-HudToContent
|
|
319
|
+
$script:hudVisualKey = $key
|
|
314
320
|
}
|
|
315
321
|
|
|
316
322
|
function Update-HudFromSnapshot($Snapshot) {
|
|
@@ -323,35 +329,51 @@ function Update-HudFromSnapshot($Snapshot) {
|
|
|
323
329
|
|
|
324
330
|
try {
|
|
325
331
|
$texts = ConvertTo-HudTexts $Snapshot
|
|
332
|
+
# Timestamps and fetch metadata do not affect the frame. Keep polling and
|
|
333
|
+
# caching fresh snapshots, but leave an identical screen untouched.
|
|
334
|
+
$visualRows = @($texts.Rows | ForEach-Object {
|
|
335
|
+
@{ Provider = $_.Provider; Prefix = $_.Parts.Prefix; Percent = $_.Parts.Percent;
|
|
336
|
+
Running = $_.Parts.Running; Color = $_.Parts.TextColor.ToArgb();
|
|
337
|
+
Reset = $_.Parts.ResetValue; Week = $_.Parts.WeekValue; Extra = $_.Parts.ExtraText }
|
|
338
|
+
})
|
|
339
|
+
$key = (@{ Rows = $visualRows; Scale = $script:hudScale; DarkText = $script:hudDarkText } | ConvertTo-Json -Depth 5 -Compress)
|
|
340
|
+
if ($script:hudVisualKey -eq $key) {
|
|
341
|
+
Invalidate-DockedTuiIfChanged $Snapshot
|
|
342
|
+
Update-HudVisibilityForFullscreen
|
|
343
|
+
return
|
|
344
|
+
}
|
|
345
|
+
$script:hudVisualKey = $null
|
|
326
346
|
$script:codexRowVisible = [bool]$texts.CodexVisible
|
|
327
347
|
$script:claudeRowVisible = [bool]$texts.ClaudeVisible
|
|
328
|
-
$
|
|
329
|
-
$
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
if ($texts.Codex.WeekValue) { $weekValues += $texts.Codex.WeekValue }
|
|
333
|
-
}
|
|
334
|
-
if ($texts.ClaudeVisible) {
|
|
335
|
-
if ($texts.Claude.ResetValue) { $resetValues += $texts.Claude.ResetValue }
|
|
336
|
-
if ($texts.Claude.WeekValue) { $weekValues += $texts.Claude.WeekValue }
|
|
337
|
-
}
|
|
348
|
+
$script:hudVisibleProviders = @($texts.Rows | ForEach-Object { $_.Provider })
|
|
349
|
+
$prefixValues = @($texts.Rows | ForEach-Object { $_.Parts.Prefix })
|
|
350
|
+
$resetValues = @($texts.Rows | ForEach-Object { $_.Parts.ResetValue } | Where-Object { $_ })
|
|
351
|
+
$weekValues = @($texts.Rows | ForEach-Object { $_.Parts.WeekValue } | Where-Object { $_ })
|
|
338
352
|
$resetWidth = Get-SharedHudColumnWidth $resetValues
|
|
339
353
|
$weekWidth = Get-SharedHudColumnWidth $weekValues
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
$
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
+
$prefixWidth = Get-SharedHudColumnWidth $prefixValues 48
|
|
355
|
+
$panel.SuspendLayout()
|
|
356
|
+
try {
|
|
357
|
+
foreach ($name in $script:hudProviderRows.Keys) {
|
|
358
|
+
$entry = $script:hudProviderRows[$name]
|
|
359
|
+
if ($script:hudVisibleProviders -notcontains $name) { Set-HudControlVisible $entry.Row $false }
|
|
360
|
+
}
|
|
361
|
+
$index = 0
|
|
362
|
+
foreach ($row in $texts.Rows) {
|
|
363
|
+
$entry = $script:hudProviderRows[$row.Provider]
|
|
364
|
+
if (-not $entry) { continue }
|
|
365
|
+
$c = $entry.Controls
|
|
366
|
+
$entry.Row.SuspendLayout()
|
|
367
|
+
try {
|
|
368
|
+
Set-HudParts $row.Parts ($c[0]) ($c[1]) ($c[2]) ($c[3]) ($c[4]) ($c[5]) ($c[6]) $resetWidth $weekWidth $prefixWidth
|
|
369
|
+
} finally { $entry.Row.ResumeLayout() }
|
|
370
|
+
if (-not $script:dockTuiStatusline -and $panel.GetRow($entry.Row) -ne $index) { $panel.SetRow($entry.Row, $index) }
|
|
371
|
+
Set-HudControlVisible $entry.Row $true
|
|
372
|
+
$index += 1
|
|
373
|
+
}
|
|
374
|
+
} finally { $panel.ResumeLayout() }
|
|
354
375
|
Resize-HudToContent
|
|
376
|
+
$script:hudVisualKey = $key
|
|
355
377
|
} catch {
|
|
356
378
|
Show-HudMessage "AI Battery unavailable"
|
|
357
379
|
}
|
|
@@ -21,7 +21,7 @@ param(
|
|
|
21
21
|
[Int64]$DockWindowHandle = 0,
|
|
22
22
|
[Int64]$DockSession = 0,
|
|
23
23
|
[int]$DockOwnerPid = 0,
|
|
24
|
-
[ValidateSet("", "codex", "claude")]
|
|
24
|
+
[ValidateSet("", "codex", "claude", "antigravity")]
|
|
25
25
|
[string]$DockProvider = "",
|
|
26
26
|
[string]$DockMarkerPath = "",
|
|
27
27
|
[ValidateSet("bottom", "tabs")]
|
|
@@ -380,8 +380,7 @@ $script:initialHudSnapshot = Read-InitialHudSnapshot
|
|
|
380
380
|
|
|
381
381
|
if ($Once) {
|
|
382
382
|
$texts = Get-Texts
|
|
383
|
-
|
|
384
|
-
if ($texts.ClaudeVisible) { Write-Output "$($texts.Claude.Prefix)[battery]$($texts.Claude.Suffix)" }
|
|
383
|
+
foreach ($row in $texts.Rows) { Write-Output "$($row.Parts.Prefix)[battery]$($row.Parts.Suffix)" }
|
|
385
384
|
exit 0
|
|
386
385
|
}
|
|
387
386
|
|
|
@@ -411,6 +410,9 @@ if ($Mode -eq "tray") {
|
|
|
411
410
|
$claudeRow = New-StatusMenuRow $trayFont
|
|
412
411
|
$menu.Items.Add($codexRow.Host) | Out-Null
|
|
413
412
|
$menu.Items.Add($claudeRow.Host) | Out-Null
|
|
413
|
+
$antigravityRow = New-StatusMenuRow $trayFont
|
|
414
|
+
$menu.Items.Add($antigravityRow.Host) | Out-Null
|
|
415
|
+
$trayRows = @{ codex = $codexRow; claude = $claudeRow; antigravity = $antigravityRow }
|
|
414
416
|
$menu.Items.Add("-") | Out-Null
|
|
415
417
|
$refreshItem = $menu.Items.Add("Refresh")
|
|
416
418
|
$exitItem = $menu.Items.Add("Exit")
|
|
@@ -431,11 +433,8 @@ if ($Mode -eq "tray") {
|
|
|
431
433
|
if ($oldIcon) { $oldIcon.Dispose() }
|
|
432
434
|
|
|
433
435
|
$shortParts = @()
|
|
434
|
-
|
|
435
|
-
$shortParts += $(if ($null -ne $
|
|
436
|
-
}
|
|
437
|
-
if ($Texts.ClaudeVisible) {
|
|
438
|
-
$shortParts += $(if ($null -ne $Texts.ClaudeResult.percentRemaining) { "Claude $($Texts.ClaudeResult.percentRemaining)%" } else { "Claude --%" })
|
|
436
|
+
foreach ($row in $Texts.Rows) {
|
|
437
|
+
$shortParts += $(if ($null -ne $row.Result.percentRemaining) { "$($row.Name) $($row.Result.percentRemaining)%" } else { "$($row.Name) --%" })
|
|
439
438
|
}
|
|
440
439
|
$notifyIcon.Text = Limit-Text "AI Battery: $($shortParts -join ', ')" 63
|
|
441
440
|
}
|
|
@@ -443,15 +442,21 @@ if ($Mode -eq "tray") {
|
|
|
443
442
|
function Update-Tray {
|
|
444
443
|
try {
|
|
445
444
|
$texts = Get-Texts
|
|
446
|
-
$
|
|
447
|
-
$
|
|
448
|
-
$
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
445
|
+
foreach ($entry in $trayRows.Values) { $entry.Host.Visible = $false }
|
|
446
|
+
$lines = @()
|
|
447
|
+
$index = 0
|
|
448
|
+
foreach ($row in $texts.Rows) {
|
|
449
|
+
$entry = $trayRows[$row.Provider]
|
|
450
|
+
if (-not $entry) { continue }
|
|
451
|
+
$entry.Host.Visible = $true
|
|
452
|
+
$menu.Items.Remove($entry.Host)
|
|
453
|
+
$menu.Items.Insert($index, $entry.Host)
|
|
454
|
+
Set-StatusMenuRow $entry $row.Parts
|
|
455
|
+
$lines += Get-LineText $row.Parts
|
|
456
|
+
$index += 1
|
|
457
|
+
}
|
|
453
458
|
Set-SingleNotifyIcon $texts
|
|
454
|
-
$script:lastBalloonText =
|
|
459
|
+
$script:lastBalloonText = $lines -join "`n"
|
|
455
460
|
} catch {
|
|
456
461
|
Set-StatusMenuRow $codexRow @{
|
|
457
462
|
Prefix = "Codex "
|
|
@@ -486,6 +491,7 @@ if ($Mode -eq "tray") {
|
|
|
486
491
|
$notifyIcon.Visible = $false
|
|
487
492
|
Dispose-StatusMenuRow $codexRow
|
|
488
493
|
Dispose-StatusMenuRow $claudeRow
|
|
494
|
+
Dispose-StatusMenuRow $antigravityRow
|
|
489
495
|
if ($notifyIcon.Icon) { $notifyIcon.Icon.Dispose() }
|
|
490
496
|
$notifyIcon.Dispose()
|
|
491
497
|
$trayFont.Dispose()
|
|
@@ -523,6 +529,7 @@ $script:dockTuiResponsiveLayoutName = ""
|
|
|
523
529
|
$script:dockTuiResponsiveThresholds = ""
|
|
524
530
|
$script:dockOuterBorderColor = [System.Drawing.Color]::FromArgb(72, 72, 72)
|
|
525
531
|
$form = New-Object System.Windows.Forms.Form
|
|
532
|
+
Enable-HudDoubleBuffering $form
|
|
526
533
|
$form.Text = "AI Battery"
|
|
527
534
|
$form.AutoScaleMode = [System.Windows.Forms.AutoScaleMode]::None
|
|
528
535
|
$form.StartPosition = [System.Windows.Forms.FormStartPosition]::Manual
|
|
@@ -593,8 +600,9 @@ $font = New-HudMainFont
|
|
|
593
600
|
$symbolFont = New-HudSymbolFont
|
|
594
601
|
|
|
595
602
|
$panel = New-Object System.Windows.Forms.TableLayoutPanel
|
|
603
|
+
Enable-HudDoubleBuffering $panel
|
|
596
604
|
$panel.Dock = [System.Windows.Forms.DockStyle]::Fill
|
|
597
|
-
$panel.RowCount = $(if ($script:dockTuiStatusline) { 1 } else {
|
|
605
|
+
$panel.RowCount = $(if ($script:dockTuiStatusline) { 1 } else { 3 })
|
|
598
606
|
$panel.ColumnCount = 1
|
|
599
607
|
$panel.GrowStyle = [System.Windows.Forms.TableLayoutPanelGrowStyle]::FixedSize
|
|
600
608
|
$panel.Padding = if ($script:dockTuiStatusline) {
|
|
@@ -608,11 +616,13 @@ $panel.BackColor = $script:hudSurfaceBackColor
|
|
|
608
616
|
$panel.RowStyles.Add([System.Windows.Forms.RowStyle]::new([System.Windows.Forms.SizeType]::Percent, $(if ($script:dockTuiStatusline) { 100 } else { 50 }))) | Out-Null
|
|
609
617
|
if (-not $script:dockTuiStatusline) {
|
|
610
618
|
$panel.RowStyles.Add([System.Windows.Forms.RowStyle]::new([System.Windows.Forms.SizeType]::Percent, 50)) | Out-Null
|
|
619
|
+
$panel.RowStyles.Add([System.Windows.Forms.RowStyle]::new([System.Windows.Forms.SizeType]::Absolute, 0)) | Out-Null
|
|
611
620
|
}
|
|
612
621
|
$panel.ColumnStyles.Add([System.Windows.Forms.ColumnStyle]::new([System.Windows.Forms.SizeType]::Percent, 100)) | Out-Null
|
|
613
622
|
|
|
614
623
|
function New-HudRow {
|
|
615
624
|
$row = New-Object System.Windows.Forms.FlowLayoutPanel
|
|
625
|
+
Enable-HudDoubleBuffering $row
|
|
616
626
|
$row.Dock = [System.Windows.Forms.DockStyle]::Fill
|
|
617
627
|
$row.FlowDirection = [System.Windows.Forms.FlowDirection]::LeftToRight
|
|
618
628
|
$row.WrapContents = $false
|
|
@@ -730,7 +740,7 @@ function Get-TuiTextWidth([string]$Value, $DrawFont) {
|
|
|
730
740
|
return [int]$size.Width
|
|
731
741
|
}
|
|
732
742
|
|
|
733
|
-
function Get-TuiProviderDisplayValues($Result, [string]$Name, [int]$BarWidth, [bool]$ShowWindows) {
|
|
743
|
+
function Get-TuiProviderDisplayValues($Result, [string]$Name, [int]$BarWidth, [bool]$ShowWindows, [bool]$PrimaryOnly = $false) {
|
|
734
744
|
$percent = if ($Result -and $Result.ok -and $null -ne $Result.percentRemaining) { [int]$Result.percentRemaining } else { $null }
|
|
735
745
|
$values = [ordered]@{
|
|
736
746
|
Prefix = $Name + " "
|
|
@@ -742,7 +752,7 @@ function Get-TuiProviderDisplayValues($Result, [string]$Name, [int]$BarWidth, [b
|
|
|
742
752
|
if ($ShowWindows -and $Result -and $Result.primary) {
|
|
743
753
|
$values.Primary = "$(Get-WindowText $Result.primary.windowMinutes) $(Get-ResetClock $Result.primary)"
|
|
744
754
|
}
|
|
745
|
-
if ($ShowWindows -and $Result -and $Result.secondary) {
|
|
755
|
+
if ($ShowWindows -and -not $PrimaryOnly -and $Result -and $Result.secondary) {
|
|
746
756
|
$values.Secondary = "$(Get-WindowText $Result.secondary.windowMinutes) $([int]$Result.secondary.remainingPercent)%"
|
|
747
757
|
if ($Result.secondary.remainingPercent -le 10 -and -not $Result.secondary.resetPassed) {
|
|
748
758
|
$values.Secondary += " $(Get-ResetClock $Result.secondary)"
|
|
@@ -751,8 +761,8 @@ function Get-TuiProviderDisplayValues($Result, [string]$Name, [int]$BarWidth, [b
|
|
|
751
761
|
return [PSCustomObject]$values
|
|
752
762
|
}
|
|
753
763
|
|
|
754
|
-
function Get-TuiProviderDisplayWidth($Result, [string]$Name, $DrawFont, [int]$BarWidth, [bool]$ShowWindows) {
|
|
755
|
-
$values = Get-TuiProviderDisplayValues $Result $Name $BarWidth $ShowWindows
|
|
764
|
+
function Get-TuiProviderDisplayWidth($Result, [string]$Name, $DrawFont, [int]$BarWidth, [bool]$ShowWindows, [bool]$PrimaryOnly = $false) {
|
|
765
|
+
$values = Get-TuiProviderDisplayValues $Result $Name $BarWidth $ShowWindows $PrimaryOnly
|
|
756
766
|
$width = (Get-TuiTextWidth $values.Prefix $DrawFont) +
|
|
757
767
|
(Get-TuiTextWidth $values.Bar $DrawFont) +
|
|
758
768
|
(Get-TuiTextWidth $values.Percent $DrawFont)
|
|
@@ -766,38 +776,32 @@ function Get-TuiProviderDisplayWidth($Result, [string]$Name, $DrawFont, [int]$Ba
|
|
|
766
776
|
return $width
|
|
767
777
|
}
|
|
768
778
|
|
|
769
|
-
function Get-DockedTuiResponsiveLayout($
|
|
770
|
-
#
|
|
771
|
-
#
|
|
772
|
-
# summary still fits at Windows Terminal's minimum practical width.
|
|
779
|
+
function Get-DockedTuiResponsiveLayout($Results, $DrawFont, [int]$AvailableWidth) {
|
|
780
|
+
# Match the text TUI: 10/5 cells with both windows, 5 cells with 5h only,
|
|
781
|
+
# then 10/5/4-cell summaries. Each stage must fit its actual content.
|
|
773
782
|
$candidates = @(
|
|
774
783
|
[PSCustomObject]@{ Name = "full"; BarWidth = 10; ShowWindows = $true },
|
|
775
784
|
[PSCustomObject]@{ Name = "metrics-half"; BarWidth = 5; ShowWindows = $true },
|
|
776
|
-
[PSCustomObject]@{ Name = "
|
|
785
|
+
[PSCustomObject]@{ Name = "primary-half"; BarWidth = 5; ShowWindows = $true; PrimaryOnly = $true },
|
|
786
|
+
[PSCustomObject]@{ Name = "summary-full"; BarWidth = 10; ShowWindows = $false },
|
|
787
|
+
[PSCustomObject]@{ Name = "summary-half"; BarWidth = 5; ShowWindows = $false },
|
|
788
|
+
[PSCustomObject]@{ Name = "summary-min"; BarWidth = 4; ShowWindows = $false }
|
|
777
789
|
)
|
|
778
|
-
$providerDividerWidth =
|
|
790
|
+
$providerDividerWidth = [math]::Max(0, @($Results).Count - 1) * (Get-TuiTextWidth " $([char]0x2503) " $DrawFont)
|
|
779
791
|
$requiredWidths = @()
|
|
780
792
|
foreach ($candidate in $candidates) {
|
|
781
793
|
$required = $providerDividerWidth
|
|
782
|
-
|
|
783
|
-
$required += Get-TuiProviderDisplayWidth $
|
|
784
|
-
}
|
|
785
|
-
if ($Claude) {
|
|
786
|
-
$required += Get-TuiProviderDisplayWidth $Claude "Claude" $DrawFont $candidate.BarWidth $candidate.ShowWindows
|
|
794
|
+
foreach ($result in $Results) {
|
|
795
|
+
$required += Get-TuiProviderDisplayWidth $result (Get-ProviderLabel $result.provider) $DrawFont $candidate.BarWidth $candidate.ShowWindows ([bool]$candidate.PrimaryOnly)
|
|
787
796
|
}
|
|
788
797
|
$requiredWidths += $required
|
|
789
798
|
}
|
|
790
799
|
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
$metricsHalfThreshold = [math]::Max($requiredWidths[1], [int][math]::Ceiling($requiredWidths[0] * 0.98))
|
|
797
|
-
$script:dockTuiResponsiveThresholds = "$fullThreshold,$metricsHalfThreshold"
|
|
798
|
-
if ($AvailableWidth -ge $fullThreshold) { return $candidates[0] }
|
|
799
|
-
if ($AvailableWidth -ge $metricsHalfThreshold) { return $candidates[1] }
|
|
800
|
-
return $candidates[2]
|
|
800
|
+
$script:dockTuiResponsiveThresholds = $requiredWidths -join ","
|
|
801
|
+
for ($i = 0; $i -lt $candidates.Count; $i += 1) {
|
|
802
|
+
if ($AvailableWidth -ge $requiredWidths[$i]) { return $candidates[$i] }
|
|
803
|
+
}
|
|
804
|
+
return $candidates[-1]
|
|
801
805
|
}
|
|
802
806
|
|
|
803
807
|
function Draw-TuiProvider($Graphics, $Result, [string]$Name, [ref]$X, [int]$Y, $DrawFont, $Layout) {
|
|
@@ -810,7 +814,7 @@ function Draw-TuiProvider($Graphics, $Result, [string]$Name, [ref]$X, [int]$Y, $
|
|
|
810
814
|
$filled = if ($null -ne $percent) { [int][math]::Round(($clamped / 100.0) * $barWidth) } else { 0 }
|
|
811
815
|
if ($clamped -gt 0 -and $filled -eq 0) { $filled = 1 }
|
|
812
816
|
$barGlyph = [string][char]0x275A
|
|
813
|
-
$values = Get-TuiProviderDisplayValues $Result $Name $barWidth ([bool]$Layout.ShowWindows)
|
|
817
|
+
$values = Get-TuiProviderDisplayValues $Result $Name $barWidth ([bool]$Layout.ShowWindows) ([bool]$Layout.PrimaryOnly)
|
|
814
818
|
|
|
815
819
|
Draw-TuiSegment $Graphics $values.Prefix $textColor $X $Y $DrawFont
|
|
816
820
|
$barStart = [int]$X.Value
|
|
@@ -834,7 +838,8 @@ function Draw-TuiProvider($Graphics, $Result, [string]$Name, [ref]$X, [int]$Y, $
|
|
|
834
838
|
|
|
835
839
|
function Get-DockedTuiProviderRunning($Result, [string]$Name) {
|
|
836
840
|
if ($script:dockTuiStatusline -and $script:dockSessionTrackingEnabled) {
|
|
837
|
-
|
|
841
|
+
$provider = if ($Result -and $Result.provider) { $Result.provider } else { $Name }
|
|
842
|
+
return Test-DockProviderActiveForTarget $provider ([Int64]$script:dockTargetHandle)
|
|
838
843
|
}
|
|
839
844
|
return [bool]($Result -and $Result.running)
|
|
840
845
|
}
|
|
@@ -842,13 +847,11 @@ function Get-DockedTuiProviderRunning($Result, [string]$Name) {
|
|
|
842
847
|
function Draw-DockedTuiStatusline($Graphics, [int]$Width, [int]$Height) {
|
|
843
848
|
$snapshot = $script:latestSnapshot
|
|
844
849
|
if (-not $snapshot -or -not $snapshot.results) { return }
|
|
845
|
-
$codex = Get-Provider $snapshot "codex"
|
|
846
|
-
$claude = Get-Provider $snapshot "claude"
|
|
847
850
|
$xValue = Scale-HudValue 15
|
|
848
851
|
$x = [ref]$xValue
|
|
849
852
|
$rightPadding = Scale-HudValue 10
|
|
850
853
|
$availableWidth = [math]::Max(1, $Width - $xValue - $rightPadding)
|
|
851
|
-
$layout = Get-DockedTuiResponsiveLayout $
|
|
854
|
+
$layout = Get-DockedTuiResponsiveLayout $snapshot.results $font $availableWidth
|
|
852
855
|
if ($script:dockTuiResponsiveLayoutName -ne $layout.Name) {
|
|
853
856
|
$script:dockTuiResponsiveLayoutName = $layout.Name
|
|
854
857
|
if (Get-Command Write-HudDockDebug -ErrorAction SilentlyContinue) {
|
|
@@ -858,11 +861,12 @@ function Draw-DockedTuiStatusline($Graphics, [int]$Width, [int]$Height) {
|
|
|
858
861
|
$visibleTop = [math]::Max(0, [int]$script:dockJoinOverlap - (Scale-HudValue 2))
|
|
859
862
|
$visibleHeight = [math]::Max(1, $Height - $visibleTop)
|
|
860
863
|
$y = $visibleTop + [math]::Max(0, [int][math]::Floor(($visibleHeight - $font.Height) / 2) - 1)
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
Draw-TuiSegment $Graphics " $([char]0x2503) " ([System.Drawing.Color]::FromArgb(150, 150, 150)) $x $y $font
|
|
864
|
+
$index = 0
|
|
865
|
+
foreach ($result in $snapshot.results) {
|
|
866
|
+
if ($index -gt 0) { Draw-TuiSegment $Graphics " $([char]0x2503) " ([System.Drawing.Color]::FromArgb(150, 150, 150)) $x $y $font }
|
|
867
|
+
Draw-TuiProvider $Graphics $result (Get-ProviderLabel $result.provider) $x $y $font $layout
|
|
868
|
+
$index += 1
|
|
864
869
|
}
|
|
865
|
-
if ($claude) { Draw-TuiProvider $Graphics $claude "Claude" $x $y $font $layout }
|
|
866
870
|
}
|
|
867
871
|
|
|
868
872
|
$script:dockTuiRenderKey = $null
|
|
@@ -870,8 +874,8 @@ $script:dockTuiRenderKey = $null
|
|
|
870
874
|
function Get-DockedTuiRenderKey($Snapshot) {
|
|
871
875
|
if (-not $Snapshot -or -not $Snapshot.results) { return "empty" }
|
|
872
876
|
$parts = @()
|
|
873
|
-
foreach ($
|
|
874
|
-
$
|
|
877
|
+
foreach ($result in $Snapshot.results) {
|
|
878
|
+
$name = $result.provider
|
|
875
879
|
if (-not $result) { $parts += "$name`:missing"; continue }
|
|
876
880
|
$primary = if ($result.primary) {
|
|
877
881
|
"$(Get-WindowText $result.primary.windowMinutes):$(Get-ResetClock $result.primary)"
|
|
@@ -932,6 +936,7 @@ function Draw-DockedTuiOuterBorder($Graphics, [int]$Width, [int]$Height) {
|
|
|
932
936
|
|
|
933
937
|
$codexRow = New-HudRow
|
|
934
938
|
$claudeRow = New-HudRow
|
|
939
|
+
$antigravityRow = New-HudRow
|
|
935
940
|
$codexPrefixLabel = New-HudLabel
|
|
936
941
|
$codexIconLabel = New-HudIconBox
|
|
937
942
|
$codexDivider1 = New-HudDivider
|
|
@@ -960,6 +965,14 @@ foreach ($label in @($codexIconLabel, $claudeIconLabel)) {
|
|
|
960
965
|
$codexHudControls = @($codexPrefixLabel, $codexIconLabel, $codexDivider1, $codexResetLabel, $codexDivider2, $codexWeekLabel, $codexExtraLabel)
|
|
961
966
|
$claudeHudControls = @($claudePrefixLabel, $claudeIconLabel, $claudeDivider1, $claudeResetLabel, $claudeDivider2, $claudeWeekLabel, $claudeExtraLabel)
|
|
962
967
|
|
|
968
|
+
$antigravityHudControls = @((New-HudLabel), (New-HudIconBox), (New-HudDivider), (New-HudLabel), (New-HudDivider), (New-HudLabel), (New-HudLabel))
|
|
969
|
+
$script:hudProviderRows = @{
|
|
970
|
+
codex = @{ Row = $codexRow; Controls = $codexHudControls }
|
|
971
|
+
claude = @{ Row = $claudeRow; Controls = $claudeHudControls }
|
|
972
|
+
antigravity = @{ Row = $antigravityRow; Controls = $antigravityHudControls }
|
|
973
|
+
}
|
|
974
|
+
$script:hudVisibleProviders = @("codex", "claude")
|
|
975
|
+
|
|
963
976
|
function Test-PointInBounds($Bounds, [System.Drawing.Point]$Point) {
|
|
964
977
|
if (-not $Bounds) { return $false }
|
|
965
978
|
return $Bounds.Contains($Point)
|
|
@@ -994,6 +1007,11 @@ foreach ($label in $claudeHudControls) {
|
|
|
994
1007
|
$label.ContextMenuStrip = $menu
|
|
995
1008
|
$claudeRow.Controls.Add($label) | Out-Null
|
|
996
1009
|
}
|
|
1010
|
+
foreach ($control in $antigravityHudControls) {
|
|
1011
|
+
$control.ContextMenuStrip = $menu
|
|
1012
|
+
$antigravityRow.Controls.Add($control) | Out-Null
|
|
1013
|
+
}
|
|
1014
|
+
$antigravityRow.ContextMenuStrip = $menu
|
|
997
1015
|
$codexRow.ContextMenuStrip = $menu
|
|
998
1016
|
$claudeRow.ContextMenuStrip = $menu
|
|
999
1017
|
$providerDivider.ContextMenuStrip = $menu
|
|
@@ -1020,6 +1038,7 @@ if ($script:dockTuiStatusline) {
|
|
|
1020
1038
|
} else {
|
|
1021
1039
|
$panel.Controls.Add($codexRow, 0, 0) | Out-Null
|
|
1022
1040
|
$panel.Controls.Add($claudeRow, 0, 1) | Out-Null
|
|
1041
|
+
$panel.Controls.Add($antigravityRow, 0, 2) | Out-Null
|
|
1023
1042
|
}
|
|
1024
1043
|
if ($script:dockTuiStatusline) {
|
|
1025
1044
|
$form.Controls.Add($script:dockTuiPaintPanel)
|
|
@@ -1138,7 +1157,7 @@ function Save-HudPositionIfReady {
|
|
|
1138
1157
|
}
|
|
1139
1158
|
|
|
1140
1159
|
if ($canMove) {
|
|
1141
|
-
$dragControls = @($form, $panel, $codexRow, $claudeRow) + $codexHudControls + $claudeHudControls
|
|
1160
|
+
$dragControls = @($form, $panel, $codexRow, $claudeRow, $antigravityRow) + $codexHudControls + $claudeHudControls + $antigravityHudControls
|
|
1142
1161
|
if ($hitForm) { $dragControls += $hitForm }
|
|
1143
1162
|
foreach ($control in $dragControls) {
|
|
1144
1163
|
$control.add_MouseDown($mouseDown)
|
|
@@ -1307,7 +1326,7 @@ $form.add_FormClosed({
|
|
|
1307
1326
|
$menuAutoHideTimer.Dispose()
|
|
1308
1327
|
Stop-FullscreenEventHooks
|
|
1309
1328
|
Stop-SnapshotFetch
|
|
1310
|
-
foreach ($box in @($codexIconLabel, $claudeIconLabel)) {
|
|
1329
|
+
foreach ($box in @($codexIconLabel, $claudeIconLabel, $antigravityHudControls[1])) {
|
|
1311
1330
|
if ($box.Image) {
|
|
1312
1331
|
$box.Image.Dispose()
|
|
1313
1332
|
$box.Image = $null
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
function Enable-HudDoubleBuffering($Control) {
|
|
2
|
+
$property = [System.Windows.Forms.Control].GetProperty("DoubleBuffered", [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic)
|
|
3
|
+
$property.SetValue($Control, $true, $null)
|
|
4
|
+
}
|
|
5
|
+
|
|
1
6
|
function Get-HudDpi {
|
|
2
7
|
try {
|
|
3
8
|
if ($DockWindowHandle -ne 0) {
|
|
@@ -96,7 +101,7 @@ function Limit-Text([string]$Text, [int]$MaxLength) {
|
|
|
96
101
|
|
|
97
102
|
function Select-TrayPercent($Texts) {
|
|
98
103
|
$items = @()
|
|
99
|
-
foreach ($result in @($Texts.CodexResult, $Texts.ClaudeResult)) {
|
|
104
|
+
foreach ($result in @($Texts.CodexResult, $Texts.ClaudeResult, $Texts.AntigravityResult)) {
|
|
100
105
|
if ($result -and $result.ok -and $null -ne $result.percentRemaining) {
|
|
101
106
|
$items += [PSCustomObject]@{
|
|
102
107
|
Percent = [int]$result.percentRemaining
|
|
@@ -169,6 +169,7 @@ function Format-Parts($Result, [string]$Name) {
|
|
|
169
169
|
$divider = [string][char]0x2502
|
|
170
170
|
if ($Result.primary) {
|
|
171
171
|
$resetWindow = Get-WindowText $Result.primary.windowMinutes
|
|
172
|
+
if ($Result.provider -eq "antigravity" -and -not $Result.primary.windowMinutes) { $resetWindow = $Result.primary.id }
|
|
172
173
|
$resetValue = "$resetWindow $(Get-ResetClock $Result.primary)".PadRight(8)
|
|
173
174
|
$resetText = $resetValue
|
|
174
175
|
}
|
|
@@ -230,6 +231,8 @@ function Merge-HudSnapshot($Snapshot, $CachedSnapshot) {
|
|
|
230
231
|
if ($usable) {
|
|
231
232
|
$current | Add-Member -NotePropertyName "hudCachedAt" -NotePropertyValue $nowUtc.ToString("o") -Force
|
|
232
233
|
}
|
|
234
|
+
# agy readings already come from a local cache; expired buckets must stay unknown.
|
|
235
|
+
if ($current.provider -eq "antigravity") { continue }
|
|
233
236
|
|
|
234
237
|
$cached = $null
|
|
235
238
|
if ($CachedSnapshot) { $cached = Get-Provider $CachedSnapshot $current.provider }
|
|
@@ -265,6 +268,13 @@ function Merge-HudSnapshot($Snapshot, $CachedSnapshot) {
|
|
|
265
268
|
function ConvertTo-HudTexts($Snapshot) {
|
|
266
269
|
$codex = Get-Provider $Snapshot "codex"
|
|
267
270
|
$claude = Get-Provider $Snapshot "claude"
|
|
271
|
+
$antigravity = Get-Provider $Snapshot "antigravity"
|
|
272
|
+
$rows = @()
|
|
273
|
+
foreach ($result in $Snapshot.results) {
|
|
274
|
+
if (-not $result) { continue }
|
|
275
|
+
$name = Get-ProviderLabel $result.provider
|
|
276
|
+
$rows += @{ Provider = $result.provider; Name = $name; Result = $result; Parts = (Format-Parts $result $name) }
|
|
277
|
+
}
|
|
268
278
|
$codexVisible = $null -ne $codex
|
|
269
279
|
$claudeVisible = $null -ne $claude
|
|
270
280
|
return @{
|
|
@@ -274,6 +284,19 @@ function ConvertTo-HudTexts($Snapshot) {
|
|
|
274
284
|
ClaudeResult = $claude
|
|
275
285
|
CodexVisible = $codexVisible
|
|
276
286
|
ClaudeVisible = $claudeVisible
|
|
287
|
+
Antigravity = $(if ($antigravity) { Format-Parts $antigravity "Gemini" } else { $null })
|
|
288
|
+
AntigravityResult = $antigravity
|
|
289
|
+
AntigravityVisible = $null -ne $antigravity
|
|
290
|
+
Rows = $rows
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function Get-ProviderLabel([string]$Provider) {
|
|
295
|
+
switch ($Provider) {
|
|
296
|
+
"codex" { return "Codex" }
|
|
297
|
+
"claude" { return "Claude" }
|
|
298
|
+
"antigravity" { return "Gemini" }
|
|
299
|
+
default { return $Provider }
|
|
277
300
|
}
|
|
278
301
|
}
|
|
279
302
|
|