fix: resolve live config paths in status and gateway metadata (#39952)

* fix: resolve live config paths in status and gateway metadata

* fix: resolve remaining runtime config path references

* test: cover gateway config.set config path response
This commit is contained in:
Tak Hoffman
2026-03-08 09:59:32 -05:00
committed by GitHub
parent da3cccb212
commit d9e8e8ac15
8 changed files with 73 additions and 15 deletions

View File

@@ -0,0 +1,25 @@
import { describe, expect, it, vi } from "vitest";
const mocks = vi.hoisted(() => ({
createConfigIO: vi.fn().mockReturnValue({
configPath: "/tmp/openclaw-dev/openclaw.json",
}),
}));
vi.mock("./io.js", () => ({
createConfigIO: mocks.createConfigIO,
}));
import { formatConfigPath, logConfigUpdated } from "./logging.js";
describe("config logging", () => {
it("formats the live config path when no explicit path is provided", () => {
expect(formatConfigPath()).toBe("/tmp/openclaw-dev/openclaw.json");
});
it("logs the live config path when no explicit path is provided", () => {
const runtime = { log: vi.fn() };
logConfigUpdated(runtime as never);
expect(runtime.log).toHaveBeenCalledWith("Updated /tmp/openclaw-dev/openclaw.json");
});
});

View File

@@ -1,18 +1,18 @@
import type { RuntimeEnv } from "../runtime.js";
import { displayPath } from "../utils.js";
import { CONFIG_PATH } from "./paths.js";
import { createConfigIO } from "./io.js";
type LogConfigUpdatedOptions = {
path?: string;
suffix?: string;
};
export function formatConfigPath(path: string = CONFIG_PATH): string {
export function formatConfigPath(path: string = createConfigIO().configPath): string {
return displayPath(path);
}
export function logConfigUpdated(runtime: RuntimeEnv, opts: LogConfigUpdatedOptions = {}): void {
const path = formatConfigPath(opts.path ?? CONFIG_PATH);
const path = formatConfigPath(opts.path ?? createConfigIO().configPath);
const suffix = opts.suffix ? ` ${opts.suffix}` : "";
runtime.log(`Updated ${path}${suffix}`);
}