Skip to content

Limit GLM sessions to 12 hours#553

Merged
jahooma merged 2 commits intomainfrom
jahooma/new-session-rate-limit
Apr 27, 2026
Merged

Limit GLM sessions to 12 hours#553
jahooma merged 2 commits intomainfrom
jahooma/new-session-rate-limit

Conversation

@jahooma
Copy link
Copy Markdown
Contributor

@jahooma jahooma commented Apr 26, 2026

Summary

Changes the GLM Freebuff session quota from 5 admissions per 20 hours to 5 admissions per 12 hours.
Updates the CLI waiting-room comments, shared wire-type docs, DB schema docs, and free-session tests to match the new window while keeping the existing retry countdown behavior.

Validation

bun test web/src/server/free-session/__tests__/public-api.test.ts passed with 41 tests.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 26, 2026

Greptile Summary

Reduces the GLM 5.1 session quota rolling window from 20 hours to 12 hours by changing the single windowHours constant in RATE_LIMITS and updating all downstream comments, type docs, and tests accordingly. All logic for enforcement, retryAfterMs calculation, and CLI display is unchanged.

Confidence Score: 5/5

Safe to merge — single constant change with no logic modifications and all tests passing.

All findings are P2. The only substantive note is a minor duplicate computation of windowMs which does not affect correctness. The constant change propagates correctly through every enforcement and display path.

No files require special attention.

Important Files Changed

Filename Overview
web/src/server/free-session/public-api.ts Single-line constant change: windowHours: 20 → 12; minor duplicate windowMs computation at the call site
web/src/server/free-session/tests/public-api.test.ts Test ages updated from 19h→11h to stay inside the new 12h window; boundary test correctly parameterised via GLM_WINDOW_HOURS
web/src/server/free-session/store.ts Comment-only update: 20h → 12h; no logic changed
common/src/types/freebuff-session.ts JSDoc comment updated from 20h to 12h; no type definitions changed
packages/internal/src/db/schema.ts Comment-only update: 20h → 12h in the audit-log table doc
cli/src/components/waiting-room-screen.tsx Comment-only update: two UI comment strings updated from 20h to 12h
cli/src/hooks/use-freebuff-session.ts Comment-only update: 20h → 12h in the 429-handling comment

Comments Outside Diff (1)

  1. web/src/server/free-session/public-api.ts, line 274-277 (link)

    P2 Duplicate windowMs computation

    fetchRateLimitSnapshot already computes cfg.windowHours * 60 * 60 * 1000 internally to derive since. That same value is re-derived here from snapshot.info.windowHours. Returning windowMs from fetchRateLimitSnapshot would eliminate the duplication.

    Alternatively, include windowMs in the return value of fetchRateLimitSnapshot so it doesn't need to be recalculated from windowHours at the call site.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: web/src/server/free-session/public-api.ts
    Line: 274-277
    
    Comment:
    **Duplicate `windowMs` computation**
    
    `fetchRateLimitSnapshot` already computes `cfg.windowHours * 60 * 60 * 1000` internally to derive `since`. That same value is re-derived here from `snapshot.info.windowHours`. Returning `windowMs` from `fetchRateLimitSnapshot` would eliminate the duplication.
    
    Alternatively, include `windowMs` in the return value of `fetchRateLimitSnapshot` so it doesn't need to be recalculated from `windowHours` at the call site.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: web/src/server/free-session/public-api.ts
Line: 274-277

Comment:
**Duplicate `windowMs` computation**

`fetchRateLimitSnapshot` already computes `cfg.windowHours * 60 * 60 * 1000` internally to derive `since`. That same value is re-derived here from `snapshot.info.windowHours`. Returning `windowMs` from `fetchRateLimitSnapshot` would eliminate the duplication.

Alternatively, include `windowMs` in the return value of `fetchRateLimitSnapshot` so it doesn't need to be recalculated from `windowHours` at the call site.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "Limit GLM sessions to 12 hours" | Re-trigger Greptile

@jahooma jahooma merged commit b7c0155 into main Apr 27, 2026
33 of 34 checks passed
@jahooma jahooma deleted the jahooma/new-session-rate-limit branch April 27, 2026 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant