fix(statusline): re-arm polling when config changes (#1416)

Co-authored-by: Letta Code <noreply@letta.com>
This commit is contained in:
jnjpng
2026-03-16 17:40:01 -07:00
committed by GitHub
parent ad7177b305
commit f8849c4536
2 changed files with 101 additions and 11 deletions

View File

@@ -3,6 +3,7 @@ import {
DEFAULT_STATUS_LINE_DEBOUNCE_MS,
normalizeStatusLineConfig,
} from "../../cli/helpers/statusLineConfig";
import { buildRefreshIntervalPlan } from "../../cli/hooks/useConfigurableStatusLine";
describe("statusline controller-related config", () => {
test("normalizes debounce and refresh interval defaults", () => {
@@ -29,3 +30,43 @@ describe("statusline controller-related config", () => {
expect(normalized.debounceMs).toBe(50);
});
});
describe("buildRefreshIntervalPlan", () => {
test("returns no-op when interval is unchanged", () => {
expect(buildRefreshIntervalPlan(null, null)).toEqual({
shouldClearExistingInterval: false,
shouldArmInterval: false,
nextRefreshIntervalMs: null,
});
expect(buildRefreshIntervalPlan(5000, 5000)).toEqual({
shouldClearExistingInterval: false,
shouldArmInterval: false,
nextRefreshIntervalMs: 5000,
});
});
test("arms interval when moving from off to polling", () => {
expect(buildRefreshIntervalPlan(null, 5000)).toEqual({
shouldClearExistingInterval: false,
shouldArmInterval: true,
nextRefreshIntervalMs: 5000,
});
});
test("re-arms interval when polling cadence changes", () => {
expect(buildRefreshIntervalPlan(5000, 1000)).toEqual({
shouldClearExistingInterval: true,
shouldArmInterval: true,
nextRefreshIntervalMs: 1000,
});
});
test("clears interval when polling is disabled", () => {
expect(buildRefreshIntervalPlan(5000, null)).toEqual({
shouldClearExistingInterval: true,
shouldArmInterval: false,
nextRefreshIntervalMs: null,
});
});
});