Skip to content

0.7.1: round capsules, a sturdier service and a cleanup - #10

Merged
moicd merged 21 commits into
mainfrom
claude/sweet-fermat-56huyq
Oct 7, 2026
Merged

moicd merged 21 commits into
mainfrom
claude/sweet-fermat-56huyq

Conversation

@moicd

@moicd moicd commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes

  • Capsules are round again. The gloss on the segmented thumb, the switches, the update button and the sidebar selection was a shorter capsule with tighter ends, so it stuck out past the control's shoulders: the corners looked square, with a light ridge. It now fills the control's own shape with a fade (GdipSetLineBlend).
  • A lost cooler comes back while another one works. The engine only rescanned while no cooler was open, so with two displays (an AK cooler and a CH case, say) one that dropped after a USB reset or a resume, or enumerated late at boot, stayed dark until the service restarted. It now also rescans every 5 s for 60 s after the start and after a loss, opening only paths that are not open yet.
  • No power spike at startup. The first power reading came microseconds after the energy counter was primed: 0 W, or hundreds of watts to kilowatts, for one refresh. Power is now averaged over at least 100 ms (CPU RAPL, and the Intel GPU energy counter on Linux). coolercast list still prints it.
  • Failing sensors are reopened. A sensor that keeps failing for 10 s is closed and opened again, at most once every 10 s. This brings the Linux NVIDIA readings back after nvidia-smi exits (driver reload); a driver that makes nvidia-smi fail outright is retried quietly.
  • The service's pipe cannot be blocked or taken.
    • The pipe instance is kept for the life of the service. Before, the name was free for a moment after each client, so another local process could take it and the IPC thread exited.
    • Overlapped I/O with 1 s timeouts, as on Linux: a client that connects and stalls no longer blocks the tray and the CLI forever. The unbounded FlushFileBuffers is replaced by waiting (1 s at most) for the client to close.
  • Tray: no abort when Explorer restarts. refresh kept the app state borrowed across Shell_NotifyIconW, which dispatches sent messages (TaskbarCreated, tray clicks); the nested borrow panicked, and release builds abort on panic.
  • Tray icon font leak. The font was deleted while still selected into the DC, so DeleteObject failed on every new icon text.
  • Arrow keys in power mode. → on the Mode control switched the display from Power to Custom.

Cleanup, no behavior change

  • AK, AG, LS and CH reports share the mode bytes and the custom-value clamp (packets are byte-identical).
  • PawnIO loads through win::Library (Library::at); unused event helpers removed.
  • The Windows HID enumeration skips other vendors before asking for their strings, which are USB transfers.
  • windows-sys definitions instead of local copies, one DIB helper and one string-drawing path in gfx, the tray menu built in loops, the preview digits drawn from arrays (no allocation per segment), a shorter Status::encode.
  • Rescans log skipped devices only while no cooler works.

Repository

  • .agents/ and skills-lock.json are no longer tracked; .gitignore covers them. AGENTS.md stays, without the skills section.
  • README: centered header with links and badges, and a shorter feature list.
  • Version 0.7.1.

Not addressed

  • A second cooler plugged in more than 60 s after the start or the last loss still needs a service restart; catching it would need device notifications.
  • The Intel "reading valid" bit and the PawnIO output counts are not checked; that needs hardware to verify.
  • During the 60 s rescan window, Windows still asks open coolers for their strings before skipping them by path.

Testing

  • cargo fmt --check; cargo clippy -D warnings for Linux, x86_64-unknown-linux-musl and x86_64-pc-windows-msvc; cargo test: 102 core tests, 9 of them new (rescan decision, power averaging, sensor reopening).
  • The gloss fix was checked with a software model of the GDI+ calls, before and after, at 100 % and 150 %.
  • The Windows code was compiled but not run here. CI's MSI test exercises the new pipe server (status, set, status). Still worth a manual run on Windows with a cooler: the settings window in dark and light, the tray menu, and coolercast status while the app is open.

After merging, tagging v0.7.1 publishes the release.


Generated by Claude Code

moicd added 21 commits October 7, 2026 07:19
…orts

The mode bytes (19, 35, 76) and the unit and custom-symbol mappings were
declared again in ag.rs, ls.rs and ch.rs. They now come from ak.rs, which
also holds the clamping of a custom value.
Format the optional numbers of the status response through one closure,
find the first hwmon directory with min() instead of collecting and
sorting, and drop the pointless closure in the nvidia-smi parser.
…vent helpers

pawnio.rs carried its own LoadLibraryExW, GetProcAddress and FreeLibrary
handling, including manual frees on each error path. It now uses
win::Library, which gains Library::at for an absolute path with the same
restricted search flags.

