Repository navigation
Shell: --headless for agents, --stop, close to tray, single instance - #251
Merged
Merged
Conversation
An agent that finds the studio closed can start it with --headless: the window is made but never shown or focused, a tray icon is the only sign of it, and the studio stops by itself after ten minutes with no agent call and nothing at work (YUE_STUDIO_IDLE_SHUTDOWN_S sets other seconds). Opening the studio the usual way brings the window up in the same session, which is an ordinary one from then on. --stop ends a studio whose window is not on screen and that has nothing at work, and never asks anything. Settings has a new choice, off by default: closing the window keeps the studio running in the system tray. A second launch now hands its flags to the running studio and ends, where it used to open a second window on the same service. The service tells an agent's calls from the window's own by the Origin and Referer of the request, so the hidden page's polling is not use. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Owner
|
Merged into the 4.1.0 branch ( |
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.
Why
An agent driving the studio over MCP has to start it when it is closed, and today that puts the studio's window on the user's screen and takes the focus while they are working on something else. This lets an agent use the studio without anything appearing, and adds the close-to-tray choice that goes with it.
What changes
--headless: the main window is still created (parts of the studio run in its page) but never shown or focused, with no taskbar button. A tray icon is the only sign of it.YUE_STUDIO_IDLE_SHUTDOWN_Ssets another period.--stop: ends a running studio only when its window is not on screen and nothing is at work. It never shows a question. With nothing running it exits at once and starts nothing.confirm_quit.tauri-plugin-single-instance): a second launch hands its flags to the running studio and ends. It used to open a second window on the same service.docs/mcp-skill.mdand the README tell an agent to start with--headless.--headless--stopHow agent use is told from the window's own requests
The hidden page keeps polling, so it cannot count as use.
crates/music-server/src/agent_use.rsis a layer on the public router (inside the access guard): a request whoseOriginorRefereris the window's page (tauri://localhost,http://tauri.localhost, or the dev server) is the window's; everything else, and every/mcpcall, is use. A call counts for as long as it is open, so a slow call is not cut off. The shell asks the service about work in progress inside the process, not over HTTP, so its own question is not counted.Tested
cargo testindesktop/src-tauri(8 passed),cargo test -p music-server --locked(525 passed),npx vitest run(212 passed),npx tsc --noEmit.--headlessstart with no visible or focused window (windows of the process enumerated from outside), the idle stop firing while the hidden page polled, agent calls keeping it alive, a second--headless,--stopon a hidden session,--stopwith nothing running, a plain second launch bringing the window up, a saved maximised state staying hidden. Tray icon and close-to-tray toggle tried by hand.Not tested
cfg(target_os = "macos")branches (set_dock_visibility,RunEvent::Reopen) are uncompiled, and whether a maximised restore keeps a hidden window hidden on macOS is unverified. On Linux the tray gives no click events, so only the menu works there.Things you may want different
--stopreusequit_now: a song started in the milliseconds between the last check and the quit would be cancelled.Refererfor media.🤖 Generated with Claude Code