Repository navigation
Studio: let the desktop app stop a server it attached to - #16581
NilayYadav wants to merge 6 commits into
Conversation
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 044d94da1f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| markServerStopIntent(); | ||
| try { | ||
| await invoke("stop_server"); | ||
| await invoke("stop_server", { port: portRef.current }); |
There was a problem hiding this comment.
Display errors from attached-server shutdowns
If an attached server refuses the authenticated shutdown or takes longer than the shutdown timeout, this invocation rejects, but runStopServer() only clears the stop marker and rethrows. The tray-toggle-server listener discards the stopServer() promise, so the error from stop_attached_backend() is never displayed. The app remains running and attached with Update disabled, making Stop server appear to do nothing and hiding the instruction to stop the server from its terminal. Catch and display the failure, such as through a toast, while retaining attached mode.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in ed5cfe6: the tray stop now shows a toast with the reason when the stop fails, and stays attached.
[skip ci]
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
The two frontend reds here ( |
## Summary `studio/frontend/tests/tray-server-status.test.ts` misreads the tray listener whenever the listener contains a nested `});`. It fails #16581, which only adds a `.catch` to the tray stop. That failure breaks both `Frontend unit tests (Windows)` and `Frontend build + bundle sanity`: ``` not ok - the tray offers a click exactly when the listener would act on it a tray toggle is clickable for a status the renderer silently drops, or greyed for one it would have handled actual (main.rs enables): ['error', 'running', 'stopped'] expected (listener acts on): ['running'] ``` The listener in #16581 still handles `running`, `stopped` and `error`, exactly as on main: ```ts register<void>("tray-toggle-server", () => { if (statusRef.current === "running") { stopServer().catch((e) => { toast.error("Could not stop the server", { description: String(e) }); }); } else if ( statusRef.current === "stopped" || statusRef.current === "error" ) { ``` `actionableStatuses` cut the listener at the first `});` after `register<void>("tray-toggle-server"`. With the `.catch` in place, that is the end of the `.catch` call, so the `stopped` / `error` branch was never read. The guard itself is useful: the tray item in `main.rs` and the renderer's listener must agree on the statuses. Only the slice was fragile, and the PR is fine. ## Change `studio/frontend/tests/tray-server-status.test.ts`, `actionableStatuses` only: the slice now ends at the `});` on the `register` call's own indentation, which is the same indent-matching approach `hookFunction` in this file already uses. If the call stops starting its own line, the test throws a clear error instead of silently reading too little. ## Testing `node --test tests/tray-server-status.test.ts`: | hook | old test | this branch | |---|---|---| | main's `use-tauri-backend.ts` | 6 pass | 6 pass | | #16581's `use-tauri-backend.ts` | 5 pass, 1 fail (above) | 6 pass | | #16581's hook with its `error` check pointed at a status that does not exist | n/a | 5 pass, 1 fail | The last row shows the guard still catches a listener that drops a status the tray enables.
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…ed the stop [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Thank you for the PR! This change landed on main through #16595 (commit f10c0ca), which includes this attached-server stop as-is: |
When the desktop app finds an Unsloth server already running for the same install (for example one started with
unsloth studioin a terminal), it attaches to it and disables Update with a note to stop that server first. But Stop server from the menu bar only detached: the server kept running, Update stayed disabled, and quitting and reopening attached to the same server again. There was no way out from the app.Stop server now shuts down the attached server through the same authenticated
/api/shutdownrequest already used for desktop-owned servers, then waits for the port to close. Only a server that accepts this install's desktop login can be stopped this way, and nothing is killed by PID. After the stop the app leaves attached mode, so Start server launches its own server and Update is enabled again. If the server does not stop, the app stays attached and returns an error.Tested on macOS with the real desktop app:
/api/health200); reopening attached to it again.Fixes #16561