fix(gateway): restore loopback detail probes and identity fallback (#51087)

Merged via squash.

Prepared head SHA: f8a66ffde2
Co-authored-by: heavenlost <70937055+heavenlost@users.noreply.github.com>
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
This commit is contained in:
heavenlost
2026-03-27 15:09:41 +08:00
committed by GitHub
parent 6f92148da9
commit 3cbd4de95c
13 changed files with 469 additions and 70 deletions

View File

@@ -3,7 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { captureEnv } from "../test-utils/env.js";
import { createCliRuntimeCapture } from "./test-runtime-capture.js";
const callGateway = vi.fn(async (..._args: unknown[]) => ({ ok: true }));
const probeGatewayStatus = vi.fn(async (..._args: unknown[]) => ({ ok: true }));
const resolveGatewayProgramArguments = vi.fn(async (_opts?: unknown) => ({
programArguments: ["/bin/node", "cli", "gateway", "--port", "18789"],
}));
@@ -36,8 +36,8 @@ const buildGatewayInstallPlan = vi.fn(
const { runtimeLogs, defaultRuntime, resetRuntimeCapture } = createCliRuntimeCapture();
vi.mock("../gateway/call.js", () => ({
callGateway: (opts: unknown) => callGateway(opts),
vi.mock("./daemon-cli/probe.js", () => ({
probeGatewayStatus: (opts: unknown) => probeGatewayStatus(opts),
}));
vi.mock("../gateway/probe-auth.js", () => ({
@@ -146,19 +146,21 @@ describe("daemon-cli coverage", () => {
it("probes gateway status by default", async () => {
resetRuntimeCapture();
callGateway.mockClear();
probeGatewayStatus.mockClear();
await runDaemonCommand(["daemon", "status"]);
expect(callGateway).toHaveBeenCalledTimes(1);
expect(callGateway).toHaveBeenCalledWith(expect.objectContaining({ method: "status" }));
expect(probeGatewayStatus).toHaveBeenCalledTimes(1);
expect(probeGatewayStatus).toHaveBeenCalledWith(
expect.objectContaining({ url: "ws://127.0.0.1:18789" }),
);
expect(findExtraGatewayServices).toHaveBeenCalled();
expect(inspectPortUsage).toHaveBeenCalled();
});
it("derives probe URL from service args + env (json)", async () => {
resetRuntimeCapture();
callGateway.mockClear();
probeGatewayStatus.mockClear();
inspectPortUsage.mockClear();
serviceReadCommand.mockResolvedValueOnce({
@@ -174,10 +176,9 @@ describe("daemon-cli coverage", () => {
await runDaemonCommand(["daemon", "status", "--json"]);
expect(callGateway).toHaveBeenCalledWith(
expect(probeGatewayStatus).toHaveBeenCalledWith(
expect.objectContaining({
url: "ws://127.0.0.1:19001",
method: "status",
}),
);
expect(inspectPortUsage).toHaveBeenCalledWith(19001);