@join-pantheon/cli 0.34.0-rc.1 → 0.34.1-rc.1

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.
@@ -1,23 +1,23 @@
1
1
  {
2
2
  "format": 1,
3
- "built_at": "2026-10-15T09:14:55.514Z",
3
+ "built_at": "2026-10-15T17:20:00.495Z",
4
4
  "swiftc": "Apple Swift version 6.3.3 (swiftlang-6.3.3.1.3 clang-2100.1.1.101)",
5
5
  "helpers": {
6
6
  "pantheon-tray": {
7
7
  "source": "menubar.swift",
8
- "source_sha256": "7f548530872c9f3d6dded680ca48264ab2ba9442dc6bc0e9de45bf5309446527",
9
- "sha256": "36596524ba2afdd4da00e6ff417cc69a2508d9cf0909cd9da5c49f27b07cf15d",
8
+ "source_sha256": "ccf2dbc6db4795d130195fbb04b3a65222f0683755480af58dda565f48a13e51",
9
+ "sha256": "6031a27f90126790e374cf8151d4a3ee14b12c06a4d441e59d1be146d6182484",
10
10
  "archs": [
11
11
  "arm64",
12
12
  "x86_64"
13
13
  ],
14
14
  "target": "macos11",
15
- "version": "2"
15
+ "version": "3"
16
16
  },
17
17
  "pantheon-hud": {
18
18
  "source": "main.swift",
19
- "source_sha256": "73f2705c2ce54b766a3b9cb44a106e3b7490aac3fb86148603f402f95c9cf169",
20
- "sha256": "a357865e2a5cc880673e92b9f7367cd2d7bb2f27977bdd2cff36a8d182044ff5",
19
+ "source_sha256": "5499c9c9396cf4fd52899baa8f8c0a5319d3eda615bd75ed500b85e7ac8ad2b5",
20
+ "sha256": "1f9bdcaaee806e6ef394f86aba684f096d3dc30115dd14a781682062821039e5",
21
21
  "archs": [
22
22
  "arm64",
23
23
  "x86_64"
Binary file
Binary file
@@ -2,9 +2,19 @@
2
2
  Pantheon's tray icon on Windows: the macOS menu bar's job, in a notification-area icon.
3
3
 
4
4
  A thin shell, like helper/macos/menubar.swift: everything it knows comes from
5
- `pantheon tray-status` (JSON), and everything it does is a pantheon command.
5
+ the CLI's tray status (JSON), and everything it does is a pantheon command.
6
6
  It never answers, sends or decides anything itself.
7
7
 
8
+ Where the status comes from (0.34.1): the host (`pantheon host`, its parent)
9
+ computes it and writes it down this process's stdin, one JSON line per change
10
+ and at least every 15 s (60 s on battery), once this tray says "@hello 3" on
11
+ its stdout. Until the first line comes, under a host that sends none, or when
12
+ they stop (2 x next_ms + 10 s), it runs `pantheon tray-status` itself every
13
+ poll, as before. It tells the host "@refresh" (Refresh now, the menu opening,
14
+ a wake from sleep) and "@power ac|battery". The pipe is read with ReadAsync and
15
+ the task polled from the 500 ms timer: no event ever arrives on a thread
16
+ without a runspace.
17
+
8
18
  The Pantheon desktop host (src/win-host.ts trayArgv) runs this file's text as
9
19
  a script block, never with -File: Windows client editions default to the
10
20
  Restricted execution policy, which refuses -File without a Bypass.
@@ -93,6 +103,13 @@ $global:PT = @{
93
103
  # like the macOS tray, two misses keep what was last known; the third is shown.
94
104
  checkTimeout = 20; missesTolerated = 2
95
105
  misses = 0; check = $null; board = $null; nextCheck = (Get-Date); quit = $false
106
+ # The host's status pipe (0.34.1): 'spawn' runs tray-status every poll; 'pipe' applies the host's frames.
107
+ mode = 'spawn'; maxFrame = 1000000; pipeAcc = (New-Object System.IO.MemoryStream); pipeDiscard = $false
108
+ pipeOpen = $false; pipeTask = $null; pipeBuf = $null; lastFrame = $null; staleSeconds = 40
109
+ # The first check of its own waits this long for the host's first frame.
110
+ firstWaitUntil = (Get-Date); refreshAt = $null; power = 'ac'; ticks = 0; lastTick = (Get-Date)
111
+ # The alert queue's folder, as last scanned: scanned again only when its modification time moves.
112
+ noticeMtime = [int64]-1
96
113
  # "Remove from this computer" runs under way, by team id: one at a time each, and how each ended is said.
97
114
  leaving = @{}
98
115
  # The most gone teams drawn in the menu; the rest are one line (the board lists them all).
@@ -426,8 +443,9 @@ function global:Open-PantheonConsole([string]$title, [string]$words) {
426
443
 
427
444
  # ---------------------------------------------------------------- status
428
445
 
429
- function global:Read-Status([string]$json) {
430
- $j = $json | ConvertFrom-Json
446
+ function global:Read-Status($json) {
447
+ # tray-status's JSON text, or a frame's status already parsed.
448
+ if ($json -is [string]) { $j = $json | ConvertFrom-Json } else { $j = $json }
431
449
  $need = 0
432
450
  foreach ($i in @($j.items)) {
433
451
  if ($null -eq $i) { continue }
@@ -451,6 +469,13 @@ function global:Read-Status([string]$json) {
451
469
  # Why this computer cannot take requests, with the fix (signed out, no agent CLI): the heading, the icon and a menu line say it.
452
470
  agentProblem = $(if ($j.agent_problem -is [string]) { $p = ([string]$j.agent_problem) -replace '[\x00-\x1f\x7f-\x9f\u200e\u200f\u202a-\u202e\u2066-\u2069]', ''; if ($p.Length -gt 200) { $p.Substring(0, 199) + $PT.ellipsis } else { $p } } else { '' })
453
471
  agentProblemLead = $(if ($j.agent_problem_lead) { [string]$j.agent_problem_lead } else { "Unattended work can't run" })
472
+ # "Your agent ran N teammate requests today (M min)" (spend.ts runsTodayLine); empty when none ran.
473
+ runsToday = (Get-RunsTodayLine $j.runs_today)
474
+ # A Pantheon process here stuck without the relay for over two minutes, with its fix (conn-report.ts).
475
+ stuck = @(@($j.stuck_connections) | Where-Object { $null -ne $_ -and $_.line -is [string] -and $_.line } | Select-Object -First 5 | ForEach-Object {
476
+ $l = ([string]$_.line) -replace '[\x00-\x1f\x7f-\x9f\u200e\u200f\u202a-\u202e\u2066-\u2069]', ''
477
+ if ($l.Length -gt 200) { $l.Substring(0, 199) + $PT.ellipsis } else { $l }
478
+ })
454
479
  # Changes to this person's setup waiting for them (0.33.10): each with the two signed links its menu items run.
455
480
  changes = $changes
456
481
  handling = $handling
@@ -463,6 +488,82 @@ function global:Read-Status([string]$json) {
463
488
  }
464
489
  }
465
490
 
491
+ # The words spend.ts runsTodayLine says: "Your agent ran 3 teammate requests today (12 min)", '' for none.
492
+ function global:Get-RunsTodayLine($r) {
493
+ if ($null -eq $r -or [string]$r.n -notmatch '^\d{1,6}$') { return '' }
494
+ $n = [int][string]$r.n
495
+ if ($n -le 0) { return '' }
496
+ $line = 'Your agent ran ' + $n + ' teammate request' + $(if ($n -eq 1) { '' } else { 's' }) + ' today'
497
+ if ([string]$r.minutes -match '^\d{1,6}$') { $m = [int][string]$r.minutes; $line += ' (' + $(if ($m -lt 1) { '<1' } else { [string]$m }) + ' min)' }
498
+ return $line
499
+ }
500
+
501
+ # ---------------------------------------------------------------- the host's status pipe
502
+
503
+ # Bytes from the host, split into lines: the complete ones are returned, the rest kept.
504
+ # A line longer than maxFrame is dropped to its newline. Searched with IndexOf, never
505
+ # byte by byte (a PowerShell loop over a 50 KB frame would cost a second of CPU).
506
+ function global:Add-PipeBytes([byte[]]$bytes, [int]$count) {
507
+ $lines = New-Object System.Collections.Generic.List[string]
508
+ $start = 0
509
+ while ($start -lt $count) {
510
+ $nl = [Array]::IndexOf($bytes, [byte]10, $start, $count - $start)
511
+ $end = if ($nl -lt 0) { $count } else { $nl }
512
+ if (-not $PT.pipeDiscard) {
513
+ $PT.pipeAcc.Write($bytes, $start, $end - $start)
514
+ if ($PT.pipeAcc.Length -gt $PT.maxFrame) { $PT.pipeAcc.SetLength(0); $PT.pipeDiscard = $true }
515
+ }
516
+ if ($nl -lt 0) { break }
517
+ if ($PT.pipeDiscard) { $PT.pipeDiscard = $false }
518
+ elseif ($PT.pipeAcc.Length -gt 0) { $lines.Add([Text.Encoding]::UTF8.GetString($PT.pipeAcc.ToArray()).TrimEnd("`r")) }
519
+ $PT.pipeAcc.SetLength(0)
520
+ $start = $nl + 1
521
+ }
522
+ return , $lines.ToArray()
523
+ }
524
+
525
+ # One frame line: @{ status; nextMs }, or $null when it is not a status frame (not JSON, not
526
+ # t=status, no status object). A status that says this machine is in no team is a frame: the
527
+ # tray shows it at once, and stays on the pipe.
528
+ function global:Read-Frame([string]$line) {
529
+ if (-not $line -or $line.Length -gt $PT.maxFrame) { return $null }
530
+ try { $f = $line | ConvertFrom-Json } catch { return $null }
531
+ if ($null -eq $f -or $f -isnot [System.Management.Automation.PSCustomObject] -or [string]$f.t -cne 'status') { return $null }
532
+ if ($null -eq $f.status -or $f.status -isnot [System.Management.Automation.PSCustomObject] -or $f.status.configured -isnot [bool]) { return $null }
533
+ $next = 15000
534
+ if ([string]$f.next_ms -match '^\d{1,7}$') { $next = [Math]::Min([Math]::Max([int][string]$f.next_ms, 1000), 600000) }
535
+ return @{ status = $f.status; nextMs = $next }
536
+ }
537
+
538
+ # A frame applied: the state is the host's, misses are forgotten, and the pipe is the source.
539
+ function global:Complete-Frame($frame) {
540
+ $next = $null
541
+ try { $next = Read-Status $frame.status } catch { $next = $null }
542
+ if ($null -eq $next) { return $false }
543
+ if ($PT.mode -ne 'pipe') { $PT.mode = 'pipe'; Write-TrayLog 'status now comes from the Pantheon host (no tray-status checks)' }
544
+ $PT.lastFrame = Get-Date
545
+ $PT.staleSeconds = [int](2 * $frame.nextMs / 1000 + 10)
546
+ $PT.misses = 0
547
+ foreach ($k in $next.Keys) { $PT.state[$k] = $next[$k] }
548
+ return $true
549
+ }
550
+
551
+ # Frames stopped (2 x next_ms + 10 s): back to checking for itself, at once.
552
+ function global:Test-PipeStale([datetime]$now) {
553
+ if ($PT.mode -ne 'pipe' -or $null -eq $PT.lastFrame) { return $false }
554
+ if (($now - $PT.lastFrame).TotalSeconds -le $PT.staleSeconds) { return $false }
555
+ $PT.mode = 'spawn'
556
+ $PT.nextCheck = $now
557
+ Write-TrayLog ('no status from the Pantheon host for ' + $PT.staleSeconds + ' s ' + $PT.dash + ' checking for itself again')
558
+ return $true
559
+ }
560
+
561
+ # Look again soon: the host is asked (pipe), or tray-status is run (spawn).
562
+ function global:Request-Check([double]$inSeconds) {
563
+ $at = (Get-Date).AddSeconds($inSeconds)
564
+ if ($PT.mode -eq 'pipe' -and $PT.pipeOpen) { $PT.refreshAt = $at } else { $PT.nextCheck = $at }
565
+ }
566
+
466
567
  # A request under "Your agents are handling", as the menu shows it: its title and
467
568
  # the two signed links (Take over, Stop) that pass Test-PantheonLink. Others are left out.
468
569
  function global:Read-Handling($items) {
@@ -552,14 +653,16 @@ function global:Get-TrayIcon([int]$count, [string]$mode) {
552
653
  # This computer can't take requests (signed out, no agent CLI): an amber "!" in the corner.
553
654
  $d = [int]([Math]::Ceiling($w * 0.62))
554
655
  $x = $w - $d; $y = $h - $d
555
- $brush = New-Object System.Drawing.SolidBrush ([System.Drawing.Color]::FromArgb(255, 230, 145, 0))
656
+ # Windows' own warning amber (#FFB900) with a dark mark: white on amber was 2:1, this is over 9:1.
657
+ $brush = New-Object System.Drawing.SolidBrush ([System.Drawing.Color]::FromArgb(255, 255, 185, 0))
556
658
  $g.FillEllipse($brush, $x, $y, $d - 1, $d - 1)
557
659
  $font = New-Object System.Drawing.Font 'Segoe UI', ([Math]::Max(6, $d * 0.62)), ([System.Drawing.FontStyle]::Bold), ([System.Drawing.GraphicsUnit]::Pixel)
558
660
  $fmt = New-Object System.Drawing.StringFormat
559
661
  $fmt.Alignment = [System.Drawing.StringAlignment]::Center
560
662
  $fmt.LineAlignment = [System.Drawing.StringAlignment]::Center
561
- $g.DrawString('!', $font, [System.Drawing.Brushes]::White, (New-Object System.Drawing.RectangleF $x, ($y + 0.5), $d, $d), $fmt)
562
- $font.Dispose(); $brush.Dispose(); $fmt.Dispose()
663
+ $mark = New-Object System.Drawing.SolidBrush ([System.Drawing.Color]::FromArgb(255, 27, 27, 27))
664
+ $g.DrawString('!', $font, $mark, (New-Object System.Drawing.RectangleF $x, ($y + 0.5), $d, $d), $fmt)
665
+ $font.Dispose(); $brush.Dispose(); $fmt.Dispose(); $mark.Dispose()
563
666
  }
564
667
  if ($shown -gt 0) {
565
668
  # The count, on a red badge in the corner: what needs the person.
@@ -619,6 +722,10 @@ function global:Watch-Check {
619
722
  $c = $PT.check
620
723
  if ($null -eq $c) { return }
621
724
  $p = $c.process
725
+ if ($p.HasExited -and $c.out.IsCompleted -and $PT.mode -eq 'pipe') {
726
+ # A check of its own that ended after the host's frames began: the host's answer is the newer one.
727
+ $p.Dispose(); $PT.check = $null; return
728
+ }
622
729
  if ($p.HasExited -and $c.out.IsCompleted) {
623
730
  $code = $p.ExitCode
624
731
  $out = $c.out.Result
@@ -676,7 +783,7 @@ function global:Set-OpenIn([string]$to) {
676
783
  }
677
784
  $p.Dispose()
678
785
  } catch { Write-TrayLog ('open-in ' + $to + ' failed: ' + $_.Exception.Message) }
679
- $PT.nextCheck = (Get-Date).AddSeconds(2)
786
+ Request-Check 2
680
787
  }
681
788
 
682
789
  function global:Invoke-Hidden([string[]]$words, [string]$what) {
@@ -685,7 +792,7 @@ function global:Invoke-Hidden([string[]]$words, [string]$what) {
685
792
  Write-TrayLog ($what + ': started')
686
793
  $p.Dispose()
687
794
  } catch { Write-TrayLog ($what + ' failed: ' + $_.Exception.Message) }
688
- $PT.nextCheck = (Get-Date).AddSeconds(3)
795
+ Request-Check 3
689
796
  }
690
797
 
691
798
  # Quit: the host must not start the tray again in this session, so it is told
@@ -702,10 +809,24 @@ function global:Exit-Tray {
702
809
  $PT.context.ExitThread()
703
810
  }
704
811
 
812
+ # Has the alert queue changed since it was last scanned? Read before the scan, so a file that
813
+ # lands during one moves the time again and is found at the next tick.
814
+ function global:Test-NoticesChanged {
815
+ $m = [int64]-2
816
+ try { $m = [IO.Directory]::GetLastWriteTimeUtc($PT.noticeDir).Ticks } catch { $m = [int64]-2 }
817
+ $retrying = @($PT.stuck.Values | Where-Object { -not $_.skip }).Count -gt 0
818
+ if ($m -eq $PT.noticeMtime -and -not $retrying) { return $false }
819
+ $PT.noticeMtime = $m
820
+ return $true
821
+ }
822
+
705
823
  # Every alert waiting in the queue, shown from this process: a toast, or a
706
824
  # balloon from this icon where toasts cannot be shown. What happened to each
707
825
  # is said in alerts.log -- shown, a balloon, or not shown, never assumed.
708
826
  function global:Show-QueuedNotices {
827
+ # One look at the folder's modification time (NTFS moves it on every file created or
828
+ # deleted in it); the files are listed only when it moved, or a file is being retried.
829
+ if (-not (Test-NoticesChanged)) { return }
709
830
  foreach ($n in (Get-QueuedNotices (Get-Date))) {
710
831
  if ($n.stale) { Write-PantheonAlertLog ('tray: dropped ' + $n.about + ' (queued more than ten minutes ago)'); continue }
711
832
  $r = Show-PantheonToast $n.xml $n.tag $n.aumids $null ([int]$n.expires)
@@ -758,7 +879,7 @@ function global:Watch-Leaving {
758
879
  $PT.leaving.Remove($space)
759
880
  Write-TrayLog ('remove ' + $space + ': exit ' + $code)
760
881
  if ($code -ne 0) { Show-LeaveFailed $l.line }
761
- $PT.nextCheck = Get-Date
882
+ Request-Check 0
762
883
  }
763
884
  }
764
885
 
@@ -782,6 +903,10 @@ function global:Build-Menu {
782
903
  $head = Get-Summary
783
904
  if ($who.Count) { $head = $head + ' ' + $PT.dot + ' ' + ($who -join (' ' + $PT.dot + ' ')) }
784
905
  Add-MenuItem $head $null $false $false
906
+ # What the worker did for teammates today, when it did anything.
907
+ if ($s.runsToday) { Add-MenuItem $s.runsToday $null $false $false }
908
+ # A process here that lost the relay and is not getting it back: which, and the fix (a click opens doctor).
909
+ foreach ($l in @($s.stuck)) { if ($l) { Add-MenuItem ('Not connected: ' + $l) { Open-PantheonConsole 'Pantheon doctor' 'doctor' } $true } }
785
910
  # Not greyed out: a click opens status, which says it in full with the fix.
786
911
  # The heading already says it cannot run (when nothing else needs you): the row says why, and the fix.
787
912
  if ($s.agentProblem) { Add-MenuItem $(if ($s.need -eq 0) { $s.agentProblem } else { $s.agentProblemLead + ': ' + $s.agentProblem }) { Open-PantheonConsole 'Pantheon status' 'status' } $true }
@@ -821,11 +946,52 @@ function global:Build-Menu {
821
946
  }
822
947
  Add-MenuItem 'Status' { Open-PantheonConsole 'Pantheon status' 'status' }
823
948
  Add-MenuItem 'Doctor' { Open-PantheonConsole 'Pantheon doctor' 'doctor' }
824
- Add-MenuItem 'Refresh now' { $PT.nextCheck = Get-Date }
949
+ Add-MenuItem 'Refresh now' { Request-Check 0 }
825
950
  [void]$menu.Items.Add((New-Object System.Windows.Forms.ToolStripSeparator))
826
951
  Add-MenuItem 'Quit tray (until you next log in)' { Exit-Tray }
827
952
  }
828
953
 
954
+ # A line to the host, on stdout ("@hello 3", "@refresh", "@power ..."). A host that is gone: nothing.
955
+ function global:Write-Parent([string]$line) {
956
+ if ($null -eq $PT.stdout) { return }
957
+ try { $b = [Text.Encoding]::UTF8.GetBytes($line + "`n"); $PT.stdout.Write($b, 0, $b.Length); $PT.stdout.Flush() } catch { $PT.stdout = $null }
958
+ }
959
+
960
+ # The pipe, polled from the timer: a finished read is taken (its lines applied) and the next
961
+ # one started, a few at most per tick; an end of input means the host is gone (or never piped).
962
+ function global:Watch-Pipe {
963
+ if (-not $PT.pipeOpen) { return $false }
964
+ $applied = $false
965
+ for ($round = 0; $round -lt 8; $round++) {
966
+ if ($null -eq $PT.pipeTask) {
967
+ try { $PT.pipeTask = $PT.stdin.ReadAsync($PT.pipeBuf, 0, $PT.pipeBuf.Length) } catch { $PT.pipeOpen = $false; break }
968
+ }
969
+ if (-not $PT.pipeTask.IsCompleted) { break }
970
+ $n = 0
971
+ try { $n = $PT.pipeTask.Result } catch { $n = 0 }
972
+ $PT.pipeTask = $null
973
+ if ($n -le 0) {
974
+ $PT.pipeOpen = $false
975
+ # Before any frame (a host that does not pipe): check at once. After: the host went.
976
+ $PT.firstWaitUntil = Get-Date
977
+ if ($PT.mode -eq 'pipe') { $PT.mode = 'spawn'; $PT.nextCheck = Get-Date; Write-TrayLog ('the Pantheon host went ' + $PT.dash + ' checking for itself') }
978
+ break
979
+ }
980
+ foreach ($line in (Add-PipeBytes $PT.pipeBuf $n)) {
981
+ $f = Read-Frame $line
982
+ if ($null -eq $f) { Write-TrayLog ('dropped a line from the host that is not a status frame (' + $line.Length + ' characters)'); continue }
983
+ if (Complete-Frame $f) { $applied = $true }
984
+ }
985
+ }
986
+ return $applied
987
+ }
988
+
989
+ # AC or battery: SystemInformation.PowerStatus, one GetSystemPowerStatus call. Unknown reads as AC.
990
+ function global:Get-PowerLine {
991
+ try { if ([System.Windows.Forms.SystemInformation]::PowerStatus.PowerLineStatus -eq [System.Windows.Forms.PowerLineStatus]::Offline) { return 'battery' } } catch { }
992
+ return 'ac'
993
+ }
994
+
829
995
  # A test loads the functions above without a desktop: it stops here.
830
996
  if ($env:PANTHEON_TRAY_NO_UI -eq '1') { return }
831
997
 
@@ -856,7 +1022,7 @@ $PT.tray = New-Object System.Windows.Forms.NotifyIcon
856
1022
  $PT.tray.Icon = Get-TrayIcon 0 'idle'
857
1023
  $PT.tray.Text = 'Pantheon'
858
1024
  $PT.menu = New-Object System.Windows.Forms.ContextMenuStrip
859
- $PT.menu.add_Opening({ try { Build-Menu } catch { Write-TrayLog ('menu: ' + $_.Exception.Message) } })
1025
+ $PT.menu.add_Opening({ try { Build-Menu; if ($PT.mode -eq 'pipe') { Request-Check 0 } } catch { Write-TrayLog ('menu: ' + $_.Exception.Message) } })
860
1026
  Build-Menu
861
1027
  $PT.tray.ContextMenuStrip = $PT.menu
862
1028
  # A left click opens the board; the right click shows the menu.
@@ -866,6 +1032,21 @@ $PT.tray.add_MouseClick({
866
1032
  })
867
1033
  # A click on an alert's balloon opens the board, as a click on its toast does.
868
1034
  $PT.tray.add_BalloonTipClicked({ try { Open-Board } catch { Write-TrayLog ('balloon click: ' + $_.Exception.Message) } })
1035
+ # The host's status pipe: say hello (and the power), then read frames as they come.
1036
+ try { $PT.stdout = [Console]::OpenStandardOutput() } catch { $PT.stdout = $null }
1037
+ $PT.power = Get-PowerLine
1038
+ try {
1039
+ if ([Console]::IsInputRedirected) {
1040
+ $PT.stdin = [Console]::OpenStandardInput()
1041
+ $PT.pipeBuf = New-Object byte[] 65536
1042
+ $PT.pipeOpen = $true
1043
+ # A host that pipes answers within a moment; one that does not (an older host) gives an end of input at once.
1044
+ $PT.firstWaitUntil = (Get-Date).AddSeconds(3)
1045
+ }
1046
+ } catch { $PT.pipeOpen = $false }
1047
+ Write-Parent '@hello 3'
1048
+ Write-Parent ('@power ' + $PT.power)
1049
+
869
1050
  $PT.timer = New-Object System.Windows.Forms.Timer
870
1051
  $PT.timer.Interval = 500
871
1052
  $PT.timer.add_Tick({
@@ -875,13 +1056,33 @@ $PT.timer.add_Tick({
875
1056
  # Alerts: polled every half second. Not a FileSystemWatcher: its events
876
1057
  # arrive on a thread with no PowerShell runspace, which ends the process.
877
1058
  if ($PT.notices) { Show-QueuedNotices }
1059
+ $now = Get-Date
1060
+ # Back from sleep (the timer stood still): the status is as old as the sleep was.
1061
+ $slept = ($now - $PT.lastTick).TotalSeconds -gt 30
1062
+ $PT.lastTick = $now
1063
+ if (Watch-Pipe) { Update-Tray }
1064
+ [void](Test-PipeStale $now)
1065
+ # The power, every 20th tick (10 s): said to the host, and the poll slows on battery.
1066
+ $PT.ticks++
1067
+ if ($PT.ticks % 20 -eq 0) {
1068
+ $p = Get-PowerLine
1069
+ if ($p -ne $PT.power) { $PT.power = $p; Write-Parent ('@power ' + $p) }
1070
+ }
1071
+ if ($PT.mode -eq 'pipe') {
1072
+ if ($slept) { $PT.refreshAt = $now }
1073
+ if ($null -ne $PT.refreshAt -and $now -ge $PT.refreshAt) { $PT.refreshAt = $null; Write-Parent '@refresh' }
1074
+ } else {
1075
+ if ($slept) { $PT.nextCheck = $now }
1076
+ }
878
1077
  Watch-Check
1078
+ if ($PT.mode -ne 'pipe') {
1079
+ if ($null -eq $PT.check -and $now -ge $PT.nextCheck -and $now -ge $PT.firstWaitUntil) {
1080
+ $PT.nextCheck = $now.AddSeconds($(if ($PT.power -eq 'battery') { [Math]::Max($PT.poll, 60) } else { $PT.poll }))
1081
+ Start-Check
1082
+ }
1083
+ }
879
1084
  Watch-Board
880
1085
  Watch-Leaving
881
- if ($null -eq $PT.check -and (Get-Date) -ge $PT.nextCheck) {
882
- $PT.nextCheck = (Get-Date).AddSeconds($PT.poll)
883
- Start-Check
884
- }
885
1086
  } catch { Write-TrayLog ('tick: ' + $_.Exception.Message) }
886
1087
  })
887
1088
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@join-pantheon/cli",
3
- "version": "0.34.0-rc.1",
3
+ "version": "0.34.1-rc.1",
4
4
  "description": "Let your coding agent collaborate directly with your teammates' agents — ask, agree an interface, and deliver, without a human relaying messages.",
5
5
  "type": "module",
6
6
  "bin": {