



















@@ -174,6 +174,7 @@ describe("resolveSessionResetPolicy", () => {
174174});
175175176176expect(freshness.fresh).toBe(false);
177+expect(freshness.staleReason).toBe("daily");
177178});
178179179180it("uses lastInteractionAt, not updatedAt, for idle reset freshness", () => {
@@ -191,6 +192,7 @@ describe("resolveSessionResetPolicy", () => {
191192192193expect(freshness.fresh).toBe(false);
193194expect(freshness.idleExpiresAt).toBe(5 * 60_000);
195+expect(freshness.staleReason).toBe("idle");
194196});
195197196198it("falls back to sessionStartedAt, not updatedAt, for legacy idle freshness", () => {
@@ -208,6 +210,25 @@ describe("resolveSessionResetPolicy", () => {
208210209211expect(freshness.fresh).toBe(false);
210212expect(freshness.idleExpiresAt).toBe(5 * 60_000);
213+expect(freshness.staleReason).toBe("idle");
214+});
215+216+it("reports the first expired reset deadline when daily and idle are both stale", () => {
217+const now = new Date(2026, 3, 25, 12, 0, 0, 0).getTime();
218+const freshness = evaluateSessionFreshness({
219+updatedAt: now,
220+sessionStartedAt: new Date(2026, 3, 24, 23, 0, 0, 0).getTime(),
221+lastInteractionAt: new Date(2026, 3, 25, 11, 0, 0, 0).getTime(),
222+ now,
223+policy: {
224+mode: "daily",
225+atHour: 4,
226+idleMinutes: 30,
227+},
228+});
229+230+expect(freshness.fresh).toBe(false);
231+expect(freshness.staleReason).toBe("daily");
211232});
212233213234it("does not let future legacy updatedAt values keep daily sessions fresh", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。