Repository navigation
feat: Keep the Mac awake from Chat and the menu - #1770
Conversation
|
Addressing the two Soft Open reviews.
Still open: the Fidget GUI has not been launched, so the press, — Grok Build, on @omesser's behalf. |
|
The coffee cup should not appear in the character, it should appear as a button with pressed/unoressed state in the chat window, and as an item in the menu (right click menu). Ticked or unticked. Don't clutter the characters look on the desktop |
The cup was drawn on the character. Chat now has a pressed and unpressed button, and the right-click menu has a tick. The tray shares that menu description, so the tick is there too. list_tools stays immutable off macOS so the Windows and Linux clippy jobs accept the caffeinate tool.
|
The cup is off the character. Chat's header has the button: outline while off, filled while on. The right-click menu has a Caffeinate item, ticked while the hold is on. The tray draws that same menu, so the tick is there as well. Both stay off macOS. The description pictures are a render of that header, not a live grab. I have not launched Fidget. — Grok Build, on @omesser's behalf. |
Linux and Windows clippy reject the chat note helper and the flag variants, because nothing there constructs them.
|
Linux and Windows clippy failed because the chat-note helper and the four flag variants are only constructed on macOS. Both are now gated the same way as the input-monitoring row. — Grok Build, on @omesser's behalf. |
The root had no xmlns, so DOMParser left it in no namespace and nothing painted it. The header button parses that one string.
|
The empty square was a missing
The live run is the one already on this pull request: Chat off and on, a second Chat that opened pressed, the Caffeinate tab, the ticked menu, — Grok Build, on @omesser's behalf. |
|
Rewrite the README bullet, comments, help strings, MCP tool text and one test name in plain words. Drop leftover main.css/main.js churn from the cup-on-sprite era.
A disabled cup keeps its reason as the tooltip.
Machine keeps one Phase and a wanted bool in place of Intent and Again. Spawner::alive replaces Poll, the tool handle returns Result<Fact, String>, and the pid moves into Machine::new. A randomized harness of 200,000 request sequences matched the old machine tick for tick. Shell side: Settings::caffeinate_flags, one emit_chat_notice for the Harness notice too, CaffeinateFrame drops its unread flags, and list_tools pushes the tool under cfg!.
Replace the cup with a teacup, saucer and steam drawn here, and drop the Caffeinate app credit. While on, a small white "caffeinated" label sits under the cup without changing the header's height.
| HELD_PID.store(pid, Ordering::SeqCst); | ||
| } | ||
|
|
||
| fn forget(pid: u32) { |
There was a problem hiding this comment.
It cleared HELD_PID, but only if it still held this pid, so reaping an old child after a restart never wipes the newer child's pid. HELD_PID exists because the quit paths call process::exit, which skips Drop, so they read it to SIGTERM the child. 3344ca8e renames the pair to set_held_pid and clear_held_pid_if and says both of those in doc comments.
— Cursor agent (Coder), on @omesser's behalf.
…start spawns it The second finish_stop read alive from the old child. An off in that tick turned the hold off and posted "Caffeinate off." while the new child still held the assertion, and a flag change spawned on top of it and failed.
Quit signals HELD_PID, so the variant, the quiet flag on Stopping and the doc line naming Release described a path that does not exist.
| } | ||
| } | ||
|
|
||
| fn letters(self) -> impl Iterator<Item = char> { |
There was a problem hiding this comment.
That's not a good implementation. use a hashmap or some dict to map the flag to its letter
There was a problem hiding this comment.
Done in 60df0b0d, with the macOS build fix in 04242f23. A Flag enum and one LETTERS table map each flag to its letter, in -d -i -m -s order, and AssertedFlags is now the set of enabled flags. The preview and argv are unchanged for all 16 flag sets.
— Cursor agent (Coder), on @omesser's behalf.
The HTML parser puts inline SVG in the SVG namespace, so CUP_SVG, the DOMParser call and its guard go. The cup test reads chat.html.
Says what the hold does, that the Chat cup and the menu turn it on, and that the flags go to the macOS caffeinate command.
AssertedFlags held four positional bools and letters() read them by index. A Flag enum and one LETTERS table now map each flag to its letter, in argv order, and AssertedFlags is the set of enabled flags.
remember and forget become set_held_pid and clear_held_pid_if, with docs on why HELD_PID exists and why the clear only matches its own pid.
Done in — Cursor agent (Coder), on @omesser's behalf. |
The command preview asked SettingsView for a method that only Settings had, so the macOS clippy job could not compile.
|
macOS clippy failed because the command preview called — Grok Build, on @omesser's behalf. |
omesser
left a comment
There was a problem hiding this comment.
Soft CLEARED
Tip: 04242f23
What changed
- Restart tick: the second
finish_stopcall is gone, so an Off or a flag change in the tick a restart spawns now waits for the new child. Two tests cover the Off and the flag change. - Cleanup:
Request::Releaseandquietare deleted, the cup SVG is inlined in chat.html, and aFlagenum with oneLETTERStable replaces the four positional bools. - Settings: the Awake section has a short intro, and the command preview builds on
SettingsViewagain.
What is wrong
- Nothing blocking. Every Soft-FIX from the last review is in.
Soft-FIX
- None
Non-blocking
- Mac look: the screenshots and How to test still come from b9975fc. Check that the inline cup and the "caffeinated" label fit the 28px button on a Mac, and refresh the grabs.
Verified: caffeinate core tests and the cup test pass at this tip. Putting the second finish_stop back makes both new restart tests fail.
— Cursor agent (Architect), on @omesser's behalf.

What
caffeinatechild with the saved flags and-wset to Fidget's pid. Pressing it again, quitting, or a crash releases it. Each launch starts off. Its tooltip reads "keep my computer awake". While the hold is on, the cup fills and a small white "caffeinated" label sits under it.-dims. The last checked flag stays checked, and the preview readscaffeinate -dims. A short help text at the top says what the hold does, that the cup and the menu turn it on, and that the flags go tocaffeinate.caffeinate, reads or sets the same hold. Chat notes on, off, and a child that exits by itself. The wake prompt names the hold on macOS.Not included: an auto-off timer, and a Linux or Windows hold. On and off are not saved across launches.
Why
Fidget stays open through long jobs, and the Mac still sleeps through them. Now you can keep it awake from Chat or the menu, and an attached harness can do the same over MCP. The cup is a generic drawing, inline in
src/chat.html.caffeinateis a built-in macOS command and has no icon of its own.How to test
Live windows below are from debug build
04242f23, isolated withFIDGET_DATA_DIR. Pressing the cup filled it, showed "caffeinated", and Chat said☕ Caffeinate on: keeping your Mac awake (-dims). The tray row was ticked. The Caffeinate tab shows the new intro. Quit from the menu left no child. Acaffeinate -dthat was already running was left alone.An earlier run, on
b9975fcb, also checkedpmset -g assertions, a second Chat that opened already pressed, a Disk flag swap (-d -i -s, then-d -i -m -sagain), and SIGINT. That build predates the tooltip, this cup, the label, the tab intro, and the restart fix. To check the restart fix on a Mac, change a flag while the hold is on, then turn it off right away. Chat should sayCaffeinate off.once, only after the new child exits.Edge cases:
-wreleases the hold if Fidget dies without running quit.Closes #1575
— Cursor agent (Coder), on @omesser's behalf.
— Grok Build, on @omesser's behalf.