chore(webchat): log url on gateway start
This commit is contained in:
@@ -4,7 +4,6 @@ const sendCommand = vi.fn();
|
|||||||
const statusCommand = vi.fn();
|
const statusCommand = vi.fn();
|
||||||
const loginWeb = vi.fn();
|
const loginWeb = vi.fn();
|
||||||
const startWebChatServer = vi.fn(async () => ({ port: 18788 }));
|
const startWebChatServer = vi.fn(async () => ({ port: 18788 }));
|
||||||
const ensureWebChatServerFromConfig = vi.fn(async () => ({ port: 18788 }));
|
|
||||||
|
|
||||||
const runtime = {
|
const runtime = {
|
||||||
log: vi.fn(),
|
log: vi.fn(),
|
||||||
@@ -22,7 +21,6 @@ vi.mock("../provider-web.js", () => ({
|
|||||||
}));
|
}));
|
||||||
vi.mock("../webchat/server.js", () => ({
|
vi.mock("../webchat/server.js", () => ({
|
||||||
startWebChatServer,
|
startWebChatServer,
|
||||||
ensureWebChatServerFromConfig,
|
|
||||||
getWebChatServer: () => null,
|
getWebChatServer: () => null,
|
||||||
}));
|
}));
|
||||||
vi.mock("./deps.js", () => ({
|
vi.mock("./deps.js", () => ({
|
||||||
|
|||||||
@@ -13,10 +13,7 @@ import { loginWeb, logoutWeb } from "../provider-web.js";
|
|||||||
import { runRpcLoop } from "../rpc/loop.js";
|
import { runRpcLoop } from "../rpc/loop.js";
|
||||||
import { defaultRuntime } from "../runtime.js";
|
import { defaultRuntime } from "../runtime.js";
|
||||||
import { VERSION } from "../version.js";
|
import { VERSION } from "../version.js";
|
||||||
import {
|
import { startWebChatServer } from "../webchat/server.js";
|
||||||
ensureWebChatServerFromConfig,
|
|
||||||
startWebChatServer,
|
|
||||||
} from "../webchat/server.js";
|
|
||||||
import { createDefaultDeps } from "./deps.js";
|
import { createDefaultDeps } from "./deps.js";
|
||||||
import {
|
import {
|
||||||
forceFreePort,
|
forceFreePort,
|
||||||
@@ -285,22 +282,6 @@ Examples:
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await startGatewayServer(port);
|
await startGatewayServer(port);
|
||||||
try {
|
|
||||||
const webchat = await ensureWebChatServerFromConfig({
|
|
||||||
gatewayUrl: `ws://127.0.0.1:${port}`,
|
|
||||||
});
|
|
||||||
if (webchat) {
|
|
||||||
defaultRuntime.log(
|
|
||||||
info(
|
|
||||||
`webchat listening on http://127.0.0.1:${webchat.port}/`,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
defaultRuntime.log(info("webchat disabled via config"));
|
|
||||||
}
|
|
||||||
} catch (webchatErr) {
|
|
||||||
defaultRuntime.error(`WebChat failed to start: ${String(webchatErr)}`);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err instanceof GatewayLockError) {
|
if (err instanceof GatewayLockError) {
|
||||||
defaultRuntime.error(`Gateway failed to start: ${err.message}`);
|
defaultRuntime.error(`Gateway failed to start: ${err.message}`);
|
||||||
|
|||||||
@@ -734,9 +734,17 @@ export async function startGatewayServer(port = 18789): Promise<GatewayServer> {
|
|||||||
// Start loopback WebChat server (unless disabled via config).
|
// Start loopback WebChat server (unless disabled via config).
|
||||||
void ensureWebChatServerFromConfig({
|
void ensureWebChatServerFromConfig({
|
||||||
gatewayUrl: `ws://127.0.0.1:${port}`,
|
gatewayUrl: `ws://127.0.0.1:${port}`,
|
||||||
}).catch((err) => {
|
})
|
||||||
logError(`gateway: webchat failed to start: ${String(err)}`);
|
.then((webchat) => {
|
||||||
});
|
if (webchat) {
|
||||||
|
defaultRuntime.log(
|
||||||
|
`webchat listening on http://127.0.0.1:${webchat.port}/`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
logError(`gateway: webchat failed to start: ${String(err)}`);
|
||||||
|
});
|
||||||
|
|
||||||
// Launch configured providers (WhatsApp Web, Telegram) so gateway replies via the
|
// Launch configured providers (WhatsApp Web, Telegram) so gateway replies via the
|
||||||
// surface the message came from. Tests can opt out via CLAWDIS_SKIP_PROVIDERS.
|
// surface the message came from. Tests can opt out via CLAWDIS_SKIP_PROVIDERS.
|
||||||
|
|||||||
Reference in New Issue
Block a user