Repository navigation
feat(webui): the user menu can stop the local server - #13
Merged
Merged
Conversation
Collaborator
|
(Automated permission probe — please ignore. A review comment reading "permission probe" was posted while checking whether this account can review. It carries no review of the change; no approve or request-changes was intended.) |
stevenjj33
force-pushed
the
feat/user-menu-stops-the-local-server
branch
from
November 10, 2026 04:43
38241f6 to
65e92d3
Compare
The user menu gets a item that asks first and then asks the service to stop. The service owns its listener, not the process, so the route is a request: it answers and then asks the host to stop. A host with no such answer refuses the route instead of pretending, and the credential is required even on loopback because ending the process is not a privilege the ordinary routes hand out.
The shutdown feature adds three source paths and changes the account menu's rendered vocabulary, so the frozen path metadata, the presentation coverage review and the public source inventory all have to say so before the gates accept the change.
stevenjj33
force-pushed
the
feat/user-menu-stops-the-local-server
branch
from
November 10, 2026 05:57
66a3030 to
183203b
Compare
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.
What it adds
The user menu gets a 关闭本地服务 item. It asks first — an
alertdialogwith 取消 / 关闭服务 — and the answer is what asks the service to stop. The launcher then ends the run the way Ctrl+C does: the sameclose()chain, the same exit.Why it is shaped this way
The service owns its listener, not the process. The host that assembled the service owns the process (the npm launcher starts the service in the same process and owns the exit), so the shutdown route is a request: it answers, and then asks the host to stop. A host that has no such answer — the service embedded in the desktop app, whose process is not the server's to end — refuses the route with 404 rather than pretending, and the dialog says the WebUI does not support stopping.
The credential is required even on loopback. Every other route drops the credential on loopback in development mode, but this one ends the process: "any local process can stop the server" is not a privilege the ordinary routes hand out. The page presents the credential it was served with — the same one the transfer routes use.
The answer goes out before the host stops. The route answers
200 {"ok":true,"closing":true}and stops the host a moment later. A request refused by a closed listener reads as a crash to the page that asked.The parts
packages/webui/src/server/http/shutdown.ts— the route.packages/webui/src/server/http/router.ts— the route, and the host's answer in the router context.packages/webui/src/server/service.ts— the host's answer as a service option.release/webui-npm/bin/mcode-webui.mjs— the launcher hands its ownclose()down.packages/webui/src/client/platform/webui-shutdown.ts— the browser IO.packages/webui/src/client/bindings/use-webui-shutdown.ts— the React edge to it: a feature's presentation does not call an IO port, so the binding is the door between the two.packages/webui/src/client/features/account/ui/UserMenu.tsx— the item and the confirmation.packages/webui/test/browser/user-menu-shutdown.spec.mjs— the confirmation, end to end against the built client.Known limitation
The item is shown wherever the menu is shown. A host without the route answers 404 and the dialog says the WebUI does not support stopping. Hiding the item instead would need the served page to say what its host supports, which is a capability flag this change does not add.