mirror of
https://github.com/multica-ai/multica.git
synced 2026-06-17 03:38:32 +02:00
@@ -157,6 +157,67 @@ describe("runtime machine grouping", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("treats a runtime with the local device name as the current machine", () => {
|
||||
const machines = buildRuntimeMachines(
|
||||
[
|
||||
makeRuntime({
|
||||
daemon_id: "legacy-hostname",
|
||||
name: "Claude (My Laptop)",
|
||||
device_info: "My Laptop · claude 1.0.0",
|
||||
}),
|
||||
],
|
||||
{
|
||||
now: NOW,
|
||||
localDaemonId: "daemon-uuid",
|
||||
localMachineName: "my laptop",
|
||||
ensureLocalMachine: true,
|
||||
},
|
||||
);
|
||||
|
||||
expect(machines).toHaveLength(1);
|
||||
expect(machines[0]).toMatchObject({
|
||||
title: "my laptop",
|
||||
section: "local",
|
||||
isCurrent: true,
|
||||
daemonId: "legacy-hostname",
|
||||
});
|
||||
});
|
||||
|
||||
it("does not treat a cloud runtime with the local device name as current", () => {
|
||||
const machines = buildRuntimeMachines(
|
||||
[
|
||||
makeRuntime({
|
||||
id: "cloud-1",
|
||||
daemon_id: null,
|
||||
runtime_mode: "cloud",
|
||||
provider: "codex",
|
||||
name: "Codex (My Laptop)",
|
||||
device_info: "My Laptop · codex 1.0.0",
|
||||
}),
|
||||
],
|
||||
{
|
||||
now: NOW,
|
||||
localDaemonId: "daemon-uuid",
|
||||
localMachineName: "my laptop",
|
||||
ensureLocalMachine: true,
|
||||
},
|
||||
);
|
||||
|
||||
expect(machines).toHaveLength(2);
|
||||
const cloud = machines.find((m) => m.id === "cloud:device:My Laptop");
|
||||
expect(cloud).toMatchObject({
|
||||
title: "My Laptop",
|
||||
section: "cloud",
|
||||
isCurrent: false,
|
||||
});
|
||||
const local = machines.find((m) => m.isCurrent);
|
||||
expect(local).toMatchObject({
|
||||
title: "my laptop",
|
||||
section: "local",
|
||||
runtimes: [],
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps cloud runtimes as cloud workers when they have no daemon", () => {
|
||||
const machines = buildRuntimeMachines(
|
||||
[
|
||||
|
||||
@@ -174,7 +174,15 @@ function finalizeRuntimeMachine(
|
||||
const first = runtimes[0];
|
||||
const providerNames = Array.from(new Set(runtimes.map((r) => r.provider))).sort();
|
||||
const isCurrent =
|
||||
!!options.localDaemonId && draft.daemonId === options.localDaemonId;
|
||||
(!!options.localDaemonId && draft.daemonId === options.localDaemonId) ||
|
||||
(draft.mode === "local" &&
|
||||
!!options.localMachineName &&
|
||||
(draft.daemonId?.toLowerCase() === options.localMachineName.toLowerCase() ||
|
||||
runtimes.some(
|
||||
(r) =>
|
||||
runtimeDeviceName(r)?.toLowerCase() ===
|
||||
options.localMachineName?.toLowerCase(),
|
||||
)));
|
||||
const title = machineTitle(runtimes, {
|
||||
isCurrent,
|
||||
localMachineName: options.localMachineName,
|
||||
|
||||
Reference in New Issue
Block a user