Skip to content

Commit ca5b817

Browse files
t3dotggclaude
andcommitted
test(client-runtime): cover idle-gate boundary and re-settle-after-idle; note clock-skew exposure
Codex review follow-ups: assert the strict one-hour boundary (activity exactly an hour old stays warm), assert the same shell re-settles once the follow-up burst goes idle, and document that cross-device clock skew shifts the idle window by its size — the same accepted exposure as the inactivity auto-settle. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent d4705ac commit ca5b817

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎packages/client-runtime/src/state/threadSettled.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ describe("effectiveSettled", () => {
168168
// message would un-settle the row only until its turn completed, then
169169
// snap straight back into the settled tail.
170170
const justActive = makeShell({ activityAt: "2026-04-09T23:30:00.000Z" });
171+
// The idle gate is strict: activity exactly one hour old is still warm.
172+
const boundary = makeShell({ activityAt: "2026-04-09T23:00:00.000Z" });
171173
const idle = makeShell({ activityAt: "2026-04-09T22:59:59.999Z" });
172174

173175
for (const changeRequestState of ["merged", "closed"] as const) {
@@ -178,6 +180,13 @@ describe("effectiveSettled", () => {
178180
changeRequestState,
179181
}),
180182
).toBe(false);
183+
expect(
184+
effectiveSettled(boundary, {
185+
now: NOW,
186+
autoSettleAfterDays: null,
187+
changeRequestState,
188+
}),
189+
).toBe(false);
181190
expect(
182191
effectiveSettled(idle, {
183192
now: NOW,
@@ -188,6 +197,16 @@ describe("effectiveSettled", () => {
188197
}
189198
});
190199

200+
it("re-settles a merged-PR thread once the follow-up burst goes idle", () => {
201+
// Same shell, advancing clock: active while warm, settled again after
202+
// the idle window passes — the burst cools and the merge signal wins.
203+
const shell = makeShell({ activityAt: "2026-04-09T23:30:00.000Z" });
204+
const options = { autoSettleAfterDays: null, changeRequestState: "merged" as const };
205+
206+
expect(effectiveSettled(shell, { ...options, now: NOW })).toBe(false);
207+
expect(effectiveSettled(shell, { ...options, now: "2026-04-10T00:30:00.001Z" })).toBe(true);
208+
});
209+
191210
it("never settles a starting session, even with a settled override", () => {
192211
const shell = makeShell({
193212
settledOverride: "settled",

‎packages/client-runtime/src/state/threadSettled.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ export function canSettle(
9797
* its turn completed, then the still-merged PR would snap it straight back
9898
* into the settled tail. An hour keeps the follow-up conversation visible
9999
* while it is warm; once the burst goes stale the merge signal settles it
100-
* again.
100+
* again. Activity timestamps can originate on another device while `now` is
101+
* this caller's clock: skew shortens or stretches the window by its size,
102+
* the same exposure the inactivity auto-settle already accepts — worst case
103+
* is a row changing lists early or late, never lost work.
101104
*/
102105
export const CHANGE_REQUEST_SETTLE_IDLE_MS = 60 * 60 * 1_000;
103106

0 commit comments

Comments
 (0)