MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / fetchRateLimitSnapshot

Function fetchRateLimitSnapshot

web/src/server/free-session/public-api.ts:154–173  ·  view source on GitHub ↗

Fetch the caller's current shared premium-session quota snapshot for * `model`, or undefined if the model is unlimited. Used by both POST (after * admit) and GET polls so the CLI's "N of M sessions used" line stays live * instead of disappearing after the first poll.

(
  userId: string,
  model: string,
  accessTier: FreebuffAccessTier,
  deps: SessionDeps,
)

Source from the content-addressed store, hash-verified

152 * admit) and GET polls so the CLI's "N of M sessions used" line stays live
153 * instead of disappearing after the first poll. */
154async function fetchRateLimitSnapshot(
155 userId: string,
156 model: string,
157 accessTier: FreebuffAccessTier,
158 deps: SessionDeps,
159): Promise<
160 | {
161 info: FreebuffSessionRateLimit
162 resetsAt: Date
163 }
164 | undefined
165> {
166 const config = quotaConfigForModel(model, accessTier)
167 if (!config) return undefined
168 const snapshot = await fetchSessionQuotaSnapshot(userId, config, deps)
169 return {
170 info: toRateLimitInfo(model, snapshot),
171 resetsAt: snapshot.resetsAt,
172 }
173}
174
175async function fetchRateLimitsByModel(
176 userId: string,

Callers 1

requestSessionFunction · 0.85

Calls 3

quotaConfigForModelFunction · 0.85
toRateLimitInfoFunction · 0.85

Tested by

no test coverage detected