Skip to content

Commit 76f204d

Browse files
hugocasaclaude
andcommitted
feat(cli): show migration warning on all project-reaching commands
Follow-up to the previous commit, which narrowed the warning to exclude worktree commands. That call was driven by a non-hermetic e2e test (it read the dev machine's real ~/.webmux registry), not by merit — so revert the narrowing: the nudge now fires on every command that reaches a project (oneshot/linear/project + worktree commands), still excluding `project migrate`. It's silent unless other servers exist, transient until you consolidate, and on stderr. Make the webmux.test.ts e2e spawns hermetic by isolating HOME, so the registry read sees an empty dir regardless of what's running locally. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 3151051 commit 76f204d

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

bin/src/webmux.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,16 @@ describe("webmux entrypoint", () => {
174174
const nestedDir = join(repoRoot, "nested", "dir");
175175
await mkdir(nestedDir, { recursive: true });
176176

177+
// Isolate HOME so the migration-warning's registry read (~/.webmux/instances)
178+
// sees an empty dir, not the dev machine's real running instances.
179+
const home = await mkdtemp(join(tmpdir(), "webmux-home-"));
180+
tempDirs.push(home);
181+
177182
const result = Bun.spawnSync(["bun", webmuxEntry, "open", "missing-branch"], {
178183
cwd: nestedDir,
179184
stdout: "pipe",
180185
stderr: "pipe",
186+
env: { ...process.env, HOME: home },
181187
});
182188
const stderr = decoder.decode(result.stderr).trim();
183189

@@ -211,12 +217,18 @@ describe("webmux entrypoint", () => {
211217
const worktreePath = join(worktreesRoot, "feature-self-remove");
212218
runOrThrow(["git", "worktree", "add", "-b", "feature-self-remove", worktreePath], repoRoot);
213219

220+
// Isolate HOME so the migration-warning's registry read sees an empty dir,
221+
// keeping stderr clean regardless of what's running on the dev machine.
222+
const home = await mkdtemp(join(tmpdir(), "webmux-home-"));
223+
tempDirs.push(home);
224+
214225
const result = Bun.spawnSync(["bun", webmuxEntry, "remove", "feature-self-remove"], {
215226
cwd: worktreePath,
216227
stdout: "pipe",
217228
stderr: "pipe",
218229
env: {
219230
...process.env,
231+
HOME: home,
220232
PATH: `${fakeBin}:${process.env.PATH ?? ""}`,
221233
},
222234
});

bin/src/webmux.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -353,17 +353,17 @@ async function main(args: string[] = process.argv.slice(2)): Promise<void> {
353353
}
354354
}
355355

356-
// Nudge toward consolidation when other webmux servers are running — on the
357-
// occasional management commands (oneshot/linear/project), but NOT the
358-
// high-frequency worktree commands (list/open/send/…) where a per-invocation
359-
// warning would be noisy, nor `project migrate` (which consolidates them
360-
// itself). Cheap: a local registry read, silent unless peers exist, and to
361-
// stderr so it never pollutes piped output.
356+
// Nudge toward consolidation when other webmux servers are running, on any
357+
// command that reaches a project (everything dispatched below) except
358+
// `project migrate`, which consolidates them itself. Cheap: a local registry
359+
// read, silent unless peers exist, and to stderr so it never pollutes piped
360+
// output. Only relevant before the user has consolidated, so it's transient.
362361
const isProjectMigrate = parsed.command === "project" && parsed.commandArgs[0] === "migrate";
363-
const isOccasionalServerCommand = parsed.command === "oneshot"
362+
const reachesAProject = parsed.command === "oneshot"
364363
|| parsed.command === "linear"
365-
|| parsed.command === "project";
366-
if (isOccasionalServerCommand && !isProjectMigrate) {
364+
|| parsed.command === "project"
365+
|| isWorktreeCommand(parsed.command);
366+
if (reachesAProject && !isProjectMigrate) {
367367
const { warnIfOtherInstances } = await import("./migrate.ts");
368368
warnIfOtherInstances(effectivePort);
369369
}

0 commit comments

Comments
 (0)