In src/commands/sessions.ts line 672-673, nowSeconds() is called twice within the same ternary expression without caching:
remaining_secs:
record.grace_ready_at > nowSeconds() ? record.grace_ready_at - nowSeconds() : 0,
If the system clock ticks between the two calls (e.g., first returns 999, second returns 1001), the guard passes but the subtraction produces a negative value (-1).
The correct pattern is already used elsewhere in the same file closeOneSession (line 338) caches now:
const now = nowSeconds();
Suggested fix:
const now = nowSeconds();
// ...
remaining_secs: record.grace_ready_at > now ? record.grace_ready_at - now : 0,
In
src/commands/sessions.tsline 672-673,nowSeconds()is called twice within the same ternary expression without caching:If the system clock ticks between the two calls (e.g., first returns
999, second returns1001), the guard passes but the subtraction produces a negative value (-1).The correct pattern is already used elsewhere in the same file
closeOneSession(line 338) cachesnow:Suggested fix: