Skip to content

Commit bbfb555

Browse files
MarcoDotIOclaude
andcommitted
fix(server): terminal labels keep the whole name of a command with spaces
The running-command label cut process names at the first space, so a terminal running "Google Chrome" was labelled "Google", and a macOS `ps` path under "My Projects" was labelled "My". The split was left over from an old `ps args=` fallback; every caller now passes a process name or `comm` path, so take the basename of the whole value. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 70e5e38 commit bbfb555

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

‎apps/server/src/terminal/Manager.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,28 @@ it.layer(
652652
}),
653653
);
654654

655+
it.effect("labels a running command by its whole process name, spaces included", () =>
656+
Effect.gen(function* () {
657+
const { manager } = yield* createManager(5, {
658+
subprocessPollIntervalMs: 1,
659+
processTable: Effect.succeed([
660+
{ pid: 9000, ppid: 1, name: "zsh" },
661+
{ pid: 200, ppid: 9000, name: "Google Chrome" },
662+
]),
663+
}).pipe(Effect.provide(layerWithHostPlatform("darwin")));
664+
const label = yield* Deferred.make<string>();
665+
const unsubscribe = yield* manager.subscribe((event) =>
666+
event.type === "activity"
667+
? Deferred.succeed(label, event.label).pipe(Effect.asVoid)
668+
: Effect.void,
669+
);
670+
yield* Effect.addFinalizer(() => Effect.sync(unsubscribe));
671+
yield* manager.open(openInput());
672+
673+
expect(yield* Deferred.await(label)).toBe("Google Chrome");
674+
}),
675+
);
676+
655677
it.effect("keeps terminals that get input or output while closeIdle checks them", () =>
656678
Effect.gen(function* () {
657679
const ptyAdapter = new FakePtyAdapter();

‎apps/server/src/terminal/Manager.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,9 @@ function normalizeChildCommandName(raw: string, platform: NodeJS.Platform): stri
333333
) {
334334
trimmed = trimmed.slice(1, -1).trim();
335335
}
336-
const firstToken = (trimmed.split(/\s+/)[0] ?? trimmed).trim();
337-
if (firstToken.length === 0) return null;
336+
// Process names and macOS `comm` paths can contain spaces ("Google Chrome").
338337
const separators = platform === "win32" ? /[\\/]/ : /\//;
339-
const base = firstToken.split(separators).at(-1) ?? firstToken;
338+
const base = (trimmed.split(separators).at(-1) ?? trimmed).trim();
340339
const withoutExe =
341340
platform === "win32" && base.toLowerCase().endsWith(".exe") ? base.slice(0, -4) : base;
342341
return withoutExe.length > 0 ? withoutExe : null;

0 commit comments

Comments
 (0)