Repository navigation
0.7.1: round capsules, a sturdier service and a cleanup - #10
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes
GdipSetLineBlend).coolercast liststill prints it.nvidia-smiexits (driver reload); a driver that makesnvidia-smifail outright is retried quietly.FlushFileBuffersis replaced by waiting (1 s at most) for the client to close.refreshkept the app state borrowed acrossShell_NotifyIconW, which dispatches sent messages (TaskbarCreated, tray clicks); the nested borrow panicked, and release builds abort on panic.DeleteObjectfailed on every new icon text.Cleanup, no behavior change
win::Library(Library::at); unused event helpers removed.gfx, the tray menu built in loops, the preview digits drawn from arrays (no allocation per segment), a shorterStatus::encode.Repository
.agents/andskills-lock.jsonare no longer tracked;.gitignorecovers them.AGENTS.mdstays, without the skills section.Not addressed
Testing
cargo fmt --check;cargo clippy -D warningsfor Linux,x86_64-unknown-linux-muslandx86_64-pc-windows-msvc;cargo test: 102 core tests, 9 of them new (rescan decision, power averaging, sensor reopening).status,set,status). Still worth a manual run on Windows with a cooler: the settings window in dark and light, the tray menu, andcoolercast statuswhile the app is open.After merging, tagging
v0.7.1publishes the release.Generated by Claude Code