docs(dsh): state what the leftover record actually gets

The docs case claimed the package does not ship the docs; it does (the
package manifest lists "docs" in "files", there is no .npmignore and the
directory is not git-ignored), so the check runs in the packed install and
the comment was the opposite of the fact.

The service lifetime also promised that Start replaces a leftover, but a
healthy one is only observed: Start reports it as already running and
replaces nothing. The wording now says so, and a case pins it.
This commit is contained in:
LiangshouX 2026-11-03 13:05:18 +08:00
parent b631e4c00c
commit 87fddc7e4c
4 changed files with 20 additions and 8 deletions

View file

@ -166,9 +166,9 @@ processes it manages when the Host exits. The plugin owns a small service adapte
- A record left by an older version under a path prefix of the same origin (for example
`127.0.0.1:2333/reme`) describes the **same** local service, because the launch configures only host
and port. When it can be proven to be this plugin's service, such a record is re-keyed to the endpoint on
screen and then managed like any other launch: **Stop** is offered, and **Start** replaces it. It is then
not reported as a foreign process the tab cannot act on, which would leave the user with a process to
kill by hand.
screen and then managed like any other launch: **Stop** is offered, and **Start** replaces it while it is
not healthy. It is then not reported as a foreign process the tab cannot act on, which would leave the
user with a process to kill by hand.
- **Stop** tree-kills the recorded process (process group on POSIX, `taskkill /T /F` on Windows), waits for it to
exit, escalates (POSIX: `SIGTERM` then `SIGKILL`; Windows: force `taskkill` again), and clears the record only
after the pid is gone. A service started elsewhere stays untouched and is only observed.

View file

@ -132,8 +132,8 @@ ReMe 在服务启动时读取 workspace 目录下的 `.env`;标签页从不把
- 服务占用端口但健康检查失败时显示为“端口被占用”;若能证明是本插件启动的,标签页仍给出**停止**按钮。
- 旧版本遗留在同一源(origin)某个路径前缀下(例如 `127.0.0.1:2333/reme`)的记录,描述的是**同一个**本地服务——
启动只配置 host 与端口。只要能证明它是本插件启动的,这种记录就会被重新登记到当前显示的地址,随后与其他启动
一样被管理:给出**停止**按钮,**启动**也会替换它。它不会再被当成标签页无从处理的外部进程,否则用户只能自己去
杀进程。
一样被管理:给出**停止**按钮,**启动**在它尚未健康时替换它。它不会再被当成标签页无从处理的外部进程,否则用户
只能自己去杀进程。
- **停止**会树杀记录的进程(POSIX 上按进程组、Windows 上为 `taskkill /T /F`),等待其退出,必要时升级(POSIX:
`SIGTERM` 后 `SIGKILL`;Windows:再次强制 `taskkill`),并**在 pid 真正消失之后**才清除记录。别处启动的服务不受影响,
只会被观察。

View file

@ -40,10 +40,11 @@ function codeSpans(text) {
test("the user docs hold no code span the GUI turns into a link", (t) => {
for (const file of ["environment.md", "environment_ZH.md"]) {
const path = join(docs, file);
// The packed plugin does not ship the docs; there is nothing to check
// there.
// The docs are part of the package (`files` includes `docs`), so the check
// runs in the packed install too. This branch only guards a checkout that
// does not have them.
if (!existsSync(path)) {
t.skip(`${file} is not part of the package`);
t.skip(`${file} is not part of this checkout`);
continue;
}
const offenders = codeSpans(readFileSync(path, "utf8")).filter(

View file

@ -474,6 +474,17 @@ test("adopts a leftover record under a same-origin path prefix", async (t) => {
);
// The adopted record is stoppable: the endpoint on screen can act on it.
// A healthy service is only observed, though: Start reports it as already
// running and replaces nothing.
const started = await manager.serviceStart(
"http://127.0.0.1:2334",
"D:\\env\\python.exe",
join(directory, "workspace"),
);
assert.equal(started.started, false);
assert.equal(started.alreadyRunning, true);
assert.equal(calls.spawn.length, 0, "a healthy service is not replaced");
const stopped = await manager.serviceStop("http://127.0.0.1:2334");
assert.equal(stopped.stopped, true);
assert.deepEqual(calls.killTree, [6000]);