diff --git a/packages/cli/__tests__/commands/status.test.ts b/packages/cli/__tests__/commands/status.test.ts index a9db08dda..5a47c6259 100644 --- a/packages/cli/__tests__/commands/status.test.ts +++ b/packages/cli/__tests__/commands/status.test.ts @@ -605,6 +605,21 @@ describe("status command", () => { expect(errors).toContain("--interval must be a positive integer"); }); + it("ignores --interval entirely when --watch is not set", async () => { + mockTmux.mockResolvedValue(null); + mockSessionManager.list.mockResolvedValue([]); + + // Invalid value (0) should NOT cause an error without --watch + await expect( + program.parseAsync(["node", "test", "status", "--interval", "0"]), + ).resolves.not.toThrow(); + + // Valid value should also be silently ignored without --watch + await expect( + program.parseAsync(["node", "test", "status", "--interval", "10"]), + ).resolves.not.toThrow(); + }); + it("schedules watch refreshes with the requested interval", async () => { mockTmux.mockResolvedValue(null); setIntervalSpy = vi.spyOn(globalThis, "setInterval").mockImplementation(() => 1 as never); diff --git a/packages/cli/src/commands/status.ts b/packages/cli/src/commands/status.ts index a6dc5e74d..625e06370 100644 --- a/packages/cli/src/commands/status.ts +++ b/packages/cli/src/commands/status.ts @@ -243,11 +243,13 @@ export function registerStatus(program: Command): void { } let watchIntervalSeconds = DEFAULT_WATCH_INTERVAL_SECONDS; - try { - watchIntervalSeconds = parseWatchIntervalSeconds(opts.interval); - } catch (err) { - console.error(chalk.red(err instanceof Error ? err.message : String(err))); - process.exit(1); + if (opts.watch) { + try { + watchIntervalSeconds = parseWatchIntervalSeconds(opts.interval); + } catch (err) { + console.error(chalk.red(err instanceof Error ? err.message : String(err))); + process.exit(1); + } } const renderStatus = async (refreshing = false): Promise => {