From 014f06db693ad89482e92742f9c16034db648fec Mon Sep 17 00:00:00 2001 From: Badcuban <108198679+badcuban@users.noreply.github.com> Date: Wed, 18 Nov 2026 18:17:32 -0500 Subject: [PATCH] fix(web): the move window no longer says a child on the target computer stays there When the computer a thread moves to keeps its children apart (an older build), the line said '1 thread it started on Mac mini stays there. It can't reach it from Mac mini.' It now says the thread is already on that computer and stays separate, matching the Moved here line. A child an older server names no computer for is matched to the target by name. --- apps/web/src/threadMove.test.ts | 14 +++++++++++-- apps/web/src/threadMove.ts | 35 +++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/apps/web/src/threadMove.test.ts b/apps/web/src/threadMove.test.ts index 4fb7a8a25..4340900bf 100644 --- a/apps/web/src/threadMove.test.ts +++ b/apps/web/src/threadMove.test.ts @@ -475,11 +475,21 @@ describe("describeRemoteChildrenStaying", () => { "'Fix tests' on Mac mini becomes its thread there again.", "2 threads it started on Windows PC stay there. It can't reach them from Mac mini.", ]); - // An older Mac mini keeps them apart: today's words. + // An older Mac mini keeps them apart, beside it rather than "there". expect( describeRemoteChildrenStaying(children, { label: "Mac mini", environmentId: MAC }), ).toEqual([ - "1 thread it started on Mac mini stays there. It can't reach it from Mac mini.", + "'Fix tests' is already on Mac mini. It stays separate, so this thread can't reach it.", + "2 threads it started on Windows PC stay there. It can't reach them from Mac mini.", + ]); + // An older server names no computer for its children: matched by name. + expect( + describeRemoteChildrenStaying( + children.map(({ label, title }) => ({ label, title })), + { label: "Mac mini", environmentId: MAC }, + ), + ).toEqual([ + "'Fix tests' is already on Mac mini. It stays separate, so this thread can't reach it.", "2 threads it started on Windows PC stay there. It can't reach them from Mac mini.", ]); }); diff --git a/apps/web/src/threadMove.ts b/apps/web/src/threadMove.ts index 8c8f6d603..068b9dc0e 100644 --- a/apps/web/src/threadMove.ts +++ b/apps/web/src/threadMove.ts @@ -1014,10 +1014,13 @@ export function describeFamilyComing(count: number): string { /** * "2 threads it started on Windows PC stay there. It can't reach them from * Mac mini.", one line per computer, for the threads its agent started on - * other computers. Those on the computer it moves to, when that computer - * takes them back (`adoptsChildren`), become its threads there again - * (docs/design/fleet.md, Part 3f, (g)): "'Fix tests' on Mac mini becomes its - * thread there again." + * other computers. Those already on the computer it moves to become its + * threads there again when that computer takes them back (`adoptsChildren`, + * docs/design/fleet.md, Part 3f, (g)): "'Fix tests' on Mac mini becomes its + * thread there again." A computer that doesn't (an older one) keeps them + * apart beside it: "'Fix tests' is already on Mac mini. It stays separate, so + * this thread can't reach it." A child the server named no computer for (an + * older server) is matched to the target by its label. */ export function describeRemoteChildrenStaying( remoteChildren: ReadonlyArray<{ @@ -1031,23 +1034,35 @@ export function describeRemoteChildrenStaying( readonly adoptsChildren?: true | undefined; }, ): string[] { - const back = remoteChildren.filter( - (child) => target.adoptsChildren === true && child.environmentId === target.environmentId, + const onTarget = remoteChildren.filter((child) => + child.environmentId !== undefined + ? child.environmentId === target.environmentId + : child.label === target.label, ); + const back = target.adoptsChildren === true ? onTarget : []; + const beside = target.adoptsChildren === true ? [] : onTarget; const byLabel = new Map(); for (const child of remoteChildren) { - if (back.includes(child)) continue; + if (onTarget.includes(child)) continue; byLabel.set(child.label, (byLabel.get(child.label) ?? 0) + 1); } - const [only] = back; + const [onlyBack] = back; + const [onlyBeside] = beside; return [ ...(back.length === 0 ? [] : [ - back.length === 1 && only !== undefined - ? `'${only.title}' on ${target.label} becomes its thread there again.` + back.length === 1 && onlyBack !== undefined + ? `'${onlyBack.title}' on ${target.label} becomes its thread there again.` : `${back.length} threads it started on ${target.label} become its threads there again.`, ]), + ...(beside.length === 0 + ? [] + : [ + beside.length === 1 && onlyBeside !== undefined + ? `'${onlyBeside.title}' is already on ${target.label}. It stays separate, so this thread can't reach it.` + : `${beside.length} threads it started are already on ${target.label}. They stay separate, so this thread can't reach them.`, + ]), ...[...byLabel].map(([label, count]) => count === 1 ? `1 thread it started on ${label} stays there. It can't reach it from ${target.label}.`