fix: honor config timeout in tui
This commit is contained in:
@@ -9,6 +9,7 @@ const onboardCommand = vi.fn();
|
||||
const callGateway = vi.fn();
|
||||
const runProviderLogin = vi.fn();
|
||||
const runProviderLogout = vi.fn();
|
||||
const runTui = vi.fn();
|
||||
|
||||
const runtime = {
|
||||
log: vi.fn(),
|
||||
@@ -30,6 +31,9 @@ vi.mock("./provider-auth.js", () => ({
|
||||
runProviderLogin,
|
||||
runProviderLogout,
|
||||
}));
|
||||
vi.mock("../tui/tui.js", () => ({
|
||||
runTui,
|
||||
}));
|
||||
vi.mock("../gateway/call.js", () => ({
|
||||
callGateway,
|
||||
randomIdempotencyKey: () => "idem-test",
|
||||
@@ -43,6 +47,7 @@ const { buildProgram } = await import("./program.js");
|
||||
describe("cli program", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
runTui.mockResolvedValue(undefined);
|
||||
});
|
||||
|
||||
it("runs message with required options", async () => {
|
||||
@@ -62,6 +67,24 @@ describe("cli program", () => {
|
||||
expect(statusCommand).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("runs tui without overriding timeout", async () => {
|
||||
const program = buildProgram();
|
||||
await program.parseAsync(["tui"], { from: "user" });
|
||||
expect(runTui).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ timeoutMs: undefined }),
|
||||
);
|
||||
});
|
||||
|
||||
it("runs tui with explicit timeout override", async () => {
|
||||
const program = buildProgram();
|
||||
await program.parseAsync(["tui", "--timeout-ms", "45000"], {
|
||||
from: "user",
|
||||
});
|
||||
expect(runTui).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ timeoutMs: 45000 }),
|
||||
);
|
||||
});
|
||||
|
||||
it("runs config alias as configure", async () => {
|
||||
const program = buildProgram();
|
||||
await program.parseAsync(["config"], { from: "user" });
|
||||
|
||||
@@ -19,14 +19,21 @@ export function registerTuiCli(program: Command) {
|
||||
.option("--deliver", "Deliver assistant replies", false)
|
||||
.option("--thinking <level>", "Thinking level override")
|
||||
.option("--message <text>", "Send an initial message after connecting")
|
||||
.option("--timeout-ms <ms>", "Agent timeout in ms", "30000")
|
||||
.option(
|
||||
"--timeout-ms <ms>",
|
||||
"Agent timeout in ms (defaults to agents.defaults.timeoutSeconds)",
|
||||
)
|
||||
.option("--history-limit <n>", "History entries to load", "200")
|
||||
.action(async (opts) => {
|
||||
try {
|
||||
const timeoutMs = Number.parseInt(
|
||||
String(opts.timeoutMs ?? "30000"),
|
||||
10,
|
||||
);
|
||||
const timeoutMs =
|
||||
typeof opts.timeoutMs === "undefined"
|
||||
? undefined
|
||||
: Number.parseInt(String(opts.timeoutMs), 10);
|
||||
const normalizedTimeoutMs =
|
||||
typeof timeoutMs === "number" && Number.isFinite(timeoutMs)
|
||||
? timeoutMs
|
||||
: undefined;
|
||||
const historyLimit = Number.parseInt(
|
||||
String(opts.historyLimit ?? "200"),
|
||||
10,
|
||||
@@ -39,7 +46,7 @@ export function registerTuiCli(program: Command) {
|
||||
deliver: Boolean(opts.deliver),
|
||||
thinking: opts.thinking as string | undefined,
|
||||
message: opts.message as string | undefined,
|
||||
timeoutMs: Number.isNaN(timeoutMs) ? undefined : timeoutMs,
|
||||
timeoutMs: normalizedTimeoutMs,
|
||||
historyLimit: Number.isNaN(historyLimit) ? undefined : historyLimit,
|
||||
});
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user