Event::set, Event::is_set, wait_any and the manual_reset parameter of
Event::new were only used by their own test; the HID transport needs just
a manual-reset event that overlapped I/O signals.
The event test still covers the signaled path of Event::wait, which the
removed Event::set used to exercise.
The Windows enumeration requested the product and serial strings and the
preparsed data of every HID interface on the PC, and only then dropped
the ones of other vendors. Those string requests are transfers to the
device, and the service rescans every 5 seconds while no cooler is found.
The vendor is now checked right after HidD_GetAttributes.
The tray icon and the settings window each built the same 32-bit top-down
DIB section; both now call one `gfx::pixel_bitmap`. `Canvas::text` and
`Canvas::text_wrapped` repeated the whole GDI+ draw call and now share
`draw_string`. `DrawTextW` takes a const pointer, so the icon text no
longer needs to be `mut`.
`Control::enabled` never read its `Config`. Without it, the Tab handler
no longer clones the whole config just to pass it along.
The mode and unit items repeated one seven-line call each; they are now
loops like the source items. The menu reads the status through
`current_status()` instead of repeating its lookup, borrows the config
instead of cloning it twice, and the `item` helper applies `checked &&
enabled` itself, so the eight `online &&` copies are gone. Offline items
still show no check mark.
The high contrast query declared its own `HIGHCONTRASTW` layout, system
color indexes and `SPI_GETHIGHCONTRAST`; the service declared
`DEVICE_NOTIFY_SERVICE_HANDLE`. windows-sys already exports all of them
(the app only needs the `Win32_UI_Accessibility` feature for the struct).
The seven-segment polygons always have six points, so they are built as
arrays and the glow copies are mapped in place, which saves the vectors
allocated for every segment and glow offset on each paint.
`icon::render` selected its font into the memory DC and then called
`DeleteObject` on it while it was still selected, which Windows refuses
(it returns zero), so every render of the tray text could leak a font
handle. The original font is selected back first, as already done for
the bitmap.
In power mode (set from the tray or the CLI) the Mode control has no
selected segment, so its index lies past the last one. Pressing Right
computed `min(index + 1, last)`, which is a step backwards, and switched
the display to Custom. Forward from there now does nothing; Left still
goes to the last segment.
The engine looked for coolers only while its list was empty, so with two
displays (say an AK cooler and a CH case) one that dropped after a USB
reset or a resume from sleep, or that enumerated late at boot, was never
reopened until the service restarted.

Rescan every 5 s while no cooler is open, as before, and also during 60 s
after the start and after losing a cooler. A scan opens only the paths
that are not open yet, so a working display is never opened twice. The
decision is a small pure function; once the window is over a healthy
setup is not enumerated again, and the scans reuse the existing wake-ups.

The devices a scan skips (unsupported or failing to open) are logged
only while no cooler works, so the rescans do not repeat them.
The highlight on the segmented thumb, the switch, the update button and the
sidebar selection was a shorter capsule over the top 55 % of the control.
Its ends had a smaller radius than the control's, so it stuck out past the
control's shoulders: the capsule looked squarer, with a light ridge at the
corners. It now fills the control's own shape with a gradient that fades
out at the same height.
The skills and their lock file stay local to whoever uses them; git ignores
them along with the other agent files.
AGENTS.md no longer points to them.
Opening the CPU power sensor primes the energy counter, and the engine
reads it again microseconds later in the same refresh. The counters only
advance about once a millisecond, so that read divided 0 or one counter
step by a few microseconds: the first displayed power was 0 W, or a
spike of hundreds of watts to kilowatts, for a whole refresh interval.
The Intel discrete GPU energy counter on Linux had the same problem, and
a wake (unlock, display on) that refreshes right after a regular refresh
could trigger it too.

Share one averaging helper between the CPU and the GPU counters. It
keeps the window open until at least 100 ms have passed, returns the
previous power for a read that comes sooner, and has no power before the
first complete window, so the existing fallback applies for that one
refresh. Regular refreshes are at least 250 ms apart and are not
affected, and `coolercast list` still averages over its 500 ms sleep.
With the proprietary NVIDIA driver the Linux GPU sensor reads from a
long-lived nvidia-smi child. When the child exits (driver reload,
crash), every later read fails with "nvidia-smi exited", and the engine
never reopened a sensor that had already opened, so the GPU values stayed
empty until the service was restarted.

A sensor whose reads keep failing for 10 seconds is now closed and opened
again. A failed attempt is repeated at the same pace, so a GPU that is
gone is not probed every refresh, and a short run of read errors does not
close anything. Sensors that fail to open the first time are still not
retried, and the engine still does no work between refreshes: the retry
is decided from the time of the refresh that samples the sensor.

A reopened sensor gets the full 10 seconds again, and time while no
display needs the sensor does not count as failing. A run of read
errors is logged once, across reopens. Opening the NVIDIA sensor now
fails when the nvidia-smi name query does (e.g. a driver mismatch after
an upgrade), so that case retries quietly instead of looping.
The service closed its only pipe instance after each client and created
a new one with FILE_FLAG_FIRST_PIPE_INSTANCE. Between the close and the
create the name is free: any local process that creates
\\.\pipe\coolercast in that window makes the re-creation fail with
ERROR_ACCESS_DENIED, and the IPC thread exits, so the CLI and the app
cannot reach the service until it restarts. Disconnect and reconnect the
same instance instead, so the service owns the name for its lifetime.
The pipe server read the request, wrote the response and flushed with
blocking calls. A client that connects and never writes, or writes and
never reads, kept the only pipe instance busy forever: every later
`coolercast status` or tray poll failed with a busy pipe until that
client went away. Any interactive user can open the pipe. Use
overlapped I/O and cancel each step after one second, like the Linux
socket timeout. Instead of the unbounded flush, wait for the client to
close its end after the response, also for at most one second.
refresh held APP.borrow_mut() across Shell_NotifyIconW, which sends
WM_COPYDATA to Explorer and, while it waits for the reply, dispatches
the messages other threads send to this one. When Explorer restarts and
broadcasts TaskbarCreated while a timer refresh is waiting on it, or a
tray click callback arrives during the call, the nested refresh,
window::open or show_menu borrowed APP again and the app aborted with
"already borrowed". Build the notify data under the borrow and call the
shell after releasing it; WM_DESTROY takes the state out first for the
same reason.
@moicd
moicd merged commit 6c2c05c into main Oct 7, 2026
3 checks passed
@moicd
moicd deleted the claude/sweet-fermat-56huyq branch October 7, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant